.
Basic Programming Principles of PLCs
◾
283
Ta
bl
e 7
.1 (
C
on
ti
nu
ed
)
Pro
gr
am
m
in
g i
ns
tr
uc
ti
on
s i
n t
hr
ee b
as
ic la
ng
ua
ge
s
Languag
e
Oper
and
Inst
ruc
tion Oper
at
ion
Boole
FBD
LAD
T
IB, IW
, QB, QW
,
MB, MW
Transf
er the content of the accumulator to the operand
independentl
y of RL
O
Complemental
instructions
CU
C
xx
CU
C
xx
CU
C
Increase the content of the counter C
xx
b
y 1 on positiv
e
going edg
e of RL
O
CD
C
xx
CD
C
xx
CD
C
Decrease the content of the counter C
xx
b
y 1 on
positiv
e g
oing edg
e of RL
O
≥, ≤, ≠
CMP ≥1
IN
1
IN
2
CMP ≥1
IN
1
IN
2
Accumulator
Per
form comparison betw
een the contents of tw
o
accumulators
JU
Label
JM
P
(JMP)
Label
Label
Jump to another program instruction (instead of the
ne
xt instruction) unconditionall
y
JC
Label
JM
P
(JMP)
Label
Label
Jump to another program instruction (instead of the
ne
xt instruction) if RL
O = 1
CALL
DB
YY
FB
XX
DB
YY
FB
XX
FB, FC
Call a F
unction Block or a F
unction
Notes:
(1) Alternativ
e terms instead of Set/Reset and L
oad/T
ransf
er respectiv
el
y
IB
=
Input By
te
CU
=
Counter Up
FB
=
Function Block
IW
=
Input W
ord
CD
=
Counter Down
FC
=
Function
QB
=
Output By
te
JMP
=
Jump
DB
=
Data Block (Data F
ile)
QW
=
Output W
ord
JU
=
Jump Uncondionall
y
RL
O
=
Result of L
ogic Operation
MB
=
Memor
y Bit By
te
JC
=
Junp Conditionall
y
MW
=
Memor
y Bit W
ord
CMP
=
Compare
284
◾
Introduction to Industrial Automation
language. In the column of variables, the following notations are depicted with the corresponding
explanations:
I
= Input
Q = Output
*
M
= Auxiliary memory bit (logic coil)
T = Timer
C = Counter
FB = POU function block
FC = POU function
IB
= Input byte
IW = Input word
†
QB = Output byte
QW = Output word
†
MB = Auxiliary memory byte
MW = Auxiliary memory word
†
Label = Alphanumeric label
‡
Each PLC contains at least two accumulators with widths of two digital words each, starting
from the least significant byte on the right to the most significant byte on the left, as shown in Figure
7.8. The two words and the four bytes are marked with the initials L or H, representing “low” or
“high” significance. The contents of the register 1 are modified by using the load instruction (abbre-
viation L). In the register, a byte, a word, or a double word can be loaded after the initial shift of
the old content of register 1 to register 2, and the reset of register 1. Obviously, loading a numeric
constant to the register creates an equivalent digital content of the constant in binary form, unless
otherwise specified by the loading instruction (e.g., BCD code). The transfer instruction (abbrevia-
tion T) always transfers the contents of register 1 to where it is specified with the instruction.
In the column named “instruction operation”, the action performed by the CPU is summa-
rized when executing each instruction respectively. But before proceeding with the actions of the
various programming instructions, it is necessary first to introduce and explain the term “result of
instruction operation”.
7.4.1 The Result of an Instruction Execution
The term “result of a logic operation” (RLO) is characterized by the logical result created in the
CPU after an instruction execution. Every time that an instruction is executed, a new RLO is cre-
ated that depends on the type of instruction and on the previous RLO, while the last one executed
is erased afterwards. The concept of the RLO will be further explained with the help of the classic
automation circuit presented in Figure 7.9. The activation of the relay C is dependent on the status
of the three switching contacts S
1
, S
2
, and S
3
. Initially, it is assumed that the relay is not energized,
and the status of the circuit branch needs to be examined. In this case, it is assumed further that
the status of the three switching contacts (their status is not known in advance) when testing the
*
The normal letter for the output notation is “O”, but since OR instruction in Boolean language uses the same
letter, “Q” has been adopted in order to avoid any confusion.
†
There are additional variables for double word (DW) with similar notation and handling that are omitted.
‡
An alphanumeric word called “label” is written in front of an instruction to define the point of program transi-
tion after a jump instruction execution.
Basic Programming Principles of PLCs
◾
285
circuit is exactly as indicated in Figure 7.9. It is initially examined with a simple voltmeter if there
is any electrical voltage at the power supply. If voltage exists, the next step is to examine if there is
voltage just after the contact S
1
. Since S
1
is a closed contact, the voltmeter will show us the trend.
Continuing the examination of this circuit branch, the next point to be checked is the one imme-
diately below the S
2
contact, as shown in Figure 7.9. Since the S
2
contact is open, the voltmeter will
not show a voltage, and therefore it explains why the relay C is not energized. However, in the wired
branch, the presence or absence of an electrical voltage, as well as the flow of the electric current,
occurs naturally by itself and automatically as a consequence of the existence of a potential differ-
ence. In programmable logic, where the switching contacts are replaced by logical instructions, the
role of the electrical voltage is carried out by the RLO. In the classic circuit, the relay C is activated
if there is voltage at point A, i.e., in its ends as depicted in Figure 7.9. In programmable logic, the
RLO is what determines—as a voltage—the result of the activating instructions. In this case, the
output C (and hence the C relay connected to it) is activated only when RLO equals 1.
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
HH Byte
HL Byte
LH Byte
LL Byte
H Word
L Word
ZB 20
ZB 20
ZB 21
ZB 20
ZB 21
ZB 22
ZB 23
Accumulator 1
Load ΖΒ 20
Load ΖW 20
Load ΖDW 20
= ΖW 20
= ΖDW 20
Where Ζ = I or Q or Μ, that is a Byte or Word of Inputs or Outputs or Memory Bits
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
ZB 20
ZB 20
ZB 21
ZB 20
ZB 21
ZB 22
ZB 23
Do'stlaringiz bilan baham: