Develop structured programs for control systems (Allen Bradley

Transcription

Develop structured programs for control systems (Allen Bradley
Electrical, Electronics
Engineering
Department
Develop structured programs
for
control systems
(Allen Bradley)
UEUNEED027B
Version
Date
Contact
1
01/09
DK
2
05/10
DK
3
06/10
DK
4
5
Chisholm Institute Berwick
Tel: 9212 4526
ALLEN BRADLEY VOL1 UEUNEED027A
Duration 60hrs
Required Skills and Knowledge
E2.3.19 Control programming fundamentals
Evidence shall show an understanding of control programming fundamentals to an extent indicated by the
following aspects:
a) Control applications of software
b) Software terminology
c) Programming languages currently used by industry
d) Control system development encompassing:
• flowcharts
• pseudocode
• Nassi-Schneidemann charts
• algorithms
e) Programming styles encompassing:
• programming structure
• documentation
• installing a language compiler
• using a text editor
• compiling source code
• generating executable files
• scalar and structured data types
• constants and variables
• reading from keyboard and writing to screen
• arithmetic, relational and logical operations
• making decisions using if/then, if/then/else, nested if/then and case
• looping operations using while/do, repeat/until and for/do
• programming to access external devices via I/O boards
• functions
Note: Examples are macros; global and local variables, auto and static variables; Intrinsic functions used in
control; Writing functions; Linking in external functions to control hardware
• numerical and character arrays
-2-
ALLEN BRADLEY VOL1 UEUNEED027A
Table of contents
Table of contents .......................................................................................................................... 3
Introduction to PLCs...................................................................................................................... 5
Individual PLC sections ................................................................................................................. 7
Inside The PLC ........................................................................................................................... 12
PLC Operation ............................................................................................................................ 13
Basic PLC instructions ................................................................................................................ 19
Getting Started ............................................................................................................................ 28
Latching Instructions ................................................................................................................... 34
Timers ......................................................................................................................................... 36
Allen Bradley Timers ................................................................................................................... 39
Counters ..................................................................................................................................... 44
Allen Bradley Counters ............................................................................................................... 47
Exercises and Assessment items ................................................................................................ 52
Assessment Item 1 – Door Simulation ................................................................................. 58
Assessment Item 2 – Level application ................................................................................ 60
Assessment Item 3 - Timer .................................................................................................. 61
Assessment Item 4 - Counter ............................................................................................... 62
Personal Safety and Safe Work Practices ................................................................................... 63
PLC Installation ........................................................................................................................... 66
Program Storage Methods .......................................................................................................... 68
PLC Hardware ............................................................................................................................ 75
Peripheral Devices ...................................................................................................................... 81
Basic diagnostics ........................................................................................................................ 92
Derived Timers............................................................................................................................ 95
Derived timer Exercises .............................................................................................................. 99
Assessment item 5 – derived timers................................................................................... 101
Reversible Counters.................................................................................................................. 102
Comparison Instructions............................................................................................................ 106
Process control ......................................................................................................................... 111
Assessment Item 6– Traffic light sequence ........................................................................ 114
Program Flow Instructions......................................................................................................... 115
Assessment Item 7 – Program Flow ................................................................................... 122
Shift Registers........................................................................................................................... 123
Assessment Item 8 – Shift Register ................................................................................... 132
-3-
ALLEN BRADLEY VOL1 UEUNEED027A
This page intentionally left blank
-4-
ALLEN BRADLEY VOL1 UEUNEED027A
Introduction to PLCs
The PLC
A PLC ( Programmable Logic Controller) is a device that was invented to replace the necessary
sequential relay circuits for machine control.
The PLC works by looking at its inputs and depending upon their state, turning on/off its outputs.
The user enters a program, usually via software, that gives the desired results.
PLCs are used in many "real world" applications. If there is industry present, chances are good
that there is a PLC present. If you are involved in machining, packaging, material handling,
automated assembly or countless other industries you are probably already using them. If you are
not, you are wasting money and time. Almost any application that needs some type of electrical
control has a need for a PLC.
For example, let's assume that when a switch turns on we want to turn a solenoid on for 5
seconds and then turn it off regardless of how long the switch is on for. We can do this with a
simple external timer. But what if the process included 10 switches and solenoids? We would
need 10 external timers. What if the process also needed to count how many times the switches
individually turned on? We need a lot of external counters.
As you can see the bigger the process the more of a need we have for a PLC. We can simply
program the PLC to count its inputs and turn the solenoids on for the specified time.
History
In the late 1960's PLCs were first introduced. The primary reason for designing such a device was
eliminating the large cost involved in replacing the complicated relay based machine control
systems. Bedford Associates (Bedford, MA) proposed something called a Modular Digital
Controller (MODICON) to a major US car manufacturer. Other companies at the time proposed
computer based schemes, one of which was based upon the PDP-8. The MODICON 084 brought
the world's first PLC into commercial production.
When production requirements changed so did the control system. This becomes very expensive
when the change is frequent. Since relays are mechanical devices they also have a limited
lifetime which required strict adhesion to maintenance schedules. Troubleshooting was also quite
tedious when so many relays are involved. Now picture a machine control panel that included
many, possibly hundreds or thousands, of individual relays. The size could be mind boggling.
How about the complicated initial wiring of so many individual devices!
These relays would be individually wired together in a manner that would yield the desired
outcome.
These "new controllers" also had to be easily programmed by maintenance and plant engineers.
The lifetime had to be long and programming changes easily performed. They also had to survive
the harsh industrial environment. That's a lot to ask! The answers were to use a programming
technique most people were already familiar with and replace mechanical parts with solid-state
ones.
-5-
ALLEN BRADLEY VOL1 UEUNEED027A
In the mid1970's the dominant PLC technologies were sequencer state-machines and the bit-slice
based CPU. The AMD 2901 and 2903 processors were quite popular in Modicon and AllenBradley PLCs.
Conventional microprocessors lacked the power to quickly solve PLC logic in all but the smallest
PLCs. As conventional microprocessors evolved, larger and larger PLCs were being based upon
them. However, even today some are still based upon the 2903.(ref A-B's PLC-3) Modicon has
yet to build a faster PLC than their 984A/B/X which was based upon the 2901.
Communications abilities began to appear in approximately 1973. The first such system was
Modicon's Modbus. The PLC could now talk to other PLCs and they could be far away from the
actual machine they were controlling. They could also now be used to send and receive varying
voltages to allow them to enter the analog world. Unfortunately, the lack of standardization
coupled with continually changing technology has made PLC communications a nightmare of
incompatible protocols and physical networks. Still, it was a great decade for the PLC!
The 80's saw an attempt to standardize communications with General Motor's manufacturing
automation protocol (MAP). It was also a time for reducing the size of the PLC and making them
software programmable through symbolic programming on personal computers instead of
dedicated programming terminals or handheld programmers. Today the world's smallest PLC is
about the size of a single control relay!
The 90's have seen a gradual reduction in the introduction of new protocols, and the
modernization of the physical layers of some of the more popular protocols that survived the
1980's. The latest standard (IEC 1131-3) has tried to merge PLC programming languages under
one international standard. We now have PLCs that are programmable in function block
diagrams, instruction lists, C and structured text all at the same time! PC's are also being used to
replace PLCs in some applications. The original company who commissioned the MODICON 084
has actually switched to a PC based control system.
-6-
ALLEN BRADLEY VOL1 UEUNEED027A
Individual PLC sections
Common to all PLCs are five sections, each of which can be subdivided into smaller but equally
important sections. These primary sections include:
• The power supply section which provides the operating DC power to the PLC and I/O
base modules and includes battery backup.
• The CPU module, which contains the processor and holds the memory.
• The memory section
• The software program section
• The I/O section, which controls peripheral devices and contains the input and output
modules.
Power supply section.
The power supply (PS) section gets its input power from an external 120VAC or 240VAC source
(line voltage), which is usually fused and fed through a control relay and filter external to the PS.
In addition, the PS has its own integral AC input fuse.
This line voltage is then stepped-down, rectified, filtered, regulated, voltage- and currentprotected, and status-monitored, with status indication displayed on the front of the PS in the form
of several LEDs (light-emitting diodes). The PS can have a key switch for protecting the memory
or selecting a particular programming mode.
The output of the PS provides low DC voltage(s) to the PLC's various modules as well as to its
integral lithium battery, which is used for the memory backup. Should the PS fail or its input line
voltage drop below a specific value, the memory contents will not change from what they were
prior to the failure.
The PS output provides power to every module in the PLC; however, it does not provide the DC
voltages to the PLC's peripheral I/O devices.
CPU module.
"CPU," "controller," or "processor" are all terms used by different manufacturers to denote the
same module that performs basically the same functions. The CPU module can be divided into
two sections: the processor section and the memory section.
The processor section makes the decisions needed by the PLC so that it can operate and
communicate with other modules. It communicates along either a serial or parallel data-bus. An
I/O base interface module or individual on-board interface I/O circuitry provides the signal
conditioning required to communicate with the processor. The processor section also executes
the programmer's RLL software program.
-7-
ALLEN BRADLEY VOL1 UEUNEED027A
The memory section
This section stores (electronically) retrievable digital information in three dedicated locations of
the memory. These memory locations are routinely scanned by the processor. The memory will
receive ("write" mode) digital information or have digital information accessed ("read" mode) by
the processor. This read/write (R/W) capability provides an easy way to make program changes.
The memory contains data for several types of information. Usually, the data tables, or image
registers, and the software program RLL are in the CPU module's memory. The program
messages may or may not be resident with the other memory data.
A battery backup is used by some manufacturers to protect the memory contents from being lost
should there be a power or memory module failure. Still others use various integrated circuit (IC)
memory technologies and design schemes that will protect the memory contents without the use
of a battery backup.
A typical memory section of the CPU module has a memory size of 96,000 (96K) bytes. This size
tells us how many locations are available in the memory for storage. Additional memory modules
can be added to your PLC system as the need arises for greater memory size. These expansion
modules are added to the PLC system as the quantity of I/O modules are added or the software
program becomes larger. When this is done, the memory size can be as high as 1,024,000
(1024K) bytes.
Manufacturers will state memory size in either "bytes" or "words." A byte is eight bits, and a bit is
the smallest digit in the binary code. It's either a logic "1" or a logic "0." A word is equal in length
to two bytes or 16 bits. Not all manufacturers use 16-bit words, so be aware of what your PLC
manufacturer has defined as its memory word bit size.
-8-
ALLEN BRADLEY VOL1 UEUNEED027A
The Program Software Section.
The PLC not only requires electronic components to operate, it also needs a software program.
The PLC programmer is not limited to writing software in one format. There are many types
available, each lending itself more readily to one application over and above another. Typical is
the RLL type previously discussed. Other S/W programs include "C," State Language, and SFC
(Sequential Function Charts).
Regardless of which software is chosen, it will be executed by the PLC's CPU module. The
software can be written and executed with the processor in an online state (while the PLC is
actually running) or in the off-line state (whereby the S/W execution does not affect current
operation of the I/O base).
In the RLL software program, we find several types of programming elements and functions to
control processes both internal to the PLC (memory and register) as well as external (field)
devices. Listed below are some of the more common types of elements, functions, and
instructions:
Contacts (can be either normally opened or closed; highlighted on the monitor means they are
active).
• Coils (can be normal or latched; highlighted means they are energized).
• Timers (coil can either be ON or OFF for the specified delay).
• Counters (can count by increments either up or down).
• Bit shift registers (can shift data by one bit when active).
• One-shot (meaning active for one scan time; useful for pulse timer).
• Drums (can be sequenced based on a time or event).
• Data manipulation instructions (enable movement, comparison of digital values).
• Arithmetic instructions (enable addition, subtraction, multiplication, and division of digital
values).
Input Output Section (I/O)
Input module
The input module has two functions: reception of an external signal and status display of that
input point. In other words, it receives the peripheral sensing unit's signal and provides signal
conditioning, termination, isolation and/or indication for that signal's state.
The input to an input module is in either a discrete or analog form. If the input is an ON-OFF type,
such as with a push button or limit switch, the signal is considered to be of a discrete nature. If, on
the other hand, the input varies, such as with temperature, pressure, or level, the signal is analog
in nature.
Peripheral devices sending signals to input modules that describe external conditions can be
switches (limit, proximity, pressure, or temperature), push buttons, or logic, binary coded decimal
(BCD) or analog-to-digital (A/D) circuits. These input signal points are scanned, and their status is
communicated through the interface module or circuitry within each individual PLC and I/O base.
-9-
ALLEN BRADLEY VOL1 UEUNEED027A
Some typical types of input modules are listed below.
* DC voltage (110, 220, 14, 24, 48, 15-30V) or current (4-20 mA).
* AC voltage (110, 240, 24, 48V) or current (4-20 mA).
* TTL (transistor transistor logic) input (3-15VDC).
* Analog input (12-bit).
* Word input (16-bit/parallel).
* Thermocouple input.
* Resistance temperature detector.
* High current relay.
* Low current relay.
* Latching input (24VDC/110VAC).
* Isolated input (24VDC/85-132VAC).
* Intelligent input (contains a microprocessor).
* Positioning input.
* PID (proportional, integral, differentiation) input.
* High-speed pulse.
Output module
The output module transmits discrete or analog signals to activate various devices such as
hydraulic actuators, solenoids, motor starters, and displays the status (through the use of LEDs)
of the connected output points. Signal conditioning, termination, and isolation are also part of the
output module's functions. The output module is treated in the same manner as the input module
by the processor.
Some typical output modules available today include the following:
* DC voltage (24, 48,110V) or current (4-20 mA).
* AC voltage (110, 240v) or current (4-20 mA).
* Isolated (24VDC).
* Analog output (12-bit).
* Word output (16-bit/parallel).
* Intelligent output.
* ASCII output.
* Dual communication port.
- 10 -
ALLEN BRADLEY VOL1 UEUNEED027A
The diagram below shows a block diagram of a PLC being used to control a simple
security system
- 11 -
ALLEN BRADLEY VOL1 UEUNEED027A
Inside The PLC
The PLC mainly consists of a CPU, memory areas, and appropriate circuits to receive
input/output data. We can actually consider the PLC to be a box full of hundreds or thousands of
separate relays, counters, timers and data storage locations. Do these counters, timers, etc. really
exist? No, they don't "physically" exist but rather they are simulated and can be considered
software counters, timers, etc. These internal relays are simulated through bit locations in
registers. (more on that later)
INPUT RELAYS (contacts)
These are connected to the outside world. They physically exist and receive signals from
switches, sensors, etc. Typically they are not relays but rather they are transistors.
INTERNAL UTILITY RELAYS (contacts)
These do not receive signals from the outside world nor do they physically exist. They are
simulated relays and are what enables a PLC to eliminate external relays. There are also some
special relays that are dedicated to performing only one task. Some are always on while some
are always off. Some are on only once during power-on and are typically used for initializing data
that was stored.
COUNTERS
These again do not physically exist. They are simulated counters and they can be programmed to
count pulses. Typically these counters can count up, down or both up and down. Since they are
simulated they are limited in counting speed. Some manufacturers also include high-speed
counters that are hardware based. We can think of these as physically existing. Most times these
counters can count up, down or up and down.
TIMERS
These also do not physically exist. They come in many varieties and increments. The most
common type is an on-delay type. Others include off-delay and both retentive and non-retentive
types. Increments vary from 1ms through 1s.
OUTPUT RELAYS (coils)
These are connected to the outside world. They physically exist and send on/off signals to
solenoids, lights, etc. They can be transistors, relays, or triacs depending upon the model chosen.
DATA STORAGE
Typically these are registers assigned to simply store data. They are usually used as temporary
storage for maths or data manipulation. They can also typically be used to store data when power
is removed from the PLC. Upon power-up they will still have the same contents as before power
was removed. Very convenient and necessary!!
- 12 -
ALLEN BRADLEY VOL1 UEUNEED027A
PLC Operation
A PLC works by continually scanning a program. We can think of this scan cycle as consisting of
3 important steps. There are typically more than 3 but we can focus on the important parts and
not worry about the others. Typically the others are checking the system and updating the current
internal counter and timer values.
CHECK INPUT STATUS
First the PLC takes a look at each input to determine if it is on or off. In other words, is the sensor
which is connected to the first input on? How about the second input? How about the third... It
records this data into its memory to be used during the next step.
EXECUTE PROGRAM
Next the PLC executes your program one instruction at a time. Maybe your program said that if
the first input was on then it should turn on the first output. Since it already knows which inputs
are on/off from the previous step it will be able to decide whether the first output should be turned
on based on the state of the first input. It will store the execution results for use later during the
next step.
UPDATE OUTPUT STATUS
Finally the PLC updates the status of the outputs. It updates the outputs based on which inputs
were on during the first step and the results of executing your program during the second step.
Based on this example it would now turn on the first output.
After the third step the PLC goes back to step one and repeats the steps continuously. One scan
time is defined as the time it takes to execute the 3 steps listed above.
- 13 -
ALLEN BRADLEY VOL1 UEUNEED027A
Response Time
The total response time of the PLC is a fact we have to consider when shopping for a PLC. Just
like our brains, the PLC takes a certain amount of time to react to changes. In many applications
speed is not a concern, in others though.
If you take a moment to look away from this text you might see a picture on the wall. Your eyes
actually see the picture before your brain says "Oh, there's a picture on the wall". In this example
your eyes can be considered the sensor.
The eyes are connected to the input circuit of your brain. The input circuit of your brain takes a
certain amount of time to realize that your eyes saw something. (If you have been drinking alcohol
this input response time would be longer!) Eventually your brain realizes that the eyes have seen
something and it processes the data. It then sends an output signal to your mouth. Your mouth
receives this data and begins to respond to it. Eventually your mouth utters the words "that's a
really ugly picture!".
Notice in this example we had to respond to 3 things:
INPUT
It took a certain amount of time for the brain to notice the input signal from the eyes.
EXECUTION
It took a certain amount of time to process the information received from the eyes. Consider the
program to be: If the eyes see an ugly picture then output appropriate words to the mouth.
OUTPUT
The mouth receives a signal from the brain and eventually spits (no pun intended) out the words
"that's a really ugly picture!"
- 14 -
ALLEN BRADLEY VOL1 UEUNEED027A
Response Time Concerns
Now that we know about response time, here's what it really means to the application. The PLC
can only see an input turn on/off when it's looking. In other words, it only looks at its inputs during
the check input status part of the scan.
It is possible that an input pulse may not be detected if the pulse is too short (the pulse is shorter
than the program scan.
To avoid this we say that the input should be on for at least 1 input delay time + one scan time.
But what if it was not possible for the input to be on this long? Then the PLC doesn't see the input
turn on. Therefore it becomes a paper weight!
Not true... of course there must be a way to get around this. Actually there are 3 ways.
Pulse stretch function.
This function extends the length of the input signal until the PLC looks at the inputs during the
next scan
(It stretches the duration of the pulse.)
Interrupt function.
This function interrupts the scan to process a special routine that you have written.
( As soon as the input turns on, regardless of where the scan currently is, the PLC immediately
stops what its doing and executes an interrupt routine.) A routine can be thought of as a mini
program outside of the main program.
After its done executing the interrupt routine, it goes back to the point it left off and continues on
with the normal scan process.
Immediate update
Some PLCs have an instruction that allows you to set points in the program where the inputs are
updated. Instead of just one input update per scan, you can set as many as you need to ensure
that the input pulse is seen by the PLC
- 15 -
ALLEN BRADLEY VOL1 UEUNEED027A
Relays
Now that we understand how the PLC processes inputs, outputs, and the actual program we are
almost ready to start writing a program. But first lets see how a relay actually works. After all, the
main purpose of a PLC is to replace "real-world" relays.
We can think of a relay as an electromagnetic switch. Apply a voltage to the coil and a magnetic
field is generated. This magnetic field sucks the contacts of the relay in, causing them to make a
connection. These contacts can be considered to be a switch. They allow current to flow between
2 points thereby closing the circuit.
Let's consider the following example. Here we simply turn on a bell (Lunch time!) whenever a
switch is closed. We have 3 real-world parts. A switch, a relay and a bell. Whenever the switch
closes we apply a current to a bell causing it to sound.
Notice in the picture that we have 2 separate circuits. The bottom, (thin) section indicates the DC
part. The top(thick) section indicates the AC part.
Here we are using a DC relay to control an AC circuit. That's the fun of relays! When the switch is
open no current can flow through the coil of the relay. As soon as the switch is closed, however,
current runs through the coil causing a magnetic field to build up. This magnetic field causes the
contacts of the relay to close. Now AC current flows through the bell and we hear it. Lunch time!
- 16 -
ALLEN BRADLEY VOL1 UEUNEED027A
Replacing Relays
Next, lets use a PLC in place of the relay. (Note that this might not be very cost effective for this
application but it does demonstrate the basics we need.) The first thing that's necessary is to
create what's called a ladder diagram. After seeing a few of these it will become obvious why its
called a ladder diagram. We have to create one of these because, unfortunately, a PLC doesn't
understand a schematic diagram. It only recognizes code. Fortunately most PLCs have software
which convert ladder diagrams into code. This shields us from actually learning the PLC's code.
First step
We have to translate all of the items we're using into symbols the PLC understands. The PLC
doesn't understand terms like switch, relay, bell, etc. It prefers input, output, coil, contact, etc. It
doesn't care what the actual input or output device actually is. It only cares that it is an input or an
output.
First we replace the battery with a symbol. This symbol is common to all ladder diagrams. We
draw what are called bus bars. These simply look like two vertical bars. One on each side of the
diagram. Think of the left one as being + voltage and the right one as being ground. Further think
of the current (logic) flow as being from left to right.
Next we give the inputs a symbol. In this basic example we have one real world input. (i.e. the
switch) We give the input that the switch will be connected to, to the symbol shown below. This
symbol can also be used as the contact of a relay.
A contact symbol
Next we give the outputs a symbol. In this example we use one output (i.e. the bell). We give the
output that the bell will be physically connected to the symbol shown below. This symbol is used
as the coil of a relay.
A coil symbol
The AC supply is an external supply so we don't put it in our ladder. The PLC only cares about
which output it turns on and not what's physically connected to it.
- 17 -
ALLEN BRADLEY VOL1 UEUNEED027A
Second step
We must tell the PLC where everything is located. In other words we have to give all the devices
an address. Where is the switch going to be physically connected to the PLC? How about the
bell? We start with a blank road map in the PLCs town and give each item an address. Could you
find your friends if you didn't know their address? You know they live in the same town but which
house? The PLC town has a lot of houses (inputs and outputs) but we have to figure out who
lives where (what device is connected where). We'll get further into the addressing scheme later.
The PLC manufacturers each do it a different way! For now let's say that our input will be called
"0000". The output will be called "500".
Final step
We have to convert the schematic into a logical sequence of events. This is much easier than it
sounds. The program we're going to write tells the PLC what to do when certain events take
place. In our example we have to tell the PLC what to do when the operator turns on the switch.
Obviously we want the bell to sound but the PLC doesn't know that.
The picture above is the final converted diagram. Notice that we eliminated the real world relay
from needing a symbol. It's actually "inferred" from the diagram.
Now let's examine some of the basic instructions is greater detail to see more about what each
one does.
- 18 -
ALLEN BRADLEY VOL1 UEUNEED027A
Basic PLC instructions
Load
The load (LD) instruction is a normally open contact. It is sometimes also called examine if on
(XIO), as in examine the input to see if its physically on. The symbol for a load instruction is
shown below.
A Load (contact) symbol
This is used when an input signal is needed to be present for the symbol to turn on. When the
physical input is on we can say that the instruction is True. We examine the input for an on signal.
If the input is physically on then the symbol is on.
This symbol normally can be used for internal inputs, external inputs and external output contacts.
Remember that internal relays don't physically exist. They are simulated (software) relays.
Example
Ladder
Assume that a normally open switch is connected to input I:1/0 and a lamp is connected to output
O:2/0.
When the switch is closed the input instruction will be true and the lamp will turn on.
When the switch is open the input instruction will be false and the lamp will turn off.
- 19 -
ALLEN BRADLEY VOL1 UEUNEED027A
LoadBar/LoadNot
The LoadBar instruction is a normally closed contact. It is sometimes also called LoadNot or
examine if closed (XIC), as in examine the input to see if its physically closed. The symbol for a
loadBar instruction is shown below.
A LoadNot symbol
This is used when an input signal does not need to be present for the symbol to turn on. When
the physical input is off we can say that the instruction is True. We examine the input for an off
signal. If the input is physically off then the symbol is on. This symbol normally can be used for
internal inputs, external inputs and sometimes, external output contacts. Remember again that
internal relays don't physically exist. They are simulated (software) relays. It is the exact opposite
of the Load instruction.
Note: With most PLCs this instruction (Load or Loadbar) MUST be the first symbol on the left of
the ladder.
Logic State
0
1
Load
False
True
LoadNot
True
False
Example
Ladder
Assume that a normally open switch is connected to input I:1/0 and a lamp is connected to output
O:2/0.
When the switch is closed the input instruction will be false and the lamp will turn off.
When the switch is open the input instruction will be true and the lamp will turn on.
- 20 -
ALLEN BRADLEY VOL1 UEUNEED027A
Out
The Out instruction is sometimes also called an Output energise instruction. The output
instruction is like a relay coil. Its symbol looks as shown below.
An OUT (coil) symbol
When there is a path of True instructions preceding this on the ladder rung, it will also be true.
When the instruction is true it is physically On. This instruction can be used for internal coils and
external outputs.
Example
Ladder
Assume that a normally open switch is connected to input I:1/0 and a lamp is connected to output
O:2/0.
When the switch is closed the input instruction will be true and the lamp will turn on.
When the switch is open the input instruction will be false and the lamp will turn off.
Outbar
The Outbar instruction is sometimes also called an OutNot instruction. Some vendors don't have
this instruction.
Its symbol looks like that shown below.
An OUTBar symbol
When there is a path of False instructions preceding this on the ladder rung, it will be true. When
the instruction is rue it is physically On.
This instruction can be used for internal coils and external outputs. It is the exact opposite of the
Out instruction.
Logic State
Load
LoadNot
0
False
True
1
True
False
Note: This instruction is not used in the SLC500 instruction set
- 21 -
ALLEN BRADLEY VOL1 UEUNEED027A
Simple Example
Now let's compare a simple ladder diagram with its real world external physically connected relay
circuit and see the differences.
In the above circuit, the coil will be energized when there is a closed loop between the + and terminals of the battery. We can simulate this same circuit with a ladder diagram.
A ladder diagram consists of individual rungs just like on a real ladder. Each rung must contain
one or more inputs and one or more outputs. The first instruction on a rung must always be an
input instruction and the last instruction on a rung should always be an output (or its equivalent).
Notice in this simple one rung ladder diagram we have recreated the external circuit above with a
ladder diagram. Here we used the Load and Out instructions. Some manufacturers require that
every ladder diagram include an END instruction on the last rung.
- 22 -
ALLEN BRADLEY VOL1 UEUNEED027A
Level Application
Let's consider the following application:
We are controlling lubricating oil being dispensed from a tank. This is possible by using two
sensors. We put one near the bottom and one near the top, as shown in the picture below.
Here, we want the fill motor to pump lubricating oil into the tank until the high level sensor turns
on. At that point we want to turn off the motor until the level falls below the low level sensor. Then
we should turn on the fill motor and repeat the process.
Here we have a need for 3 I/O (i.e. Inputs/Outputs). 2 are inputs (the sensors) and 1 is an output
(the fill motor). Both of our inputs will be NC (normally closed) fiber-optic level sensors. When they
are NOT immersed in liquid they will be ON. When they are immersed in liquid they will be OFF.
We will give each input and output device an address. This lets the PLC know where they are
physically connected. The addresses are shown in the following tables:
Inputs
Low
High
Address
0000
0001
Outputs
Motor
Address
5000
- 23 -
Internal Utility
1000
ALLEN BRADLEY VOL1 UEUNEED027A
Below is what the ladder diagram will actually look like. Notice that we are using an internal utility
relay in this example. You can use the contacts of these relays as many times as required. Here
they are used twice to simulate a relay with 2 sets of contacts. Remember, these relays DO NOT
physically exist in the PLC but rather they are bits in a register that you can use to simulate a
relay.
We should always remember that the most common reason for using PLCs in our applications is
for replacing real-world relays. The internal utility relays make this action possible. It's impossible
to indicate how many internal relays are included with each brand of PLC. Some include 100's
while others include 1000's while still others include 10's of 1000's! Typically, PLC size (not
physical size but rather I/O size) is the deciding factor. If we are using a micro-PLC with a few I/O
we don't need many internal relays. If however, we are using a large PLC with 100's or 1000's of
I/O we'll certainly need many more internal relays.
If ever there is a question as to whether or not the manufacturer supplies enough internal relays,
consult their specification sheets. In all but the largest of large applications, the supplied amount
should be MORE than enough.
- 24 -
ALLEN BRADLEY VOL1 UEUNEED027A
The Program Scan
Let's watch what happens in this program scan by scan.
Initially the tank is empty therefore, input 0000 is TRUE and input 0001 is also TRUE.
Scan 1
Scan 2-100
Gradually the tank fills because 5000 (fill motor) is on.
- 25 -
ALLEN BRADLEY VOL1 UEUNEED027A
After 100 scans the oil level rises above the low level sensor and it becomes open. ( false)
Scan 101-1000
Notice that even when the low level sensor is false there is still a path of true logic from left to
right. This is why we used an internal relay.
Relay 1000 is latching the output (5000) on. It will stay this way until there is no true logic path
from left to right.(i.e. when 0001 becomes false).
After 1000 scans the oil level rises above the high level sensor at it also becomes open (false)
Scan 1001
Scan 1002
- 26 -
ALLEN BRADLEY VOL1 UEUNEED027A
Since there is no more true logic path, output 5000 is no longer energized (true) and therefore the
motor turns off.
After 1050 scans the oil level falls below the high level sensor and it will become true again.
Scan 1050
Notice that even though the high level sensor became true there still is NO continuous true logic
path and therefore coil 1000 remains false!
After 2000 scans the oil level falls below the low level sensor and it will also become true again.
At this point the logic will appear the same as SCAN 1 above and the logic will repeat as
illustrated above.
- 27 -
ALLEN BRADLEY VOL1 UEUNEED027A
Getting Started
To start the program
Double click on the RS500 icon on your desktop. When we start this it automatically starts to
communicate with the PLC.
File New is used to start a new project.
The screen below is shown asking you to select a processor.
Normally inside the CPU door is a part number
i.e. it could be1747-L531
You then select this from the display
- 28 -
ALLEN BRADLEY VOL1 UEUNEED027A
You then select I/O configuration and select the other modules you have in your rack, i.e. input,
output, analog.
With the SLC 5/03 or higher, you can choose to press read I/O config. This automatically goes
and finds the modules present in your PLC rack.
- 29 -
ALLEN BRADLEY VOL1 UEUNEED027A
When selecting the read I/O config if communications link to the PLC is OK it should display the
modules.
Once you have completed I/O config you can begin to write your program.
- 30 -
ALLEN BRADLEY VOL1 UEUNEED027A
RSLogix Program Creation
Enter the following single run program which consists of a single Input instruction (XIC Examine If Closed) and a single Output instruction (OTE - Output Energize). There's more than
one way to accomplish this task, but for now I will outline what I consider to be the most
commonly used approach.
First click on the "New Rung" button in the User Instruction Bar. It's the first button on the very
left end of the Bar. If you hold the mouse pointer over any of these buttons for a second or two,
you should see a short "ToolTip" which describes the function or name of the instruction that the
button represents.
You should now see a new Rung added to your program as shown above, and the Rung number at
the left side of the new rung should be highlighted. Note that the new Rung was inserted above the
existing (END) End Of Program Rung. Alternatively you could have dragged (left mouse button
held down) the Rung button into the program window and dropped it onto one of the locating
boxes that would have appeared.
Now click on the XIC instruction with your left mouse button (Left Click) and it will be added
to the right of your highlighted selection. Note that the new XIC instruction is now selected
(highlighted). Once again, you could have alternatively dragged and dropped the instruction into
the program window.
If you accidentally add an instruction which you wish to remove, just Left Click on the instruction
to select it, and then press the "Del" key on your keyboard. Alternatively, you may right click on
the instruction and then select "Cut" from the drop-down menu that appears.
- 31 -
ALLEN BRADLEY VOL1 UEUNEED027A
Left Click on the OTE output instruction and it will be. added to the right of your current
selection.
Double Click (2 quick left mouse button clicks) on the XIC instruction and a textbox should
appear which will allow you to enter the address (I:1/0) of the switch we wish to monitor. Use the
Backspace key to get rid of the "?" currently in the textbox. Once you type in the address, click
anywhere else on the instruction (other than the textbox) and the box should close.
Right Click on the XIC instruction and select "Edit Symbol" from the drop-down menu that
appears. Another textbox will appear where you can type in a name (Switch-0) to associate with
this address. As before, a click anywhere else will close the box.
Enter the address and symbol for the OTE instruction and your first RSLogix program will now be
complete. Before continuing however,
Double check that the addresses of your instructions are correct.
- 32 -
ALLEN BRADLEY VOL1 UEUNEED027A
Testing your Program
It's now time to "Download" your program to the PLC.
Click on the "DownLoad" button to initiate the downloading of your program to the PLC. Once
complete, click inside the "RUN" option selection circle to start the PLC scanning.
Toggle the Switch On and Off a number of times and note the result. Try placing the PLC back
into the "PGM" mode and then toggle the simulator's Switch a few times and note the result. Place
the PLC back into the "Run" mode and the Scan should resume.
We are usually told to think of the XIC instruction as an electrical contact that allows electrical
flow to pass when an external switch is closed. We are then told that the OTE will energize if the
flow is allowed to get through to it. In actual fact the XIC is a conditional instruction which tests
any bit that we address for on or a 1.
Editing your Program
Now add a second rung to your program as shown below. This time instead of entering the
addresses as you did before, try dragging the appropriate address which is displayed in the I/O
simulation and dropping it onto the instruction.
Note that the XIO instruction which Tests for Zero or False has it's address highlighted in yellow.
This indicates that the instruction is True, which in the case of an XIO, means that the bit
addressed is currently a Zero or off.
This is probably a good time to practice your drag and drop skills. Try moving instructions from
rung to rung by holding the left mouse button down while over an instruction, and then while
keeping the mouse button down, move the mouse (and instruction) to a new location. Try doing
the same with complete rungs by dragging the box at the left end of the rung and dropping it in a
new location.Once you feel comfortable with drag and drop, ensure that your program once again
looks like the one pictured above, Now download your program to the PLC and place the PLC into
the Run Mode. Toggle both Switch-0 and Switch-1 on and off a number of times and observe the
effects this has on the outputs. Ensure that you are satisfied with the operation of your program
before proceeding further.
- 33 -
ALLEN BRADLEY VOL1 UEUNEED027A
Latching Instructions
Regular output coils are of course an essential part of our programs but we must remember that
they are only TRUE when all instructions before them on the rung are also TRUE. What happens
if they are not? Then of course, the output will become false (turn off).
Think back to the lunch bell example we did a few chapters ago. What would've happened if we
couldn't find a "push on/push off" switch? Then we would've had to keep pressing the button for
as long as we wanted the bell to sound. (A momentary switch) The latching instructions let us use
momentary switches and program the PLC so that when we push one the output turns on and
when we push another the output turns off.
Here is a real world example.
Picture the remote control for your TV. It has a button for ON and another for OFF. When you
push the ON button the TV turns on. When you push the OFF button the TV turns off. You don't
have to keep pushing the ON button to keep the TV on. This would be the function of a latching
instruction.
The latch instruction is often called a SET or OTL (output latch).
The unlatch instruction is often called a RES (reset), OTU (output unlatch) or RST (reset). The
diagram below shows how to use them in a program.
Here we are using 2 momentary push button switches. One is physically connected to input 0000
while the other is physically connected to input 0001. When the operator pushes switch 0000 the
instruction "set 0500" will become true and output 0500 physically turns on.
Even after the operator stops pushing the switch, the output (0500) will remain on. It is latched on.
The only way to turn off output 0500 is turn on input 0001. This will cause the instruction "res
0500" to become true thereby unlatching or resetting output 0500.
Here's something to think about. What would happen if input 0000 and 0001 both turn on at the
exact same time.
Will output 0500 be latched or unlatched?
To answer this question we have to think about the scanning sequence. The ladder is always
scanned from top to bottom, left to right. The first thing in the scan is to physically look at the
inputs. 0000 and 0001 are both physically on.
Next the PLC executes the program. Starting from the top left, input 0000 is true therefore it
should set 0500. Next it goes to the next rung and since input 0001 is true it should reset 0500.
The last thing it said was to reset 0500. Therefore on the last part of the scan when it updates the
outputs it will keep 0500 off.
Latching Exercise
- 34 -
ALLEN BRADLEY VOL1 UEUNEED027A
Stop/Start utilizing OTL and OTU
For this exercise we need two Normally Open momentary switches. Add the following two rungs
to your program. Once you have the rungs entered correctly, download and run your modified
program.
Activate the Start and Stop switches and ensure that the OTL and OTU output instructions are
responding as outlined in your text. Once you have the lamp ON, could you turn it off if power
was lost in the Stop Switch circuit?
Now modify your program so that it operates correctly when you substitute the N.O. Stop switch
(I:1/03) with a Normally Closed Switch. If we now lost power on the N.C. Stop switch circuit,
what would happen to the state of Lamp (O:2/02)?
- 35 -
ALLEN BRADLEY VOL1 UEUNEED027A
Timers
Let's now see how a timer works. What is a timer? Its exactly what the word says... it is an
instruction that waits a set amount of time before doing something.
When we look at the different kinds of timers available the fun begins. As always, different types
of timers are available with different manufacturers. Here are most of them:
On-Delay timer-This type of timer simply "delays turning on". In other words, after our sensor
(input) turns on we wait x-seconds before activating a solenoid valve (output). This is the most
common timer. It is often called TON (timer on-delay), TIM (timer) or TMR (timer).
Off-Delay timer- This type of timer is the opposite of the on-delay timer listed above. This timer
simply "delays turning off". After our sensor (input) sees a target we turn on a solenoid (output).
When the sensor no longer sees the target we hold the solenoid on for x-seconds before turning it
off.
It is called a TOF (timer off-delay) and is less common than the on-delay type listed above.
Retentive or Accumulating timer- This type of timer needs 2 inputs. One input starts the timing
event (i.e. the clock starts ticking) and the other resets it. The on/off delay timers above would be
reset if the input sensor wasn't on/off for the complete timer duration. This timer however holds or
retains the current elapsed time when the sensor turns off in mid-stream.
For example, we want to know how long a sensor is on for during a 1 hour period.
If we use one of the above timers they will keep resetting when the sensor turns off/on. This timer
however, will give us a total or accumulated time. It is often called an RTO (retentive timer) or
TMRA (accumulating timer).
Let's now see how to use them. We typically need to know 2 things:
What will enable the timer. Typically this is one of the inputs.(a sensor connected to input 0000 for
example)
How long we want to delay before we react. Let's wait 5 seconds before we turn on a solenoid, for
example.
When the instructions before the timer symbol are true the timer starts "timing".
When the time elapses the timer will automatically close its contacts.
When the program is running on the PLC, the program typically displays the elapsed or
"accumulated" time for us so we can see the current value.
Typically timers can time from 0 to 9999 or 0 to 65535 times.
Why the weird numbers? Again its because most PLCs have 16-bit timers. 0-9999 is 16-bit BCD
(binary coded decimal) 0 to 65535 is 16-bit binary.
Each tick of the clock is equal to x-seconds.
Typically each manufacturer offers several different ticks.
Most manufacturers offer 10 and 100 ms increments (ticks of the clock).
A "ms" is a milli-second or 1/1000th of a second.
Several manufacturers also offer 1ms as well as 1 second increments.
These different increment timers work the same as above but sometimes they have different
names to show their timebase.
Some are TMH (high speed timer), TMS (super highspeed timer) or TMRAF (accumulating fast
timer)
Shown below is a typical timer instruction symbol we will encounter (depending on which
manufacturer we choose) and how to use it. Remember that while they may look different they
are all used basically the same way. If we can setup one we can setup any of them.
- 36 -
ALLEN BRADLEY VOL1 UEUNEED027A
This timer is the on-delay type and is named Txxx.
When the enable input is on the timer starts to tick.
When it ticks yyyyy (the preset value) times, it will turn on its contacts that we will use later in the
program.
Remember that the duration of a tick (increment) varies with the vendor and the timebase used.
(i.e. a tick might be 1ms or 1 second or...)
Below is the symbol shown on a ladder diagram:
In this diagram we wait for input 0001 to turn on. When it does, timer T000 (a 100ms increment
timer) starts ticking.
It will tick 100 times. Each tick (increment) is 100ms so the timer will be a 10000ms (i.e. 10
second) timer.
100ticks X 100ms = 10,000ms. When 10 seconds have elapsed, the T000 contacts close and 500
turns on.
When input 0001 turns off(false) the timer T000 will reset back to 0 causing its contacts to turn
off(become false) thereby making output 500 turn back off.
An accumulating/retentive timer would look similar to this:
This timer is named Txxx. When the enable input is on the timer starts to tick.
When it ticks yyyyy (the preset value) times, it will turn on its contacts that we will use later in the
program. Remember that the duration of a tick (increment) varies with the vendor and the
timebase used. (i.e. a tick might be 1ms or 1 second or...) If however, the enable input turns off
before the timer has completed, the current value will be retained.
When the input turns back on, the timer will continue from where it left off. The only way to force
the timer back to its preset value to start again is to turn on the reset input.
- 37 -
ALLEN BRADLEY VOL1 UEUNEED027A
The symbol is shown in the ladder diagram below.
In this diagram we wait for input 0001 to turn on. When it does timer T000 (a 10ms increment
timer) starts ticking. It will tick 100 times.
Each tick (increment) is 10ms so the timer will be a 1000ms (1 second) timer. (100ticks X 10ms =
1,000ms).
When 1 second has elapsed, the T000 contacts close and 5000 turns on.
If input 0001 turns off while the timer is timing the accumulated value will be retained. When 0001
turns back on the timer will continue where it left off.
When input 0002 turns on (true) the timer T000 will reset back to 0 causing its contacts to turn off
(become false).
Always remember that although the symbols may look different they all operate the same way.
Typically the major differences are in the duration of the ticks increments.
- 38 -
ALLEN BRADLEY VOL1 UEUNEED027A
Allen Bradley Timers
(TON)
Description
Use the TON instruction to turn an output on or off after the timer has been on for a preset time
interval.
This output instruction begins timing (at either one second or one hundredth of a second
intervals) when its rung goes "true." It waits the specified amount of time (as set in the PRESET),
keeps track of the accumulated intervals which have occurred (ACCUM), and sets the DN (done)
bit when the ACCUM (accumulated) time equals the PRESET time.
As long as rung conditions remain true, the timer adjusts its accumulated value (ACC) each
evaluation until it reaches the preset value (PRE).
The accumulated value is reset when rung conditions go false, regardless of whether the timer
has timed out.
Instruction bits:
13 = DN (done)
14 = TT (timer timing bit)
15 = EN (enable bit)
and TT bits remain set , and the accumulated value (ACCUM) remains the same. This is also true
if the processor changes from the run to the program mode.
If either the Accumulator If power is lost while a TON is timing but has not reached its preset
value, the EN, or the Preset is negative when the TON instruction is executed on a true rung, a
Major Fault is generated.
Note
If the rung goes "false" (loses logical continuity) during the timing process, the accumulated value
is reset, and the DN, EN, and TT bits all reset whether or not the timer has reached the PRESET
value.
- 39 -
ALLEN BRADLEY VOL1 UEUNEED027A
Example (TON)
Enter the following program being careful to enter the addresses exactly as shown.
Confirm that you have entered the number 1000 as the timer's preset value. This value
represents a 10 second timing interval (1000x0.01) as the timebase is fixed at 0.01 seconds:
Once you have your program entered, and have ensured that it is correct, download it to the PLC.
Ensure that Switch I:1/0 is Open, and then place the PLC into the Run mode.
Note the initial value of timer T4:1's accumulator and preset in the spaces below. Also indicate the
state of each of the timer's control bits in the spaces provided:
Initial
T4:1.ACC = _____
T4:1.PRE = _____
T4:1/EN = ____
T4:1/TT = ____
T4:1/DN = ____
State
(Switch
I:1/0=Open):
Close switch I:1/0, and carefully observe the incrementing of the timer's accumulator, and the
state of each of it's control bits.
- 40 -
ALLEN BRADLEY VOL1 UEUNEED027A
Once the Timer stops incrementing, note the final value of timer T4:1's accumulator, preset, and
the state of it's control bits below:
Final
T4:1.ACC = _____
T4:1.PRE = _____
T4:1/EN = ____
T4:1/TT = ____
T4:1/DN = ____
State
(Switch
I:1/0=Closed):
Toggle the state of switch I:1/0 a number of times, and observe the operation of the Timer in the
Ladder Rung program display.
Confirm that when the rung is taken false, the accumulator and all 3 control bits are reset to zero.
This type of timer is a non-retentive instruction.
Use the TON instruction to turn an output on or off after the timer has been on for a preset time
interval. This output instruction begins timing when its rung goes "true". It waits the specified
amount of time (as set in the PREset), keeps track of the accumulated intervals which have
occurred (ACCumulator), and sets the DN (done) bit when the ACC (accumulated) time equals
the
PRESET
time.
As long as rung conditions remain true, the timer adjusts its accumulated value (ACC) each
evaluation until it reaches the preset value (PRE). The accumulated value is reset when rung
conditions go false, regardless of whether the timer has timed out.
- 41 -
ALLEN BRADLEY VOL1 UEUNEED027A
(TOF)
Description
Use the TOF instruction to turn an output on or off after its rung has been off for a preset time
interval. The TOF instruction begins to count timebase intervals when the rung makes a true-tofalse transition. As long as rung conditions remain false, the timer increments its accumulated
value (ACC) based on the timebase for each scan until it reaches the preset value (PRE). The
Accumulated value is reset when rung conditions go true regardless of whether the timer has
timed out.
Status bits:
Done bit (DN)Set when rung conditions are true; remain so until rung conditions go false and the
accumulated value is greater than or equal to the preset value
Timer timing bit (TT)Set when rung conditions are false and the accumulated value is less than
the preset value; remain so until rung conditions go true or when the done bit is reset.
Enable bit (EN)Set when rung conditions are true; remain so until rung conditions go false.
When processor operation changes from run program mode or if user power is lost while a TOF is
timing but has not reached its preset value, the EN, TT, and DN bits remain set, and the
accumulated value (ACCUM) remains the same. On returning to the run mode, the following
can happen:
If the rung is true:
TT bit is reset DN bit remains set EN bit is set ACC value is reset
If the rung is false:
TT bit is reset DN bit is reset EN bit is reset ACC value is set equal to the
preset value.
- 42 -
ALLEN BRADLEY VOL1 UEUNEED027A
(RTO)
Description
An RTO functions the same as a TON with the exception that once it has begun timing, it holds its
count of time even if the rung goes false, a fault occurs, the mode changes from run to program,
or power is lost. When rung continuity returns (rung goes true again), the RTO begins timing from
the accumulated time which was held when rung continuity was lost. By retaining its accumulated
value, retentive timers measure the cumulative period during which rung conditions are true.
Status bits
DN (done)
TT (timer timing bit)
EN (enable bit)
If the Preset or Accumulated value are negative when the instruction is executed, a major fault
results.
Note
The accumulated value can be reset by the RES instruction. When the RES instruction having the
same address as the RTO is enabled, the accumulated value and the control bits are reset.
- 43 -
ALLEN BRADLEY VOL1 UEUNEED027A
Counters
A counter is a simple device intended to do one simple thing - count. Using them, however, can
sometimes be a challenge because every manufacturer (for whatever reason) seems to use them
a different way. The following information will let you simply and easily program anybody's
counters.
Types of counters
What kinds of counters are there? Well, there are up-counters (they only count up 1,2,3...). These
are called CTU,(count up) CNT,C, or CTR.
There are down counters (they only count down 9,8,7,...). These are typically called CTD (count
down) when they are a separate instruction.
There are also up-down counters (they count up and/or down 1,2,3,4,3,2,3,4,5,...).
These are typically called UDC (up-down counter) when they are separate instructions.
Many manufacturers have only one or two types of counters but they can be used to count up,
down or both.
To further confuse the issue, most manufacturers also include a limited number of high-speed
counters.
These are commonly called HSC (high-speed counter), or CTH (Counter High-speed?).
Typically a high-speed counter is a "hardware" device. The normal counters listed above are
typically "software" counters, in other words they don't physically exist in the plc but rather they
are simulated in software.
Hardware counters do exist in the plc and they are not dependent on scan time.
A good rule of thumb is simply to always use the normal (software) counters unless the pulses
you are counting will arrive faster than 2X the scan time. (i.e. if the scan time is 2ms and pulses
will be arriving for counting every 4ms or longer then use a software counter.
If they arrive faster than every 4ms (3ms for example) then use the hardware (high-speed)
counters. (2xscan time = 2x2ms= 4ms)
To use them we must know 3 things:
Where the pulses that we want to count are coming from. Typically this is from one of the
inputs.(a sensor connected to input 0000 for example)
How many pulses we want to count before we react. Let's count 5 bottles before we box them, for
example.
When/how we will reset the counter so it can count again. After we count 5 bottles lets reset the
counter, for example.
When the program is running on the PLC the program typically displays the current or
"accumulated" value for us so we can see the current count value.
Typically counters can count from "0 to 9999", "-32,768 to +32,767" or "0 to 65535". Why the
weird numbers?
This is because 0-9999 is 16-bit BCD (binary coded decimal) and -32,768 to 32767 and 0 to
65535 require 16-bit binary and most PLCs use 16bit numbers
Here are some of the instruction symbols we will encounter (depending on which manufacturer
we choose) and how to use them.
Remember that while they may look different they are all used basically the same way. If we can
program one we can program any of them.
- 44 -
ALLEN BRADLEY VOL1 UEUNEED027A
In this counter we need 2 inputs. One goes before the reset line. When this input turns on the
current (accumulated) count value will return to zero.
The second input is the address where the pulses we are counting are coming from.
For example, if we are counting how many bottles pass in front of the sensor that is physically
connected to input 0001 then we would put normally open contacts with the address 0001 in front
of the pulse line.
Cxxx is the name of the counter. If we want to call it counter 000 then we would put "C000" here.
yyyyy is the number of pulses we want to count before doing something. If we want to count 5
bottles before turning on a physical output to box them we would put 5 here. If we wanted to
count 100 bottles then we would put 100 here, etc.
When the counter is finished (i.e we counted yyyyy bottles) it will turn on a separate contact that
we also label Cxxx.
Note that the counter accumulated value ONLY changes at the off to on transition of the pulse
input.
Here's the symbol on a ladder showing how we set up a counter (we'll name it counter 000) to
count 100 bottles from input 0001 before turning on output 500.
Sensor 0002 resets the counter.
- 45 -
ALLEN BRADLEY VOL1 UEUNEED027A
Below is one symbol we may encounter for an up-down counter. We'll use the same abbreviation
as we did for the example above.(i.e. UDCxxx and yyyyy)
In this up-down counter we need to assign 3 inputs. The reset input has the same function as
above, however, instead of having only 1 input for the pulse counting we now have 2.
One is for counting up and the other is for counting down.
In this example we will call the counter UDC000 and we will give it a preset value of 1000. (we'll
count 1000 total pulses) For inputs we'll use a sensor which will turn on input 0001 when it sees a
target and another sensor at input 0003 will also turn on when it sees a target. When input 0001
turns on we count up and when input 0003 turns on we count down. When we reach 1000 pulses
we will turn on output 500. Again note that the counter accumulated value ONLY changes at the
off to on transition of the pulse input. The ladder diagram is shown below.
One important thing to note is that in some PLCs counters and timers can't have the same
address.
This is because they typically use the same registers.
- 46 -
ALLEN BRADLEY VOL1 UEUNEED027A
Allen Bradley Counters
The following counter instructions are examples of the types used by the Allen Bradley SLC500
series PLCs
(CTU)
Description
This output instruction counts up for each false-to-true transition of conditions preceding it in the
rung and produces an output when the accumulated value reaches the preset value. Rung
transitions might be triggered by a limit switch or by parts travelling past a detector.
The ability of the counter to detect false-to-true transitions depends on the speed (frequency) of
the incoming signal.
The on and off duration of an incoming signal must not be faster than the scan time.
Each count is retained when the rung conditions again become false, permitting counting to
continue beyond the preset value.
This way you can base an output on the preset but continue counting to keep track of
inventory/parts, etc.
Note Use a RES (reset) instruction with the same address as the counter, or another instruction
in your program to overwrite the value.
The on or off status of counter done, overflow, and underflow bits is retentive. The accumulated
value and control bits are reset when a RES is enabled.
Status Bits:
OV (count up overflow) bit
DN (done) bit
CU (count up enable) bit
- 47 -
ALLEN BRADLEY VOL1 UEUNEED027A
Entering Parameters
Enter a COUNTER address, PRESET value and ACCUM value.
The preset value is the point which must be reached to set the DN (done) bit.
The accumulated value represents the current count status.
The CTU and RES ...... Counter Instructions
Enter the following program being careful to enter the addresses exactly as shown.
Confirm that you have entered the number 10 as the counter's preset value. This value is
optionally used to set the point at which the counter's Done Bit will be Set, indicating that the
count is complete.
Once you have your program entered, and have ensured that it is correct, download it to the PLC.
Ensure that Switch I:1/0 and I:1/1 are Open, and then place the PLC into the Run mode.
- 48 -
ALLEN BRADLEY VOL1 UEUNEED027A
Note the initial value of Counter C5:1's accumulator and preset in the spaces below. Also indicate
the state of each of the Counter's primary control bits in the spaces provided:
Initial
C5:1.ACC = ______
C5:1.PRE = ______
C5:1/CU = ___
C5:1/CD = ___
C5:1/DN = ___
State
(Switch
I:1/0=Open):
Open and Close switch I:1/00 a number of times and carefully observe the incrementing of C5:1's
accumulator and the operation of the enable and done bits.
Close switch I:1/01 and observe the effect that the "RES" instruction has on the counter.
Attempt to increment the counter while switch I:1/01 is closed. You should not be able to
increment the counter while the "RES" instruction is held "True".
Open switch I:1/01 to allow the "RES" instruction to go false, and then increment the counter until
the accumulator matches the preset.
Increment the counter 2 or 3 more times and note the final value of C5:1's accumulator, preset
and status bits in the spaces below.
Final
C5:1.ACC = ______
C5:1.PRE = ______
C5:1/CU = ___
C5:1/CD = ___
C5:1/DN = ___
State
(Switch
I:1/0=Closed):
The CTU output instruction counts up for each false-to-true transition of conditions preceding it in
the rung and produces an output (DN) when the accumulated value reaches the preset value.
The ability of the counter to detect a false-to-true transition depends on the speed (frequency) of
the incoming signal. The on and off duration of an incoming signal must not be faster than the
scan time.
Each count (accumulator) is retained when the rung conditions again become false, permitting
counting to continue beyond the preset value. This way you can base an output on the preset but
continue counting to keep track of inventory/parts, etc.
Use a RES (reset) instruction with the same address as the counter, or another instruction in your
program to overwrite the value of the accumulator and control bits. The on or off status of counter
done, overflow, and underflow bits is retentive. The accumulated value and control bits are reset
when a RES is enabled.
- 49 -
ALLEN BRADLEY VOL1 UEUNEED027A
(CTD)
Description
This output instruction counts down for each false-to-true transition of conditions preceding it in
the rung and produces an output when the accumulated value reaches the preset value.
Rung transitions might be triggered by a limit switch or by parts travelling past a detector.
Each count is retained when the rung conditions again become false
The count is retained until a RES (reset) instruction with the same address as the counter is
enabled, or if another instruction in your program overwrites the value.
The accumulated value is retained after the CTU or CTD instruction goes false, and when power
is removed from and then restored to the processor.
The on or off status of counter done, overflow, and underflow bits is also retentive.
The accumulated value and control bits are reset when a RES is enabled.
Status Bits:
UN (count down underflow) bit
DN (done) bit
CD (count down enable) bit
- 50 -
ALLEN BRADLEY VOL1 UEUNEED027A
(UDC)
Entering Parameters
Enter a COUNTER address, PRESET value and ACCUM value.
The preset value is the point which must be reached to set the DN (done) bit.
The accumulated value represents the current count status.
Using an up/down counter with the Allen Bradley PLC
Single up/down counter instructions are not available in all PLCs.
In the program above, SW1 increments the counter and SW2 decrements.
Lamp1 energises when the count reaches 20.
Note that the CTU and CTD instructions have the same address.
- 51 -
ALLEN BRADLEY VOL1 UEUNEED027A
Exercises and Assessment items
- 52 -
ALLEN BRADLEY VOL1 UEUNEED027A
Exercise 1
STOP START STATION.
When the start button is operated the line contactor is energised, closing the hold in contact. The
line contactor will remain energised until the stop button is pressed.
- 53 -
ALLEN BRADLEY VOL1 UEUNEED027A
Exercise 2
MULTIPLE STOP START STATION.
Operation of either PB3 or PB4 will energise the line contactor and operation of PBI or PB2 will
de-energise the circuit.
- 54 -
ALLEN BRADLEY VOL1 UEUNEED027A
Exercise 3
DIRECT ON LINE MOTOR STARTER.
A D.O.L. motor starter is used to connect AC motors to the supply mains in one switching step.
A typical D.O.L. starter would cater for;
a: Stop button input.
b: Start button input.
c: Thermal overload protection.
d: motor stop/run indicators.
- 55 -
ALLEN BRADLEY VOL1 UEUNEED027A
Exercise 4
CONVEYOR CONTROL
The above circuit operates as follows.
When the conveyor is stopped 'Motor stopped' light is on.
When the reverse start button is pressed the conveyor starts in reverse and the reverse indicator
light comes on.
When the forward start button is pressed the conveyor starts in forward and the forward indicator
light comes on.
The Conveyor must be stopped before changing from reverse to forward and vice versa.
The conveyor shuts down if either 'Thermal overload' or 'master stop' is pressed.
- 56 -
ALLEN BRADLEY VOL1 UEUNEED027A
Exercise 5
CONVEYOR CONTROL OPERATION
PB2 starts the conveyor in fast forward mode.
PB3') starts the conveyor in fast reverse mode.
Interlocking prevents forward and reverse being energised at the same time.
PB5 puts the conveyor into slow mode.
(Only when fast forward or reverse is selected).
- 57 -
ALLEN BRADLEY VOL1 UEUNEED027A
Assessment Item 1 – Door Simulation
Take the time to familiarize yourself with the components used in the Door system, and take
particular note of the current state of the limit switches.
When the door is in the closed position, the lower limit is activated and the upper limit is
deactivated. Both upper and lower limit switches are normally open switches and only close when
the striker on the bottom of the door comes in contact with them.
Don't continue on with the exercise until you are confident that you understand the operation of the
system.
In this exercise we want you to apply your knowledge of Relay Logic Instructions to design a
program which will control the Door. The Door System includes a Reversible Motor, a pair of
Limit Switches and a Control Panel, all connected to your PLC. The program you create will
monitor and control this equipment while adhering to the following criteria:
•
The Open and Close pushbuttons will be used to control the movement of the door.
Movement will not be maintained when either switch is released.
•
Pressing the Open Switch will cause the door to move upwards (open) if not already fully
open. The opening operation will continue as long as the switch is held down. If the switch
is released, or if limit switch LS1 closes, the door movement will halt immediately.
- 58 -
ALLEN BRADLEY VOL1 UEUNEED027A
•
Pressing the Close Switch will cause the door to move down (close) if not already fully
closed. The closing operation will continue as long as the switch is held down. If the switch
is released, or if limit switch LS2 closes, the door movement will halt immediately.
•
If the Door is already fully opened, Pressing the Open Switch will Not energize the motor.
•
If the Door is already fully closed, Pressing the Close Switch will Not energize the motor.
•
Under no circumstance will both motor windings be energized at the same time.
•
The Open Lamp will be illuminated if the door is in the Fully Open position.
•
The Shut Lamp will be illuminated if the door is in the Fully Closed position.
•
The Ajar lamp will be illuminated when the door is ajar
Design, debug, and test your Program. Avoid the use of Set or Reset latching instructions, and
make a concerted effort to minimize the number of rungs employed.
Ensure that you have made effective use of both instruction and rung comments to clearly
document your program. All I/O components referenced within your program should be clearly
labelled, and rung comments should be employed to add additional clarity as required.
- 59 -
ALLEN BRADLEY VOL1 UEUNEED027A
Assessment Item 2 – Level application
Level Application (Using Latching instructions.)
Write a PLC program to control the following process using latch (S) and unlatch (R) instructions
We are controlling the level of lubricating oil being dispensed from a tank. This is possible by
using two sensors.
We put one near the bottom and one near the top, as shown in the picture below.
The fill motor is to pump lubricating oil into the tank until the high level sensor turns on. At that
point the motor is turned off until the level falls below the low level sensor. The fill motor should
turn on again and repeat the process.
Both inputs are NC (normally closed) fibre-optic level sensors.
When they are NOT immersed in liquid they will be ON.
When they are immersed in liquid they will be OFF.
- 60 -
ALLEN BRADLEY VOL1 UEUNEED027A
Assessment Item 3 - Timer
Carton filling timer.
This circuit places a ten second shot of liquid into a carton each time a carton position limit switch
is operated.
The circuit must provide for a carton position limit input and a dosing solenoid output.
- 61 -
ALLEN BRADLEY VOL1 UEUNEED027A
Assessment Item 4 - Counter
Pallet Loading Counter.
This system batches boxes onto a pallet.
A solenoid is energised when the eighth box is loaded, and de-energised when a full pallet moves
out.
The circuit provides for the following inputs and outputs;
a: Box detector limit switch, LSI, actuated by boxes arriving on the pallet.
b: Pallet change limit switch, LS2, actuated by an outgoing pallet.
c: Pallet change solenoid.
- 62 -
ALLEN BRADLEY VOL1 UEUNEED027A
Personal Safety and Safe Work Practices
One of the most important features of any type of technology is Personal Safety and Safe Work
Practices.
Australian Standards
The Australian Standards are the guiding publication for safety. Listed below are some of the key
clauses in the current versions of the standards.
AS/NZ 3000 clause 2.8 devices for isolation and switching
Clause 2.8.3.2 states that a semiconductor device shall not be used for isolation purposes
AS/NZ 3000 clause 2.11.8 refers to cranes and hoists
This will also refer you to AS1418
AS 1543 Electrical equipment of industrial machines - all sections (but in general)
Section 1 - Scope & general
Section 3 - Power & control circuits
Section 4 - Control Equipment
Section 6 – Wiring
Appendix C - Protective interlocking
Employers' Responsibility
Employers shall ensure as far as is reasonably practicable that machinery, plant and equipment is
safe and without risks when used property. This requires having the application of hazard
analysis procedures at the design stage together with procedures which specifically relate to the
following:
• Design and procurement.
• Installation.
• Commissioning and acceptance.
• Training and supervision.
• Operation.
• Maintenance.
- 63 -
ALLEN BRADLEY VOL1 UEUNEED027A
Design and Procurement
Where practicable, manufacturers shall ensure that their product complies with the requirements
of the appropriate standards, e.g. hearing conservation control.
When preparing documents for the design, repair, procurement or hire of machinery, plant and
equipment, either from a manufacturer, importer, supplier, or a service within the same enterprise.
The employer shall also ensure that the specifications are in compliance with the relevant
requirements of this standard, any other appropriate standard, the requirements of statutory
authorities, together with other recognised good practices (which shall be in writing).
Note: In some States, manufacturers, importers and suppliers of machinery, plant and equipment,
have legal obligations to supply plant and substances which are without risks to health and safety
when used properly).
Installation
The installation, spacing, clearance, services and foothold around machinery, plant and
equipment shall be such as to ensure:
stability, safe operation, access and supervision.
satisfactory facilities for maintenance work, operating adjustments and cleaning.
adequate space for handling materials and parts to or from machines and for work in progress.
Commissioning and Acceptance
Before any machinery, plant or equipment is brought into operation, measures shall be taken to
ensure that:
• machinery, plant or equipment is not used or operated until it has been ascertained that
such use or operation does not expose any person to risk of injury;
• the manufacturer's operating and maintenance instructions/ manuals are readily available
to employees and job instructions have been prepared.
Note: Attention is drawn to the requirements of some regulatory authorities which, for example,
prescribe minimum age limits for operators of some machines.
- 64 -
ALLEN BRADLEY VOL1 UEUNEED027A
Training and Supervision
Job safety training and instructions form the basis for operator safety training. Supervisory and
operating staff should be completely familiar with correct training and operating techniques. It is
important to emphasise that methods of operation, training, instruction, testing, auditing and
monitoring must be kept up-to-date.
Isolating controls
All power driven machinery or equipment shall have a control for isolating it from all sources of
power, whether electrical, hydraulic, pneumatic, mechanical or other.
The isolator shall be either on the machine, or in close proximity to it, and shall be clearly visible,
readily accessible and clearly identified.
There shall be provision for the manual locking of the isolator in the isolated position, except
where the machinery or equipment is supplied through a removable plug or coupling.
- 65 -
ALLEN BRADLEY VOL1 UEUNEED027A
PLC Installation
Installation of a PLC requires the installer to understand many factors, including environmental,
electrical and safety considerations. This chapter will explore these factors in more detail.
Specifications and Documentation
PLCs, I/O and special purpose modules are complex and expensive pieces of equipment.
It is important to consult the manufacturer’s installation specifications prior to installing hardware;
this is often supplied with the equipment.
It is not uncommon to receive a CD or be referred to the product’s support web site.
Some installation documentation can come as part of the online help within the programming
software package.
Technical documentation often has a language of its own and can be very ‘dry’ in its text.
There is also a degree of assumed knowledge in some text, and that may require careful reading
and further research.
Common Installation Considerations
Safety
There are many rules governing the installation of automated equipment and extreme care must
be taken to meet these requirements.
Climatic Environment
•
Heat, moisture and airborne materials can affect a PLC system.
•
A suitable enclosure should be chosen.
•
The location of PLC should be away from heat sources, preferably towards the bottom of
the electrical enclosure.
Electrical Interference
Some electrical equipment, such as welders and Variable Speed Drives (VSDs), emit high levels
of electrical interference.
A PLC can be affected by this interference and precautions such as line filtering may need to be
taken.
Generally PLCs should be installed away from sources of interference such as above as well the
cables running to such devices.
The PLC input signal wiring must be kept away from these interference sources and any power
cables that may be in the vicinity.
- 66 -
ALLEN BRADLEY VOL1 UEUNEED027A
Earthing
For the safety reasons, earthing procedures are important on PLC installations.
It is also important that the PLC equipment is correctly earthed so as to limit and/or exclude any
unwanted electrical interference.
Manufacturers will clearly state the minimum earthing requirements and these should be adhered
to.
Basic Commissioning Procedures
Commissioning a PLC controlled system is an important procedure.
Incorrect installation procedures or programming can injure personnel or damage equipment.
Good practice requires the installers to follow a set of commissioning procedures, some of which
could be:
• Check each cable connection & continuity between PLC I/O terminals & field devices
• Test & verify the operation of the emergency stop facility
• Manually operate field devices and check they are connected to the correct I/O, and that
they are in the correct state, i.e.: NO, NC etc.
• Simulate signals for each analogue loop
• Force each output ‘on’ or ‘off’ in turn to ensure correct operation of the field devices
When all devices & wiring have been checked against the documentation and software, the
system control simulation can commence
- 67 -
ALLEN BRADLEY VOL1 UEUNEED027A
Program Storage Methods
In most applications, the USER PROGRAM which is developed for a P.L.C. is stored in, RAM
(Random Access Memory) within the P.L.C. where the C.P.U. can gain fast access to the DATA
stored in the memory and act upon the user instructions to enable the P.L.C. to operate as
programmed.
The DATA which is held in the R.A.M. can easily be READ from, WRITTEN to or ALTERED which
makes it a very flexible and versatile method of storing the user program as this program also
may need to be altered at some point. R.A.M. is also often referred to as READ/WRITE memory
because of its operation.
The major drawback with R.A.M. is that because of it's design and physical construction it
requires power to be applied at all times so as to retain it's data, and if power is removed or
interrupted for only a very short period of time then all data will be lost. For this reason R.A.M is
also known as VOLATILE MEMORY meaning that it's contents are volatile if the correct
conditions do not exist.
Because the user program is vital to the correct operation of the field controlled equipment there
are various methods available to copy the exact contents of the R.A.M. onto another form of
memory medium that does not require power to be continuously applied to it, and these types of
memory medium are known as NON-VOLATILE MEMORY.
Although different methods are used the principle of storing the data onto NON-VOLATILE
memory is basically the same. The information that the P.L.C. accesses and uses from the
R.A.M. memory is stored in groups of BITS (Binary Digits) which can only be in one of two states,
being either ON or OFF (1 or 0) and the R.A.M. memory area consists of thousands of these
groups made up of wafer thin logic gates that are either in the ON state or the OFF state.
The principal of storing the data on a NON-VOLATILE medium simply means that a direct copy of
the states of the BITS within the groups is taken and placed in the NON-VOLATILE medium. If the
need arises it is a simple matter to re-copy this same data back to the R.A.M. memory area within
a very short space of time.
- 68 -
ALLEN BRADLEY VOL1 UEUNEED027A
Non-Volatile Program Storage
There are various types of NON-VOLATILE memory storage mediums and some of these are
outlined below:
The Floppy Disk
This is a NON-VOLATILE memory storage medium that makes use of a FLEXIBLE diskette (i.e.
FLOPPY DISK). The disk has a thin coating of material that can be electrically magnetised by
equipment within a FLOPPY DISK DRIVE, which must be used in conjunction with the disk so as
to transfer the data. The diskette is housed in a protective jacket and the whole disk is inserted
into the disk drive to enable data transfer.
The DATA is transferred to the diskette one bit at a time onto sections of the disk called TRACKS
by magnetising the surface to represent groups of bit patterns in either the ON or OFF state.
Within the disk drive there is a magnetising head which is known as the READ / WRITE HEAD
and is used to either WRITE data onto the disk or READ data from the disk whilst it is spinning at
extremely high speed.
The head moves in and out over the spinning disk to access the different sections of the disk area
and because this can occur at very high speeds then the resultant access time to READ or
WRITE to the disk is extremely low.
- 69 -
ALLEN BRADLEY VOL1 UEUNEED027A
For this type of memory storage however, it is required that the P.L.C.'s programming unit has a
floppy disk drive or the P.L.C. must be connected to a COMPUTER which is equipped with a
floppy disk drive and the appropriate software for the computer to communicate with the P.L.C.
Once the data has been transferred to the floppy diskette the disk can be removed from the disk
drive and providing it is stored in a safe place and treated correctly the data will remain on the
disk until required.
The Hard Disk
The HARD DISK operates in essentially the same manner as the floppy disk, with the major
difference being that the hard disk as it's name implies, is made from a rigid material and is
permanently housed in a separate compartment within either the P.L.C.'s programming unit or
within a computer. Because of this the hard disk is often referred to as a FIXED DISK because
the disk, the corresponding disk drive and the data are permanent fixtures of the programming
unit.
The hard disk is kept spinning whereas the floppy disk is only rotated when required, the speed of
rotation is greater than that of the floppy, therefore the access time of the hard disk is quicker
than that of the floppy disk. The storage capacity of the hard disk is also much greater than the
floppy and it is usual to find the hard disk has in excess of 1000 times the capacity of a floppy
disk.
A typical track and a typical sector is shown in the above diagram.
- 70 -
ALLEN BRADLEY VOL1 UEUNEED027A
A sector contains a fixed number of bytes -- for example, 256 or 512. Either at the drive or the
operating system level, sectors are often grouped together into clusters.
Again as with the use of floppy disks the hard disk drive which contains the READ / WRITE
HEADS and the motors required for rotating the disk must be included within the P.L.C.'s
programming unit or within a computer configured to communicate with the P.L.C.
ROM
Similar to RAM, ROM chips contain a grid of columns and rows. But where the columns and rows
intersect, ROM chips are fundamentally different from RAM chips. While RAM uses transistors to
turn on or off access to a capacitor at each intersection, ROM uses a diode to connect the lines if
the value is 1. If the value is 0, then the lines are not connected at all.
A diode normally allows current to flow in only one direction and has a certain threshold, known
as the forward breakover, that determines how much current is required before the diode will pass
it on. In silicon-based items such as processors and memory chips, the forward breakover voltage
is approximately 0.6 volts. By taking advantage of the unique properties of a diode, a ROM chip
can send a charge that is above the forward breakover down the appropriate column with the
selected row grounded to connect at a specific cell. If a diode is present at that cell, the charge
will be conducted through to the ground, and, under the binary system, the cell will be read as
being "on" (a value of 1). If the cell's value is 0, there is no diode at that intersection to connect
the column and row. So the charge on the column does not get transferred to the row.
As you can see, the way a ROM chip works necessitates the programming of perfect and
complete data when the chip is created. You cannot reprogram or rewrite a standard ROM chip. If
it is incorrect, or the data needs to be updated, you have to throw it away and start over. Creating
the original template for a ROM chip is often a laborious process full of trial and error. But the
benefits of ROM chips outweigh the drawbacks. Once the template is completed, the actual chips
can cost as little as a few cents each. They use very little power, are extremely reliable and, in the
case of most small electronic devices, contain all the necessary programming to control the
device.
- 71 -
ALLEN BRADLEY VOL1 UEUNEED027A
PROM
Creating ROM chips totally from scratch is time-consuming and very expensive in small
quantities. For this reason, mainly, developers created a type of ROM known as programmable
read-only memory (PROM). Blank PROM chips can be bought inexpensively and coded by
anyone with a special tool called a programmer.
PROM chips have a grid of columns and rows just as ordinary ROMs do. The difference is that
every intersection of a column and row in a PROM chip has a fuse connecting them. A charge
sent through a column will pass through the fuse in a cell to a grounded row indicating a value of
1. Since all the cells have a fuse, the initial (blank) state of a PROM chip is all 1s. To change the
value of a cell to 0, you use a programmer to send a specific amount of current to the cell. The
higher voltage breaks the connection between the column and row by burning out the fuse. This
process is known as burning the PROM.
PROMs can only be programmed once. They are more fragile than ROMs. A jolt of static
electricity can easily cause fuses in the PROM to burn out, changing essential bits from 1 to 0.
But blank PROMs are inexpensive and are great for prototyping the data for a ROM before
committing to the costly ROM fabrication process.
EPROM
Working with ROMs and PROMs can be a wasteful business. Even though they are inexpensive
per chip, the cost can add up over time. Erasable programmable read-only memory (EPROM)
addresses this issue. EPROM chips can be rewritten many times. Erasing an EPROM requires a
special tool that emits a certain frequency of ultraviolet (UV) light. EPROMs are configured using
an EPROM programmer that provides voltage at specified levels depending on the type of
EPROM used.
Once again we have a grid of columns and rows. In an EPROM, the cell at each intersection has
two transistors. The two transistors are separated from each other by a thin oxide layer. One of
the transistors is known as the floating gate and the other as the control gate. The floating gate's
only link to the row (wordline) is through the control gate. As long as this link is in place, the cell
has a value of 1. To change the value to 0 requires a curious process called Fowler-Nordheim
tunnelling.
Tunnelling is used to alter the placement of electrons in the floating gate. An electrical charge,
usually 10 to 13 volts, is applied to the floating gate. The charge comes from the column (bitline),
enters the floating gate and drains to a ground.
This charge causes the floating-gate transistor to act like an electron gun. The excited electrons
are pushed through and trapped on the other side of the thin oxide layer, giving it a negative
charge. These negatively charged electrons act as a barrier between the control gate and the
- 72 -
ALLEN BRADLEY VOL1 UEUNEED027A
floating gate. A device called a cell sensor monitors the level of the charge passing through the
floating gate. If the flow through the gate is greater than 50 percent of the charge, it has a value of
1. When the charge passing through drops below the 50-percent threshold, the value changes to
0. A blank EPROM has all of the gates fully open, giving each cell a value of 1.
To rewrite an EPROM, you must erase it first. To erase it, you must supply a level of energy
strong enough to break through the negative electrons blocking the floating gate. In a standard
EPROM, this is best accomplished with UV light at a frequency of 253.7. Because this particular
frequency will not penetrate most plastics or glasses, each EPROM chip has a quartz window on
top of it. The EPROM must be very close to the eraser's light source, within an inch or two, to
work properly.
An EPROM eraser is not selective, it will erase the entire EPROM. The EPROM must be removed
from the device it is in and placed under the UV light of the EPROM eraser for several minutes.
An EPROM that is left under too long can become over-erased. In such a case, the EPROM's
floating gates are charged to the point that they are unable to hold the electrons at all.
EEPROMs and Flash Memory
Though EPROMs are a big step up from PROMs in terms of reusability, they still require
dedicated equipment and a labour-intensive process to remove and reinstall them each time a
change is necessary. Also, changes cannot be made incrementally to an EPROM; the whole chip
must be erased. Electrically erasable programmable read-only memory (EEPROM) chips remove
the biggest drawbacks of EPROMs.
In EEPROMs:
• The chip does not have to removed to be rewritten.
• The entire chip does not have to be completely erased to change a specific portion of it.
• Changing the contents does not require additional dedicated equipment.
Instead of using UV light, you can return the electrons in the cells of an EEPROM to normal with
the localised application of an electric field to each cell. This erases the targeted cells of the
EEPROM, which can then be rewritten. EEPROMs are changed 1 byte at a time, which makes
them versatile but slow. In fact, EEPROM chips are too slow to use in many products that make
quick changes to the data stored on the chip.
Manufacturers responded to this limitation with Flash memory, a type of EEPROM that uses incircuit wiring to erase by applying an electrical field to the entire chip or to predetermined sections
of the chip called blocks. Flash memory works much faster than traditional EEPROMs because it
writes data in chunks, usually 512 bytes in size, instead of 1 byte at a time.
Cassette Tape Storage
This is a method of data storage that incorporates the use of cassette tapes to hold the data
transferred from the P.L.C.'s R.A.M. memory, this method of storage falls into two distinct types
which are mentioned below:
Audio Cassette Storage
With this method the data held in the PLC.'s R.A.M. memory area can be transferred onto
standard audio type cassette tapes using a standard audio cassette recorder and associated
cables. This method is only available on PLC.'s that have this facility and those that do have
standard audio cassette INPUT/OUTPUT jacks fitted to their programming units which are usually
labelled MIC for transfer of data to the cassette recorder and EAR for transferring from the
cassette recorder back into the PLC.'s R.A.M. memory area.
This method is quite tedious and requires that the plugs and cables are placed in the correct jacks
at both the P.L.C. and the recorder ends, and also that the volume control of the recorder is set to
- 73 -
ALLEN BRADLEY VOL1 UEUNEED027A
a specific level so as to achieve a good quality transfer of data, therefore this is not one of the
most widely used methods of data storage, but can be found in smaller models of P.L.C.
especially the older types.
Digital Cassette Data Storage
This method incorporates the use of both Digital grade quality cassette tape and also a Digital
tape recording system, and although physically this method may look similar to the Audio tape
method it is far superior in both recording transfer quality and time. Some PLC.'s have a digital
tape recording system built into their programming units or separate digital recorders can be
obtained. This method is very reliable as generally no controls must be adjusted by the user and
the tapes are designed specially to record digital data.
Both tape methods are forms of NON-VOLATILE program storage but with the increases in
technology it would be more common to see either DISK or E.P.R.O.M. type storage mediums
used in P.L.C. systems these days in preference to cassette tape methods.
Printing Facilities
Although the user program contained within the PLC's memory can be searched through and
monitored using the PLC's programming unit it is almost essential that a hard copy print-out can
be obtained from the PLC system.
Being able to view the entire Ladder diagram layout of the user program on paper allows the user
to follow through the operational sequence of the program.
If the Ladder print-out is correct and well documented then fault finding and commissioning can
be accomplished with much less confusion and also quite possibly without the use of the PLC's
programming unit.
At the very least the print-out obtained generally consists of the program Ladder diagram layout
plus all of the associated addressing information contained within the program. Additional
features available with most PLC systems allow the user to print out comments on the programs
operation, specific names given to each of the addresses (usually known as Mnemonics), Cross
reference information on all addresses used within the program and a listing of all contents of
associated data registers (i.e. Timer, Counter and Shift Register values etc.).
- 74 -
ALLEN BRADLEY VOL1 UEUNEED027A
PLC Hardware
Correct choice of PLC hardware is an important step in an automation project. There are many
types on packages with various CPUs, I/O modules and mounting chassis’. There is also an I/O
limit to each of the packages. In this chapter we investigate the various choices that are
commonly available.
PLC Package Configurations
PLCs come in a variety of configurations. Usually the project will determine the type used,
however some users will standardise on a particular configuration. This allows them to keep the
minimum amount of spares, plus the training of personnel in just the one type can be viewed as
an advantage. Below we describe some common package styles.
Micro
Typically used for small projects
Usually fixed I/O sizes from 10 to 30 points
A typical micro PLC package showing the Allen-Bradley MicroLogix 1000
Shoe Box
Used for medium sized projects with a fixed I/O base
Configuration can be expanded with additional modules
Usually up to 64 I/O but can be configured up to 128 I/O
A typical shoe-box PLC package showing the Allen-Bradley MicroLogix 1500
- 75 -
ALLEN BRADLEY VOL1 UEUNEED027A
Rack-Chassis Type
Used for medium to large projects with a CPU, Power Supply and I/O modules on a rack or
chassis
Usually 64 I/O and upwards to many hundreds or even thousands of I/O
A typical rack/chassis PLC package showing the Allen-Bradley SLC 500
CPU Speed
CPU speed is often mentioned by technical sales people when referring to features of a particular
PLC. It should be kept in mind that PLCs are all fast, some just faster than others.
Unless your project has a particular requirement for speed of operation, a rule of thumb is that the
basic CPU will probably do. The choice will then be based on the number of I/O points that are
required.
Omron
Micro Programmable Controller CPM1A
The CPM1A series micro controllers solve both basic and semi-complex applications.
The brick style models include AC inputs/relay outputs, DC inputs/transistor or relay outputs to
meet your design requirements.
The base I/O for the CPUs ranges from 10, 20, 30, and 40 I/O points with maximum expansion to
100 I/O.
Specialised expansion modules include mixed analogue I/O, temperature sensor inputs and serial
communications
- 76 -
ALLEN BRADLEY VOL1 UEUNEED027A
•
•
•
•
•
•
•
•
10, 20, 30 and 40 point I/O CPUs
Expandable up to 100 I/O points
Peripheral communications port built in
AC or DC input models
Analogue expansion modules available
Temperature sensor input expansion modules available
Auxiliary 24 VDC supply (AC type only)
Relay or Transistor outputs
ZEN Simple Logic Controller
Nano sized controller has the features and functions of both a programmable controller and smart
relay to allow simple yet powerful control.
Apply the ZEN to small-scale control applications where simple functionality and low cost are
critical.
Provides an economical alternative to discrete timers, counters and general purpose relays.
Control programs can be created using the 32-bit, Windows-based ZEN support software or using
the operation buttons on the front panel (LCD models only). The ZEN is also flexible, with six CPU
types, multiple expansion options, and a wide selection of accessories.
Wide variety of functions.
Saving and copying of programs.
Space saver-the extreme compact size allows for installation in almost any location.
Flexible expansion- up to 3 expansion I/O modules can be added to any CPU for a maximum of
34 I/O points.
Memory backup.
- 77 -
ALLEN BRADLEY VOL1 UEUNEED027A
Siemens
Siemens PLCs are widely used around the world and are available in many configurations and
sizes.
The S5-90U is the standard 16 I/O unit for use with units requiring digital signals only.
The S5-95U and 100U both have additional analogue capabilities for the more sophisticated
products such as the Enhanced PLC Trainer and the Process Control Unit.
All PLCs are available in a pre-wired PLC Mounting Frame.
The S5 series of PLCs has a number of programming options available:
•
•
•
The PC programming software follows the Siemens STEP5 structured programming which
divides the programming into manageable pieces where only appropriate program blocks
are executed to increase scan times.
Alternatively, the Siemens POG605U Programming Panel (PLCSP1) is a small, on-line
LCD programming panel suitable for entering basic programs into any of the S5 range of
PLCs.
Programs are entered using the STatement List (STL) method and programming is aided
by the display of system prompts and error messages.
- 78 -
ALLEN BRADLEY VOL1 UEUNEED027A
Allen Bradley
The Allen Bradley SLC500 range of PLCs are, perhaps, one of the most popular choices for
solving many industrial control applications at relatively low cost. The units are available in 'fixed'
or 'modular' format, depending on requirements.
Bytronic have taken the 20 I/O fixed controller for their products that require digital only and
added an analogue module to cater for some special applications. The 'modular' type controller
has been used with our Process Control Unit.
SLC500 Accessories
Allen Bradley have many programming options and accessories available for their PLCs. PC
programming of the PLCs is easily achieved using the RS Logix Programming Software
(RSLOGIX), which features Ladder Programming and Monitoring, together with a suite of editing
tools. Programs are downloaded to the PLC using the PLC to PC converter supplied with the
software. Multi-user versions of the software are also available.
The hand held programming terminal (PLCAP1) is a powerful, portable programming
tool for the SLC500 fixed or 5/01 and 5/02 modular processors and can display up to 5 rungs of
ladder logic at any time. The data access module (PLCAP8) is a plant floor device that gives easy
assess to timer, counter and other data table areas.
Order
Code
Base Unit
Inputs
Outputs Analogue Range
Memory
PLCA1
SLC500
Fixed
12
8 relay
–
–
1k UVPROM
PLCA2
SLC500
Fixed
12
8 relay
4 inputs
±10V or
1k UVPROM
SLC502
Fixed
8
PLCA3
±20mA
8 relay
8 inputs
±10V/20mA 4k UVPROM
4 outputs
±10V
- 79 -
ALLEN BRADLEY VOL1 UEUNEED027A
Micrologix 1000 PLC
Allen Bradley's Micrologix 1000 is a low-cost 'micro' plc, offering 16 or 32 digital I/O and available
with a variety of power supply options.
The 24V DC. option is ideal to link to low-cost applications such as the Traffic Control Unit, Rotary
Transfer Unit and the Single Conveyor Unit.
Order
Code
Base Unit
Inputs
Outputs Power Supply
Dimensions
PLCA4
L16BWB
10
6 relay
24V
120 x 80 x 40mm
PLCA5
L32BWB
12
12 relay
24V
200 x 80 x 40mm
Micrologix Accessories
The Micrologix 1000 is fully supported by the standard Allen Bradley RS Logix Software, which
includes program documentation for adding rung comments and instructions, editing facilities cut, copy and paste, program reports, plus many more.
A hand held programmer uses the globally accepted instruction list language to program the PLC
and offers the facility to monitor operation, enter and modify programs plus store and transfer
programs between controllers.
The 'Micro-View' low-cost data access panel is available that gives access to the various data
areas of the PLC.
- 80 -
ALLEN BRADLEY VOL1 UEUNEED027A
Peripheral Devices
Peripheral devices to the PLC and its I/O base(s) can be anything from a host computer and
control console to a motor drive unit or field limit switch. Printers and industrial terminals used for
programming are also peripheral devices.
Peripheral devices can generate or receive AC or DC voltages and currents as well as digital
pulse trains or single pulses of quick length (pulse width).
These external operating devices, with their sometimes harsh and/or fast signal characteristics,
must be able to interface with the PLC's sensitive microprocessor. Various types of I/O modules
(using the proper shielded cabling) are available to do this job.
Input modules
The input module has two functions: reception of an external signal and status display of that
input point. In other words, it receives the peripheral sensing unit's signal and provides signal
conditioning, termination, isolation and/or indication for that signal's state.
The input to an input module is in either a discrete or analogue form. If the input is an ON-OFF
type, such as with a push button or limit switch, the signal is considered to be of a discrete nature.
If, on the other hand, the input varies, such as with temperature, pressure, or level, the signal is
analogue in nature.
Peripheral devices sending signals to input modules that describe external conditions can be
switches (limit, proximity, pressure, or temperature), push buttons, or logic, binary coded decimal
(BCD) or analogue-to-digital (A/D) circuits. These input signal points are scanned, and their status
is communicated through the interface module or circuitry within each individual PLC and I/O
base.
Some typical types of input modules are:
• DC voltage (110, 220, 14, 24, 48, 15-30V) or current (4-20 mA).
• AC voltage (110, 240, 24, 48V) or current (4-20 mA).
• TTL (transistor logic) input (3-15VDC).
• Analogue input (12-bit).
• Word input (16-bit/parallel).
• Thermocouple input.
• Resistance temperature detector.
• High current relay.
• Low current relay.
• Latching input (24VDC/110VAC).
• Isolated input (24VDC/85-132VAC).
• Intelligent input (contains a microprocessor).
• Positioning input.
• PID (proportional, integral, differentiation) input.
• High-speed pulse.
- 81 -
ALLEN BRADLEY VOL1 UEUNEED027A
Digital Inputs
There are two forms of input signal, AC and DC.
Input modules are required to accept high voltage AC or DC, and low voltage DC signals. The
input module has a number of common sections, the functions of which are as follows:
The input lamp shows the on/off status of the input to the assembly.
The electrical isolation provides protection to the PLC internal logic by isolating it from the field
wiring and terminations.
The input filter provides field contact de-bouncing which will assist in reducing multiple unwanted
field contact closures due to the characteristics of mechanical contacts. In addition, the input filter
will reduce the possibility of electrical noise being detected as a field contact operation.
The logic circuit processes the input signal to make it suitable to be fed into the PC CPU.
A block diagram of a typical PLC digital input module
- 82 -
ALLEN BRADLEY VOL1 UEUNEED027A
DC Inputs
Let's now take a look at how the input circuits of a plc work. This will give us a better
understanding of how we should wire them up. Bad things can happen if we wire them up
incorrectly!
Typically, dc input modules are available that will work with 5, 12, 24, and 48 volts. Be sure to
purchase the one that fits your needs based upon the input devices you will use.
We'll first look at how the dc inputs work. DC input modules allow us to connect either PNP
(sourcing) or NPN (sinking) transistor type devices to them. If we are using a regular switch (i.e.
toggle or pushbutton, etc.) we typically don't have to worry about whether we wire it as NPN or
PNP. We should note that most PLCs won't let us mix NPN and PNP devices on the same
module. When we are using a sensor (photo-eye, proximity switch, etc.) we do, however, have to
worry about its output configuration. Always verify whether it's PNP or NPN (Check with the
manufacturer when unsure).
The difference between the two types is whether the load (in our case, the plc is the load) is
switched to ground or positive voltage. An NPN type sensor has the load switched to ground
whereas a PNP device has the load switched to positive voltage.
Below is what the outputs look like for NPN and PNP sensors.
On the NPN sensor we connect one output to the PLCs input and the other output to the power
supply ground. If the sensor is not powered from the same supply as the plc, we should connect
both grounds together.
Many engineers will say that PNP is better (i.e. safer) because the load is switched to ground, but
whatever works for you is best. Just remember to plan for the worst.
On the PNP sensor we connect one output to positive voltage and the other output to the PLCs
input. If the sensor is not powered from the same supply as the plc, we should connect both V+'s
together. PNP sensors are most commonly used in Europe.
- 83 -
ALLEN BRADLEY VOL1 UEUNEED027A
Inside the sensor, the transistor is just acting as a switch. The sensors internal circuit tells the
output transistor to turn on when a target is present. The transistor then closes the circuit between
the 2 connections shown above. (V+ and plc input).
The only things accessible to the user are the terminals labelled COMMON, INPUT 0000, INPUT
0001, INPUTxxxx... The common terminal either gets connected to V+ or ground. Where it's
connected depends upon the type of sensor used. When using an NPN sensor this terminal is
connected to V+. When using a PNP sensor this terminal is connected to 0V (ground).
An ordinary switch (i.e. limit switch, pushbutton, toggle, etc.) would be connected to the inputs in
a similar fashion. One side of the switch would be connected directly to V+. The other end goes to
the plc input terminal. This assumes the common terminal is connected to 0V (ground). If the
common is connected to V+ then simply connect one end of the switch to 0V (ground) and the
other end to the plc input terminal.
A device called a photocoupler is used to isolate the PLCs’ internal circuit from the inputs. This
eliminates the chance of any electrical noise entering the internal circuitry. They work by
converting the electrical input signal to light and then by converting the light back to an electrical
signal to be processed by the internal circuit.
- 84 -
ALLEN BRADLEY VOL1 UEUNEED027A
AC Inputs
Now that we understand how dc inputs work, let's take a close look at AC inputs. An AC voltage is
non-polarised. Put simply, this means that there is no positive or negative to "worry about".
However, AC voltage can be quite dangerous to work with if we are careless. Typically, AC input
modules are available that will work with 24, 48, 110, and 220 volts. Be sure to purchase the one
that fits your needs based upon the input devices (voltage) you will use.
AC input modules are less common these days than dc input modules. The reason being that
today's sensors typically have transistor outputs. A transistor will not work with an AC voltage.
Most commonly, the AC voltage is being switched through a limit switch or other switch type. If
your application is using a sensor it probably is operating on a dc voltage.
We typically connect an AC device to our input module as shown above. Commonly the AC "hot"
wire is connected to the switch while the "neutral" goes to the PLC common. The AC ground (3rd
wire where applicable) should be connected to the frame ground terminal of the PLC.(not shown)
As is true with DC, AC connections are typically colour coded so that the individual wiring the
device knows which wire is which. This coding varies from country to country. In Australia it is
coded as brown (active), blue (neutral) and green with a yellow stripe (3rd wire ground where
applicable).
The only things accessible to the user are the terminals labelled COMMON, INPUT 0000,
INPUTxxxx... The common terminal gets connected to the neutral wire.
A common switch (ie. limit switch, pushbutton, toggle, etc.) would be connected to the input
terminals directly. One side of the switch would be connected directly to INPUT XXX. The other
end goes to the AC active wire. This assumes the common terminal is connected to neutral.
Always check the manufacturers specifications before wiring, to be sure AND SAFE.
The photocouplers are used to isolate the PLCs internal circuit from the inputs. This eliminates
the chance of any electrical noise entering the internal circuitry. They work by converting the
- 85 -
ALLEN BRADLEY VOL1 UEUNEED027A
electrical input signal to light and then by converting the light back to an electrical signal to be
processed by the internal circuit.
One last note, typically an AC input takes longer than dc input for the lc to see. In most cases it
doesn't matter to the programmer because an AC input device is typically a mechanical switch
and mechanical devices are slow. It's quite common for a PLC to require that the input be on for
25 or more milliseconds before it's seen. This delay is required because of the filtering which is
needed by the PLC internal circuit. Remember that the PLC internal circuit typically works with 5
or less volts dc.
Digital Outputs
The output assembly of a programmable controller consists of a number of sections (see Figure
below). The output signal is derived from signals in the processor being fed to the output logic
circuits which are isolated to protect the logic from accidental application of excessive voltages to
field wiring. The output is usually provided with over current protection such as a fuse to stop the
output assembly from being damaged if an accidental short circuit is applied in the field wiring.
A block diagram of a typical digital output module
A blown-fuse indicator is provided as a feature on some programmable controllers; it will indicate
if any of the individual output fuses blow and assist in troubleshooting by indicating the general
location, such as rack or module, of a fault.
The output module of a programmable controller acts as a switch to supply power from the user
power supply to operate the output. The output, under the control of the program, is fed from the
processor to a logic circuit that will receive and store the processor command that is required to
make an output become inactive. It is necessary to store the command because once an output is
made active it must. remain in the active state until it is instructed by the program to become
inactive.
- 86 -
ALLEN BRADLEY VOL1 UEUNEED027A
The output switching devices most often used to switch power to the load in programmable
controllers are:
A relay for AC or DC loads;
A triac for AC loads only;
A transistor for DC loads only.
The output module with a relay output provides contacts to switch power to the load.
The contacts are not referenced to earth or supply, therefore providing complete electrical
isolation between the programmable controller and the load.
Relay Outputs
One of the most common types of outputs available is the relay output. A relay can be used with
both AC and DC loads. A load is simply a fancy word for whatever is connected to our outputs.
We call it a load because we are "loading the output" with something. If we connected no load to
the output (ie. just connect it directly to a power supply) we would certainly damage the outputs.
This would be similar to replacing the light bulb in the lamp you're using to read this with a piece
of wire. If you did this, the lamp would draw a tremendous amount of current from the outlet and
certainly pop your circuit breaker or blow your fuse.
Some common forms of a load are a solenoid, lamp, motor, etc. These "loads" come in all sizes.
Electrical sizes, that is. Always check the specifications of your load before connecting it to the
PLC output. You always want to make sure that the maximum current it will consume is within the
specifications of the PLC output. If it is not within the specifications (ie. draws too much current) it
will probably damage the output. When in doubt, double check with the manufacturer to see if it
can be connected without potential damage.
Some types of loads are very deceiving. These deceiving loads are called "inductive loads".
These have a tendency to deliver a "back current" when they turn on. This back current is like a
voltage spike coming through the system.
A good example of an inductive load that most of us see about 6 months per year is an air
conditioning unit. Perhaps in your home you have an air conditioner. Have you ever noticed that
when the air conditioner "kicks on" the lights dim for a second or two? Then they return to their
normal brightness. This is because when the air conditioner turns on it tries to draw a lot of
current through your wiring system. After this initial voltage surge it requires less current and the
lights go back to normal. This could be dangerous to your PLCs output relays. It is estimated that
this voltage surge is about 30 times the rated current of the load.
- 87 -
ALLEN BRADLEY VOL1 UEUNEED027A
Typically a diode, varistor, or other "snubber" circuit should be used to help combat any damage
to the relay.
Shown above is a typical method of connecting our outputs to the relays. Although our diagram
shows the output connected to an AC supply, DC can be used as well. A relay is non-polarised
and typically it can switch either AC or DC. Here the common is connected to one end of our
power supply and the other end of the supply is connected to the load. The other side of our load
gets connected to the actual PLC output you have designated within your ladder program.
The relay is internal to the PLC. Its circuit diagram typically looks like that shown above. When
our ladder diagram tells the output to turn on, the PLC will internally apply a voltage to the relay
coil. This voltage will allow the selected contact to close.
When the contact closes, an external current is allowed to flow through our external circuit. When
the ladder diagram tells the PLC to turn off the output, it will simply remove the voltage from the
internal circuit thereby enabling the output contact to release. Our load will than have an open
circuit and will therefore be off.
- 88 -
ALLEN BRADLEY VOL1 UEUNEED027A
Transistor Outputs
The next type of output we should learn about is our transistor type outputs. It is important to note
that a transistor can only switch a DC current. For this reason it cannot be used with an AC
voltage.
We can think of a transistor as a solid-state switch. Or more simply put, an electrical switch. A
small current applied to the transistors "base" (ie. input) lets us switch a much larger current
through its output. The PLC applies a small current to the transistor base and the transistor output
"closes". When it's closed, the device connected to the PLC output will be turned on. This is a
very simple explanation of a transistor. There are, of course, more details involved but we don't
need to get too deep.
We should also keep in mind that as we saw before with the input circuits, there are generally
more than one type of transistor available. Typically a PLC will have either NPN or PNP type
outputs. The "physical" type of transistor used also varies from manufacturer to manufacturer.
Some of the common types available are BJT and MOSFET. A BJT type (Bipolar Junction
Transistor) often has more switching capacity (ie. it can switch more current) than a MOS-FET
(Metal Oxide Semiconductor- Field Effect Transistor) type. The BJT also has a slightly faster
switching time. Once again, please check the output specifications of the particular PLC you are
going to use. Never exceed the manufacturer’s maximum switching current.
Shown above is how we typically connect our output device to the transistor output. Please note
that this is an NPN type transistor. If it were a PNP type, the common terminal would most likely
be connected to V+ and V- would connect to one end of our load. Note that since this is a DC
type output we must always observe proper polarity for the output. One end of the load is
connected directly to V+ as shown above.
- 89 -
ALLEN BRADLEY VOL1 UEUNEED027A
Let's take a moment and see what happens inside the output circuit. Shown below is a typical
output circuit diagram for a NPN type output.
Notice that as we saw with the transistor type inputs, there is a photocoupler isolating the "real
world" from the internal circuit. When the ladder diagram calls for it, the internal circuit turns on
the photocoupler by applying a small voltage to the LED side of the photocoupler. This makes the
LED emit light and the receiving part of the photocoupler will see it and allow current to flow. This
small current will turn on the base of the output transistor connected to output 0500. Therefore,
whatever is connected between COM and 0500 will turn on. When the ladder tells 0500 to turn
off, the LED will stop emitting light and hence the output transistor connected between 0500 and
COM will turn off.
One other important thing to note is that a transistor typically cannot switch as large a load as a
relay. Check the manufacturers specifications to find the largest load it can safely switch. If the
load current you need to switch exceeds the specification of the output, you can connect the LC
output to an external relay then connect the relay to the large load. You may be thinking, "why not
just use a relay in the first place"? The answer is because a relay is not always the correct choice
for every output.
A transistor gives you the opportunity to use external relays when and only when necessary.
In summary, a transistor is fast, switches a small current, has a long lifetime and works with DC
only. Whereas a relay is slow, can switch a large current, has a shorter lifetime and works with AC
or DC. Select the appropriate one based upon your actual application needs.
- 90 -
ALLEN BRADLEY VOL1 UEUNEED027A
Summary
Inputs
•
•
Digital DC – Sink or Source
o Very Common
o Fast DC switching
o Voltage dependent, typically 24 VDC
Digital AC
o Less common
o Fast AC switching
o Voltage dependent, typically 110 or 230 VAC
Outputs
•
•
•
Relay
o Very common.
o Slow switching at high currents up to 2.5A
o Voltage dependent
Transistor – Sink or Source
o Very common
o Fast switching at low currents up to 0.5A
o Voltage dependant, typically 24 VDC
Triac
o Less common
o Fast AC switching at low currents up to 0.25A
o Voltage dependant, typically 110 or 230 VAC
- 91 -
ALLEN BRADLEY VOL1 UEUNEED027A
Basic diagnostics
Diagnostics provide a programmer with the ability to problem solve and debug their program.
PLCs have tools and features called diagnostics to enable fault finding. . By using diagnostics a
programmer can also test and commission a PLC project. The type and extent of the diagnostics
will depend on the PLC type and model.
Common diagnostics tools for the RSLogix 500 are:
• Error Codes
• Controller Online Toolbar
• S2 Status File
• Error Dialogue
• Force Instruction
Note: A well designed program will be constructed so as to quickly locate and record
programming and other errors. It is well worth your time to explore and understand the use
of each of diagnostics tools described.
Below we describe each of the common diagnostic tools.
Error Codes
These codes are presented as an alert when a particular programming or communication fault
occurs.
The help file contains a list of these codes along with a description.
View of the help file showing some of the diagnostic error codes
- 92 -
ALLEN BRADLEY VOL1 UEUNEED027A
Controller Online Toolbar
If a controller fault occurs the fault can be reset by clicking Clear Fault or click Goto Error to view
a particular fault.
Clear or
Go To Error
S2 – Status
View of the Goto Error choice from the Online Toolbar menu
S2 Status File
If you prefer you can reset or view an error from the S2 Status file
Note: The controller properties dialog has many tabs some are for intermediate level
programmers and some for advanced programmers. We are interested in the error codes in this
discussion.
Make a point of using this dialog when you receive an error during your programming exercises.
If you have the time, explore some of the other tabs.
Clear Major
Error Button
Major Error
description
Minor Errors
(can be reset
programmatically)
The S2 status showing the Errors tab
- 93 -
ALLEN BRADLEY VOL1 UEUNEED027A
Error Dialogue
The error dialog will open when a syntax error or programming fault occurs.
Error Dialog
(double click to take
you to the error)
Syntax Error
Syntax Error
View of the error dialog showing a program with missing addressing
Diagnostics Tools
The diagnostic tools will help find many unexpected problems and errors, but will not find program
logic errors.
Program logic errors must be solved using other methods such as flow charts or truth tables.
Force Instruction
Another diagnostics tool is force accessed from the Project Tree.
Forcing is a way of turning (forcing) a bit in a program. This can help in problem solving and
commissioning by recording the behaviour of an output or other snippet of code.
Enable forces from the On Line toolbar then change a value in the tag monitor from 0 to 1 then
use the ladder file to monitor the results of forcing.
Enable
Forces
Right click to
set a force for
the instruction
Open the Force Files dialog to
toggle the force by
changing the value from 1 to 0
- 94 -
ALLEN BRADLEY VOL1 UEUNEED027A
Derived Timers
Intermediate Programming
To be an effective, a programmer must have a wide range of programming instruction available to
them. Not only must the programmer know when to use a particular instruction or function, they
must also have a good understanding of the instructions use and parameters.
In this section we will explore the program instructions that provide the programmer with
Derived Timers
Depending on the PLC, you may not have a particular timer function, such as Off Delay.
If this is the case you will need to ‘construct’ or ‘derive’ a timer function from one or more On
Delay timers.
Common derived timers are:
• Off Delay
o Begins timing when the input goes false
o When the input goes false the output energises instantaneously
o The output de-energises after the time delay period
•
Self resetting (Free running)
o Constantly resetting time base
•
Constant Duty Cycle (cross coupled or recycling)
o On and off times can be different
o Often used for flasher circuits
Examples
Off Delay Derived Timer
An Off Delay timer is a timer that begins timing when the rung goes false.
The SLC 500 has an Off Delay timer (TOF) instruction, but many other PLCs do not.
Timing starts when
the input is OFF
A derived Off Delay timer in operation
- 95 -
ALLEN BRADLEY VOL1 UEUNEED027A
Self Resetting (Free Running)
The Self Resetting timer is an easily built and widely used derived timer.
It is used as a fixed duration pulse of one scan cycle, the period being adjustable by the preset.
A Self Resetting timer self resets after every timing cycle.
Timing starts when
the input is true
Timer will reset itself
every timing cycle
The output will pulse
every timing cycle
A one second Self Resetting timer in action
Constant Duty Cycle (Recycling)
Construct this derived timer for use in circuits that require a regular duty cycle such as a flasher.
A Recycling timer can have separately adjustable interval and duration times.
The output can be programmed to start in a true or false state.
A recycling or Constant Duty Cycle timer with different off and on times
Depending
upon
the initial state of
the DN bit, the
output will cycle
from true to false
or vice-versa
- 96 -
ALLEN BRADLEY VOL1 UEUNEED027A
Note: Many PLCs have internal clocks that can be used for some of the derived timer functions
we have described here.
Retentive Instructions
Retentive instructions retain their state or value even after a power cycle.
A retentive timer will hold its accumulated value and begin timing at the held state once it has
been re-activated.
Retentive instructions are those that will ‘remain’ after power has been cycled. An example would
be where a counter is counting the number of parts passing through a check point on a
manufacturing line. If power is cycled, then the counter would lose its accumulated value if it was
not retentive.
The same applies for timers, and outputs or more particularly, memory bits that have been set.
There are retentive instructions that provide the user with the retained value after a power failure.
The common retentive instructions in the SLC 500 processor are:
• OTL and OTU (Output Latch and Unlatch)
• CTU (Counter Up)
• RTO (Retentive Timer On)
• SLC 500 non-retentive instructions are:
• OTE (Output Energise)
• TON (Timer On Delay)
• TOF (Timer Off Delay)
- 97 -
ALLEN BRADLEY VOL1 UEUNEED027A
Cascading Timers
It is possible to combine timers, counters, and timers and counters to obtain values higher than
the maximum available settings.
Combinations are:
• Timers cascaded with timers
• Counters cascaded with counters
• Timers and counters cascaded together
Note: It is important to note that cascading will be required where the maximum positive decimal
number in the preset exceeds 32,767 and the maximum negative number exceeds 32,768.
Cascade two timers for a value
above the maximum preset
Cascade two counters for a value
above the maximum preset
Cascade a timer and counter for a
value above the maximum preset
Three examples of cascading
- 98 -
ALLEN BRADLEY VOL1 UEUNEED027A
Derived timer Exercises
Exercise 1
Turn on a fan for 22 seconds after a switch is turned off.
Exercise 2
When a switch is turned on, LAMP1, LAMP2 and LAMP3 energise immediately.
When the switch is turned off, turn off LAMP1, LAMP2 and LAMP3 at 5 second intervals.
(use set and reset instructions to energise and de-energise the lamps)
- 99 -
ALLEN BRADLEY VOL1 UEUNEED027A
Exercise 3
In a factory there is a machine that has a large steel shaft supported by three bearings
The shaft is coupled to an electric motor
The bearings are lubricated by an oil pump driven by a small electric motor
To start the machine, the operator turns on SW1
Before the shaft starts to turn, the bearings must receive oil for 10 seconds
When the operator turns SW1 off to stop the machine, the oil pump continues to supply oil for an
additional 15 seconds
Exercise 4
A timing operation requires to time a long period of 27.5 hours
Construct a timer program that will operate a lamp once the period has elapsed
- 100 -
ALLEN BRADLEY VOL1 UEUNEED027A
Note
Retentive instructions can be useful when keeping the status of a timer, counter or bit after a
power fail or unexpected stoppage.
However, it must always be remembered that returning to the previous state after a re-start can
be a possible safety issue; consequently your circuit design must take this into account.
Assessment item 5 – derived timers
A high-speed machine requires the number of parts to be counted before changing the dies for
the next part. The number of parts is 50,200.
Construct a counter program that will operate a buzzer and stop the process when the number of
parts is reached
A manual reset is required
- 101 -
ALLEN BRADLEY VOL1 UEUNEED027A
Reversible Counters
In many PLCs including the SLC 500 there are two counter instructions.
In the SLC 500 these instructions are:
• CTU – Count up
• CTD – Count down
o Use these counters in pairs
o Both counters have the same address
o A count up bit will control the CTU counter
o A count down bit will control the CTD counter
o A count up will increment the accumulator
o A count down will decrement the accumulator
Use of reversible counters
An example of a reversible counter could be a car park which uses sensors for cars passing
through the entry and exit points.
An operation of the entry sensor would activate the CTU instruction while an operation of the exit
sensor would activate the CTD instruction.
The counter preset would contain the maximum number of cars that the car park could hold and
the accumulator the actual number of cars in the car park.
Note: Remember that the CTU and CTD counter instruction in the Allen-Bradley PLCs requires a
single reset instruction for the counter pair.
In some other PLCs the counter instruction will be both up and down and include the reset all as
part of the one instruction. The purists will say that this takes up program memory, however in
most cases this wont matter.
The CTU and CTD will continue counting until reset.
For example, if the preset is set at 100, the counter will continue to count past 100 until reset.
- 102 -
ALLEN BRADLEY VOL1 UEUNEED027A
CTU and CTD counters used together to
count the number of cars in and out of a car
park
Example of reversible counters used in a program
- 103 -
ALLEN BRADLEY VOL1 UEUNEED027A
One Shot (OSR)
The one shot instruction allows you to cause an output to occur for one rung scan based upon a
change in rung status.
You typically precede the OSR instruction with an input instruction.
When disabled by an input instruction, the OSR instruction disables the remainder of the rung.
Example 1
In this example we have one button and a light. First time we press on the button the light will go
on and the second time we press the button the light goes off. In other word we want this button
to work exactly like a toggle switch.
Input / Output
Switch I:1.0/6
Light O:2.0/6
Ladder Logic Solution
First Time the button is pushed.
First Scan:
When the push button is pressed the LIGHT_OSR will energize the rung ONLY for
one scan and during that scan the LIGHT_ONS will be energized.
Rung 0 Second Scan:
Whether the button is pressed or not, the LIGHT_OSR will not pass the signal and
hence the LIGHT_ONS will NOT be energized.
First Scan:
LIGHT_ONS is on and the light itself is not on so the rung will be energized and
the output light will be ON.
Rung 1 Second Scan:
LIGHT_ONS is off, LIGHT is on so the light will stay energized.
- 104 -
ALLEN BRADLEY VOL1 UEUNEED027A
Second Time the button is pushed.
First Scan:
When the push button is pressed the LIGHT_OSR will energize the rung ONLY for
one scan and during that scan the LIGHT_ONS will be energized.
Second Scan: Whether the button is pressed or not, the LIGHT_OSR will not pass the signal and
hence the LIGHT_ONS will NOT be energized.
Second time we press the button rung 0 will react exactly the same way as the first time we
pressed the button. The difference will be in rung 1.
First Scan:
LIGHT_ONS is on and the light is OFF so the rung will be de-energized and the
output light will go off.
Second Scan: LIGHT_ONS is off LIGHT is off so the light will stay de-energized.
It is important to use the tag created for the OSR exclusively for a single purpose and location
within your program. If more OSR instructions are required, you should create a new tag for
each.
Some PLCs, such as the Allen-Bradley SLC 500 use the Binary memory file as a memory location
for an OSR, for example B3/10. The same usage restrictions apply, the memory address must
set aside for the OSR instruction exclusively and must not be used elsewhere in you program.
Th
e
OS
R instruction in use
- 105 -
ALLEN BRADLEY VOL1 UEUNEED027A
Comparison Instructions
Comparison instructions are extremely useful in PLC programming in industry and are available in
almost all manufacturers' controllers.
The following compare instructions are taken from the Allen Bradley SLC500 series controller
instruction set but they are available in some form in all PLCs.
Equal to
Description
This input instruction is true when Source A = Source B.
The EQU instruction compares two user specified values. If the values are equal, it allows rung
continuity.
The rung goes true and the output is energised (provided no other forces affect the rung's status).
Not equal to
Description
Use the NEQ instruction to test whether two values are not equal. If Source A and Source B are
not equal, the instruction is logically true.
If the two values are equal, the instruction is logically false.
- 106 -
ALLEN BRADLEY VOL1 UEUNEED027A
Less than
Description
This conditional input instruction tests whether one value (Source A) is less than another (Source
B).
If the value at Source A is less than the value at Source B, the instruction is logically true.
If the value at Source A is greater than or equal to the value at Source B, the instruction is
logically false.
Less than or equal to
Description
This conditional input instruction tests whether one value (source A) is less than or equal to
another (source B).
If the value at source A is less than or equal to the value at source B, the instruction is logically
true.
If the value at source A is greater than the value at source B, the instruction is logically false.
- 107 -
ALLEN BRADLEY VOL1 UEUNEED027A
Greater than
Description
This input instruction compares two user specified values.
If the value stored in Source A is greater than the value stored in Source B, it allows rung
continuity.
The rung will go "true" and the output will be energised (provided no other instructions affect the
rung's status).
If the value at Source A is less than or equal to the value at Source B, the instruction is logically
false.
Greater than or equal to
Description
This input instruction compares two user specified values.
If the value stored in Source A is greater than or equal to the value stored in Source B, it allows
rung continuity.
The rung will go true and the output will be energised (provided no other instructions affect the
rung's status).
If the value at Source A is less than the value at Source B, the instruction is logically false.
- 108 -
ALLEN BRADLEY VOL1 UEUNEED027A
Limit Test
Description
Use the LIM instruction to test for values within or outside a specified range, depending on how
you set the limits.
Depending on how you define the Test parameter, the Low and High Limit parameters can be a
word address or program constant
If the Low Limit has a value equal to or less than the High Limit, the instruction is true when the
Test value is between the limits or is equal to either limit. If the Test value is outside the limits, the
instruction is false.
If the Low Limit has a value greater than the High Limit, the instruction is false when the Test
value is between the limits. If the Test value is equal to either limit or outside the limits, the
instruction is true.
- 109 -
ALLEN BRADLEY VOL1 UEUNEED027A
Using Compare Instructions
The program below shows how to use a 'GRT' than instruction to turn on an output when the
accumulated value of timer (T1) is greater than 20.
The program below shows how to use a 'LEQ' instruction to turn on an output when the
accumulated value of counter (C1) is less than or equal to 15.
- 110 -
ALLEN BRADLEY VOL1 UEUNEED027A
Process control
Compare Exercises
Exercise 1 – Part 1
The process shown below has the capacity to contain 50 parts at any one time.
Two sensors connected to the inputs of a PLC are to be used to keep track of the number
of parts in the process.
S1 detects parts entering and S2 detects parts leaving.
An alarm is to be turned on when the process is full.
Use the count up and count down instructions to achieve this.
- 111 -
ALLEN BRADLEY VOL1 UEUNEED027A
Exercise 1 – Part 2
A panel is used to display the contents of the process as follows
A green light is to be on when the number of parts in the process is less than 40.
An amber light is to be on between 40 and 49.
A red light indicates that the process is full.
- 112 -
ALLEN BRADLEY VOL1 UEUNEED027A
Exercise 2 – Car park control
The car park shown below has the capacity to contain 100 cars.
Two sensors connected to inputs of a PLC are to be used to keep track of the number of
parking spaces available.
S1 detects cars entering and S2 detects cars leaving.
An output is to be turned on when the car park is full.
Use the count up and count down instructions to achieve this.
- 113 -
ALLEN BRADLEY VOL1 UEUNEED027A
Assessment Item 6– Traffic light sequence
The intersection of King Street and Turner street is controlled by traffic lights operating in a
continuous sequence.
The start of the sequence is taken to be when King St red is off and Turner St red is on.
The timing diagram below shows the sequence of the traffic lights
(The black areas are on)
Program
Write a program using a repeating timer and six compare instructions to control the intersection .
- 114 -
ALLEN BRADLEY VOL1 UEUNEED027A
Program Flow Instructions
Jump (JMP) to Label (LBL) Instruction
The jump instruction provides an ability to jump to a referenced target (label) elsewhere in a
program. Jumping can be described by the following points:
• A jump can only reference one label.
• A label has a unique identifier.
• In a program there can be many jumps to one label.
• Jumping forward can save scan time.
• Care should be taken not to jump backwards excessively or jump into an infinite loop that
will cause the scan to exceed the watchdog time and fault the PLC
• Jumping backwards, will increase the scan time by the total time taken by the instructions
that are processed from the label to rung where the jump was initiated.
• JMP and LBL are memory bits
• JMP and LBL automatically assign the Q2 address prefix
• Jumped rungs are not scanned
• The LBL instruction must be the first on the rung
When rung 12 is true, the program scan will jump
over rung 13 and continue at rung 14
A program snippet showing the JMP and LBL instructions
Notice that the reset is
disabled when the scan
jumps over rung 13
- 115 -
ALLEN BRADLEY VOL1 UEUNEED027A
Master Control Reset (MCR)
This output instruction (sometimes known as Zone Control) is used to set up areas or “zones” of
your ladder program where all non-retentive outputs may be disabled at the same time for the
same length of time.
Used in pairs, one MCR defines the start of the ladder area to be affected and one MCR defines
the end of the area.
An input instruction should be programmed on the rung of the first MCR to control rung logic
continuity.
When the MCR rung goes false all non-retentive outputs within the “controlled zone” are
disabled.
When the MCR rung goes true all rungs are scanned according to their normal rung conditions
(disregarding the zone control instruction).
First of a pair of MCR instructions
This output will be disabled if the MCR above goes
false. The same would apply to any other rungs if
they were present between the MCRs
Second MCR instruction
A pair of MCR instructions in use
Note
The MCR instruction can disable a group of outputs within the MCR pair; however these outputs
must be of the non-retentive type.
- 116 -
ALLEN BRADLEY VOL1 UEUNEED027A
SLC500 Program Control instructions
JMP [Jump to Label]
Description
When the rung condition for this output instruction is true, the processor jumps forward or
backward to the corresponding label instruction (LBL) and resumes program execution at the
label.
More than one JMP instruction can jump to the same label.
Jumping forward to a label saves program scan time by omitting a program segment until needed.
Jumping backward lets the controller execute program segments repeatedly.
LBL [Label]
Description
This input instruction is the target of the JMP instruction having the same label number.
You must program this instruction as the first instruction of a rung.
This instruction has no control bits. It is always evaluated as true or logic 1.
You can program multiple jumps to the same label by assigning the same label number to
multiple JMP instructions, but assigning the same label number to two or more labels causes a
compile time error.
- 117 -
ALLEN BRADLEY VOL1 UEUNEED027A
JSR [Jump to Subroutine]
Description
When rung conditions are true for this output instruction, it causes the processor to jump to the
targeted subroutine file.
You can only jump to the first instruction in a subroutine.
Each subroutine must have a unique file number (decimal, 3-255).
RET [Return from Subroutine]
Description
This output instruction marks the end of subroutine execution or the end of the subroutine file.
It causes the processor to resume execution in the main program file at the instruction following
the JSR instruction where it exited the program.
If a sequence of nested subroutines is involved, the instruction causes the processor to return
program execution to the previous subroutine.
The rung containing the RET instruction may be conditional if this rung precedes the end of the
subroutine. In this way, the processor omits the balance of a subroutine only if its rung condition
is true.
- 118 -
ALLEN BRADLEY VOL1 UEUNEED027A
MCR [Master Control Reset]
Warning!
The MCR instruction is not a substitute for a hard-wired master control relay that provides
emergency stop capability. You still should install a hard-wired master control relay to provide
emergency I/O power shutdown.
Description
This output instruction (sometimes known as "Zone Control") is used to set up areas or "zones" of
your ladder program where all non-retentive outputs may be disabled at the same time for the
same length of time.
It is used in pairs, one MCR to define the start of the ladder area to be affected and one MCR to
define the end of the area.
An input instruction is programmed on the rung of the first MCR to control rung logic continuity.
When the rung goes "false" all non-retentive outputs within the controlled zone are disabled.
When the rung goes "true" all rungs are scanned according to their normal rung conditions
(disregarding the zone control instruction).
- 119 -
ALLEN BRADLEY VOL1 UEUNEED027A
TND [Temporary End]
Description
Use this instruction to progressively debug a program, or conditionally omit the balance of your
current program file or subroutines.
When the logic preceding this output instruction is true, TND stops the processor from scanning
the rest of the program file, updates the I/O, and resumes scanning at rung 0 of the main program
(File 2).
If this instruction’s rung is false, the processor continues the scan until the next TND instruction or
the END statement.
- 120 -
ALLEN BRADLEY VOL1 UEUNEED027A
Exercise – Program Flow
Refer to the program below
Write the program and download to the PLC.
Alter the program as follows using the appropriate program control instructions.
When normally open switch, I:1/10 is closed, Rungs 1 -4 are not scanned and all outputs remain
in their last state
- 121 -
ALLEN BRADLEY VOL1 UEUNEED027A
Assessment Item 7 – Program Flow
Refer to the program below
Write the program and download to the PLC.
Alter the program as follows using the appropriate program control instructions.
When normally open switch, I:1/10 is open, all outputs in rungs 1 – 4 are turned off.
- 122 -
ALLEN BRADLEY VOL1 UEUNEED027A
Shift Registers
Bit Shift
Shift registers are used extensively in industry for a variety of purposes.
Essentially a shift register uses a register or group of registers to form a train of bits to store the
previous on/off status.
Each time the Clock input is pulsed, the status of the data input gets stored in the first bit and the
remaining bits get shifted down the train.
The shift register goes by many names. SFT (Shift), BSL (Bit Shift Left), SFR (Shift Forward
Register) are some of the common names.
These registers shift the bits to the left.
BSR (Bit Shift Right) and SFRN (Shift Forward Register Not) are some examples of instructions
that shift bits to the right.
We should note that not all manufacturers have shift registers that shift data to the right but most
have left shifting registers.
A typical shift register instruction has a symbol like that shown below.
The symbol needs 3 inputs and has some data inside the symbol.
- 123 -
ALLEN BRADLEY VOL1 UEUNEED027A
Data
The data input gathers the true/false status that will be shifted down the train. When the data
input is true the first bit in the register will be a 1.
This data is only entered into the register on the rising edge of the clock input.
Clock
On the rising edge of the clock input, the shift register shifts the data one location to the right or
left enters the status of the data input into the first bit. On each rising edge of this input the
process will repeat.
Reset
The reset input does just what it says. It clears all the bits inside the register to 0.
Bit 1000 inside the shift register symbol is the location of the first bit of our shift register.
Bit 1003 inside the symbol above is the last bit of our shift register.
Bits 1001 and 1002 are intermediate bits.
So this shift register has 4 bits.
(1003, 1002, 1001, 1000)
- 124 -
ALLEN BRADLEY VOL1 UEUNEED027A
The SLC500 series bit shift instructions
BSL [Bit Shift Left]
Description
On each false-to-true transition, this output instruction loads a bit of data into a bit array, shifts the
pattern of data through the array to the left, and unloads the end bit of data.
An example of the use of this instruction might be for tracking bottles through a bottling line where
each bit represents a bottle.
BSR [Bit Shift Right]
Description
On each false-to-true transition, this output instruction loads a bit of data into a bit array, shifts the
pattern of data through the array to the right, and unloads the end bit of data.
An example of the use of this instruction might be for tracking bottles through a bottling line where
each bit represents a bottle.
- 125 -
ALLEN BRADLEY VOL1 UEUNEED027A
The following application describes a typical use for a bit shift register.
An ice-cream cone machine has 4 steps.
1. First we verify the cone is not broken.
2. Next we put ice cream inside the cone.(turn on output 0).
3. Next we add chocolate.(turn on output 1)
4. Finally we add sprinkles.(turn on output 2)
If the cone is broken we obviously don't want to add ice cream and the other items.
Therefore we have to track the bad cone down our process line so that we can tell the machine
not to add each item.
We use a sensor to look at the bottom of the cone as it enters the machine.
(input 1).
If it is on then the cone is perfect and if it is off then the cone is broken.
Another sensor clocks the register each time a cone enters the machine.
(input 0)
- 126 -
ALLEN BRADLEY VOL1 UEUNEED027A
Here's what the ladder would look like:
Let's now follow the shift register as the operation takes place. Here's what the B3:0 register (the
register we're shifting) looks like initially:
B3 Register
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
0
0
0
0
A good cone comes in front of the sensor (input 1).
The sensor (bit address) turns on.
Bit 0 will not turn on until the rising edge of the clock pulse. (input 0).
When the clock input generates a pulse the status of the data input (cone sensor input 1) is
transferred to bit 0.
The register now looks like:
B3 Register
15
14
13
12
11
10
9
8
7
- 127 -
6
5
4
3
2
1
0
0
0
0
1
ALLEN BRADLEY VOL1 UEUNEED027A
As the conveying system moves on, another cone comes in front of the sensor.
This time it's a broken cone, the fault sensor remains off and the clock input generates another
pulse.
The old status of bit 0 is transferred to bit 1.
The old status of bit 1 shifts to bit 2.
The old status of bit 2 shifts to bit 3 and the new status of the data input (cone sensor) is
transferred to bit 0.
The register now looks like:
B3 Register
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
0
0
1
0
Since the register shows that bit 1 is now on, the ladder says that output 0 will turn on and ice
cream is put in the cone.
As the conveying system continues to move on, another cone comes in front of the sensor. This
time it's a good cone and the sensor turns on.
Now the clock input generates another pulse.
The old status of bit 0 is transferred to bit 1.
The old status of 1 shifts to 2.
The old status of 2 shifts to 3 and the new status of the data input (cone sensor) is transferred to
bit 0.
The register now looks like:
B3 Register
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
0
1
0
1
Since the register shows that bit 2 is now on the ladder says that output 1 will turn on and
chocolate is put on the cone.
Since bit 1 now holds the status of a broken cone, output 0 remains off and no ice-cream is
inserted into this cone.
As the conveying system continues to move on, another cone comes in front of the sensor.
This time it's also a good cone and the sensor turns on and the clock input generates another
pulse.
The old status of bit 0 is transferred to bit 1.
- 128 -
ALLEN BRADLEY VOL1 UEUNEED027A
The old status of 1 shifts to 2.
The old status of 2 shifts to 3 and the new status of the data input (cone sensor) is transferred to
bit 0.
The register now looks like:
B3 Register
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
1
0
1
1
Since the register shows that bit 3 is now on, the ladder says that output 2 will turn on and
sprinkles are put on the cone.
Since bit 2 now holds the status of a broken cone, output 1 remains off and no chocolate is put
onto this cone.
Since the register shows that bit 1 is now on, the ladder says that output 0 will turn on and ice
cream is put in that cone.
As the conveying system continues to move on, another cone comes in front of the sensor.
This time it's another broken cone and the sensor turns off.
The clock input generates another pulse.
The old status of bit 0 is transferred to bit 1.
The old status of 1 shifts to 2.
The old status of 2 shifts to 3 and the new status of the data input (cone sensor) is transferred to
bit 0.
The register now looks like:
B3 Register
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
0
1
1
0
Notice that the status of our first cone has disappeared.
In reality its sitting in location bit 4 but because our application only requires four operations it is
not required.
It is however, important to note that the status of each bit will be shifted all the way to the left so
the rest of the bits in the word should not be used for other operations in the program
After the bit is shifted all the way to the left it disappears and is never seen again.
In other words, it has been shifted out of the register and is erased from memory.
- 129 -
ALLEN BRADLEY VOL1 UEUNEED027A
The operation above would continue on with each bit shifting on the rising edge of the clock
signal.
Some other bit-shift applications
The shift register is most commonly used in conveyor systems, labelling or bottling applications,
etc.
Sometimes it's also conveniently used when the operation must be delayed in a fast moving
bottling line.
For example, a solenoid can't immediately kick out a bad bottle of beer when the sensor says its
bad.
By the time the solenoid reacted, the can would have already passed by.
Typically the solenoid is located further down the conveyor line and a shift register tracks the can
to be kicked out later when it's more convenient.
- 130 -
ALLEN BRADLEY VOL1 UEUNEED027A
Exercise 1 – Bit shift
Refer to the diagram below.
The spray booth operates as follows:
• Parts are indexed through the paint booth from left to right.
• When a part is positioned in front of either of the spray guns, an output is energised to
spray the part.
• The spray guns should not operate if no part is present.
• Proximity switch (prox1) activates each time a part holder passes.
• Proximity switch (prox2) detects whether a part is present.
• The controller and limit switches are mounted outside the spray booth to avoid electrical
hazards.
Write a program using the bit shift instruction to achieve this.
Note
Assume that the movement of parts has already been programmed, you only have to program the
shift register
- 131 -
ALLEN BRADLEY VOL1 UEUNEED027A
Assessment Item 8 – Shift Register
Create a car wash program with three treatment points one each for Suds, Rinse and Hot Wax
This program must turn on and off each of the treatment points as cars proceed through the wash
The treatment points should be outputs on your simulator
- 132 -