
- •Table of Contents
- •Preface
- •Chapter 1 - Ladder Diagram Fundamentals
- •1-1. Objectives
- •1-2. Introduction
- •1-3. Basic Components and Their Symbols
- •1-4. Fundamentals of Ladder Diagrams
- •1-5. Machine Control Terminology
- •1-6. Summary
- •Chapter 2 - The Programmable Logic Controller
- •2-1. Objectives
- •2-2. Introduction
- •2-4. PLC Configurations
- •2-5. System Block Diagram
- •2-6. ... - Update - Solve the Ladder - Update - ...
- •2-7. Update
- •2-8. Solve the Ladder
- •2-9. Summary
- •Chapter 3 - Fundamental PLC Programming
- •3-1. Objectives
- •3-2. Introduction
- •3-3. Physical Components vs. Program Components
- •3-4. Example Problem 1
- •3-5. Disagreement Circuit
- •3-6. Majority Circuit
- •3-7. Oscillator
- •3-8. Holding (also called Sealed, or Latched) Contacts
- •3-9. Always-ON and Always-OFF Contacts
- •3-10. Ladder Diagrams Having More Than One Rung
- •Chapter 4 - Advanced Programming Techniques
- •4-1. Objectives
- •4-2. Introduction
- •4-3. Ladder Program Execution Sequence
- •4-5. RS Flip Flop
- •4-6. One Shot
- •4-8. T Flip Flop
- •4-9. J-K Flip Flop
- •4-10. Counters
- •4-11. Sequencers
- •4-12. Timers
- •Chapter 5 - Mnemonic Programming Code
- •5-1. Objectives
- •5-2. Introduction
- •5-3. AND Ladder Rung
- •5-4. Handling Normally Closed Contacts
- •5-5. OR Ladder Rung
- •5-6. Simple Branches
- •5-7. Complex Branches
- •Chapter 6 - Wiring Techniques
- •6-1. Objectives
- •6-2. Introduction
- •6-3. PLC Power Connection
- •6-4. Input Wiring
- •6-5. Inputs Having a Single Common
- •6-6. Output Wiring
- •6-7. Relay Outputs
- •6-8. Solid State Outputs
- •Chapter 7 - Analog I/O
- •7-1. Objectives
- •7-2. Introduction
- •7-3. Analog (A/D) Input
- •7-4. Analog (D/A) Output
- •7-5. Analog Data Handling
- •7-6. Analog I/O Potential Problems
- •Chapter 8 - Discrete Position Sensors
- •8-1. Objectives
- •8-2. Introduction
- •8-3. Sensor Output Classification
- •8-4. Connecting Discrete Sensors to PLC Inputs
- •8-5. Proximity Sensors
- •8-6. Optical Proximity Sensors
- •Chapter 9 - Encoders, Transducers, and Advanced Sensors
- •9-1. Objectives
- •9-2. Introduction
- •9-3. Temperature
- •9-4. Liquid Level
- •9-5. Force
- •9-6. Pressure/Vacuum
- •9-7. Flow
- •9-8. Inclination
- •9-9. Acceleration
- •9-10. Angle Position Sensors
- •9-11. Linear Displacement
- •Chapter 10 - Closed Loop and PID Control
- •10-1. Objectives
- •10-2. Introduction
- •10-3. Simple Closed Loop Systems
- •10-4. Problems with Simple Closed-Loop Systems
- •10-5. Closed Loop Systems Using Proportional, Integral, Derivative (PID)
- •10-6. Derivative Function
- •10-7. Integral Function
- •10-8. The PID in Programmable Logic Controllers
- •10-9. Tuning the PID
- •10-10. The “Adjust and Observe” Tuning Method
- •10-11. The Ziegler-Nichols Tuning Method
- •Chapter 11 - Motor Controls
- •11-1. Objectives
- •11-2. Introduction
- •11-3. AC Motor Starter
- •11-4. AC Motor Overload Protection
- •11-5. Specifying a Motor Starter
- •11-5. DC Motor Controller
- •11-6. Variable Speed (Variable Frequency) AC Motor Drive
- •11-7. Summary
- •Chapter 12 - System Integrity and Safety
- •12-1. Objectives
- •12-2. Introduction
- •12-3. System Integrity
- •12-4. Equipment Temperature Considerations
- •12-5. Fail Safe Wiring and Programming
- •12-6. Safety Interlocks
|
|
|
Chapter 3 - Fundamental PLC Programming |
|
| |
IN1 |
IN2 |
OUT1 |
|
1--- |
| | |
------- | | --------------------------------------------------------- |
(OUT)| |
|
| |
|
|
|
|
| |
|
|
|
|
| |
IN1 |
|
OUT2 |
|
| |
|
|||
2--- |
| | |
------------------------------------------------------------------- | |
(OUT)| |
|
| |
IN2 |
|
|
|
|--- |
| |--- |
+ |
|
|
| |
|
|
|
|
| |
|
|
|
|
| |
IN1 |
IN2 |
OUT3 |
|
| |
||||
3--- |
| |------- --------------------------------------------------------- |
| | |
(OUT)| |
|
| |
IN3 |
IN4 |
| |
|
|--- |
| |------- --- |
| | |
+ |
|
| |
|
|
|
|
| |
|
|
|
|
| |
IN1 |
IN3 |
OUT4 |
|
| |
||||
4--- |
| |------- --------------------------------------------------------- |
| | |
(OUT)| |
|
| |
IN2 |
| IN4 |
| |
|
|--- |
| |------- --- |
| | |
+ |
|
| |
|
|
|
|
Figure 3-8 - PLC Program with AND-OR and OR-AND Added
3-4. Example Problem 1
A lighting control system is to be developed. The system will be controlled by four switches, SWITCH1, SWITCH2, SWITCH3, and SWITCH4. These switches will control the lighting in a room based on the following criteria:
1.Any of three of the switches SWITCH1, SWITCH2, and SWITCH3, if turned ON can turn the lighting on, but all three switches must be OFF before the lighting will turn OFF.
2.The fourth switch SWITCH4 is a Master Control Switch. If this switch is in the ON position, the lights will be OFF and none of the other three switches have any control.
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

