Tải bản đầy đủ (.doc) (13 trang)

Tìm hiểu về PID trong PLC

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (182.79 KB, 13 trang )

SIMATIC
S7-200 Tips
S7-200 Tip PID-Instruction Tip No. 53
Group Topic
6 Using the PID-Instruction
CPUs required for this tip
CPU 210  CPU 212  CPU 214  CPU 215  CPU 216  OTHER 
Overview
The following S7-200 program is an short example of how to use the PID instruction.
The PID instruction will be explained using an example of a water tank. The aim is to maintain a
constant water pressure and also keep the tank from being emptied.
Analog Input (4-20mA) for PID PV
B+,B- and C+,C-
are unused inputs
Analog Output (0-10V) from PID process
pump with the
water supply
water level 75 %
I 0.7
I 0.2
I 0.6
I 0.5
I 0.4
I 0.3
I 0.1
I 0.0
I 1.2
I 1.5
I 1.4
I 1.3
I 1.1


I 1.0
Q 0.7
Q 0.2
Q 0.6
Q 0.5
Q 0.4
Q 0.3
Q 0.1
Q 0.0
Q 1.1
Q 1.0
STOP
RUN
SF
SIEMENS
6ES7 214-1BC01-0XB0
CPU 216
SIMATIC
S7-200
X
4
1
3
EXTF
EM 235
AI 3x12Bit
AQ 1x12Bit
A+
A-
B+

B-
Vo
L+
M
M
L+
Figure 53.1
Copyright 1997 by SIEMENS page 1 / 13 pgb1404015135.doc
Status: 10/97 Version 1.1
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip PID-Instruction Tip No. 53
Hardware Requirements
1 S7-200 PLC
1 Expansion Module EM 235 Analog Combination AI 3/ AQ 1x 12 Bits
General Description
In this example, a water tank is used to maintain a constant water pressure. Water is
continuously being taken from the water tank at a varying rate. A variable speed pump is used
to add water to the tank at a rate that will maintain adequate water pressure and also keep the
tank from being emptied.
The setpoint for this system is a water level setting that is equivalent to the tank being 75% full.
The process variable is supplied by a float gauge that provides an equivalent reading of how full
the tank is and which can vary from 0% or empty to 100% or completely full. The output is a
value of pump speed that allows the pump to run from 0% to 100% of maximum speed.
The setpoint is predetermined and will be entered directly into the loop table. The process
variable will be supplied as a 4 to 20 ma analog value from the float gauge. The loop output will
be written to the analog output (0 to 10 V), which is used to control the pump speed. The span
of both, the analog input and analog output is 32,000.
NOTE: The Analog value (AIW0) can be averaged by an average subroutine, to filter the input
before the value is used as the PV. Refer tip no. 54 for details.

Only proportional and integral control will be employed in this example. The loop gain and time
constants have been determined from engineering calculations and may be adjusted as
required to achieve optimum control. The calculated values of the time constants are:
K
C
- 0.25 T
S
- 0.1 seconds and T
I
- 30 minutes.
The tank speed will be controlled manually until the water tank is 75% full, then the valve will be
opened to allow water to be drained from the tank. At the same time, the pump will be switched
from manual to auto control mode. A digital input will be used to switch the control from manual
to auto. This input is described below:
I0.0 - Manual/Auto control: 0 - manual, 1 - auto
While in manual mode, the pump speed will be written by the operator to VD108 as a real
number value from 0.0 to 1.0.
The following information documents the program and its operation as well as defining the
variables, subroutines and interrupt routines used by the program.
Subroutines:
SBR0 Initialization subroutine
SBR1 Subroutine to check, if an error occurred at the analog module
Copyright 1997 by SIEMENS page 2 / 13 pgb1404015135.doc
Status: 10/97 Version 1.1
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip PID-Instruction Tip No. 53
Interrupt Routines:
INT 0 100 ms timed interrupt that invokes PID execution
Description of variables:

I0.0 Manual/Auto control
Q0.7 Error on the Analog module
The loop table is 36 byte long and the parameters in the V-memory table are all standard
double words (VD) The loop table has the following format:
Offset Calculation Format Data
type
Description user
definable
0 Process
variable
Double word
- real
In Contains the process variable, which must be
scaled between 0.0 and 1.0
NO
4 Setpoint Double word
- real
I
N
Contains the setpoint, which must be scaled
between 0.0 and 1.0
YES
8 Output Double word
- real
In/Out Contains the calculated output,
scaled between 0.0 and 1.0
NO
12 Gain Double word
- real
In Contains the gain, which is a proportional

