Vous êtes sur la page 1sur 3

Chapter 5 - Mnemonic Programming Code

LD
NOT IN1
AND IN2
STO OUT1

ENTER
ENTER
ENTER

As stated above, different PLC's may use different commands to perform some functions.
For instance, the Mitsubishi PLC uses the command LDI (LD INVERSE) instead of LD
NOT. This requires a single keystroke instead of two keystrokes to input the same
command.
If the normally closed contact had been IN2 instead of IN1, the command lines would
have to be modified as follows:
LD
IN1
AND NOT IN2
STO OUT1

ENTER
ENTER
ENTER

If using the Mitsubishi PLC, the AND NOT command would be replaced with the ANI (AND
INVERSE) command.
5-5.

OR Ladder Rung
Now, let us translate the ladder of Figure 5-3 into machine code.

Figure 5-3 - Ladder Diagram for OR Function


As can be seen, the contact logic for Figure 5-3 is an OR connection controlling coil
OUT1. Following the same steps as with Figure 5-1, the command lines for this rung are:

5-4

Chapter 5 - Mnemonic Programming Code


LD
IN1 ENTER
OR IN2 ENTER
STO OUT1 ENTER
Notice again each line contains a command, an object and a terminator. In the case
of this particular controller, the coil has a descriptive label (OUT) associated with it to tell
us that this coil is an output for the controller. In some controllers, this is not the case.
Some controllers designate the coil as output or internal depending upon the number
assigned to it. For instance, output coils may be coils having numbers between 100 and
110 and inputs may be contacts having numbers between 000 and 010. Systems that are
composed of plug in modules may set the output coil and input contact numbers by the
physical location of the modules in the system.
5-6.

Simple Branches

Now consider the ladder diagram of Figure 5-4, a more complicated AND-OR-AND
logic containing two branches.

Figure 5-4 - Ladder Diagram AND - OR - AND Function


The previous examples have had only a single branch in each case. A branch may be
defined as a single logic expression contained in the overall Boolean expression for a rung.
In the case of Figure 5-4, the Boolean expression would be that of Equation 5-1. As can
be seen in the Boolean equation, there are two logic expressions OR'ed together; IN1 AND
IN2 and IN3 AND IN4. Each of the two expressions is called a branch of logic and must
be handled carefully when being input into the controller. Incorrect entering of branches
will result in improper (possibly dangerous) operation of the PLC. In cases where entering
a branch incorrectly violates the controller logic internally, an error message will be
generated and the entry disallowed. In cases where the entry does not violate controller
logic, operation will be allowed and could cause bodily injury to personnel if the controller
is in a position to operate dangerous machinery.
5-5

Chapter 5 - Mnemonic Programming Code

OUT1 = (IN1)(IN2) + (IN3)(IN4)

(5-1)

This configuration of logic in Figure 5-4 utilizes four contacts, IN1, IN2, IN3 and IN4
controlling an output coil OUT1. As discussed in earlier chapters, coil OUT1 will energize
when (IN1 AND IN2) OR (IN3 AND IN4) is true. The first line (IN1 AND IN2) is entered in
the same manner as described in the previous examples:
(the 1. and 2. are line numbers for our reference only)
1.
2.

LD
IN1
AND IN2

ENTER
ENTER

For the next line (IN3 AND IN4) we must start a new branch. This is accomplished through
the use of another LD statement and a portion of PLC memory called the stack.
As program commands for a rung are entered into the PLC they go into what we will
call an active memory area. There is another memory area set aside for temporarily storing
portions of the commands being input. This area is called the Stack. Each time and LD
command is input, the controller transfers all logic currently in the active area to the Stack.
When the first LD command of the rung is input, there is nothing in the active area to
transfer to the stack. The next two lines of code would be as follows:
3.
4.

LD
IN3
AND IN4

ENTER
ENTER

The LD command for IN3 causes the previous two lines of code (lines 1 and 2) to
be transferred to the Stack. After lines 3 and 4 have been input, lines 1 and 2 will be in the
stack and lines 3 and 4 will be in the active memory area.
The two areas, active and the stack, may now be OR'ed with each other using the
command OR LD. This tells the controller to retrieve the commands from the stack and OR
that code with what is in the active area. The resulting expression is left in the active area.
This line of code would be input as shown below:
5.

OR

LD

ENTER

Up to now, most controllers would have recognized the same type of commands
(AND, OR). The LD and OR LD commands will, however appear differently in various
controllers depending upon how the manufacturer wishes to design the controller. For
instance, the Allen Bradley SLC-100 handles branches using branch open and branch
5-6

Vous aimerez peut-être aussi