Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
PLC
An introduction to PLC programming can be found at PLC Training - Introduction to Ladder Logic.
16 CHAPTER 3. PLC
Ladder code
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
Pnemonic
Translate code
Transfer to PLC
CPU Memory
Computer
In Out
XIC
END
1. Understand the system specifications; be clear on what is required in the way of inputs and outputs
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
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