Professional Documents
Culture Documents
Chapter 3 - Fundamental PLC Programming: Switch1 Lamp1 PB1 L1 IN1 PLC Out1
Chapter 3 - Fundamental PLC Programming: Switch1 Lamp1 PB1 L1 IN1 PLC Out1
|
IN1
IN2
OUT1
1---| |-------| |---------------------------------------------------------(OUT)|
|
|
|
|
IN1
OUT2
2---| |-------------------------------------------------------------------(OUT)|
|
IN2
|
|---| |---+
|
|
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
3-6
3-4.
Example Problem 1
2.
Problem:
Design the wiring diagram for the controller connections, assign the inputs
and outputs and develop the ladder diagram which will accomplish the task.
The first item we may accomplish is the drawing of the controller wiring diagram.
All we need do is connect all switches to inputs and the lighting to an output and note the
numbers of the inputs and output associated with these connections. The remainder of the
task becomes developing the ladder diagram. The wiring diagram is shown in Figure 3-9.
3-7
PLC
IN1
S1
OUT1
LIGHTS
CR1
SWITCH2
S2
IN2
OUT2
IN3
OUT3
IN4
OUT4
SWITCH3
S3
SWITCH4
S4
120V
CONTROL
VOLTAGE
120V
CONTROL
VOLTAGE
COM
COM
/)))1 /)))))1
*
IN3
*
/)))1 /)))))*
*
3-5.
Disagreement Circuit
Occasionally, a program rung may be needed which produces an output when two
signals disagree (one signal is a logical 1 and the other a logical 0). For example, assume
we have two signals A and B. We would like to produce a third signal C under the condition
A=0, B=1 or A=1, B=0. Those familiar with digital logic will recognize this as being the
exclusive OR operation in which the expression is C = AB + AB = A B . This can also
be implemented in ladder logic. Assume the two signals are inputs IN1 and IN2 and the
result is OUT1. In this case, the disagreement circuit will be as shown in Figure 3-11.
IN1
IN2
OUT1
1)))1 /)))))))1//)))))0)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(OUT)1
IN1
IN2 *
*
/)))1//)))))))1 /)))))*
3-9
Majority Circuit
There are situations in which a PLC must make a decision based on the results of
a majority of inputs. For example, assume that a PLC is monitoring five tanks of liquid and
must give a warning to the operator when three of them are empty. It doesnt matter which
three tanks are empty, only that any three of the five are empty. As it turns out, by using
binomial coefficients, there are ten possible combinations of three empty tanks. There are
also combinations of four empty tanks and the possibility of five empty tanks, but as we will
see, those cases will be automatically included when we design the system for three empty
tanks.
It is important when designing majority circuits to design them so that votes of
more than a marginal majority will also be accepted. For example, lets assume that for our
five tank example, the tanks are labeled A, B, C, D, and E and when an input from a tank
is ON, it indicates that the tank is empty. One combination of three empty tanks would be
tanks A, B, and C empty and D and E not empty. If this is expressed as a Boolean
expression, it would be ABCDE. However, this expression would not be true if A, B, C,
and D were on, nor would it be true if all of the inputs were on. However, if we leave D and
E as dont cares it will take into account these possibilities. Therefore, we would shorten
our expression to ABC, which would cover the conditions ABCDE, ABCDE, ABCDE, and
ABCDE, all of which would be majority conditions. It turns out that if we write our program
to cover all the conditions of three empty tanks, and each expression uses only three
inputs, we will cover (by virtue of dont cares) the four combinations of four empty tanks
and the one combination of five empty tanks.
To find all the possible combinations of three empty tanks out of five, we begin by
constructing a binary table of all possible 5-bit numbers, beginning with 00000 and ending
with 11111, and we assign each of the five columns to one of the tanks. To the right of the
columns, we make another column which is the sum of the ones in each row. When
completed, the table will appear as shown below.
3-10
Then, referring to the table, find every row that has a sum of 3. For each of these rows,
write the combination of the three tanks for that row (the columns containing the 1's). The
ten combinations of three empty tanks are: CDE, BDE, BCE, BCD, ADE, ACE, ACD, ABE,
ABD, and ABC.
When we write the program for this problem, we can economize on relay contacts
in our program. We should keep in mind that simplifying a complex relay structure will save
on PLC memory space used by the program. However, if the simplification makes the
program difficult for another programmer to read and understand, it should not be
simplified. We will simplify by factoring, and then check to see if the ladder diagram is
easily readable. We will factor as follows:
A(B(C+D+E)+C(D+E) + DE) + B(C(D+E)+DE) + CDE
3-11
Oscillator
With the above examples, little or no discussion has been made of scan operations
or timing. We have merely assumed that when all the conditions were met for a coil to
energize, it would do so. However, we must always be aware of the procedure the
controller uses to solve the ladder logic diagram. As an example of how an understanding
of scanning can benefit us as programmers, let us develop an oscillator. An oscillator in
the ladder diagram world is a coil that turns on and off alternately on each scan. An
oscillator can be useful to control things like math functions and other types of functions
which are controlled by a transitional contact. A transitional contact is a contact that
switches from closed to open or from open to closed. Functions such as math functions
in some controllers only perform their assigned process on the one scan when the control
logic switches from open to closed. As long as the control logic remains closed or open,
the function will not be performed. To enable the function to occur on an ongoing basis,
a transitional contact may be placed in the control logic. This will cause the function to be
performed on (in the case of using an oscillator) every other scan. This is because the
transitional contact from the oscillator will switch from open to closed on every other scan.
3-12
*
*
*
*
3-14
*
*
There are instances when a coil must remain energized after contact logic has been
found to be true even if on successive scans the logic solution becomes false. A typical
application of this would be an ON/OFF control using two separate switches, one to turn
the equipment on and one to turn the equipment off. In this case, the coil being controlled
by the switches must energize when the ON switch is pressed and remain energized until
the OFF switch is pressed. This function is accomplished by developing a rung which
contains a holding contact or sealing contact that will maintain the coil in the energized
state until released. Such a configuration is shown in Figure 3-15.
IN1
IN2
CR1
1)))1 /)))))0)))1//)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(RLY)1
CR1
*
*
/)))1 /)))))*