Escolar Documentos
Profissional Documentos
Cultura Documentos
Page 2 of 12
always off. Some are on only once during power-on and are typically used for initializing data
that was stored.
2.1.3 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 their 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.
2.1.4 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.
2.1.5 Output Relays
These are connected to the outside world. They physically exist and send on/off signals to
solenoids, lights, pumps, motors, etc. The output circuitry can be made of transistors, relays, or
triacs depending upon the model chosen.
2.1.6 Data Storage
Typically there are registers assigned to simply store data. They are usually used as temporary
storage for math 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.
2.2 Additional functions
There are other functions that a PLC can perform. For example, data comparison, data movement,
arithmetic operations, code conversions, PID controllers, etc. You can read more about these
functions in your textbook.
2.2.1 Data comparison
PLCs can compare data using less than (<), equal to (=), greater than (>), less than or equal to
(), greater than or equal to (), and not equal to (<>, ). The data comparison is performed
using the following structure:
>
Compare
instruction
Source Destination
Address Address
Page 3 of 12
Page 4 of 12
a) Define the Problematic - What do you want to control? You have to establish the right order of
your sequence, you have to identify the inputs (sensors, switches such as the start and stop
buttons, etc). Here you assign names (nicknames) and addresses to each input, output and
auxiliary contacts and coils.
b) Ladder Logic Diagram - Converts this problematic into a ladder logic diagram that meets the
requirements to control the process or device, and simulate the program in order to detect
possible failures/mistakes.
c) Mnemonic Language (Programming Language) Here you can program using either a
programmable console or programming software installed in a computer.
d) Transfer the program to the PLC After simulating the program, it is transferred to the PLC
via a serial port such as the RS-232.
2.5 Ladder Logic Programming
This is the most popular method of program PLCs. Graphically it shows which switches must be
closed or open to allow the current to flow to an output load. Figure 3 shows the general
appearance of a ladder diagram. The vertical lines on the left and right sides of the diagram
represent (virtually) the positive (+) and negative (-) terminals of a DC power supply.
(+)
(-)
(-)
(+)
PB1
L1
Figure 3
The horizontal lines are called rungs or steps (as a ladder). Each rung basically consists of an
input element, an output load, and electrical wires (that for the case of a PLC, most of them will
not exist physically). Input elements such as pushbuttons, switches and sensors are located on the
left side of the rung. Output loads, such as pilot lamps, valve solenoids, motors, pumps and relay
coils (for the Internal relays (IR) or Contact relays (CR)) are located on the right side. When the
input element on a rung is closed, it forms a continuous path or closed circuit to the output load,
allowing the current to flow from the positive (+) terminal of the DC power supply to energize
the output load. Two or more input elements can be connected on a rung in series or parallel to
form the logic functions AND or OR as it is shown in Figure 4.
(-)
(+)
(-)
(+)
PB1
PB1
PB2
L1
PB2
L1
Page 5 of 12
Series (AND)
Parallel (OR)
Figure 4
Input elements must be drawn on the left side of the ladder diagram, and output loads
must be drawn on the right side. There must be at least one input element and at most
one series output load per rung. Input elements should never be connected directly o
the negative (-) terminal and load devices should never be connected directly to the
positive (+) terminal of the virtual DC power supply.
When more than one output load is required, it must be connected in parallel (loads
must never be connected in series in the same rung).
All ladder rungs must be numbered and each device must be identified with a
representative abbreviation. For example, PB is the abbreviation for pushbutton, and
CR is an abbreviation for relay coil (or contact relay). In your textbook you will find
the abbreviation IR as Internal-Relay that it is the same as Contact-Relay (CR).
Contacts operated by a relay coil must be identified with the same abbreviation as the
coil which operates them. For example, contacts operated by relay coil CR1 are labeled
CR1-A, CR1-B, CR1-C. Timers will be identified as TMR, Counters as CNT.
All inputs and auxiliary contact relays are represented with the same symbol in a
ladder-logic program. That is:
for a NO (Normally Open) contact,
or
for a NC (Normally Closed) contact.
All outputs, auxiliary contact relays coils are represented with the same symbol that
is:
or, ( )
According with your manufacturer requirements, you should name the inputs,
outputs, auxiliary relays , timers and counters with specific names (for example, for a
particular PLC all the inputs should be named X#, all the outputs as Y#, etc, etc.),
with the addresses (X400, Y430, etc).
Page 6 of 12
USE
Start a rung with an open contact
Start a rung with a closed contact
AND logic function series element with an
open contact
AND NOT logic function series element
with a closed contact
OR logic function parallel element with an
open contact
OR NOT logic function parallel element
with a closed contact
Connect an Output
AND used with two sub circuits
OR used with two sub circuits
Reset shift register or counter
Shift
Insert a constant
End ladder
Page 7 of 12
MNEMONIC PROGRAM
LD
X400
AND
X401
OUT
Y430
OR
X400 X401 Y430
NOR
X400 X401 Y430
NAND
XOR
X400 X401 Y430
0
1
MNEMONIC PROGRAM
LD
X400
OR
X401
OUT
Y430
MNEMONIC PROGRAM
LDI
X400
ORI
X401
OUT
Y430
MNEMONIC PROGRAM
LDI
X400
ANI
X401
OUT
Y430
MNEMONIC PROGRAM
LDI
X400
AND
X401
LD
X400
ANI
X401
ORB
OUT
Y430
Page 8 of 12
2.8 Examples
2.8.1 Level control
Suppose that we what to control the oil level 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 Figure 5.
0000
OR
1000
ANI
0001
OUT
1000
LD
1000
OUT
0500
Figure 6. Ladder Logic Diagram and mnemonic program for the Lever application
Page 9 of 12
Cylinder A
A+
a-
a+
A-
Cylinder B
B+
b-
b+
B-
Figure 7
Start
b-
A+
a+
B+
b+
A-
a-
B-
END
Figure 8
Since a- and b- are active in the beginning of the sequence, the ladder logic shown in Figure 8
will work as follows: before we push the start button, in the fourth rung the a- contact will be
closed (is NO but since it is active, it is closed momentarily). When we press the start button (and
since b- is active, then it is closed), A+ will be energized. When A+ is energized, the solenoid will
change its position and air will flow through it, extending cylinder A, deactivating a- and
activating a+. When a+ is activated, the second rung will energize B+, extending cylinder B,
deactivating b- and activating b+. When b+ is activated, it will close its contact NO, then it will
Page 10 of 12
energize the third rung of the ladder, energizing A-, retracting cylinder A, deactivating a+ and
activating a- again. When a- is activated, solenoid B- will be energized, then the cylinder B will
be retracted, activating b- and deactivating b+. Then, the cycle will only start again when the start
button is pressed. Notice that this will work if you maintain pressed the start button. If you want
to let the program run without pressing the start button you have to put a latch in your system.
This is a contact that will energize the ladder indefinitely until its coil is not energized.
Timer1
Timer1
Timer2
Timer2
output
END
Figure 9
In the ladder shown in Figure 9, the input (it can be a sensor or a switch) will activate the timer 1.
Timer 1 will count the time set, then it will activate its contacts (this is a ON-DELAY timer. The
OFF-DELAY timer always activates its contacts and after the elapsed time it will deactivate its
contacts). When the timer1 has reaches its preset time, the contact named timer1 will close and it
will activate timer2 that will close its contact when other preset time is reached. When timer2 is
closed, it will activate the output. The output will remain energized until the input is deactivated
(if the input contact opens again, it will deactivate timer1, timer2 and the output).
Timer2
Timer2
output
END
Page 11 of 12
Figure 10
The ladder shown in Figure 10 is exactly the same shown in Figure 9 but it has a NC contact
(associated to timer2) in the first rung. The program will work as mentioned above but when
timer2 reaches its preset time value, the NC contact in rung 1 will open and then it will deactivate
all the circuit. But, if the input is still active (its contact is closed), the program will be executed
again.
Start
IR
A+
a+
IR
B+
b+
IR
IR
a+
IR
IR
IR
IR
Bb-
A-
END
Figure 11
When we press the start button (and since IR is not active, then it is closed), A+ will be energized.
When A+ is energized, the solenoid will change its position and air will flow through it,
extending cylinder A, deactivating a- and activating a+. When a+ is activated, the second rung
will energize B+, extending cylinder B, deactivating b- and activating b+. When b+ is activated, it
will energize IR, opening its contacts in rung 1, 2 and the first line of rung 3, and it will also close
its contacts from the second line of rung 3, rung 4 and rung 5. Then IR will be a latch for itself (it
will keep the coil IR energized until b+ is deactivated. a+ in this rung will enable the flow of
current through IR. IR will energize the four rung of the ladder, energizing B-, retracting cylinder
B, deactivating b+ and activating b- again. When b- is activated, solenoid A- will be energized,
then the cylinder A will be retracted, activating a- and deactivating a+. Then, the cycle will only
start again when the start button is pressed.
Page 12 of 12
3. References
[1] http://www.plcs.net/contents.shtml
[2] Mechatronics textbook