0% found this document useful (0 votes)
19 views25 pages

Duy SCE EN 010-050 R1209 S7-1200 Analog Values

The document outlines the SCE Training Curriculum for Integrated Automation Solutions using the TIA Portal, specifically focusing on Analog Value Processing with the SIMATIC S7-1200. It includes details on training packages, prerequisites, programming software, and analog signal processing. The curriculum is intended for educational and R&D facilities, with specific usage restrictions for commercial purposes.

Uploaded by

Anh Nguyễn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views25 pages

Duy SCE EN 010-050 R1209 S7-1200 Analog Values

The document outlines the SCE Training Curriculum for Integrated Automation Solutions using the TIA Portal, specifically focusing on Analog Value Processing with the SIMATIC S7-1200. It includes details on training packages, prerequisites, programming software, and analog signal processing. The curriculum is intended for educational and R&D facilities, with specific usage restrictions for commercial purposes.

Uploaded by

Anh Nguyễn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Industry Sector, IA&DT

SCE Training Curriculum


for Integrated Automation Solutions
Totally Integrated Automation (TIA)
Siemens Automation Cooperates with Education

TIA Portal Module 010-050


Analog Value Processing with SIMATIC S7-1200
Xử lý giá trị tương tự với SIMATIC S7-1200

SCE Training Curriculum Page 1 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT

Matching SCE training packages for these training curriculums


 SIMATIC S7-1200 AC/DC/RELAY 6er "TIA Portal"
Order number: 6ES7214-1BE30-4AB3
 SIMATIC S7-1200 DC/DC/DC 6er "TIA Portal"
Order number 6ES7214-1AE30-4AB3
 SIMATIC S7-SW for Training STEP 7 BASIC V11 Upgrade (for S7-1200) 6er "TIA Portal"
Order number 6ES7822-0AA01-4YE0

Please note that these training packages are replaced with successor packages when necessary.
An overview of the currently available SCE packages is provided under: siemens.com/sce/tp

Continued Training
For regional Siemens SCE continued training, please contact your regional SCE contact person
siemens.com/sce/contact

Additional information regarding SCE


siemens.com/sce

Information regarding Usage

This SCE training curriculum for the integrated automation solution Totally Integrated Automation (TIA) was
prepared for the program "Siemens Automation Cooperates with Education (SCE)“ specifically for training
purposes for public education facilities and R&D facilities. Siemens AG does not guarantee the contents.

This document is to be used only for initial training on Siemens products/systems; i.e., it can be copied entirely
or partially and given to those being trained for usage within the scope of their training. Passing on as well as
copying this training curriculum and sharing its content is permitted within public training and advanced training
facilities for training purposes.

Exceptions require written permission by the Siemens AG contact person: Roland Scheuerer
[email protected].

Offenders will be held liable. All rights including translation are reserved, particularly if a patent is granted or a
utility model or design is registered.

Usage for industrial customer courses is explicitly not permitted. We do not consent to the training curriculums
being used commercially.

We wish to thank the Michael Dziallas Engineering Corporation and all other involved persons for their support
during the preparation of this training curriculum.

SCE Training Curriculum Page 2 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT

PAGE

Contents
1. Preface – Giới thiệu.................................................................................................................................. 4
2. Notes on Programming the SIMATIC S7-1200 – Các chú ý khi lập trình S7 1200...................................6
2.1 Automation System SIMATIC S7-1200 – Hệ thống tự động S7 1200.......................................................6
2.2 Programming Software STEP 7 Professional V11 (TIA Portal V11) – Lập trình TIA.................................6
3. Analog Signals – Các tín hiệu tương tự................................................................................................... 7
4. Data Types at the SIMATIC S7-1200 – Các loại dữ liệu trong S7 1200...................................................7
5. Reading In/Reading Out Analog Values – Đọc vào/đọc ra các giá trị Analog...........................................9
5.1 Normalizing Analog Values – Chuẩn hóa các giá trị analog...................................................................10
6. Sample Task – Monitoring the Tank Level – Ví dụ về giám sát mức trong bồn chứa.............................10
6.1. Programming Level Monitoring for the SIMATIC S7-1200 – Lập trình giám sát mức trên S7 1200........11