Chapter 3 - Fundamental PLC Programming
SWITCH1 |
PLC |
|
S1 |
IN1 |
OUT1 LIGHTS |
|
|
|
SWITCH2 |
|
CR1 |
|
|
|
S2 |
IN2 |
OUT2 |
|
|
|
SWITCH3 |
|
|
S3 |
IN3 |
OUT3 |
SWITCH4 |
|
|
S4 |
IN4 |
OUT4 |
|
|
|
120V |
|
120V |
CONTROL |
|
CONTROL |
VOLTAGE |
|
VOLTAGE |
|
COM |
COM |
Figure 3-9 - PLC Wiring Diagram for Example
Problem 1.
Notice that all four switches are shown as normally open selector switches and the output is connected to a relay coil CR1. We are using the relay CR1 to operate the lights because generally the current required to operate a bank of room lights is higher than the maximum current a PLC output can carry. Attempting to operate the room lights directly from the PLC output will most likely damage the PLC.
For this wiring configuration, the following definition list is apparent:
INPUT IN1 = SWITCH1
INPUT IN2 = SWITCH2
INPUT IN3 = SWITCH3
INPUT IN4 = SWITCH4 (Master Control Switch)
OUTPUT OUT1 = Lights control relay coil CR1
This program requires that when SWITCH4 is ON, the lights must be OFF. In order to do this, it would appear that we need a N/C SWITCH4, not a N/O as we have in our wiring diagram. However, keep in mind that once an input signal is brought into a PLC, we may use as many contacts of the input as we need in our program, and the contacts may be either N/O or N/C. Therefore, we may use a N/O switch for SWITCH4 and then in the program, we will logically invert it by using N/C IN4 contacts.
The ladder diagram to implement this example problem is shown in Figure 3-10.
3-8

|
|
Chapter 3 - Fundamental PLC Programming |
|
* IN1 |
IN4 |
OUT1 |
|
1)))1 /)))))0))))1//)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(OUT)1
*IN2 *
/)))1 /)))))1
*IN3 *
/)))1 /)))))-
*
*
Figure 3-10 - Example 1, Lighting Control Program
First, note that this ladder diagram looks smoother than previous ones. This is because, although it was created using the same program, the ladder was printed using graphics characters (extended ASCII characters) instead of standard ASCII characters.
Notice the normally closed contact for IN4. A normally closed contact represents an inversion of the assigned element, in this case IN4, which is defined as SWITCH 4. Remember, SWITCH 4 has to be in the OFF position before any of the other switches can take control. In the OFF position, SWITCH 4 is open. This means that IN4 will be OFF (de-energized). So, in order for an element assigned to IN4 to be closed with the switch in the OFF position, it must be shown as a normally closed contact. When SWITCH 4 is turned ON, the input, IN4, will become active (energized). If IN4 is ON, a normally closed IN4 contact will open. With this contact open in the ladder diagram, none of the other switches will be able to control the output. REMEMBER: A normally closed switch will open when energized and will close when de-energized.
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 /)))))-
*
Figure 3-11 - Disagreement Circuit
3-9

Chapter 3 - Fundamental PLC Programming
For this program, OUT1 will be OFF whenever IN1 and IN2 have the same value, i.e., either both ON or both OFF, and OUT1 will be ON when IN1 and IN2 have different values, i.e., either IN1 ON and IN2 OFF, or IN1 OFF and IN2 ON.
3-6. 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 doesn’t 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, let’s 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 ABCD’E’. 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 “don’t cares” it will take into account these possibilities. Therefore, we would shorten our expression to ABC, which would cover the conditions ABCD’E’, ABCDE’, ABCD’E, 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 “don’t 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 “one’s” in each row. When completed, the table will appear as shown below.
3-10

Chapter 3 - Fundamental PLC Programming
A |
B |
C |
D |
E |
# |
|
|
|
|
|
|
0 |
0 |
0 |
0 |
0 |
0 |
|
|
|
|
|
|
0 |
0 |
0 |
0 |
1 |
1 |
|
|
|
|
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|
|
|
1 |
1 |
1 |
1 |
0 |
4 |
|
|
|
|
|
|
1 |
1 |
1 |
1 |
1 |
5 |
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