Sei sulla pagina 1di 10

Chapter 3

PLC

3.1 PLCs and Ladder logic


Control systems built using relay logic can be cost effective. However, modifications to the system are
challenging because everything is in the hardware and is hard-wired. Modern processing systems use
Programable Logic Controllers (PLC). Figure 3.1 is a photograph of common PLC. These devices have
become very sophisticated and as well as incorporating logic control, have internet and security capability
built in. The programming of PLCs is done graphical using Ladder Logic. The name “ladder” derives
from the two vertical lines between which the logic function flows from the left, the inputs, to the right,
the outputs.

Figure 3.1: Example of a PLC (Allen-Bradley Micrologix 1400)

An introduction to PLC programming can be found at PLC Training - Introduction to Ladder Logic.
16 CHAPTER 3. PLC

Figure 3.2: Connections of a PLC system.

Ladder code

Power CPU Input Output


Unit Unit Unit Unit

Pilot
Light
Push button switch

I suggest that you watch the first 10 minutes or so at first and come back later to go through the rest of
the video when you understand the idea behind PLCs.
The video by Ron Beaufort on how to think about Ladder Programming and PLCs is a good place
to start and can found at the site PLC Training / Tutorial for Allen-Bradley (Video 1 of 11). His other
videos in the series are also very good.
Figure 3.4 shows an example of a ladder program. The two thick lines are the struts of the ladder.
Between the struts are the rungs. Each rung represents a step in the program. The program starts at the
top and works its way down the ladder. Completing rung 1 before moving onto rung 2 and so on. When it
reaches the “End” rung, the program returns to the first rung and goes through the program again. This
sequence continues until the program is stopped. Table 3.1 explains the meaning XIO, XIC and OTE.
3.1. PLCS AND LADDER LOGIC 17

Figure 3.3: Process of programming a PLC.

Pnemonic
Translate code

Transfer to PLC
CPU Memory
Computer

In Out

I:00/0 I:00/1 O:00/0

XIO XIO OTE


0:00/0

XIC

END

Figure 3.4: An example of a simple ladder program.


18 CHAPTER 3. PLC

Table 3.1: Some symbols used in ladder logic


Examine if Use the XIC instruction in your ladder program to determine
Closed (XIC) if a bit is On. When the instruction is executed, if the bit
addressed is on (1), then the instruction is evaluated as true.
When the instruction is executed, if the bit addressed is off
(0), then the instruction is evaluated as false
Examine If Use the XIO instruction in your ladder program to determine
Open (XIO) if a bit is Off. When the instruction is executed, if the bit
addressed is off (0), then the instruction is evaluated as true.
When the instruction is executed, if the bit addressed is on
(1), then the instruction is evaluated as false.
Output Ener- Use the OTE instruction in your ladder program to turn on
gize (OTE) a bit when rung conditions are evaluated as true.
Output Latch OTL and OTU are retentive output instructions. OTL can
(OTL) and only turn on a bit, while OTU can only turn off a bit. These
Output Un- instructions are usually used in pairs, with both instructions
latch (OTU) addressing the same bit.
One-shot Ris- The OSR instruction is a retentive input instruction that trig-
ing (OSR) gers an event to occur one time. Use the OSR instruction
when an event must start based on the change of state of the
rung from false-to-true. When the rung conditions preceding
the OSR instruction go from false-to-true, the OSR instruc-
tion will be true for one scan. After one scan is complete, the
OSR instruction becomes false, even if the rung conditions
preceding it remain true. The OSR instruction will only be-
come true again if the rung conditions preceding it transition
from false-to-true.
3.1. PLCS AND LADDER LOGIC 19

Progamming and PLCs


The International Electrotechnical Commission standard IEC 61131 describes Programmable Logic Con-
trollers. A description of the standard is at the URL IEC 61131 Wiki. The part of the standard related to
programming languages is available from the IEC Web-site: IEC 61131-3:2013 Programmable Controllers
Part 3 Programming Languages. These standards are important to the industry because they reduce
maintenance costs and improve compatibility between manufacturers of PLCs and related equipment.
When designing a controller the following steps should be considered