SCE Training Curriculum Page 3 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT

1. Preface

Regarding its content, module SCE_EN_010-050 is part of the training unit Basics of PLC
Programming’ and represents a fast a fast entry point for programming the SIMATIC S7-1200 with
the TIA Portal.

Fundamentals of
PLC Programming
Module 010, Module
020
Simulation SIMIT
Module 150
Additional Functions
for PLC Programming
Module 030

More Programming
Languages PROFIBUS PROFINET AS-Interface
Module 040 Module060 Module070 Module 050

Safety /Security Sensor Technology Process Visualization Drives


Systems Module 080 Module 110 (HMI) Module 090 Module 100

Training Objective

In this module SCE_EN_010-050, the reader learns how to program limit value monitoring for an analog
value. The controller (PLC) in our case is the SIMATIC S7-1200 and the program is created with the
programming tool TIA Portal. Module SCE-DE-010-1050 provides the fundamentals and shows how it’s
done using a detailed example.

Prerequisites

To successfully work through module SCE_EN_010-050, the following knowledge is assumed


 How to operate Windows
 Fundamentals of PLC programming with the TIA Portal (for example, Module_010-010
‘Startup’ Programming the SIMATIC S7-1200 with TIA- Portal V11)

SCE Training Curriculum Page 4 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
Required Hardware and Software

1 PC Pentium 4, 1.7 GHz 1 (XP) – 2 (Vista) GB RAM, free disk storage approx. 2 GB,
operating system Windows XP Professional SP3/Windows 7 Professional/Windows 7 Enterprise/
Windows 7 Ultimate/Windows 2003 Server R2/Windows Server 2008
Premium SP1, Business SP1, Ultimate SP1
2 Software STEP7 Professional V11 SP1 (Totally Integrated Automation (TIA) Portal V11)
3 Ethernet connection between PC and CPU 315F-2 PN/DP
4 PLC SIMATIC S7-1200; for example, CPU 1214C.
The inputs have to be brought out to a panel.
.

2 STEP7 Professional
V11
1 PC
(TIA Portal)

3 Ethernet connection

4 S7-1200 with
CPU 1214C

SCE Training Curriculum Page 5 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT

2. Notes on Programming the SIMATIC S7-1200

2.1 Automation System SIMATIC S7-1200

The automation system SIMATIC S7-1200 is a modular mini-controller system for the lower and
medium performance range.
An extensive module spectrum is available for optimum adaptation to the automation task.
The S7 controller consists of a power supply, a CPU and input/output modules for digital and analog
signals.
If needed, communication processors and function modules are added for special tasks such as step
motor control.

With the S7 program, the programmable logic controller (PLC) monitors and controls a machine or a
process, whereby the IO modules are polled in the S7 program by means of the input addresses
(%I) and addressed by means of output addresses (%Q).

The system is programmed with the software STEP 7.

2.2 Programming Software STEP 7 Professional V11 (TIA Portal V11)

The software STEP 7 Professional V11 (TIA Portal V11) is the programming tool for the following
automation systems
- SIMATIC S7-1200
- SIMATIC S7-300
- SIMATIC S7-400
- SIMATIC WinAC
With STEP 7 Professional V11, the following functions can be utilized to automate a plant:
- Configuring and parameterizing the hardware
- Defining the communication
- Programming
- Testing, commissioning and service with the operating/diagnostic functions
- Documentation
- Generating the visual displays for the SIMATIC basic panels with the integrated WinCC Basic
- With additional WinCC packages, visual display solutions for PCs and other panels can be
prepared

All functions are supported with detailed online help.

SCE Training Curriculum Page 6 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT

3. Analog Signals – Các tín hiệu tương tự

In contrast to binary signals that can assume only the two signal states "Voltage present +24V“ and
"Voltage not present 0V“, analog signals within a certain range can assume any number of values. A
typical example of an analog sensor is a potentiometer. Depending on the position of the rotary button,
any resistance can be set, up to the maximum value.
Khác với các tín hiệu nhị phân chỉ có hai mức điện áp “Có điện áp +24V” và “không có điện áp 0V”, các
tín hiệu tương tự được cung cấp với bất cứ mức điện áp nào. Một ví dụ điển hình của cảm biến tín hiệu
tương tự là biến trở. Tùy thuộc vào vị trí của nút xoay, một giá trị điện trở nào đó sẽ được thiết lập, chó
tới giá trị cực đại.

