Beruflich Dokumente
Kultur Dokumente
function block
Function blocks
Function blocks can have standard functions, such as those of
the logic gates or counters or times, or have functions defined
by the user, e.g. a block to obtain an average value of inputs.
Programs are often concerned with logic gates. Two forms of
standard circuit symbols are used for logic gates, one having
originated in the United States and the other being an
international standard form (IEEE/ANSI) which uses a
rectangle with the logic function written inside it. The 1 in a
box indicates that there is an output when the input is 1.
Logic gates
The OR function is given by 1, this is because there is an
output if an input is greater than or equal to 1. A negated
input is represented by a small circle on the input, a negative
output by a small circle on the output
.
relationship to the
ladder diagram, OR gat
relationship to the
ladder diagram, And gate
Pump application
Consider the development of a function block diagram and
ladder diagram for an application in which a pump is
required to be activated and pump liquid into a tank when
the start switch is closed, the level of liquid in the tank is
below the required level and there is liquid in the reservoir
from which it is to be pumped. What is required is an AND
logic situation between the start switch input and a sensor
input which is on when the liquid in the tank is below the
required level.
Pump application
We might have a switch which is on until the liquid is at the
required level. These two elements are then in an AND logic
situation with a switch indicating that there is liquid in the
reservoir. Suppose this switch gives an input when there is
liquid.
example
consider a valve which is to be operated to lift a load when a
pump is running and either the lift switch is operated or a
switch operated indicating that the load has not already been
lifted and is at the bottom of its lift channel. We have an OR
situation for the two switches and an AND situation involving
the two switches and the pump. Note that with the ladder
diagram we tell the PLC when it has reached the end of the
program by the use of the END or RET instruction.
example
consider a system where there has to be no output when any
one of four sensors gives an output, otherwise there is to be
an output. One way we could write a program for this is for
each sensor to have contacts that are normally closed so
there is an output. When there is an input to the sensor the
contacts open and the output stops. We have an AND logic
situation.
illustration
As an illustration of the use of IEC 113-1 operators,
consider the following:
LD
A
(*Load A*)
AND B
(*AND B*)
ST Q
(* Store result in Q, i.e. output to
Q*)
In the first line of the program, LD is the operator, A the
operand, and the words at the ends of program lines and in
brackets and preceded and followed by * are comments added
to explain what the operation is and are not part of the
program operation instructions to the PLC.
illustration
LD A is thus the instruction to load the A into the memory
register. It can then later be called on for further operations.
The next line of the program has the Boolean operation AND
performed with A and B. The last line has the result stored in
Q, i.e. outputted to Q.
illustration
With the IEC 113-1 operators, an N after it is used to negate
its value.
For example, if we have:
LD
(*Load A*)
ANDN
AND gate
: AND gate
Mitsubishi
(b) Siemens) a(
AND gate
This is followed by another open contacts input and so the
next program line involves the instruction AND with the
address of the element, thus the instruction is AND X401. The
rung terminates with an output and so the instruction OUT is
used with the address of the output, i.e. OUT Y430.
The single rung of a ladder would thus be entered as:
LD
X400
AND
X401
OUT
Y430
For the same rung with Siemens notation (Figure (b)) we
have:
A I0.1
A I0.2
= Q2.0
OR gate
Consider another example, an OR gate. Figure (a) shows
the gate with Mitsubishi notation.
The instructions for the rung
start with an open contact is LD
X400.
The next item is the parallel OR
set of contacts X401. Thus the
next instruction is OR X401. The
last step is the output, hence
OUT Y430. The instruction list
would thus be:
Figure (a)
OR gate
Figure (b) shows the Siemens version of the OR gate. The
following is the Siemens instruction list:
NOR gate
Figure (a) shows the ladder system for a NOR gate in
Mitsubishi notation.
The rung starts with normally closed contacts and so
the instruction is LDI. I when added to Mitsubishi
instruction is used to indicate the inverse of the
instruction.
Figure (a)
NOR gate
The next step is a series normally closed contact
and so ANI, again the I being used to make an AND
instruction the inverse. I is also the instruction for a
NOT gate. The instructions for the NOR gate rung of
the ladder would thus be entered as:
NOR gate
Figure (b) shows the NOR gate with Siemens notation. Note
that N added to an instruction is used to make the inverse.
The instruction list then becomes:
Figure (b)
NAND gate
Consider the rung shown in Figure (a) in Mitsubishi
notation, a NAND gate.
It starts with the normally closed contacts X400 and so starts
with the instruction LDI X400. The next instruction is for a
parallel set of normally closed contacts, thus the instruction is
ORI X401. The last step is the output, hence OUT Y430. The
instruction list is thus:
NAND gate
Mitsubishi) a(
Siemens) b(
NAND gate
NAND gate
It starts with the normally closed contacts X400 and so starts
with the instruction LDI X400. The next instruction is for a
parallel set of normally closed contacts, thus the instruction is
ORI X401. The last step is the output, hence OUT Y430. The
instruction list is thus:
LDI
X400
ORI
X401
OUT
Y430
Figure 6.4(b) shows the NAND gate in Siemens notation. The
instruction list is then:
AN
ON
=
I0.1
I0.2
Q2.0
Branch codes
The Exclusive OR (XOR) gate shown in Figure (a) in
Mitsubishi notation has two parallel arms with an AND
situation in each arm.
)a(
) b(
Figure 6.5 XOR gate: (a) Mitsubishi, (b) Siemens
Branch codes
In such a situation Mitsubishi uses an ORB instruction to
indicate OR together parallel branches. The first instruction
is for a normally open pair of contacts X400. The next
instruction is for a series set of normally closed contacts X401,
hence ANI X401. After reading the first two instructions, the
third instruction starts a new line. It is recognized as a new
line because it starts with LDI, all new lines starting with LD
or LDI.
But the first line has not been ended by an output. The PLC
thus recognizes that a parallel line is involved for the second
line and reads together the listed elements until the ORB
instruction is reached.
Branch codes
The mnemonic ORB (OR branches/blocks together)
indicates to the PLC that it should OR the results of the first
and second instructions with that of the new branch with the
third and fourth instructions. The list concludes with the
output OUT Y430. The instruction list would thus be
entered as:
LD
ANI
LDI
AND
ORB
OUT
X400
X401
X400
X401
Y430
Branch codes
Figure (b) shows the Siemens version of XOR gate. Brackets
are used to indicate that certain instructions are to be carried
out as a block.
They are used in the same way as brackets in any
mathematical equation.
For example, (2 + 3)/4 means that the 2 and 3 must be added
before dividing by 4. Thus with the Siemens instruction list
we have in step 0 the instruction A(. The brackets close in
step 3. This means that the A in step 0 is applied only after
the instructions in steps 1 and 2 have been applied.
Branch codes
Step
Instruction
0
1
2
3
4
5
6
7
8
A(
A
AN
(
O(
AN
A
)
=
I0.0
I0.1
I0.0
I0.1
Q2.0
Branch codes
The IEC 1131-3 standard for such programming is to use
brackets in the way used in the above Siemens example.
Figure (a) shows a circuit, in Mitsubishi notation, which can
be considered as two branched AND blocks. The instruction
used here is ANB. The instruction list is thus:
Block
Block
) a(
) b(
Branch codes
Branch codes
Programming examples
Programming examples
Programming examples
Programming examples