1. Understand the system specifications; be clear on what is required in the way of inputs and outputs

2. Review possible control methods

3. Flow chart the process

4. Implement the flow-chart using logic diagrams or relay logic

5. Assign I/O addresses

6. Translate into PLC code


20 CHAPTER 3. PLC

3.2 Examples of ladder programs


An example of a ladder program is shown in figure 3.5 and alternative, less safe realization is shown in
figure 3.6

Figure 3.5: PLC realization of a motor controller. Pushing the start button momentarily will start the
motor. The motor will stay on until the stop button is pressed.
Start I:00/0 I:00/1 O:00/0
I:000/0 O:000/0
0 1 A
Stop I:000/1 O:000/1
Start Stop Motor A
1 0
I:000/2 0:00/0 O:000/2
0 0
I:000/3 O:000/3
Motor A
0 0
I:000/4 O:000/4
0 0
I:000/5 O:000/5
0 0
I:000/6 O:000/6
0 0
I:000/7 O:000/7
0 0

3.3 Counter intuitive function of a ladder program


In this section we will go step-by-step through an example intended to indicate how ladder programs are
not like logic circuits or relay circuits and should be considered on their own without reference to previous
concepts of controllers. In this example, it appears that both motors A and B are controlled by switch A
and we would naively expect that when swtich A is closed both motors should turn on. However, what
happens is only motor A will turn on. Motor B will not turn on.
The initial condition is shown in figure 3.7. The PLC repeatedly reads in the state of the inputs from
the physical world and sets the outputs to the physical world only at the beginning and end of a clock
cycle (say every 5ms) respectively. When switch A closes, at the beginning of its clock cycle, the PLC will
read the state the physical world into its memory input variable. This state is shown in figure 3.8, bit 0 of
the input variable changes to a true or ”1” value; all other bits stay the same. The PLC will then process
rung 1, and determine that since bit 0 of the input is true then then bit 0 of the output variable changes
to true or ”1”. This state is shown in figure 3.9. Next the PLC will process rung 2 and since bit 1 of the
input variable is false or ”0”, bit 0 of the input variable will change to ”0”. This state is shown in figure
3.10. Next the PLC processes rung 3. Bit 0 of the input variable is ”0” hence bit 1 of the output variable
will stay at ”0”. This state is shown in figure 3.11. Next the PLC reads the output variable to the outside
world and Motor A will turn on and Motor B will stay off. This state is shown in figure 3.12. The PLC
will then repeat the process in the next clock cycle.
Exercise What happens if both switches A and B are closed?
3.3. COUNTER INTUITIVE FUNCTION OF A LADDER PROGRAM 21

Figure 3.6: Alternative PLC realization of a motor controller. Pushing the start button momentarily will
start the motor. The motor will stay on until the stop button is pressed. However, if the connection to
the stop button switch input breaks it is not possible to turn the motor off. If the start button switch
connection breaks the motor will come on without warning. Both of this conditions are possible and
dangerous. This is clearly not a good design and is not what is called “fail safe”
Start I:00/0 I:00/1 O:00/0
I:000/0 O:000/0
1 1 A
Stop I:000/1 O:000/1
Start Stop Motor A
0 0
I:000/2 0:00/0 O:000/2
0 0
I:000/3 O:000/3
Motor A
0 0
I:000/4 O:000/4
0 0
I:000/5 O:000/5
0 0
I:000/6 O:000/6
0 0
I:000/7 O:000/7
0 0

Figure 3.7: Initial state: both switches A and B are open, the program has cycled through, bit I:000/0=0
and bit I:000/1=0; bit O:000/0=0 and bit O:000/1=0; both motors are off
SW A I:00/0 O:00/0
I:000/0 O:000/0
0 0 A
SW B I:000/1 O:000/1
SW A Motor A
0 0 B
I:000/2 I:00/1 I:00/0 O:000/2
0 0
I:000/3 O:000/3
SW B SW A
0 0
I:000/4 I:00/0 O:00/1 O:000/4
0 0
I:000/5 Motor B O:000/5
SW A
0 0
I:000/6 O:000/6
0 0
I:000/7 O:000/7
0 0
22 CHAPTER 3. PLC

Figure 3.8: Read in physical world values. When switch A is closed and B is left open, the PLC
takes in the values at the input at the beginning of its clock cycle: bit I:000/0=1 and bit I:000/1=0; bit
O:000/0=0 and bit O:000/1=0; both motors are off
SW A I:00/0 O:00/0
I:000/0 O:000/0
1 0 A
SW B I:000/1 O:000/1
SW A Motor A
0 0 B
I:000/2 I:00/1 I:00/0 O:000/2
0 0
I:000/3 O:000/3
SW B SW A
0 0
I:000/4 I:00/0 O:00/1 O:000/4
0 0
I:000/5 Motor B O:000/5
SW A
0 0
I:000/6 O:000/6
0 0
I:000/7 O:000/7
0 0

Figure 3.9: Process rung 1. bit I:000/0=1 and bit I:000/1=0; hence output bit 0 will be changed: bit
0:000/0=1. Output bit O:000/1=0; both motors are off
SW A I:00/0 O:00/0
I:000/0 O:000/0
1 1 A
SW B I:000/1 O:000/1
SW A Motor A
0 0 B
I:000/2 I:00/1 I:00/0 O:000/2
0 0
I:000/3 O:000/3
SW B SW A
0 0
I:000/4 I:00/0 O:00/1 O:000/4
0 0
I:000/5 Motor B O:000/5
SW A
0 0
I:000/6 O:000/6
0 0
I:000/7 O:000/7
0 0
3.3. COUNTER INTUITIVE FUNCTION OF A LADDER PROGRAM 23

Figure 3.10: Process rung 2. This step changes bit I:000/0=0 and no change to bit I:000/1=0; bit
O:000/0=1 and bit O:000/1=0; both motors are off
SW A I:00/0 O:00/0
I:000/0 O:000/0
0 1 A
SW B I:000/1 O:000/1
SW A Motor A
0 0 B
I:000/2 I:00/1 I:00/0 O:000/2
0 0
I:000/3 O:000/3
SW B SW A
0 0
I:000/4 I:00/0 O:00/1 O:000/4
0 0
I:000/5 Motor B O:000/5
SW A
0 0
I:000/6 O:000/6
0 0
I:000/7 O:000/7
0 0

Figure 3.11: Process rung 3. bit I:000/0=0 and bit I:000/1=0; bit O:000/0=1 and bit O:000/1=0; both
motors are off;
SW A I:00/0 O:00/0
I:000/0 O:000/0
0 1 A
SW B I:000/1 O:000/1
SW A Motor A
0 0 B
I:000/2 I:00/1 I:00/0 O:000/2
0 0
I:000/3 O:000/3
SW B SW A
0 0
I:000/4 I:00/0 O:00/1 O:000/4
0 0
I:000/5 Motor B O:000/5
SW A
0 0
I:000/6 O:000/6
0 0
I:000/7 O:000/7
0 0
24 CHAPTER 3. PLC

Figure 3.12: Transfer outputs to the physical world bit I:000/0=0 and bit I:000/1=0; bit O:000/0=1
and bit O:000/1=0; Motor A is turned on and Motor B is off;
SW A I:00/0 O:00/0
I:000/0 O:000/0
0 1 A
SW B I:000/1 O:000/1
SW A Motor A
0 0 B
I:000/2 I:00/1 I:00/0 O:000/2
0 0
I:000/3 O:000/3
SW B SW A
0 0
I:000/4 I:00/0 O:00/1 O:000/4
0 0
I:000/5 Motor B O:000/5
SW A
0 0
I:000/6 O:000/6
0 0
I:000/7 O:000/7
0 0

Potrebbero piacerti anche