Below are some examples of analog variables in control engineering:


Dưới đây là một số ví dụ về các biến tương tự trong điều khiển kỹ thuật:

- Temperature -50 ... +150°C _ Nhiệt độ từ -50 … +150oC


- Flow 0 ... 200l/min _ Lưu lượng từ 0 … 200l/min
- Speed 500 ... 1500 r/min _ Tốc độ 500 …. 1500r/min
- etc. v.v..

Using a transducer, these variables are converted into electrical voltages, currents or resistances. If, for
example, a certain speed is to be recorded, the speed range of 500 ... 1500 r/min can be converted by
means of a transducer into a voltage range of 0 ... +10V. If a speed of 865 rpm is measured, the
transducer would read out a voltage of + 3.65 V.
Sử dụng một bộ chuyển đổi tín hiệu, các biến này được biến đổi thành các tín hiệu điện áp, dòng điện
hoặc điện trở. Ví dụ một tín hiệu tốc độ trong dải từ 500 – 1500 r/min có thể biến đổi thành dải điện áp
0 - +10V. Nếu tốc độ là 865 rpm bộ chuyển đổi sẽ cho ra điện áp +3.65V

500 865 1500 U/min

365
10V: 1000 U/min = 0,01 V/U/min
1000 U/min
365 U/min x 0,01 V/U/min = 3,65
10V

0V +10V
<<U/min = r/min>>

These electrical voltages, currents or resistances are then connected to an analog module that
digitalizes this signal.
Các tín hiệu điện áp, dòng điện hoặc điện trở sẽ được nối vào module tương tự để số hóa các tín
hiệu này.

If analog variables are processed with a PLC, the voltage, current or resistance value that was read
in has to be converted into digital information. This conversion is called analog/digital conversion
(A/D conversion).
Nếu các biến tương tự được xử lý trong PLC, giá trị điện áp, dòng điện hoặc điện trở sẽ được biến
đổi thành tín hiệu số. Quá trình biến đổi này được gọi là biến đổi từ tương tự sang số (Biến đổi A/D).

This means, for example, that the voltage 3.65V is stored in a series of binary digits as information.
The more binary digits are used for digital representation, the finer is the resolution. If, for example,
there were only 1 bit available for the voltage range 0 ... +10V, only one statement could be made
whether the measured voltage is in the range 0… +5V or in the range +5V ... +10V. With 2 bits, the
range can be divided into 4 individual ranges; i.e. 0 ... 2.5/2.5 ... 5/5 ... 7.5/7.5 ... 10V. A/D
converters commonly used in control engineering convert with 8 or 11 bits.
Có nghĩa là nếu điện áp 3.65V sẽ được lưu trữ dưới dạng một chuỗi các thông tin nhị phân số.
Nhiều bit nhị phân sẽ được sử dụng biểu diễn cho thông tin số này, số bit sẽ quyết định độ nhiễu
SCE Training Curriculum Page 7 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
của giá trị tương tự. Ví dụ nếu chỉ 1 bit biểu diễn cho dải điện áp từ 0 – 10V, thì khi điện áp vào từ 0
– 5V giá trị số sẽ là 0, từ 5 – 10 V sẽ là 1. Nếu sử dụng hai bit sẽ biểu diễn được 4 mức điện áp: 0 –
2.5V = 00; 2.5-5V = 01; 5-7.5V = 10 và 7.5 – 10V = 11. Các bộ biến đổi A/D trong điều khiển kỹ thuật
thường sử dụng 8 hoặc 11 bit.

With 8 bits, we have 256 individual ranges and with 11 bits a resolution of 2048 individual ranges.
Với 8 bit, chúng ta sẽ có 256 dải điện áp và 11 bit sẽ là 2048.
0A/0V 20mA/10V
10V: 2048 = 0,0048828
 es können
→ Voltage differences of <5mV can be
Spannungs-
11 Bit detected
unterschiede <5mV erkannt
0 2048
werden

4. Data Types at the SIMATIC S7-1200 _ Các loại dữ liệu trong S7 1200

The SIMATIC S7-1200 is provided with a large number of data types that can be used to represent
different numerical formats. The list below shows the elementary data types.
S7 1200 cung cấp rất nhiều kiểu dữ liệu có thể sử dụng cho các định dạng số khác nhau. Bảng sau
sẽ liệt kê các kiểu dữ liệu này.

Data Type Size (Bit) Range _ Dải Example of a Constant Entry


Kiểu Kích thước Ví dụ giá trị hằng

Bool 1 0 to 1 TRUE, FALSE, 0,1


Byte 8 16#00 to 16#FF 16#12, 16#AB
Word 16 16#0000 to 16#FFFF 16#ABCD, 16#0001
DWord 32 16#00000000 to 16#FFFFFFFF 16#02468ACE
Char 8 16#00 to 16#FF 'A‘, 't‘, '@‘
Sint 8 -128 to 127 123, -123
Int 16 -32768 to 32767 123, -123
Dint 32 -2.147.483.648 to 2.147.483.647 123. -123
USInt 8 0 to 255 123
UInt 16 0 to 65.535 123
UDInt 32 0 to 4.294.967.295 123
Real 32 +/-1.18 x 10-38 to +/-3.40 x 10 38 123,456, -3.4, -1.2E+12, 3.4E3
LReal 64 +/-2.23 x 10-308 to +/-1.79 x 10 308 12345.123456789
-1.2E+40
Time 32 T#-24d_20h_31m_23s_648ms_ to T#5m_30s
T#-24d_20h_31m_23s_647ms 5#-2d
Stored as -2.147.483.648 ms to T#1d_2h_15m_30x_45ms
+2.147.483.647 ms
String Variable 0 to 254 characters in byte size 'ABC‘

Note: Chú ý
For analog value processing, the data types 'INT’ and 'REAL’ play an important part since entered
analog values are present as integers in the format 'INT’ and for accurate further processing, only
floating point numbers 'REAL’ can be used because of the rounding off error in the case of 'INT’.
Cho việc xử lý tín hiệu tương tự, các kiểu dữ liệu ‘INT’ và ‘REAL’ là các kiểu dữ liệu quan trọng cho
việc chuyển đổi các giá trị tương tự thành một số nguyên dưới dạng ‘INT’ và để xử lý chính xác hơn
cần sử dụng các số dấu phẩy động ‘REAL’.

SCE Training Curriculum Page 8 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT

5. Reading In/Reading Out Analog Values – Đọc vào/đọc ra các giá trị tương tự

Analog values are entered/read out in the PLC as word information. These words are accessed with
the operands
Các giá trị tương tự được vào ra Cpu dưới dạng từ. Các từ này được truy xuất như các toán hạng.

%IW 64 Analog input word 64 Từ vào tương tự địa chỉ 64


%QW 80 Analog output word 80 Từ ra tương tự địa chỉ 80
for example. Ví dụ

