Basic Programming Principles of PLCs
◾
325
(C
1
, C
2
, and C
3
) with their corresponding START-STOP control buttons. Because START-STOP
automation is exactly the same for the three machines, a simple FC can be used instead of a single
unified program. The first step is the FC programming that includes the declaration of variables,
the FC naming, the introduction of comments, and the automation program implemented by the
FC. These actions will have the result that follows:
Program
A(
O
SR T
O
MRT
)
A
ST P
=
MRT
BE
Variable declaration
Name
Declaration
Type
Comment
SR T
INPUT
Boole
Starting motor
ST P
INPUT
Boole
Stopping motor
MRT
OUTPUT
Boole
Power relay of motor
FC3
The second step is to write the general program that will call the FC3 in series for the three
machines, and which will have the following form:
CAL L
FC 3
SR T:= I0.0
ST P:=
I0.1
MRT: = Q2.0
CAL L
FC 3
SR T:= I0.2
ST P:=
I0.3
MRT: = Q2.3
CAL L FC 3
SR T:= I0.4
ST P:= I0.5
MRT: = Q2.6
BE
Main program
Of course, the number of instructions included in the FC3 is small due to the simplicity of
the example. The use of an FC is greatly facilitated when the repetitive operation requires a large
number of instructions and repetitions. For example, let’s assume that FC3 has 80 instructions
and 25 motors. Then the number of the required instructions and thus the size of a single unified
program without using FCs can be easily imagined.
Both the main program and the FC3, as well as any other POU, are programmed, as expected, in
the PLC software environment that will be utilized. Since the main program and FC3 are declared,
programmed, and stored, the software environment is the one that will establish their interface without
the need for any additional programming action by the user. In Figure 7.57, the I/O devices of two
motors with inversion of rotation (from the overall 10 available, whose operation will be programmed
326
◾
Introduction to Industrial Automation
using an FC) are shown. The same figure shows the FC1 that implements the inversion function of
motors as a subroutine, the main program, and the instruction calls among them.
The programming of an FB that is directly linked to one or more data blocks is also addressed
in a similar way. Figure 7.58 shows a production process consisting of three conveyor belts (M
1
, M
2
,
and M
3
) for transferring different objects, three processing machines (W
1
, W
2
, and W
3
), a central
conveyor belt (M
4
) and a finishing, assembly, and packaging station (S). The four conveyor belts
have a similar function (e.g., ON, OFF, counting, etc.), but because they carry different objects,
certain technical parameters and data are different for each conveyor. This may be, for example,
the transport speed, the number limits of objects that each conveyor transfers, etc. Therefore, the
operation of the conveyor belts can be controlled by a single FB, which will be associated with four
data blocks (DB1,..., DB4) in which the corresponding parameter values for each conveyor belt will
be stored. The processing machines W
1
, W
2
, and W
3
have a completely similar function and the
only element in which they differ also belongs in the START-STOP logic function. For example, if
W
1
, W
2
, and W
3
are coloring machines, only the paint color they apply can vary, and therefore the
output that will be activated in each one. It is understood that each machine can paint with three
different colors. If these are labeling machines, they can only differ in the type of label and so on;
many similar examples can be assumed. For this reason, the processing machines W
1
, W
2
, and W
3
...
...
Outputs
...
...
PLC
Inputs
0 V
+24 V DC
0 V
+24 V DC
I 1.0
I 1.4
C
1L
Q 0.4
I 1.2
I 2.0
I 2.2
Q 0.0
STOP 1
STOP 2
I 1.6
C
1R
C
2L
C
2R
1
st
call
2nd ca
ll
10th
cal
l
Q 0.2
Q 0.6
START 1
Left
START 1
Right
START 2
Left
START 2
Right
FC1
Variable declaration
Name
Type
Declaration
Comment
STARTL
Input
Bool
Start left
STARTW
Input
Bool
Start right
STOP
Input
Bool
Stop operation
OUTPUTL
Output
Bool
OUTPUTW Output
Bool
Right rotation relay
Program
Α
STARTL
AN STARTW
S
OUTPUTL
R
OUTPUTW
A
STARTW
AN STARTL
S
OUTPUTW
R
OUTPUTL
A
STOP
R
OUTPUTL
R
OUTPUTW
END FUNCTION
Main program
CALL FC1
STARTL:=
I1.0
STARTW:=
I1.2
STOP:=
I1.4
OUTPUTL:=
Q0.0
OUTPUTW:=
Q0.2
CALL FC1
STARTL:=
I1.6
STARTW:=
I2.0
STOP:=
I2.2
OUTPUTL:=
Q0.4
OUTPUTW:=
Q0.6
(Next calls of FC1 for the
operation of other motors)
ΒΕ
Left rotation relay
Do'stlaringiz bilan baham: