Professional Documents
Culture Documents
Using PLC For Custom-Design of A PIDPWM Program To Control A Heater Temperature
Using PLC For Custom-Design of A PIDPWM Program To Control A Heater Temperature
Using PLC For Custom-Design of A PIDPWM Program To Control A Heater Temperature
ISSN 1546-9239
2007 Science Publications
PLC, PID software program, PWM, PLC, analogue input digital output, interface board
a high cost proprietary power interface module, this
simplifies the circuit and reduces its cost.
PLC manufacturers very often provide the option
of analogue I/O and support instant PID functions for
extra cost. Such functions can be used directly by
entering the control parameters and constants.
Nevertheless, this feature is only usable if the analogue
I/O module is installed. Therefore PID algorithm was
designed instead of using a ready one. This, also,
provides more flexibility to use the program with those
PLCs, which do not support ready PID loops. Designed
I/O board shown in Fig. 1 satisfies our demands and
costs one third of the I/O module's cost approximately.
Because of the limited size of this paper, the design
procedure of the I/O interface board is not illustrated. It
will be published in a special paper. However, I would
like to add that cost is not the only factor. As Johnson[2]
wrote: (every engineer has personal preferences as to
which flavor of PID algorithm should be used in any
particular situation). For example full PID algorithm
can only be used when the signal has little noise or
where suitable filtering or limiting has been applied.
Another example is that the derivative action could be
on the process variable only and could be on the system
error depending on the severity of change of system
error. In our study we make use of the digital values of
the PID output to initiate a PWM signal in order to
control the timing of the power switch.
INTRODUCTION
The use of a digital signal processor (DSP) to
evaluate the actual value of an analogue process output
and then compute a correction signal has many
advantages. DSP does not suffer from the long-term
drift effect that analogue circuits do. Changes to
constants can easily be made without the actual
physical change to the circuitry and simply modifying
the loaded program or loading a new one can radically
alter the mode of control. Realizing PWM techniques
and other advanced functions is some of the vast power
points of digital controllers. Actually, in most cases
DSPs are designed to replace the ON-line analogue
ones. This explains the continuous approaches to
implement digitally the traditional analogue control
modes such as PID actions.
Because of the advantages of the PLCs[1], a PLC
type S7-200 was utilized as a DSP. Nowadays most
modern sequential control systems are based on PLCs,
which are in fact specialized industrial computers.
Thus, one of the targets of this work is to design a PLC
program for PID control algorithm and to develop it to
get at the PLC output a PWM signal proportional to the
value at the output of PID controller. In this case there
is no need for a DAC IC nor for a specific power
amplifier stage. Here the PWM signal with the power
static switch emulates the function of a D-type power
amplifier. From another side, by using the designed
interface board, one can exclude the implementation of
PLC application consideration: The SIMATIC S7200 with CPU-214 supports many of the familiar
Corresponding Author: Mohammad A.K.Alia, Faculty of Engineering Technology, Al - Balqa' Applied University
307
R1
R2
R3
R4
R5
R6
750
750
75
15
120 K
325 K
R7
R8
R9
R10
R11
R12
1.2 K
100 K
2.2 K
1.2 K
2.2 K
325 K
R13
R14
R15
R16
R17
R18
39 K
47 K
2.2 K
2.2 K
1.2 K
150 K
R19
P1
P2
P3
P4
P5
308
75
100 K
500 K
1 M
300 K
2.4 K
C1
C2
D1
D2
D3
--
0.1F
100F
Silicon
2.2V LED
Zener 5V
--
0
I 1.0
1
I 0.1
2
I 0.2
3
I 0.3
4
I 0.4
5
I 0.5
6
I 0.6
7
I 0.7
Table 2: PLC program written in ladder diagram and statement list forms and illustrated network by network
Network 1
LAD
STL
SM0.1
Q0.0
( S )
0
(CALL)
On first scan, set image register bit "High".
Call SUBROUTINE 0.
First scan is indicated by the special memory bit SM0.1
Network 2
LAD
LD SM0.1
S Q0.0,1
CALL 0
STL
LD SM0.0
SM0.0
ATCH
EN
1 INT
ATCH 1,0
0 EVENT
SM0.0
MOV_B
EN
MOVB IB0,VB0
IB0 IN OUT VB0
Transfer the status of all inputs (I0.0,I0.1 I0.7) as a Byte called (VB0) containing the process variable value .
Note: this action involves (I0.0), which is not technically a process variable bit, for instance, this will not cause errors and shall be
treated soon.
Network 4
LAD
STL
LD I1.0
I1.0
V0.0
= V0.0
( )
Correcting the last network, replace the misplaced (V0.0) coming from (I0.0) with the actual bit obtained from (I1.0)
Network 5
LAD
STL
LD SM0.0
SM0.0
MOV_W
EN
MOVW VW10,VW20
MOV_W
EN
MOVW SMW28,VW10
SMW28 IN OUTVW10
309
SUB_I
EN
-I VW0,VW10
VW0 IN1
SM0.0
MOV_W
EN
MOVW Kp,VW30
Kp IN OUT VW30
MOV_W
EN
MOVW Ki,VW40
Ki IN OUT VW40
MOV_W
EN
MOVW Kd,VW50
Kd IN OUT VW50
MOV_W
EN
MOVW VW20,AC0
MUL
EN
VW30 IN1
MUL VW30,AC0
MOV_W
EN
MOVW VW20,AC1
ADD_I
EN
VW10 IN1
+I VW10,AC1
MUL
EN
VW40 IN1
MUL VW40,AC1
MUL
EN
1000/2 IN1
MUL 1000/2,AC1
ADD_DI
EN
AC1 IN1
+D AC1,AC0
310
MOV_W
EN
MOVW VW10,AC1
SUB_I
EN
VW20 IN1
-I VW20,AC1
MUL
EN
VW50 IN1
MUL VW50,AC1
DIV
EN
1000 IN1
DIV 1000,AC1
ADD_DI
EN
AC1 IN1
+D AC1,AC0
AC0 IN2 OUT AC0
SM0.0
DIV
EN
65535 IN1
MOV_W
EN
STL
LD SM0.0
DIV 65535,AC0
311
MOVW AC0,VW100
Scaling :
This network is necessary for scaling the output to comply with the next steps and give a flexible range of variation for the controller constants.
65535 is the maximum possible 16-bit (word) value.
Network 8
LAD
STL
MEND
(END)
SBR 0
SBR: 0
INITIALIZATION SUBROUTINE:
This subroutine is executed once at the first scan, its purpose is to initialize the function of the PWM featured by CPU-214 as follows.
Network 10
LAD
STL
LD SM0.0
SM0.0
MOV_B
MOVB 16#CA,SMW67
EN
MOV_W
EN
MOVW 1000,SMW68
1000 IN OUT SMW68
MOV_W
EN
MOVW 0,SMW70
0 IN OUT SMW70
PLS
EN
PLS 0
0 Q0.x
ENI
(ENI)
Control byte for PWM is stored in special memory byte (SM67) as illustrated in the following Table:
Table (2.1.1): PWM Control Byte
SM67.x
Bit no.
7
6
5
4
3
2
1
Bit value
1
1
0
0
1
0
1
effect
Enable
Select
Not used
(msec/tick)
No update
Update pulse
PWM
PWM
increments
for pulse
width time
count
value
The hexadecimal equivalent for (2 # 1100 1010) is (16 # CA)
Cycle time is stored in the special memory word (SM68)
Pulse width is initialized to be (zero) and stored in the special memory word (SM70)
Invoke PWM operation (PLS 0 activate Q 0.0)
Enable all interrupts (ENI)
Network 11
LAD
STL
(RET)
RET
312
0
0
No update
for cycle
time
INT 1
INT: 1
SM0.0
ADD_I
/EN
SMW70 IN1
+I VW100,SMW70
Each time (I0.0) transitions from OFF to ON , increase/decrease the pulse width depending on the sign and magnitude of controllers output stored
in (VW100)
Network 14
LAD
STL
LDW<= SMW70,SMW68
NOT
SMW70 SMW68
MOV_W
<=WNOTEN
MOVW SMW68,SMW70
OUTPUT LIMITATION:
If the pulse width (SM70) exceeds the duty cycle (due to controller output) ignore the excessive increment and store the maximum applicable
pulse width, which is equal to the cycle time (SM68).
Network 15
LAD
STL
LDW>= SMW70,0
NOT
SMW70 0
MOV_W
<=WNOTEN
MOVW 0,SMW70
this network prevents negative values of pulse width and stores a (zero) in (SM70) if such values occur.
Network 16
LAD
STL
LD SM0.0
SM0.0
PLS
PLS 0
EN
0 Q0.x
DTCH
DTCH 0
EN
0 EVENT
RETI
(RETI)
End of interrupt 1
End of PLC program
Time
[sec]
1210
1220
1230
1240
1250
1260
1270
1280
1290
1300
1310
1320
1330
1340
1350
1360
1370
1380
1390
1400
1410
1420
1430
1440
1450
1460
1470
1480
1490
1500
1510
1520
1530
1540
1550
1560
1570
1580
1590
1600
Time
[sec]
1210
1220
1230
1240
1250
1260
1270
1280
1290
1300
1310
1320
1330
1340
1350
1360
1370
1380
314
Temp.
[C]
46.4
46.4
46.4
46.4
46.3
46.3
46.3
46.3
46.3
46.3
46.2
46.1
45.9
45.6
45.7
45.9
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
46.2
Temp. [C]
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
Time
[sec]
1610
1620
1630
1640
1650
1660
1670
1680
1690
1700
1710
1720
1730
1740
1750
1760
1770
1780
1790
1800
1810
1820
1830
1840
1850
1860
1870
1880
1890
1900
1910
1920
1930
1940
1950
1960
1970
1980
1990
2000
Time
[sec]
1610
1620
1630
1640
1650
1660
1670
1680
1690
1700
1710
1720
1730
1740
1750
1760
1770
1780
Temp.
[C]
46.2
46.2
46.2
46.2
41.8
42.5
43.6
44.0
44.5
46.1
46.9
47.9
48.3
48.7
49.3
49.7
49.9
50.1
50.2
50.2
50.2
50.1
50.0
49.9
49.8
49.7
49.5
49.2
49.0
48.8
48.6
48.5
48.2
48.0
47.7
47.6
47.4
46.3
45.5
45.6
Temp. [C]
44.5
44.7
44.7
45.6
46.4
46.7
47.6
48.2
48.8
49.0
49.2
50.0
50.2
50.6
51.0
51.2
51.5
52.0
Time
[sec]
2010
2020
2030
2040
2050
2060
2070
2080
2090
2100
2110
2120
2130
2140
2150
2160
2170
2180
2190
2200
2210
2220
2230
2240
2250
2260
2270
2280
2290
2300
2310
2320
2330
2340
2350
2360
2370
2380
2390
2936
Time
[sec]
2010
2020
2030
2040
2050
2060
2070
2080
2090
2100
2110
2120
2130
2140
2150
2160
2170
2180
Temp.
[C]
45.5
45.4
45.3
45.2
45.1
44.9
43.7
43.8
45.0
45.3
45.3
45.1
44.8
44.6
44.6
44.6
44.5
44.5
44.3
44.0
44.0
44.1
44.0
44.0
43.8
43.8
43.7
43.7
43.5
43.6
43.6
43.4
43.2
43.2
43.2
43.2
43.2
43.2
43.2
43.2
Temp. [C]
52.3
52.0
51.8
51.6
51.4
51.2
51.3
51.2
51.3
51.3
51.4
51.5
51.6
51.7
51.9
52.0
52.1
52.3
51.8
52.7
53.4
54.0
54.3
54.6
54.7
54.6
54.6
54.4
54.1
53.8
53.4
53.1
52.7
52.3
51.8
51.4
51.1
50.8
50.5
50.2
590
600
610
620
630
640
650
660
670
680
690
700
710
720
730
740
750
760
770
780
790
800
51.1
51.3
51.2
51.4
51.3
51.4
51.3
51.3
50.5
50.7
50.8
50.8
51.0
51.2
51.4
51.6
52.2
52.5
52.8
53.4
53.9
54.7
990
1000
1010
1020
1030
1040
1050
1060
1070
1080
1090
1100
1110
1120
1130
1140
1150
1160
1170
1180
1190
1200
52.6
52.5
52.4
52.4
52.5
52.5
52.7
53.0
53.1
53.2
53.1
53.4
53.5
53.6
53.6
53.7
53.7
53.5
53.5
53.5
53.4
53.4
1390
1400
1410
1420
1430
1440
1450
1460
1470
1480
1490
1500
1510
1520
1530
1540
1550
1560
1570
1580
1590
1600
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
53.3
1790
1800
1810
1820
1830
1840
1850
1860
1870
1880
1890
1900
1910
1920
1930
1940
1950
1960
1970
1980
1990
2000
51.9
52.5
53.4
54.5
55.0
56.0
56.7
58.0
58.3
58.3
58.0
57.5
57.1
56.7
56.1
55.6
55.0
54.5
53.4
53.1
52.1
52.4
2190
2200
2210
2220
2230
2240
2250
2260
2270
2280
2290
2300
2310
2320
2330
2340
2350
2360
2370
2380
2390
2936
52.4
52.6
52.7
52.7
52.7
52.7
52.6
52.7
52.6
52.5
52.7
52.8
52.9
52.9
53.0
53.1
53.2
53.2
53.3
53.3
53.3
53.3
60
Temperature [ Celsius ]
50
40
30
20
10
0
0
10
15
20
25
30
35
40
45
50
time [ Minute ]
70
60
50
40
30
20
10
0
0
10
15
20
25
30
35
40
45
50
time [ Minute ]
REFERENCES
1.
2.
3.
4
5.
CONCLUSION
*
316