Each analog value ("channel“) is assigned one input or output word. The format is 'Int’, an integer.
Mỗi giá trị analog (“kênh”) là được gán một từ ngõ vào hoặc ngõ ra. Định dạng là ‘Int’ là một số
nguyên.

Addressing the input or output word depends on the addressing in the device overview. For
example:
Địa chỉ từ ngõ vào hoặc ngõ ra tùy thuộc vào địa chỉ của thiết bị. Ví dụ:

The address of the first analog input would be here %IW 64, the address of the second analog input
%IW 66, and the address of the analog output %QW 80.
Địa chỉ của ngõ vào tương tự đầu tiên ở đây là IW64, địa chỉ của ngõ vào tương tự thứ hai là IW66,
và địa chỉ của ngõ ra tương tự là QW80

The analog value transformation for further processing in the PLC is the same for analog inputs and
analog outputs.
Các giá trị tương tự chuyển đổi cho việc xử lý trong PLC hoàn toàn giống nhau cho các ngõ vào và
ngõ ra
The digitalized values look like this: Các giá trị được số hóa nhìn như thế này:

SCE Training Curriculum Page 9 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT

Nominal range of the analog value


Dải tín hiệu tương tự

Digitalized value for further processing in


the PLC
Giá trị số hóa để xử lý trong PLC

Often, these digitalized values have to be normalized through corresponding further processing in the PLC.
Thông thường, các giá trị số hóa sẽ được chuẩn hóa thông qua quá trình xử lý tương ứng trong PLC.

5.1 Normalizing Analog Values – Chuẩn hóa các giá trị tương tự

If an analog input value is present as digitalized value, it usually has to be normalized so that the
numerical values correspond to the physical values in the process.
Nếu một giá trị ngõ vào tương tự được biểu diễn thành giá trị số hóa, nó thường được chuẩn hóa
thành các giá trị số tương ứng với các giá trị vật lý trong quá trình điều khiển.

Likewise, the analog output to the IO output word usually takes place only after the output value is
normalized.
Giống như vậy, các tín hiệu ra analog được đưa tới các từ ra IO, thông thường sau khi

In STEP7 programs, computing operations are used for normalizing. For this to be done as
accurately as possible, the values have to be converted to the data type REAL normalizing, to keep
the rounding off errors to a minimum.
Trong các chương trình STEP7, các phép tính toán được sử dụng cho normalizing. Điều này cho độ
chính xác nhất có thể, các dữ liệu sẽ được chuyển thành giá trị chuẩn hóa REAL, để giữ cho các sai
số là nhỏ nhất.
.
In the chapters below, an example is provided using level monitoring of a tank as an illustration.
Trong các phần dưới, sẽ trình bày một ví dụ giám sát mức chất lỏng trong một bồn chứa.

6. Sample Task – Monitoring the Tank Level: Ví dụ giám sát mức bồn chứa

We are going to program monitoring the level in a tank.


Chúng ta viết chương trình giám sát mức trong bồn

A sensor measures the level in a tank and converts it into the voltage signal 0 to 10V. 0V
corresponds to a level of 100 liters and 10V to a level of 1000 liters.
Một cảm biến đo mức trong một bồn chứa và chuyển thành tín hiệu điện áp 0 tới 10V. 0V tương
ứng với mức 100 lít và 10V tương ứng với mức 1000 lít.

This sensor is connected to the analog input of the SIMATIC S7-1200. Now, this signal is to be
entered in a function FC1 and normalized.
Ngõ ra cảm biến sẽ nối tới ngõ vào tương tự của S7-1200. Chương trình sẽ nhận tín hiệu này và
chuẩn hóa trong một hàm FC1.

Next, the following is to be programmed: monitoring and displaying the maximum permissible level
of 990 liters and monitoring the minimum permissible level of 110 liters.
Tiếp theo các công việc sau sẽ được lập trình: giám sát và hiển thị giá trị cực đại cho phép 990 lít và
giá trị cực tiểu cho phép là 110 lit.

SCE Training Curriculum Page 10 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
Assignment list: Danh sách gán

Address Symbol Data Type Comment

%IW 64 AI_level_tank1 Int Analog input level Tank1- Ngõ và tương tự


%Q 0.0 Tank1_max Bool Display level > 990 liters – Giá trị max
%Q 0.1 Tank1_min Bool Display level < 110 liters – giá trị min

6.1. Programming Level Monitoring for the SIMATIC S7-1200


Lập trình giám sát mức trên S7-1200

The project is managed and programmed with the software 'Totally Integrated Automation Portal’.
Dự án được quản lý và lập trình bằng phần mềm TIA

Here, under a uniform interface, the components such as the control system, visualization and
networking the automation solution are set up, parameterized and programmed.
Ở đây dưới một giao diện duy nhất, các thành phần như hệ thống điều khiển, giám sát và mạng của
giải pháp tự động sẽ được thiết lập, cài đặt tham số và lập trình.

For error diagnosis, online tools are available. Các công cụ trực tuyến sẽ sẵn sàng cho việc chuẩn
đoạn lỗi.

In the steps below, a project can be set up for the SIMATIC S7-1200 and the solution of the task can be
programmed.
Trong các bước sau, một dự án có thể thiết lập cho S7-1200 và lập trình cho giải pháp giám sát bồn
chứa

1. The central tool is the 'Totally Integrated Automation Portal’. It is called here with a double click.
(®® Totally Integrated Automation Portal V11)
Chạy TIA Portal

SCE Training Curriculum Page 11 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
2. Programs for the SIMATIC S7-1200 are managed in projects. Such a project is now set up in the
Portal View. (®® Create new project ®® Tank_Analog ®® Create)
Tạo project mới

3. Now, 'First Steps‘ are recommended for the configuration.


Cấu hình thiết bị
First, we want to 'Configure a device’. (®® First steps ®® Configure a device)

SCE Training Curriculum Page 12 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
4. Then we 'Add new device’ with the device name "controller_tank“. To this end, we select from
the catalog 'CPU1214C’ with the matching order number. (®® Add new device ®® controller_tank
®® CPU1214C ®® 6ES7 ……. ®® Add)
Thêm phần cứng vào project.

