Chapter 3 - Fundamental PLC Programming
When the program shown in Figure 3-3 is run, the PLC first updates the input image
register by storing the values of the inputs on terminals IN1 and IN2 (it stores a one if an
input is on, and a zero if it is off). Then it solves the ladder diagram according to the way
it is drawn and based on the contents of the input image register. For our program, if both
IN1 and IN2 are on, it turns on OUT1 in the output image register (careful, it does NOT turn
on the output terminal yet!). Then, when it is completed solving the entire program, it
performs another update. This update transfers the contents of the output image register
(the most recent results of solving the ladder program) to the output terminals. This turns
on terminal OUT1 which turns on the lamp LAMP1. At the same time that it transfers the
contents of the output image register to the output terminals, it also transfers the logical
values on the input terminals to the input image register. Now it is ready to solve the ladder
again.
For an operation this simple, this is a lot of trouble and expense. However, as we
add to our program, we will begin to see how a PLC can economize not only on wiring, but
on the complexity (and cost) of external components.
Next, we will add another lamp that switches on when either SWITCH1 or SWITCH2
are on. If we were to add this circuit to our electrical diagram in Figure 3-1, we would have
the circuit shown in Figure 3-4
H1
H3
H2
H4
T1
F1
X1
SWITCH1
X2
SWITCH2
LAMP1
3
PB1
4
PB2
L1
LAMP2
SWITCH1
5
PB1
SWITCH2
L2
PB2
Figure 3-4 - OR Circuit
3-4
Chapter 3 - Fundamental PLC Programming
Notice that to add this circuit to our existing circuit, we had to add additional contacts to the
switches PB1 and PB2. Obviously, this raises the cost of the switches. However, when
doing this on a PLC, it is much easier and less costly.
The PLC wiring diagram to implement both the AND and OR circuits is shown in
Figure 3-5. Notice here that the only change weve made to the circuit is to add LAMP2 to
the PLC output OUT2. Since the SWTICH1 and SWITCH2 signals are already available
inside the PLC via inputs IN1 and IN2, it is not necessary to bring them into the PLC again.
This is because of one unique and very economical feature of PLC programming. Once
an input signal is brought into the PLC for use by the program, you may use as many
contacts of the input as you wish, and the contacts may be of either N/O or N/C
polarity. This reduces the cost because, even though our program will require more than
one contact of IN1 and IN2, each of the actual switches that generate these inputs, PB1
and PB2, only need to have a single N/O contact.
SWITCH1
PB1
PLC
IN1
OUT1
IN2
OUT2
IN3
OUT3
IN4
OUT4
LAMP1
L1
LAMP2
L2
SWITCH2
PB2
120V
CONTROL
VOLTAGE
120V
CONTROL
VOLTAGE
COM
COM
Figure 3-5 - PLC Wiring Diagram to Add
SWITCH2 and LAMP2
Now that we have the inputs and outputs connected, we can write the program. We
do this by simply adding to the program the additional rung that we need to perform the OR
operation. This is shown in Figure 3-6. Keep in mind that other than the additional lamp
and the time it takes to add the additional program, this additional OR feature costs
nothing.
3-5
Chapter 3 - Fundamental PLC Programming
|
IN1
IN2
OUT1
1---| |-------| |---------------------------------------------------------(OUT)|
|
|
|
|
IN1
OUT2
2---| |-------------------------------------------------------------------(OUT)|
|
IN2
|
|---| |---+
|
|
Figure 3-6 - PLC Program with Added OR Rung
Next, we will add AND-OR and OR-AND functions to out PLC. For this, we will need
two more switches, SWITCH3 and SWITCH4, and two more lamps, LAMP3 and LAMP4.
Figure 3-7 shows the addition of these switches and lamps.
SWITCH1
PB1
PLC
IN1
OUT1
IN2
OUT2
IN3
OUT3
IN4
OUT4
LAMP1
L1
LAMP2
L2
LAMP3
L3
LAMP4
L4
SWITCH2
PB2
SWITCH3
PB3
SWITCH4
PB4
120V
CONTROL
VOLTAGE
120V
CONTROL
VOLTAGE
COM
COM
Figure 3-7 - PLC Wiring Diagram Adding
Switches PB3 and PB4 and Lamps L3 & L4.
Once the connection scheme for these components is known, we can add the additional
programming required to implement the AND-OR and OR-AND functions. This is shown
in Figure 3-8.
3-6