constant. Can be a positive or negative number.
YES
16 Sample time Double word
- real
In Contains the sample time, in seconds.
Must be a positive number.
YES
20 Integral time or
reset
Double word
- real
In Contains the integral time or reset, in minutes.
Must be a positive number.
YES
24 Derivative time
or rate
Double word
- real
In Contains the derivative time or rate, in minutes.
Must be a positive number
YES
28 Bias Double word
- real
In/Out Contains the bias or integral sum value
between 0.0 and 1.0
YES
32 Previous
process variable
Double word
- real

In/Out Contains the previous value of the process
variable stored from the last execution of the
PID instruction.
NO
(Note: The basic address of the example program is VD100.)
VD100 process variable (PV) , from the analog input AWI0
VD104 setpoint (SP)
VD108 output (M), contains the calculated output
VD112 gain (Kc), a proportional constant
VD116 sample time (Ts)
VD120 integral time (Ti)
VD124 derivative time (Td) or rate
VD128 bias (MX) or integral sum
VD132 previous process variable (PV
N-1
)
More information about the PID Instruction is provided in the S7-200 System manual. Basics of
Controlling with PID is explained in tip 32.
Information about the analog module is provided in the S7-200 System manual and in tip 34.
Copyright 1997 by SIEMENS page 3 / 13 pgb1404015135.doc
Status: 10/97 Version 1.1
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip PID-Instruction Tip No. 53
Program Structure
Get the process variable value from the the anlog input word (AIW0),
scale value and store the converted value in the loop table.


main program

Start
main program
End
On the first scan: Initialization (SBR 0)
Set and enable time interrupts (INT 0)
In auto mode : execute PID-instruction
Update analog output

Interrupt program
Start
Interrupt program
End
On every scan: Check if the analog module has an error (SBR1)
Set Q0.7 if an error occured.
Copyright 1997 by SIEMENS page 4 / 13 pgb1404015135.doc
Status: 10/97 Version 1.1
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip PID-Instruction Tip No. 53
LAD (S7-MicroDOS) STL (IEC)
program description and main program
// PID Example Program

│ SM0.1 0
1 ├─┤ ├────────────────────────( CALL )


│ SM0.0 1
2 ├─┤ ├────────────────────────( CALL )



3 ├──────────────────────────────( MEND )

LD SM0.1 // On the first scan
CALL 0 // Call the initialization
// subroutine
LD SM0.0 // On each scan
CALL 1 // Check if error at the analog
//module
MEND // End the main program
Subroutines
// SBR0: Initialization (set and enable timed interrupt)
┌──────────┐
│ SBR: 0 │
└───┬──────┘
│ SM0.0 MOV_B───┐
5 ├─┤ ├───────────┬────────────┤EN │
│ │ K100┤IN OUT├SMB34
│ │ └───────┘
│ │ ATCH────┐
│ ├────────────┤EN │
│ │ K0┤INT │
│ │ K10┤EVT │
│ │ └───────┘
│ │
│ └────────────( ENI )

6 ├──────────────────────────────( RET )
SBR 0
LD SM0.0

MOVB 100, SMB34
// time interval (100ms) for timed
// interrupt
ATCH 0, 10
//Set timed interrupt to invoke
// PID execution
ENI // Enable interrupts
RET
// SBR1: Check for errors at the analog module. If an error occurs set the Q0.7.

┌──────────┐
│ SBR: 1 │
└───┬──────┘
│ SMB8 KH19 Q0.7
8 ├─────┤ == B ├─────┤NOT├─┬──────( )
│ │
│ │
│ │
│ │
│ SMB9 KH0 │
├─────┤ == B ├─────┤NOT├─┘


9 ├──────────────────────────────( RET )
SBR 1
LDB= SMB8, 16#19 // Check,
NOT // if analog module is plugged in
LDB= SMB9, 16#0 // Check,
NOT // if analog module has an error
OLD

= Q0.7
// Error reading analog module
RET
Copyright 1997 by SIEMENS page 5 / 13 pgb1404015135.doc
Status: 10/97 Version 1.1
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip PID-Instruction Tip No. 53

// INT 0: Interrupt routine - PID- Routine (timed interrupt for PID-execution).
┌──────────┐
│ INT: 0 │
└───┬──────┘
│ Q0.7 WXOR_DW─┐
11 ├─┤ / ├───────────┬────────────┤EN │
│ │ AC0┤IN1 OUT├AC0
│ │ AC0┤IN2 │
│ │ └───────┘
│ │ MOV_W───┐
│ ├────────────┤EN │
│ │ AIW0┤IN OUT├AC0
│ │ └───────┘
│ │ DI_REAL─┐
│ ├────────────┤EN │
│ │ AC0┤IN OUT├AC0
│ │ └───────┘
│ │ SUB_R───┐
│ ├────────────┤EN │
│ │ KR+6400.00┤IN1 OUT├AC0
│ │ AC0┤IN2 │