5. The software now changes automatically to the Project View with the opened hardware
configuration. Here, more modules can be added from the hardware catalog (on the right). Here,
the signal board for an analog output is to be inserted from the catalog using drag&drop. (®®
Catalog ®® Signal board ®® AO1 x 12Bit ®® 6ES7 232-…)
Thêm module analogue input.

SCE Training Curriculum Page 13 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
6. In the ’Device view‘, the addresses of the inputs and outputs can be checked or reset. Here, the
integrated analog outputs of the CPU have the addresses %IW64 to %IW66 and the integrated
digital outputs the addresses %Q0.0 to %Q1.1. The analog output at the signal board has the
address %QW80
Dùng Device view xem địa chỉ của các ngõ vào ra. Địa chỉ của các ngõ vào tương tự tích hợp
trong CPU là %IW64 tới %IW66. Ngõ ra số tích hợp là %Q0.0 tới %Q1.1. Ngõ ra trên Signal board
là %QW80.

7. So that the software later accesses the correct CPU, its IP address and the subnet mask have to
be set. (®® Properties ®® General ®® PROFINET interface ®® Ethernet addresses ®®IP
address: 192.168.0.1 ®® subnet mask: 255.255.255.0)
Thiết lập địa chỉ IP và subnet mask.

SCE Training Curriculum Page 14 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
8. Since modern programming does not program with absolute addresses but with tags, the global
PLC tags have to be specified here.
Với phương pháp lập trình hiện đại không sử dụng các địa chỉ tuyệt đối (phần cứng) mà thực hiện
với các thẻ, chúng ta sẽ khai báo các thẻ trong global PLC tags.

These global PLC tags are descriptive names with a comment for those inputs and outputs that are
used in the program. Later, during programming, the global PLC tags can be accessed by means of
this name. These global tags can be used in the entire program in all blocks.
Các thẻ toàn cục được mô tả bằng tên với các ghi chú cho các ngõ vào và các ngõ ra được sử dụng
trong chương trình. Sau đó trong suốt quá trình lập trình, các thẻ PLC toàn cục có thể truy cập bằng
các tên này. Các thẻ toàn cục này có thể sử dụng trong toàn bộ chương trình và trong tất các các khối.

To this end, select in project navigation 'controller_tank [CPU1214C DC/DC/DC]’ and then 'PLC
tags’. With a double click, open the table 'PLC tags’ and enter the names for the inputs and the
outputs, as shown below. (®® controller_tank[CPU1214C DC/DC/DC]’ ®® PLC tags®® Default tag
table)
Để kết thúc việc này, chọn trong project navogation mục 'controller_tank [CPU1214C DC/DC/DC]’ và
sau đó chọn 'PLC tags’. Nhấp đúp mở 'PLC tags’ và nhập các tên của các ngõ vào ra như hình sau:
(®® controller_tank[CPU1214C DC/DC/DC]’ ®® PLC tags®® Default tag table)

SCE Training Curriculum Page 15 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
9. To create function block FC1, select in Project navigation controller_tank [CPU1214C
DC/DC/DC]’ and then 'Program blocks’. Next, double click on 'Add new block’. (®®
controller_tank[CPU1214C DC/DC/DC]’ ®® Program block ®® Add new block)
Tạo FC1 chọn (®® controller_tank[CPU1214C DC/DC/DC]’ ®® Program block ®® Add new
block)

