SIMATIC S7-200 Tips6 Measuring and Monitoring Temperature with a PT100 Resistance Temperature Detector CPUs required for this tip CPU 210 CPU 212 CPU 214 CPU 215 CPU 216 OTHER
Trang 1SIMATIC S7-200 Tips
6 Measuring and Monitoring Temperature with a PT100 Resistance
Temperature Detector
CPUs required for this tip
CPU 210 CPU 212 CPU 214 CPU 215 CPU 216 OTHER
Overview
This program tip discusses the following: measuring a temperature and monitoring the specified limits by using the analog expansion module EM235; at one input channel of the analog module,
a temperature sensor PT100 is connected
In order to convert the temperature-conditioned resistance change of the PT100 into a voltage, the analog output is used as constant current source The output supplies the PT100 sensor with a 12.5mA constant current With this circuit, a linear input voltage of 5mV/°C is generated The EM235 converts this voltage into a digital value, which the program reads out cyclically From the value read, the program calculates the temperature[ ° C], using the following formula
T[°C] = Digital Value - 0 ° C-Offset
1°C-Value Digital Value = value stored in AIWx (x=0,2,4).
0°C-Offset = digital value, measured at 0°C In the case in point, this offset is 4000.
1°C-Value = value difference at a temperature rise of 1°C In this tip, 1°C-Value = 16.
The program calculates the value to the first decimal point and writes the result in the embedded variable of Message 1: ’’Temperature = xxx.x°C’’, which is read out with a TD200 In the initialization segment of the program, the user can enter a high and low temperature limit The program monitors the measured value and displays a warning via the TD200 if the measured temperature leaves the selected range Message 2: ‘’Temperature > xxx.x°C’’ appears in the second display line of the TD200 if the measured temperature exceeds the high temperature limit; Message 3: ‘’Temperature < xxx.x°C" is displayed if the measured temperature drops below the low temperature limit.
Trang 2T D 2 0 0
F 5
S H I F T
E S C E N T E R
C P U 2 1 4
M L + C + C - L + M
E M 2 3 5
0 V + 2 4 V
T E M P E R A T U R E = 2 3 6 ° C
P T 1 0 0
I o
Figure 36.1
Trang 3Program Structure
Figure 36.2
Initialization: delete operands, load 1 °C-value, load 0 °C-Offset, specify
monitoring limits Write value from output current to AQW0
Program Start
Transfer the measured value from AIWx in temperature value
Subtract 0 °C-Offset from temp.value; divide result by 1 °C-value; Shift
quotient by 1 decimal point to the left
Divide remainder X 10 by 1°C-value and add to temp.value Write
calculated temperature in embedded variable of Message Nr 1
Enable the first message for display
Temperatur > high limit?
Set enable bit for Message Nr 2;
switch off furnace
Reset enable bit for Message Nr 2
Set enable bit for Message Nr 3<
switch on furnace
Reset enable bit for Message Nr 3 Temperatur < low limit ?
END
No
No Yes
Yes
Trang 4Program Description
Temperature Sensor:
The PT100 is a platinum resistance temperature detector which is suitable for temperature measurements in an application range from -60 to +400°C.
Calculating the Supply Current for PT100:
The PT100 has a resistance value of 100 Ohm at 0C° The resistor changes linear with the temperature by approximately 0.4 Ohm per degree Celsius.
R [ O h m ]
T [ ° C ]
1 0 0
1 0 2
1 0 4
1 0 6
1 0 8
1 1 0
0 1 0 2 0
To generate a voltage coefficient of 5mV/°C, 12.5mA supply current is needed The resolution at the analog output is 10uA/Count, so that the required count value has to be 1250, in order to get 12.5mA Since the data word format of the AQW is shifted to the right by 4 bits, the count value has to be multiplied by 16 Consequently, 20000 has to be entered in AQW0 in order to initialize 12.5mA current at the analog output Io
Format Equation: (32000/20mA * 12.5mA = 20000)
Trang 5RA A+ A- RB B+ B- RC C+ C- V0 I0 L+ M I
EM 235
ANALOG In-Out-PB
PT100
I0
Figure 36.3
EM235 Circuit
With the configuration switches on the EM235 module, the voltage range of 0 10V is selected
as follows:
ON OFF OFF OFF ON OFF Depending on the number of the channel used on the EM235, the corresponding address of the
AI word has to be used in the program:
AIW0 for Input Channel 1, AIW2 for Input Channel 2,
AIW4 for Input Channel 3, AQW0 for Output Channel 1
The unused EM 235 inputs are short-circuited.
Trang 6LAD (S7-MicroDOS) STL (IEC)
Main Program
// TITLE: Measuring Temperature with PT100 RTD and Displaying it using the TD200
│ SM0.1 MOV_DW──┐
1 ├─┤ ├─────────────────────────────┬────────────┤EN │
│ │ │ │
│ │ K0┤IN OUT├VD196
│ │ │ │
│ │ └───────┘
│ │ MOV_W───┐
│ ├────────────┤EN │
│ │ │ │
│ │ K16┤IN OUT├VW250
│ │ │ │
│ │ └───────┘
│ │ MOV_W───┐
│ ├────────────┤EN │
│ │ │ │
│ │ K4000┤IN OUT├VW252
│ │ │ │
│ │ └───────┘
│ │ MOV_W───┐
│ ├────────────┤EN │
│ │ │ │
│ │ K300┤IN OUT├VW260
│ │ │ │
│ │ └───────┘
│ │ MOV_W───┐
│ ├────────────┤EN │
│ │ │ │
│ │ K200┤IN OUT├VW262
│ │ │ │
│ │ └───────┘
│ │ MOV_W───┐
│ └────────────┤EN │
│ │ │
│ K20000┤IN OUT├AQW0
│ │ │
│ └───────┘
Trang 7│ SM0.0 SUB_I───┐
2 ├─┤ ├───────────────────────────┬────────────┤EN │
│ │ │ │
│ │ AIW4┤IN1 OUT├VW200
│ │ VW252┤IN2 │
│ │ └───────┘
│ │ DIV─────┐
│ ├────────────┤EN │
│ │ │ │
│ │ VW200┤IN1 OUT├VD198
│ │ VW250┤IN2 │
│ │ └───────┘
│ │ MUL─────┐
│ ├────────────┤EN │
│ │ │ │
│ │ K10┤IN1 OUT├VD196
│ │ VW198┤IN2 │
│ │ └───────┘
│ │ DIV─────┐
│ ├────────────┤EN │
│ │ │ │
│ │ VW198┤IN1 OUT├VD196
│ │ VW250┤IN2 │
│ │ └───────┘
│ │ MOV_W───┐
│ ├────────────┤EN │
│ │ │ │
│ │ VW198┤IN OUT├VW160
│ │ │ │
│ │ └───────┘
│ │ MOV_W───┐
│ ├────────────┤EN │
│ │ │ │
│ │ K0┤IN OUT├VW198
│ │ │ │
│ │ └───────┘
│ │ MUL─────┐
│ ├────────────┤EN │
│ │ │ │
│ │ K10┤IN1 OUT├VD198
│ │ VW200┤IN2 │
│ │ └───────┘
│ │ ADD_I───┐
│ ├────────────┤EN │
│ │ │ │
│ │ VW160┤IN1 OUT├VW200
│ │ VW200┤IN2 │
│ │ └───────┘
│ │ MOV_W───┐
│ ├────────────┤EN │
│ │ │ │
│ │ VW200┤IN OUT├VW116
│ │ │ │
│ │ └───────┘
│ │ V12.7 K1
│ └────────────( S )
│
Trang 8LD SM0.0 // Always load the measured
│
│ VW200 VW260 V12.6
3 ├───────┤ >= W ├───────────┬────────────( )
│ │
│ │ Q0.0 K1
│ ├────────────( R )
│ │
│ │ MOV_W───┐
│ └────────────┤EN │
│ │ │
│ VW260┤IN OUT├VW136
│ │ │
│ └───────┘
// display of Message 2
│ VW200 VW262 V12.5
4 ├───────┤ <= W ├───────────┬────────────( )
│ │
│ │ Q0.0 K1
│ ├────────────( S )
│ │
│ │ MOV_W───┐
│ └────────────┤EN │
│ │ │
│ VW262┤IN OUT├VW156
│ │ │
│ └───────┘
// display of Message 3
Trang 9
│
5 ├───────────────────────────────────────( MEND )
Data Block DB1 (V Memory):
The Parameter block for TD200 for reading out the message with embedded value of the
measured temperature, and warnings with embedded temperature limits.
// BEGIN TD200_BLOCK 0
// (Comments within this block should not be edited or removed)
VB0 'TD' // TD 200 Identification
VB2 16#10 // Set Language to English, set Update to As fast as possible
VB3 16#00 // Set the display to 20 character mode; Up key V3.2; Down key V3.3
VB4 3 // Set the number of messages
VB5 0 // Set the Function Keys notification bits to M0.0 - M0.7
VW6 100 // Set the starting address for messages to VW100
VW8 12 // Set the starting address for message enable bits to VW12
// MESSAGE 1
// Message Enable Bit V12.7
VB100 'Temperature = '
VB114 16#00 // No Edit; No Acknowledgement; No Password;
VB115 16#31 // Unsigned Word; 1 Digits to the right of the decimal;
VW116 16#00 // Embedded Data Value: Move data for display here.
VB118 'ßC'
// MESSAGE 2
// Message Enable Bit V12.6
VB120 'Temperature > '
VB134 16#00 // No Edit; No Acknowledgement; No Password;
VB135 16#31 // Unsigned Word; 1 Digits to the right of the decimal;
VW136 16#00 // Embedded Data Value: Move data for display here.
VB138 'ßC'
// MESSAGE 3
// Message Enable Bit V12.5
VB140 'Temperature < '
VB154 16#00 // No Edit; No Acknowledgement; No Password;
VB155 16#31 // Unsigned Word; 1 Digits to the right of the decimal;
VW156 16#00 // Embedded Data Value: Move data for display here.
VB158 'ßC'
// END TD200_BLOCK 0
Trang 10Conversion Notes
To Convert from IEC STL to S7-Micro/DOS STL:
Add a ‘K’ before all non-Hex numerical constants (i.e 4 ⇒ K4)
Replace ‘16#’ with ‘KH’ for all Hex constants (i.e 16#FF ⇒ KHFF)
Commas denote field divisions Use arrow or TAB keys to toggle between fields To convert an S7-Micro/DOS STL program to LAD form, every network must begin
with the word ‘NETWORK’ and a number Each network in this Application Tip program is designated by a number on the ladder diagram Use the INSNW
command under the EDIT menu to enter a new network The MEND, RET, RETI, LBL, SBR, and INT commands each receive their own networks.
Line-Comments denoted by ‘//’ are not possible with S7-Micro/DOS, but
Network-Comments are possible.
The data block shown was created in Micro/Win; in Micro/DOS use the V-memory editor to enter a data block (Refer to the Micro/DOS users’ guide) Note that in Micro/Win:
16# denotes a hexadecimal value
‘text‘ represents a string value
General Notes
The SIMATIC S7-200 Application Tips are provided to give users of the S7-200 some indication
as to how, from the view of programming technique, certain tasks can be solved with this controller These instructions do not purport to cover all details or variations in equipment, nor
do they provide for every possible contingency Use of the S7-200 Application Tips is free Siemens reserves the right to make changes in specifications shown herein or make improvements at any time without notice or obligation It does not relieve the user of responsibility to use sound practices in application, installation, operation, and maintenance of the equipment purchased Should a conflict arise between the general information contained in this publication, the contents of drawings or supplementary material, or both, the latter shall take precedence.
Siemens is not liable, for whatever legal reason, for damages or personal injury resulting from the use of the application tips.
All rights reserved Any form of duplication or distribution, including excerpts, is only permitted with express authorization by SIEMENS.
Trang 11Tham khảo
Chương trình ví dụ này bàn luận một vài điều sau: Đo nhiệt độ và hiển thị nhiệt độ chỉ định bằng cách dùng khối mở rộng EM235, trong đó có một kênh khối analog, có cảm biến nhiệt
độ là PT 100 được nối vào khối.
Chuyển đổi nhiệt độ được qui định thông qua điện trở của PT100 sang điện áp, đầu ra analog được sử dụng là nguồn dòng Nguồn đầu ra cấp cho cảm biến PT100 với dòng cố định
là 12,5 mA Với mạch này, một điện áp tuyến tính đầu vào 5mV/o C sẽ được sinh ra Khối EM235 chuyển đổi điện áp này sang giá trị số mà chương trình sẽ cập nhật liên tục Từ giá trị đọc được này, chương trình sẽ tính ra nhiệt độ bằng công thức:
T[°C] = Digital Value - 0 ° C-Offset
1°C-Value Digital Value là giá trị được chứa trong AIWx (x = 0,2,4)
0oC – Offset là giá trị số đo được ở 0oC, trong trường hợp này là 4000
1oC – Value là giá trị thay đổi khi nhiệt độ tăng được 1oC Trong ví dụ này là 16
Chương trình sẽ tính giá trị đến 1 số sau dấu phẩy thập phân và hiển thị kết quả “Nhiệt độ = xxx.xoC” ra màn hình TD 200 Trong phần khởi tạo của chương trình, người dùng có thể nhập vào giá trị giới hạn nhiệt độ cao và thấp Chương trình sẽ hiển thị giá trị nhiệt độ đo được và đưa ra cảnh báo nếu giá trị đó vượt ra ngoài khoảng giới hạn thông qua màn hình TD 200 Thông báo “Nhiệt độ > xxx.x oC” sẽ xuất hiện ở dòng thứ 2 của màn hình nếu nhiệt độ lớn hơn nhiệt độ giới hạn trên Và thông báo “Nhiệt độ < xxx.x oC” sẽ được hiện ra nếu nhiệt độ đo được giảm xuống dưới mức giới hạn nhiệt độ thấp.
Sơ đồ đấu nối thiết bị được cho dưới đây:
Trang 12T D 2 0 0
F 5
S H I F T
E S C E N T E R
C P U 2 1 4
M L + C + C - L + M
E M 2 3 5
0 V + 2 4 V
T E M P E R A T U R E = 2 3 6 ° C
P T 1 0 0
I o
Lưu đồ thuật toán chương trình được cho dưới đây:
Trang 13Khởi tạo: xóa bỏ toán hạng, lấy giá trị chênh lệch 1oC và tại 0oC, chỉ
định giá trị giới hạn, ghi giá trị dòng điện ra AQW0
Bắt đầu CT
Chuyển giá trị đo được về nhiệt độ trong AIWx
Thực hiện tính toán nhiệt độ: giá trị đo được trừ đi giá trị đo được tại
0oC, chia cho độ chênh tương ứng với 1oC
Chia phần dư nhân 10 cho độ chênh tương ứng 1oC sau đó cộng vào
giá trị đã tính được Ghi vào vùng nhớ cập nhật ra thông báo 1 TD200
Hiển thị thông báo 1
Nhiệt độ > Nhiệt độ mức cao?
Hiện thông báo 2;
Tắt lò
Xóa bít cho phép hiển thị thông báo
2
Hiển thị thông báo 3
Mở lò
Xóa bít cho phép hiển thị thông báo
3 Nhiệt độ<Nhiệt độ mức thấp ?
Kết thúc
Sai
Sai Đúng
Đúng
Trang 14Mô tả chương trình:
Cảm biến nhiệt độ:
PT 100 là thiết bị phát hiện nhiệt độ bằng điện trở bạch kim, dải nhiệt độ thích hợp sử dụng thiết bị này là từ -60 đến 400 oC.
Tính toán nguồn cấp cho PT100
PT100 có giá trị điện trở là 100Ω ở nhiệt độ là 0oC Điện trở này thay đổi tuyến tính với nhiệt độ với tỷ lệ xấp xỉ 0,4 Ω/ oC
R [ O h m ]
T [ ° C ]
1 0 0
1 0 2
1 0 4
1 0 6
1 0 8
1 1 0
0 1 0 2 0
Để sinh ra một điện áp 5 mV/ oC, một nguồn dòng 12,5 mA được cấp cho PT 100 Độ phân giải ở đầu ra analog là 10uA/ 1 đơn vị Vì thế, giá trị để tạo ra dòng 12,5 mA là 1250 Do vùng nhớ cho đầu ra analog AQW là 16 bít Do vậy, phải nạp ra vùng nhớ này giá trị là 20000
để có thể tạo ra dòng điện 12,5 mA ở đầu ra Io.
20mA tương ứng với giá trị 32000 Do đó, (32000/20mA * 12.5mA = 20000)
RA A+ A- RB B+ B- RC C+ C- V0 I0 L+ M I
EM 235
ANALOG In-Out-PB
PT100
I0