│ │ └───────┘
│ │ DIV_R───┐
│ ├────────────┤EN │
│ │ AC0┤IN1 OUT├AC0
│ │ KR+25600.0┤IN2 │
│ │ └───────┘
│ │ MOV_R───┐
│ └────────────┤EN │
│ AC0┤IN OUT├VD100
│ └───────┘
│ I0.0 PID─────┐
12 ├─┤ ├────────────────────────┤EN │
│ VB100┤TBL │
│ 0┤LOOP │
│ └───────┘
│ SM0.0 MUL_R───┐
13 ├─┤ ├───────────┬────────────┤EN │
│ │ VD108┤IN1 OUT├AC0
│ │ KR+32000.0┤IN2 │
│ │ └───────┘
│ │ TRUNC───┐
│ ├────────────┤EN │
│ │ AC0┤IN OUT├AC0
│ │ └───────┘
│ │ MOV_W───┐
│ └────────────┤EN │
│ AC0┤IN OUT├AQW0
│ └───────┘

14 ├──────────────────────────────( RETI )

INT 0
LDN Q0.7
// If analog module is O.K.?
XORD AC0, AC0
// Clear the accumulator
MOVW AIW0, AC0
// save the analog value
DTR AC0, AC0
// Convert 32-bit integer to real
-R 6400.0, AC0
// Adjust for 4 to 20 mA offset
/R 25600.0, AC0
// Normalize the PV
// value in the accumulator
MOVR AC0, VD100
// Store accu in the loop Table
LD I0.0 // When auto mode,
PID VB100, 0 // invoke PID execution
// Analog Output
LD SM0.0
MOVR VD108, AC0 // loop output to accu
*R 32000.00, AC0 // scale value in accu
TRUNC AC0, AC0 // Convert real to
// 32-bit integer
MOVW AC0, AQW0
// write the value to analog output
RETI
Copyright 1997 by SIEMENS page 6 / 13 pgb1404015135.doc
Status: 10/97 Version 1.1
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.

Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip PID-Instruction Tip No. 53
Data Block DB1 (V Memory):
// initialize values
VD104 0.75 // setpoint = 0.75 = 75% full
VD112 0.25 // loop gain = 0.25
VD116 0.10 // sample time = 0.1 seconds
VD120 30.0 // integral time = 30 minutes
VD124 0.0 // no derivation action
Conversion 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.
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.
Copyright 1997 by SIEMENS page 7 / 13 pgb1404015135.doc
Status: 10/97 Version 1.1
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip PID-Instruction Tip No. 53
Tham khảo:
Chương trình S7 – 200 dưới đây chỉ là một ví dụ ngắn về cách sử dụng PID thông qua ví
dụ về điều khiển mức nước trong bể để vừa đảm bảo áp suất vừa đảm bảo nước trong bình
không bị cạn hết. Cấu trúc hệ thống như hình dưới đây:
Yêu cầu thiết bị điều khiển: 01 PLC S7 200/ CPU 216 trở lên và 01 khối EM 235 gồm có
3 đầu vào analog và một đầu ra analog 12 bít
Mô tả hệ thống:
Trong hệ thống này, một bể nước được dùng để khống chế áp lực nước không đổi.
Nước liên tục được lấy ra từ vòi với một tốc độ bất kỳ. Bơm được dùng để tăng thêm nước vào
bể với một tốc độ đủ để duy trì áp suất cũng như mức nước trong bình không hạ xuống quá
mức cho phép.
Giá trị đặt của hệ thống là mức nước (trong ví dụ này là 75% bể). Đại lượng đầu vào
của hệ thống là tín hiệu do một cảm biến đo mức đưa về thông qua đầu vào analog A+, A Tín
hiệu đưa về có thể thay đổi từ 4 – 20mA tương ứng với 0 – 100% mức đầy của bể. Tín hiệu ra
của hệ thống là tín hiệu điện áp có thể thay đổi từ 0 – 10 V dùng để điều khiển tốc độ bơm
tương ứng là 0 – 100% tốc độ định mức.
Giá trị đặt được quyết định bởi người sử dụng và được đưa trực tiếp vào quá trình.
Trong chương trình này, bộ điều khiển sử dụng hai thông số là P và I, không dùng đến D. Thời
gian lấy mẫu là T