10. Select 'Function(FC)’ and assign the name ‘supervision filling level tank1’. As programming
language, 'FBD’ (function block diagram) is specified. Numbering is automatic. Since this FC1 is
called later by its symbolic name, the number is no longer that important. Accept the inputs with
'OK’. (®® Function (FC1) ®® supervision filling level tank1 ®® FBD ®® OK)
Chọn 'Function(FC)’ và gán tên ‘supervision filling level tank1’ . Chọn ngôn ngữ lập trình FBD.
Số tự động, vì FC1 sau này sẽ được gọi bằng tên của nó, số là không quan trọng. Chấp nhận các
ngõ vào bằng cách nhấn OK:
(®® Function (FC1) ®® supervision filling level tank1 ®® FBD ®® OK)

SCE Training Curriculum Page 16 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
11. The block ‘supervision filling level tank1’ [FC1]’ is opened automatically. Before writing the
program, the interface of the block has to be declared. When the interface is declared, the local
variables are specified that are known in this block.
Khối ‘supervision filling level tank1’ [FC1]’ được mở tự động. Trước khi viết chương trình cần
khai báo giao diện của khối. Sau khi khai báo giao diện, các biến cục bộ được sử dụng trong khối.

The variables consist of two groups: Các biến được chia thành hai nhóm:

 Block parameters that are the interface of the block for calls in the program.
Các tham số khối sử dụng để giao tiếp với khối đó khi nó được gọi trong chương trình.

Type – Kiểu Name- tên Function- chức năng Available in – Sử dụng trong
Input parameter
Parameters whose values the Functions, function blocks and some
Input
block reads. types of organization blocks

Parameters whose values the


Output parameter Output Functions and function blocks
block writes.
Parameters whose values the
block reads when called, and
InOut parameter InOut Functions and function blocks
after processing writes again to
the same parameter.

 Local data used for storing interim results: Các biến cục bộ sử dụng cho việc chứa các kết quả tạm thời

Type Name Function Available in


Variables used to store
temporary interim results. Functions, function blocks and
Temporary local data Temp
Temporary data is retained for organization blocks
one cycle only.
Variables used to store static
interim results in the instance
Static local data Static data block. Static data is Function blocks
retained -even over several
cycles- until it is rewritten.

12. When local variables are declared, the following variables are needed for our example.
Khi các biến cục bộ được khai báo, các biến sau sẽ cần cho ví dụ của chúng ta.

Input: Ngõ vào


tank_level_AI Here, the level sensor enters the analog value
Là mức cảm biến nhập vào giá trị tương tự

Output: Ngõ ra
tank_max Here, the status of the maximum display is written to the output
Ở đây, trạng thái cực đại hiển thị được ghi tới ngõ ra
tank_min Here, the status of the minimum display is written to the output
Ở đây, trạng thái cực đại hiển thị được ghi tới ngõ ra

Temp: Biến tạm


tank_level_real This variable is needed to store an interim value
Biến này cần thiết cho việc chứa một giá trị
tank_level_norm Here, a value for the level, normalized in the floating point format to the range of
100 to 1000 liters is provided.
Ở đây, một giá trị cho mức được chuẩn hóa trong dạng dấu phẩy động trong
dải từ 100 tới 1000 lit.

SCE Training Curriculum Page 17 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
In this example, it is particularly important to use the correct data types since otherwise they would not
be compatible in the following program with the conversion functions that are used. For the sake of
clarity, all local variables should be provided with a sufficient comment.
Trong ví dụ này, chú ý quan trọng là phải sử dụng các kiểu dữ liệu đúng tương thích với các hàm biến
đổi sử dụng trong chương trình. Để dễ dàng trong việc khai báo tất cả các biến cục bộ đều có chú thích
cụ thể.

