
- •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
Chapter 5 - Mnemonic Programming Code
5-1. Objectives
Upon completion of this chapter, you will know
”why mnemonic code is used in some cases instead of graphical ladder language.
”some of the more commonly used mnemonic codes for AND OR and INVERT operations.
”how to represent ladder branches in mnemonic code.
”how to use stack operations when entering mnemonic coded programs.
5-2. Introduction
All discussions in previous sections have considered only the ladder diagram in all program example development. The next thing to be considered is how to get the ladder diagram into the programmable controller. In higher order controllers, this can be accomplished through the use of dedicated personal computer software that allows the programmer to enter the ladder diagram as drawn. The software then takes care of translating the ladder diagram into the code required by the controller. In the lower order, more basic controllers, this has to be performed by the programmer and entered by hand into the controller. It is this type of language and the procedure for translating the ladder diagram into the required code that will be discussed in this chapter. This will be accomplished by retracing the examples and ladder diagrams developed in earlier chapters and translating them into the mnemonic code required to program a general controller.
This controller will be programmed in a somewhat generic type of code. As the code is learned, comparisons will be presented with similar types of statements found in controller use. The student will have only to adapt to the statements required by the type of controller being used to develop a program for that controller.
5-3. AND Ladder Rung
Let us begin with the ladder diagram of Figure 5-1. This is the AND combination of two contacts, IN1 and IN2 controlling coil OUT1.
5-1

Chapter 5 - Mnemonic Programming Code
Figure 5-1 - Ladder Diagram for AND Function
Ladder diagrams are made up of branches of contact logic connected together which control a coil. For instance, IN1 AND IN2 can be considered a branch. This rung has only one branch. We will see examples of multiple branches later. The code command which alerts the controller to the beginning of a branch is LD. The LD command tells the controller that the following set of contacts composes one branch of logic. The complete contact command code for these is:
LD IN1
AND IN2
The lines tell the controller to start a branch with IN1 and with this contact, AND contact IN2. LD commands are terminated with either another LD command or a coil command. In this case, a coil command would terminate because there are no more contacts contained in the ladder. The coil command is STO. The contact and coil commands for this rung of logic are:
LD IN1
AND IN2
STO OUT1
The STO command tells the controller that the previous logic is to control the coil that follows the STO command. Each line of code must be input into the controller as an individual command. The termination command for a line of code is generally ENTER.
NOTE: Two types of terminators have been described and should not be confused with each other. Commands are terminated by another command (a software item) while lines are terminated with ENTER (a hardware keyboard key).
5-2

Chapter 5 - Mnemonic Programming Code
The complete command listing for this ladder rung including termination commands is:
LD IN1 ENTER
AND IN2 ENTER
STO OUT1 ENTER
The commands may be entered using a hand-held programmer, dedicated desktop programmer or a computer containing software that will allow it to operate as a programming device. Each controller command line contains (1) a command, (2) the object of the command and (3) a terminator (the ENTER key). In the case of the first line, LD is the command, IN1 is the object of the command and the ENTER key is the terminator.
Each line of code will typically consume one word of memory, although some of the more complicated commands will consume more than one word. Examples of commands that may consume more than one word of memory are math functions and timers, which will be discussed later.
5-4. Handling Normally Closed Contacts
Notice that the rung of Figure 5-1 has only normally open contacts and no normally closed contacts. Let us look at how the command lines would change with the inclusion of a normally closed contact in the rung. This is illustrated in Figure 5-2. Notice that normally open contact IN1 of Figure 5-2 has been replaced with normally closed contact
IN1.
Figure 5-2 - Rung With Normally Closed Contact
To indicate a normally closed contact to the PLC, the term NOT is associated with the contact number. This may take different forms in different controllers depending on the program method used by the manufacturer. Using the same form as in the previous example, the command lines for this rung would appear as follows:
5-3

Chapter 5 - Mnemonic Programming Code
LD |
NOT IN1 |
ENTER |
AND |
IN2 |
ENTER |
STO |
OUT1 |
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 |
ENTER |
AND |
NOT IN2 |
ENTER |
STO |
OUT1 |
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