
- •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 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. LD IN1 ENTER
2.AND IN2 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. LD IN3 ENTER
4.AND IN4 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

Chapter 5 - Mnemonic Programming Code
close commands instead of OR LD. Mitsubishi controllers use OR BLK instead of OR LD.
Some controllers will use STR in place of LD. Also, in some cases all coils may be entered as OUT with an associated number that specifies it as an output or internal coil. The concept is generally the same, but commands vary with controller manufacturer type and even by model in some units.
Adding the coil command for the ladder diagram of Figure 5-4, the commands required are as follows:
1. |
LD |
IN1 |
ENTER |
2. |
AND |
IN2 |
ENTER |
3. |
LD |
IN3 |
ENTER |
4. |
AND |
IN4 |
ENTER |
5. |
OR |
LD |
ENTER |
6.STO OUT1 ENTER
As a matter of comparison, if the above program had been input into a controller that utilizes STR instead of LD and OUT instead of STO, the commands would be as below:
STR IN1 ENTER
AND IN2 ENTER
STR IN3 ENTER
AND IN4 ENTER
OR STR ENTER
OUT 101 ENTER
The 101 associated with the OUT statement designates the coil as number 101, which, in the case of this particular PLC would, by PLC design, cause it to be an internal or output coil as defined by the PLC manufacturer. As can be seen, the structure is the same but with different commands as required by the PLC being used.
Let us now discuss the ladder rung of Figure 5-5. Recall that this is an OR-AND-OR logic rung having a Boolean expression as shown in Equation 5-2.
OUT1 = (IN1+ IN2)(IN3 + IN4) |
(5-2) |
Two branches can be seen in this expression; (IN1 OR IN2) and (IN3 OR IN4).
These two branches are to be AND'ed together.
5-7

Chapter 5 - Mnemonic Programming Code
Figure 5-5 - Ladder Diagram to Implement OR - AND - OR
Function
Using the LD and STO commands and the same approach as in the examples above, the command structure would be as follows:
1. |
LD |
IN1 |
ENTER |
2. |
OR |
IN2 |
ENTER |
3. |
LD |
IN3 |
ENTER |
4. |
OR |
IN4 |
ENTER |
5. |
AND |
LD |
ENTER |
6.STO OUT1 ENTER
As in the previous example, the LD command in line 3 causes lines 1 and 2 to be transferred to the stack. Line 5 causes the active area and stack to be AND'ed with each other.
5-7. Complex Branches
Now that we have discussed basic AND and OR techniques and simple branches, let us look at a rung with a more complex logic expression to illustrate how multiple branches would be programmed. Consider the rung of Figure 5-6. As can be seen, there are multiple logic expressions contained in the overall ladder rung. The Boolean expression for this rung is shown in Equation 5-3.
5-8

Chapter 5 - Mnemonic Programming Code
Figure 5-6 - Complex Ladder Rung
OUT1= ((((IN1+ IN3+ IN8)(IN2 + IN7))
(5-3)
+IN5)(IN 4 + IN 9)) + IN 6
To develop the program commands for this logic, we will begin with the innermost logic expression. This is IN1' + IN3 + IN8'. The commands to enter this expression are:
1. |
LD |
NOT IN1 |
ENTER |
2. |
OR |
IN3 |
ENTER |
3. |
OR |
NOT IN8 |
ENTER |
The next expression to enter is IN2 + IN7', which must be AND'ed with the expression now in the active area. To accomplish this, the logic in the active area must be transferred to the stack, the next expression entered, and then AND'ed with the stack. The command lines for this are:
5-9

Chapter 5 - Mnemonic Programming Code
4. |
LD |
IN2 |
ENTER |
5. |
OR |
NOT IN7 |
ENTER |
6. |
AND |
LD |
ENTER |
Line 4 places the previous expression in the stack and begins the new expression and line
5 completes the new expression. Line 6 causes the stack logic to be retrieved and AND'ed with the active area with the result left in the active area. Referring to Equation 5-3 notice that the expression now located in the active area must now be OR'ed with IN5. This is a simple OR command since the first part of the OR is already in the active area. The command to accomplish this is:
7. OR IN5 |
ENTER |
Now the active area contains:
{(IN1' + IN3 + IN8') (IN2 + IN7')} + IN5
This must be AND'ed with (IN4 + IN9'). To input this expression we must transfer the logic in the active area to the stack, input the new expression, retrieve the stack and AND it with the expression in the active area. These commands are:
8. |
LD |
IN4 |
ENTER |
9. |
OR |
NOT IN9 |
ENTER |
10. |
AND |
LD |
ENTER |
Line 8 transfers the previous expression to the stack and begins input of the new expression, line 9 completes entry of the new expression and line 10 AND's the stack with the new expression. The active area now contains:
(((IN1' + IN3 + IN8') (IN2 + IN7')) + IN5) (IN4 + IN9')
As may be seen in Figure 6-1 - all that remains is to OR this expression with IN6 and add the coil command. The command lines for this are:
11. |
OR |
IN6 |
ENTER |
12. |
STO |
OUT1 |
ENTER |
Combining all the command lines into one set is shown below:
5-10

Chapter 5 - Mnemonic Programming Code
1. |
LD |
NOT IN1 |
ENTER |
2. |
OR |
IN3 |
ENTER |
3. |
OR |
NOT IN8 |
ENTER |
4. |
LD |
IN2 |
ENTER |
5. |
OR |
NOT IN7 |
ENTER |
6. |
AND |
LD |
ENTER |
7. |
OR |
IN5 |
ENTER |
8. |
LD |
IN4 |
ENTER |
9. |
OR |
NOT IN9 |
ENTER |
10. |
AND |
LD |
ENTER |
11. |
OR |
IN6 |
ENTER |
12. |
STO |
OUT1 |
ENTER |
The previous example should be reviewed to be sure operation involving the stack is thoroughly understood.
5-11

Chapter 5 - Mnemonic Programming Code
Chapter 5 Review Question and Problems
1.Draw the ladder diagram and write the mnemonic code for a program that will accept inputs from switches IN1, IN2, IN3, IN4 and IN5 and energize coil OUT123 when one and only one of the inputs is ON.
2.Draw the ladder diagram and write the mnemonic code for an oscillator named CR3.
3.Write the mnemonic code for the J-K Flip Flop.
4.Draw the ladder diagram, assign contact and coil numbers and write the mnemonic code for a T Flip Flop.
5.Write the mnemonic code for the ladder diagram of Figure 5-7.
Figure 5-7 - Ladder for Problem 5
5-12