13. After the local variables were declared, the program can be entered only by using the names of
the variables (identified with the symbol '#’). For the example in FBD, it could look like this:
Sau khi khai báo các biến cục bộ chương trình chỉ có thể nhập giá trị theo tên của các biến (nhận dạng
bằng ký hiệu #). Ví dụ trong FBD nó có thể giống như sau:

Program in function block diagram (FBD): Chương trình FBD

SCE Training Curriculum Page 18 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
Program in ladder diagram (LAD): Chương trình LAD

SCE Training Curriculum Page 19 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
14. Next, the ‘Properties’ of the block 'Main[OB1]’ that is processed cyclically are selected. Block
properties can be changed. (®® Properties ®® Main[OB1])
Tiếp theo thay đổi ngôn ngữ lập trình trong (®® Properties ®® Main[OB1])

15. In the properties, select the programming ‘Language’ function block diagram ‘FBD’. (®® FBD ®®
OK)
Chọn ngôn ngữ FBD

SCE Training Curriculum Page 20 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
16. Now, the block "supervision filling level tank1 [FC1]“ has to be called from the program block Main
[OB1]. Otherwise, the block would not be processed. With a double click on 'Main [OB1]’ open this
block. (®® Main [OB1])
Bây giờ khối "supervision filling level tank1 [FC1]“ có thể được gọi từ Main [OB1]. Nếu không gọi
các lệnh trong khối sẽ không được thực hiện. Nhấp đúp vào Main [OB1] để mở.

17. With drag&drop, the block "supervision filling level tank1 [FC1]“ can then be dragged to
Network 1 of the block Main [OB1]. Don‘t forget to document the networks also in the block Main
[OB1]. (®® supervision filling level_tank1 [FC1])
Bằng thao tác kéo thả khối "supervision filling level tank1 [FC1]“ vào network 1 của Main [OB1].
Không quên các tài liệu của các network cũng nằm trong Main[OB1].

SCE Training Curriculum Page 21 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
18. Next, the input variable as well as the output variable is wired in OB1 with the PLC tags shown

here. Clicking on saves the project. (®® „AI_LEVEL_TANK1“ ®® "TANK1_MAX“

®® "TANK1_MAX“ ®® )
Tiếp theo nhập các biến vào ra trên các dây của OB1 bằng các thẻ PLC như phía dưới. Nhấp
chuột vào Save project để lưu dự án.

(®® „AI_LEVEL_TANK1“ ®® "TANK1_MAX“ ®® "TANK1_MAX“ ®® )

19. To load your entire program to the CPU, first highlight the folder 'controller_tank’ and then click
on the symbol Load to device. (®® controller_tank ®® ).
Nạp toàn bộ chương trình vào CPU, trước tiên làm sáng thư mục 'controller_tank’ và sau đó
nhấp chuột trên nhãn down load để nạp chương trình vào thiết bị (®® controller_tank ®® ).

SCE Training Curriculum Page 22 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
20. If the PG/PC interface was not specified previously, a window is displayed where this can still be
done. (®® PG/PC interface for loading ®® load).
Nếu PG/PC chưa được chọn trước , một của sổ sẽ hiện lên để chọn (®® PG/PC interface for
loading ®® load).

21. Then, click on 'Load’ once more. During downloading, the status is displayed in a window. (®®
Load)
Sau đó, nhấp vào ‘Load’ một lần nữa. trong quá trình nạp chương trình màn hình sẽ hiển thị cửa
sổ theo dõi sẽ hiện trên màn hình.

SCE Training Curriculum Page 23 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
22. Successful downloading is indicated in a window. Now click on ‘Finish’. (®® Finish)
MỘt cửa số thôn gba1o sẽ hiển thị khi việc nạp chương trình thành công. Bây giời nhấp chuột vào
Finish.

23. Next, start the CPU by clicking on the symbol . (®® )


Tiếp theo bắt đều thực hiện chương trình bằng cách nhấp vào biểu tượng chạy RUN.

SCE Training Curriculum Page 24 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200
Industry Sector, IA&DT
24. Confirm the question whether you actually want to start the CPU with 'OK’. (®® OK)
Xác nhận câu hỏi khi bạn thực sự muốn chạy chương trình với nút OK

25. By clicking on the symbol Monitoring on/off, the status of the variables can be monitored while

the program is tested. (®® supervision filling level tank1[FC1] ®® )


Nhấp vào biểu tượng Monitoring on/off, có thể giám sát trạng thái của các biến trong khi chương
trình chạy thủ nghiệm.

SCE Training Curriculum Page 25 of 25 To be used only at Educational and R&D Facilities
TIA Portal Module 010-050, Edition 09/2012 Unrestricted / © Siemens AG 2012.All Rights Reserved
SCE_EN_010-050_R1209_Analog Value Processing with SIMATIC S7-1200

You might also like