s
= 0.1 giây, K
C
= 0.25 và T
i
= 30 phút.
Trước tiên, bể nước sẽ được tiếp đầy nước cho đến khi được 75%. Sau đó, van xả sẽ
được mở để lấy nước từ bể và cùng lúc bơm sẽ được chuyển từ chế độ điều khiển bằng tay
sang chế độ tự động.
Trong quá trình điều khiển bằng tay, tốc độ bơm được qui định bởi số thực lưu tại
VD108 nằm trong khoảng 0.0 tới 1.0.
Copyright 1997 by SIEMENS page 8 / 13 pgb1404015135.doc
Status: 10/97 Version 1.1
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip PID-Instruction Tip No. 53
SBR0 là hàm thực hiện khởi tạo hệ thống.
SBR 1 là hàm thực hiện kiểm tra lỗi của khối analog.
Đầu vào I0.0 sẽ được dùng là tín hiệu khởi động hệ thống điều khiển tự động.
Đầu ra Q0.7 báo lỗi xảy ra ở module analog
Ngắt INT 0 thực hiện thuật toán PID mỗi 100 ms một lần
Bảng lặp dùng cho PID gồm có 36 byte và những thống số được đặt trong vùng nhớ V
và tất cả đều dùng là double word (VD)
Khoảng
cách
so với
địa chỉ
bắt đầu
Thông số tính
toán

Định dạng vào/ra Mô tả Người
dùng có
thể định
nghĩa
0 PV Double word
- real
vào Tín hiệu về mức nước hiện tại trong bể, khoảng
0.0 – 1.0 tương ứng 0 – 100%
NO
4 SP Double word
- real
I
N
Giá trị đặt về mức nước trong bể, cũng phải
nằm trong khoảng 0.0 – 1.0
YES
8 M Double word
- real
In/Out Giá trị tín hiệu ra, nằm trong khoảng 0.0 – 1.0 NO
12 K
C
Double word
- real
In Hệ số khuếch đại P. YES
16 T
S
Double word
- real
In Thời gian trích mẫu YES
20 T

i
Double word
- real
In Thời gian tích phân. YES
24 T
d
Double word
- real
In Thời gian vi phân YES
28 Bias (MX) Double word
- real
In/Out Tổng tích phân (bias MX or integral sum) YES
32 PV
N-1
Double word
- real
In/Out Giá trị mức nước đo được lần lấy mẫu trước NO
Trong chương trình dùng địa chỉ bắt đầu của bảng là VD100
VD100 PV , lấy vào từ AWI0
VD104 SP
VD108 M
VD112 Kc
VD116 Ts
VD120 Ti
VD124 Td
VD128 MX
VD132 PV
N-1
Có thể tham khảo thêm về PID trong các tài liệu được cung cấp trong Hướng dẫn sử
dụng hệ thống S7 200 và các sách tham khảo khác.

Copyright 1997 by SIEMENS page 9 / 13 pgb1404015135.doc
Status: 10/97 Version 1.1
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip PID-Instruction Tip No. 53
Lưu đồ thuật toán
Copyright 1997 by SIEMENS page 10 / 13 pgb1404015135.doc
Status: 10/97 Version 1.1
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip PID-Instruction Tip No. 53
CHƯƠNG TRÌNH ĐIỀU KHIỂN
// PID

│ SM0.1 0
1 ├─┤ ├────────────────────────( CALL )


│ SM0.0 1
2 ├─┤ ├────────────────────────( CALL )


3 ├──────────────────────────────( MEND )

LD SM0.1 // ON tại vòng quét đầu
CALL 0 // Gọi hàm khởi tạo hệ thống
LD SM0.0 // Luôn luôn ON
CALL 1 // Gọi hàm kiểm tra lỗi của
// khối analog
MEND // Kết thúc

Hàm chức năng
// SBR0: Khởi tạo hệ thống và khởi động ngắt thời gian
┌──────────┐
│ SBR: 0 │
└───┬──────┘
│ SM0.0 MOV_B───┐
5 ├─┤ ├───────────┬────────────┤EN │
│ │ K100┤IN OUT├SMB34
│ │ └───────┘
│ │ ATCH────┐
│ ├────────────┤EN │
│ │ K0┤INT │
│ │ K10┤EVT │
│ │ └───────┘
│ │
│ └────────────( ENI )

6 ├──────────────────────────────( RET )
SBR 0
LD SM0.0
MOVB 100, SMB34
// Thời gian ngắt là 100 ms
ATCH 0, 10
// Gọi chương trình ngắt thời gian (10) để
thực hiện thuật toán PID
ENI // Chấp nhận hoạt động
RET // Trở về chươn trình chính
// SBR1: Kiểm tra lỗi khối analog và báo lỗi bằng Q0.7

