Você está na página 1de 12

Page 1 of 12

Polytechnic University of Puerto Rico


Mechanical Engineering Department
Mechatronics ME-5250
Professor: Sandra L. Ordez Estvez
Programmable Logic Controllers (PLCs)
1. Introduction
Programmable Logic Controllers (PLCs) are industrial controllers. A Programmable Logic
controller (PLC) is an event driver controller intended for industrial usage, which can be
programmed and interfaced to a variety of devices and other computers. PLCs were designed to
be replacements for hard-wired relay logic, which required a large amount of physical labor to
wire the control logic, an also required a substantial amount of space to contain the relays and
terminal strips.
A PLC 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.
2. PLC Internal Structure
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 do not "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. Figure 1 shows a schematic diagram for the internal structure of the PLC.

Figure 1. PLC internal Structure


2.1 Basic Structure

2.1.1 Input Relays (contacts)


These are connected to the outside world. They physically exist and receive signals from
switches, sensors, etc.

2.1.2 Internal Utility Relays - (auxiliary Contact Relays)


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

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

2.2.2 Master relays


A master relay is a relay used to select and execute only parts of a ladder diagram. This option is
explained using an example in section 2.8.
2.3 PLC Operation
A PLC works by continually scanning a program. We can think of this scan cycle as consisting of
3 important steps (as it is shown in Figure 2). 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.

Figure 2. Cycle for the PLC Operation


Step 1 - 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 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.
Step 2 - 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.
Step 3 - 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 the example in step 2 it would now turn
on the first output because the first input was on and your program said to turn on the first output
when this condition is true.
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.
2.4 Programming the PLC
To effectively program a PLC, it is necessary to follow four steps:

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

2.5.1 Rules for drawing ladder diagrams


- The ladder diagram must show only electrical control devices, such as switches, sensors,
relay coils, motors, pumps, lights or solenoids. Pneumatic or hydraulic or other types of
mechanical devices never appear on a ladder diagram.
-

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).

Use a step or rung to indicate the end of the program

Page 6 of 12

2.5.2 Interpreting a ladder logic diagram


- For all the contacts (inputs, auxiliary contact relays, timer relays, counter relays or
other output associated relays), they default value will be as it is named. For example,
a NC contact it is Normally-Closed, which means that it will be closed until it is
activated. When the contact is activated, it changes its state, and then it will be open
until the contact is deactivated again. When the contact is deactivated, it will return to
its normal condition, closed for this case. For a NO (Normally_Open) contact, it will
be open until it is activated. When the contact is activated, it changes its state, and
then it will be closed until the contact is deactivated again. When the NO contact is
deactivated, it will return to its normal condition, open for this case.
- When an auxiliary contact relay is activated (that is when the current flow through its
coil), all the contacts associated with this device (the contact with the same name and
address) will be activated as well. When the current is removed from coil CR, the
relay contacts are returned to their normal state.
2.5.3 Pushbuttons
They are used to allow an operator to manually start and stop a sequence of operations. Each
pushbutton is connected to a pair of terminals called contact. Depressing a pushbutton causes
the contact to close or open, but it will be activated only while the operator keeps pressing it.
These pushbuttons (start, stop) are usually connected in series in the first rung of the ladder, to
allow the operator to start the sequence or to stop it in an emergency. Physically, the start
pushbutton is a NO and the stop button is a NC, while in the ladder they will be both NO.
However, to simulate the ladder (without having the physical contacts connected) it is necessary
to use a NC contact to simulate the stop pushbutton.
2.6 Mnemonic Language
You can program the PLC also using either a programmable console or programming software
installed in a computer with some instructions called mnemonics. The mnemonic instructions
used for Mitsubishi PLCs are:
MNEMONIC
LD
LDI
AND
ANI
OR
ORI
OUT
ANB
ORB
RST
SHF
K
END

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

2.7 Logic Gates representation


Since the ladder programming uses digital logic, the logic-gates can be represented using
series/parallel contacts as follows:
(Remember that a closed contact can be represented as a 0, and an open contact can be
represented as a 1).
AND

X400 X401 Y430

MNEMONIC PROGRAM

LD

X400

AND

X401

OUT

Y430

OR
X400 X401 Y430

NOR
X400 X401 Y430

NAND

X400 X401 Y430

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.

Figure 5. A Level Application


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. Looking at this process, 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) level sensors. They will be activated when the oil
touches the sensors. Sometimes you will require assigning addresses to the inputs and outputs.
This lets the PLC know where they are physically connected. The addresses are shown in the
table 1. Figure 6 shows the ladder logic diagram for this level application. 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.
MNEMONIC PROGRAM
LDI

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

2.8.2 Pneumatic Sequence 1


Both cylinders (A and B) are retracted, then a- and b- are active (a+, b+, a- and b- are limit
switches or other sensing devices that are used to detect when the cylinders A and B are fully
extended or fully retracted respectively). The double solenoid valves control the two double
acting cylinders. Determine the sequence of operation using the pneumatic circuit shown in
Figure 7 and the ladder logic program shown in Figure 8.

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.

2.8.3 Example with timers


input

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).

2.8.4 Example with timers - 2


input Timer2 Timer1
Timer1

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.

2.8.5 Pneumatic Sequence 2


Both cylinders (A and B) are retracted, then a- and b- are active (a+, b+, a- and b- are limit
switches or other sensing devices that are used to detect when the cylinders A and B are fully
extended or fully retracted respectively). The double solenoid valves control the two double
acting cylinders. Determine the sequence of operation using the pneumatic circuit shown in
Figure 7 and the ladder logic program shown in Figure 11.

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

Você também pode gostar