Encoder Front Page
SRS Home | Front Page | Monthly Issue | Index
Search WWW Search seattlerobotics.org


At the March SRS meeting the subject of ladder logic or relay logic came up and there seemed to be some interest in what it is. I’ve been using this since 1975 when I started working as an electrical draftsman. This was “B.C.” (before computers) and I first learned to use it designing motor circuits and then entire relay panels. The reason it’s called ladder logic is the program is drawn pictorially and looks like a ladder, unlike a program listing you may be familiar with like basic or C++ which use alpha numeric characters.

Ladder diagrams are used to describe the logic of electrical control systems. There are differences in the way ladder logic was implemented in computerized form as compared to hard wired so I will be talking about the old way first. The basic component of the control system is the control relay which is a solenoid that operates a number of switches or contacts. The contacts come normally open and normally closed, normal being when the relay is not energized. Relays come in various breeds like time delay and latching types. Other components of the control system are the field devices such as push buttons, limit switches, lights, and controlled devices like motor starters and solenoid operated valves. As I said, ladder diagrams show the logic of the controls but they are not used to build the system, a wiring diagram is used for that. But the wiring diagram wouldn’t be used to trouble shoot with or show functionality, that’s where the ladder is most useful.

Fig. 1 Standard motor control circuit.

When viewing the pictorial version of the controls as in Figure 1, one can see that the devices on a rung of the ladder are in series reading horizontally and in parallel reading vertically. Control voltage is supplied to the vertical rails, L1 being hot and L2 being common or ground. In industry it is common to see 120vac control and 480vac power circuits. Anything less than 600 volts is considered low voltage and virtually everything will have an insulation rating of 600 volts. (My robot uses 5vdc control and 28vdc power circuits.) In Figure 1 we see a normally closed (N.C.) stop button and a normally open (N.O.) start button and a motor starter. The circle with the M represents the coil of a relay, not the actual motor. The M contact is physically part of the starter and actuates with the coil. The contact labeled O.L. (over load) is also part of the starter and is a circuit breaker tripped by over current in the motor legs. The M contact is called the seal contact. Without it, the motor would run as long as someone held down the start button and would stop when released. With it, the power is allowed to flow through the start button to energize the coil, which closes the M contact, maintaining the complete circuit when the start button is released. To stop the motor, any element in series with the coil can break the circuit, in this case the stop button. True, this was a long winded explanation but you now have the critical pieces, how to turn something on, make it stay on, and how to shut it off. It’s a truth table in disguise, ANDs and ORs, ONs and OFFs.
Figure 1 is about as simple as it gets so lets build it up. Sometimes we want to jog or creep the motor. In figure 2 the jog button is added which closes on the very bottom rung and opens on the middle rung when pushed.

Figure 2, motor circuit with jog.

Easy? How about a light or two to tell us if the motor has been energized or not?

Figure 3, motor circuit with indicator lights.

By now you may be seeing more of a ladder in the pictures. If we wanted to start more than one motor with one set of buttons we could use a control relay in place of, or in parallel with, the M coil and use the contacts of the CR to start the other motors. We could use time delay relays (TDR) with different settings to cascade the starting of the motors. That method is used with conveyor systems for example.
A few last points about hard wired circuits are in order here. First, notice that the controlled devices like the motors and valve operators are drawn on the far right next to the rail. There are safety reasons for this even though it is appealing aesthetically. Imagine the motor on the left side with the switches following to the right. A short in the circuit could run the motor with no way to turn it off other than killing all the power! Another point may be insignificant but here it is: the system is always powered up to some logical state, it’s always solved. When a field device changes state, that is what initiates a change of state of the system. I make this point because it’s different in computerized systems.

Figure 4

Ladder diagrm for hard wired system.

Figure 5

Combination wiring and ladder diagram for PLC system. Input divices are on the left and output devices are on the right. The program for the PLC is in the center.

Figures 4 and 5 show the transition from hard wire to computer. The computers used in industry are called programmable logic controllers (PLC) and they are programmed with ladder logic, pictorially. Physically, the components are arranged in a very clean way. The input devices are individually wired to the input terminals of the PLC and the controlled components are individually wired to the output terminals. Each terminal has it’s own address and the ladder diagram is programmed using these numbers for the real components. The inputs are all shown as contacts, either N.O. or N.C., not the fancy graphics of drafting. And all the outputs are depicted as circles and called coils. PLCs build the programs in what are referred to as networks. In a Modicon brand for example, a network may have eleven elements on a rung including the coil, and may have seven rungs. One is not required to use all the element positions and in fact it is bad practice to use more than a few rungs because the space will probably be needed for future growth. When the Modicon is running it does four things. First it reads all the inputs and records the state in a table. Second it solves the logic based on the input table and updates the output table. Third, it changes the outputs based on the table, and last is housekeeping routines. All that is called a “scan”. When scanning the logic, the program is solved one network at a time, and the network is scanned by columns. So the last thing to be solved in each network is the coils which are always in column eleven. The unwary programmer can find himself with problems by not accounting for scanning issues. Which reminds me of the old hard wire problem relay chase. Two relays turning each other on and off as fast as they can operate! Quite embarrassing at start up.
The last thing I would like to cover concerns the I/O. The PLC reads and writes to a bus where many different modules are attached. The input and output modules can be all variations of ac or dc voltages, digital or analog. Specialized modules for encoders and user input devices are available. You haven’t seen Plug and Play until you’ve played with PLCs! The modules are intelligent and that takes a lot of stress off the program.
This is the cook’s tour and just the tip of the iceberg of ladder logic and PLCs. Maybe this will be showing up in robotics soon. I remember a very small PLC being shown a few months back at the SRS meeting. If anyone is interested in hearing more I will oblige. Maybe a demo could be arranged for some afternoon after the meeting?

Jeff Bullock 5/97