┌──────────┐

│ SBR: 1 │
└───┬──────┘
│ SMB8 KH19 Q0.7
8 ├─────┤ == B ├─────┤NOT├─┬──────( )
│ │
│ │
│ │
│ │
│ SMB9 KH0 │
├─────┤ == B ├─────┤NOT├─┘


9 ├──────────────────────────────( RET )

SBR 1
LDB= SMB8, 16#19
// Nếu không có khối EM235 thì báo lỗi
NOT
LDB= SMB9, 16#0
// Nếu đã có EM235 nhưng có lỗi thì cũng
báo lỗi
NOT
OLD
= Q0.7
// Error reading analog module
RET
Copyright 1997 by SIEMENS page 11 / 13 pgb1404015135.doc
Status: 10/97 Version 1.1
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.

S7-200 Tip PID-Instruction Tip No. 53
// INT 0: Thực hiện thuật toán PID
┌──────────┐
│ INT: 0 │
└───┬──────┘
│ Q0.7 WXOR_DW─┐
11 ├─┤ / ├───────────┬────────────┤EN │
│ │ AC0┤IN1 OUT├AC0
│ │ AC0┤IN2 │
│ │ └───────┘
│ │ MOV_W───┐
│ ├────────────┤EN │
│ │ AIW0┤IN OUT├AC0
│ │ └───────┘
│ │ DI_REAL─┐
│ ├────────────┤EN │
│ │ AC0┤IN OUT├AC0
│ │ └───────┘
│ │ SUB_R───┐
│ ├────────────┤EN │
│ │ KR+6400.00┤IN1 OUT├AC0
│ │ AC0┤IN2 │
│ │ └───────┘
│ │ DIV_R───┐
│ ├────────────┤EN │
│ │ AC0┤IN1 OUT├AC0
│ │ KR+25600.0┤IN2 │
│ │ └───────┘
│ │ MOV_R───┐
│ └────────────┤EN │

│ AC0┤IN OUT├VD100
│ └───────┘
│ I0.0 PID─────┐
12 ├─┤ ├────────────────────────┤EN │
│ VB100┤TBL │
│ 0┤LOOP │
│ └───────┘
│ SM0.0 MUL_R───┐
13 ├─┤ ├───────────┬────────────┤EN │
│ │ VD108┤IN1 OUT├AC0
│ │ KR+32000.0┤IN2 │
│ │ └───────┘
│ │ TRUNC───┐
│ ├────────────┤EN │
│ │ AC0┤IN OUT├AC0
│ │ └───────┘
│ │ MOV_W───┐
│ └────────────┤EN │
│ AC0┤IN OUT├AQW0
│ └───────┘

14 ├──────────────────────────────( RETI )
INT 0
LDN Q0.7
// Nếu khối analog không có lỗi
XORD AC0, AC0
// Xóa AC0
MOVW AIW0, AC0
// Lấy giá trị đo được về mức nước PV
DTR AC0, AC0

// Chuyển đổi sang số thực 32 bít
-R 6400.0, AC0
// Chuyển đổi sang tín hiệu 4 – 20 mA
/R 25600.0, AC0
// Chuyển PV về giá trị thường dùng
MOVR AC0, VD100
// Lưu vào vùng nhớ
LD I0.0 // Chế độ Auto
PID VB100, 0 // Thực hiện PID với địa
chỉ bắt đầu là VB100
// Tín hiệu đầu ra analog
LD SM0.0
MOVR VD108, AC0 // Đưa ra AC0
*R 32000.00, AC0 // chuyển thang giá trị
TRUNC AC0, AC0
//Chuyển sang số nguyên 32 bít
MOVW AC0, AQW0
// Gửi ra đầu ra
RETI // Trở lại chương trình chính
Copyright 1997 by SIEMENS page 12 / 13 pgb1404015135.doc
Status: 10/97 Version 1.1
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.
S7-200 Tip PID-Instruction Tip No. 53
Dữ liệu DB1 (V Memory):
// Khởi tạo
VD104 0.75 // SV = 0.75 = 75% full
VD112 0.25 // K
c
= 0.25

VD116 0.10 // T
s
= 0.1 seconds
VD120 30.0 // T
i
= 30 minutes
VD124 0.0 // T
d
= 0
Copyright 1997 by SIEMENS page 13 / 13 pgb1404015135.doc
Status: 10/97 Version 1.1
SIMATIC S7-200 customers have free use of the application tips. These tips are only a general approach to using the S7-200 with various applications.
Your specific application may be different. It is your responsibility to use the SIMATIC S7-200 properly in your applications.

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×