Ladder Logic - Link to SPSU`s main Web page.

ECET 4530
Industrial Motor Control
Ladder Logic Instructions
RS Logix 5000 – Ladder Logic
Ladder Logic is often used when programming PLCs in the
RS Logix environment.
A Ladder Logic Diagram is a graphical method of expressing
a PLC’s program.
Note that Ladder Logic is not exclusive to the RS Logix
environment. It is utilized by many control system
manufacturers as a method for programming their PLCs.
1
Ladder Logic Diagrams
Ladder Logic Diagrams ( or “Ladder Diagrams”) are named
such because, in their simplest form, they take on the
appearance of a ladder, with two side-rails and multiple
horizontal rungs.
Ladder Logic Diagrams
The rungs of the ladder diagram contain various instructions
that define the operation of the PLC similar to lines of code.
Instructions
Rungs
2
Ladder Logic Instructions
The instructions can typically be separated into two categories:
◦ Logic Instructions
◦ Output Instructions
Output
Instructions
Logic
Instructions
Output Instructions
Output Instructions cause something to happen, either within
the local PLC or in an external device, such as:
◦ Setting a bit in memory
◦ Causing one of the PLC’s outputs to “turn on”
◦ Activating a Variable Frequency Drive (VFD)
Output
Instructions
3
Output Instructions
Output Instructions always appear one the right side of each
rung and are triggered whenever the Logic Instructions
placed to their left provide an over-all “True” rung-condition.
Output
Instructions
Logic Instructions
Logic Instructions provide the operational logic that
determines the state of the Output Instruction(s).
Whenever all of the Logic Instructions on a rung are “True”,
the Rung-Condition for that rung is said to be “True”, and
all of the output instructions on that rung will activate.
Logic
Instructions
4
Ladder Logic Execution
Similar to normal programs that are executed sequentially lineby-line, ladder logic programs are executed sequentially
rung-by-rung, from top to bottom, after which the process
repeats indefinitely as long as the PLC is in “Run” mode.
Program
Execution
Ladder Logic Execution
Beginning with Rung 0, the PLC checks the state of the Logic
Instructions, and activates the Output Instruction(s) on that
rung if the Rung-Condition is True.
If the Output Instruction is triggered, the PLC completes that
instruction before going on to the next rung.
Program
Execution
5
Ladder Logic Execution
Once the PLC is finished with Rung 0, the PLC checks the logic
state of Rung 1 and activates that rung’s Output Instructions
if its Rung-Condition is True.
Program
Execution
Ladder Logic Execution
The PLC continues to execute the program, rung-by-rung, until
the “End” rung is reached. Once that happens, the PLC
jumps back to Rung 0 and the process repeats.
Program
Execution
6
Rung Requirements
Each rung must have at least one Output Instruction.
Each rung is not required to have any Logic Instructions.
Note that a rung with no Logic Instructions will always
return a “True” Rung-Condition.
Examine if Closed (XIC)
XIC – Examine-if-Closed
?
An Examine-if-Closed Instruction is a Logic Instruction
whose operation is similar to that of a normally-open
(NO) contact.
7
Examine if Closed (XIC)
XIC – Examine-if-Closed
?
An Examine-if-Closed Instruction is a Logic Instruction
whose operation is similar to that of a normally-open
(NO) contact.
The XIC must be assigned a Tag Name.
The Tag Name is the name of the bit that is stored in
memory that determines the state of the XIC.
Examine if Closed (XIC)
XIC – Examine-if-Closed
A
Given an XIC that is assigned the Tag Name “A”, if the bit
named “A” stored in memory is a:
0 – then the XIC will return a “False” logic state
1 – then the XIC will return a “True” logic state
8
Examine if Opened (XIO)
XIO – Examine-if-Opened
?
An Examine-if-Opened Instruction is a Logic Instruction
whose operation is similar to that of a normally-closed
(NC) contact.
Examine if Opened (XIO)
XIO – Examine-if-Opened
?
An Examine-if-Opened Instruction is a Logic Instruction
whose operation is similar to that of a normally-closed
(NC) contact.
The XIO must be assigned a Tag Name.
The Tag Name is the name of the bit that is stored in
memory that determines the state of the XIO.
9
Examine if Opened (XIO)
XIO – Examine-if-Opened
A
Given an XIO that is assigned the Tag Name “A”, if the bit
named “A” stored in memory is a:
0 – the XIO returns a “True” logic state
1 – the XIO returns a “False” logic state
Output Energize (OTE)
OTE – Output Energize
?
An Output Energize Instruction is an Output Instruction
whose operation determines the state of a bit in memory.
10
Output Energize (OTE)
OTE – Output Energize
A
An Output Energize Instruction is an Output Instruction
whose operation determines the state of a bit in memory.
The OTE must be assigned a Tag Name.
If the OTE is assigned a “new” Tag Name, then a bit is
reserved in memory and given that name. The state of
the OTE determines the state of that bit.
Output Energize (OTE)
OTE – Output Energize
A
Given an OTE that is assigned the Tag Name “A”, if the
Rung-Condition for the OTE is:
False – the OTE resets bit “A” (A = 0)
True – the OTE sets bit “A” (A = 1)
Note that bit “A” will only change in value when the PLC is
executing the rung with the OTE named “A”
11
On-Delay Timer (TON)
TON – On-Delay Timer
TON
Timer On Delay
Timer
Preset
Accum
?
?
?
(EN)
(DN)
The On-Delay Timer is a non-retentive timer that
accumulates time when the instruction is enabled.
On-Delay Timer (TON)
TON – On-Delay Timer
rung-condition-in
TON
Timer On Delay
Timer
Preset
Accum
?
?
?
(EN)
(DN)
The On-Delay Timer is a non-retentive timer that
accumulates time when the instruction is enabled.
(I.e. – Begins counting when the rung-condition-in is true)
12
On-Delay Timer (TON)
TON – On-Delay Timer
TON
Timer On Delay
Timer
Preset
Accum
?
?
?
(EN)
(DN)
The On-Delay Timer is a non-retentive timer that
accumulates time when the instruction is enabled.
◦ Timer – Tag (name) of timer
On-Delay Timer (TON)
TON – On-Delay Timer
TON
Timer On Delay
Timer
Preset
Accum
?
?
?
(EN)
(DN)
The On-Delay Timer is a non-retentive timer that
accumulates time when the instruction is enabled.
◦ Timer – Tag (name) of timer
◦ Preset – Time delay (in msec) until timer is
“Done” counting
13
On-Delay Timer (TON)
TON – On-Delay Timer
TON
Timer On Delay
Timer
Preset
Accum
?
?
?
(EN)
(DN)
The On-Delay Timer is a non-retentive timer that
accumulates time when the instruction is enabled.
◦ Timer – Tag (name) of timer
◦ Preset – Time delay (in msec) until timer is
“Done” counting
◦ Accum – Current time value (in msec) stored in
the timer’s accumulator
On-Delay Timer (TON)
TON – On-Delay Timer
TON
Timer On Delay
Timer
Preset
Accum
?
?
?
(EN)
(DN)
The On-Delay Timer is a non-retentive timer that
accumulates time when the instruction is enabled.
◦ EN – Enable Bit that is set when the TON
instruction is enabled.
14
On-Delay Timer (TON)
TON – On-Delay Timer
TON
Timer On Delay
Timer
Preset
Accum
?
?
?
(EN)
(DN)
The On-Delay Timer is a non-retentive timer that
accumulates time when the instruction is enabled.
◦ EN – “Enable Bit” that is set when the TON
instruction is enabled.
◦ DN – “Done Bit” that is set when the Accum
reaches the Preset value.
On-Delay Timer (TON)
TON – On-Delay Timer
TON
Timer On Delay
Timer
Preset
Accum
?
?
?
(EN)
(DN)
The On-Delay Timer is a non-retentive timer…
Non-Retentive Timer – the timer does not retain its
Accum value when the timer
timer is disabled.
(I.e. – the accumulator resets to zero when the timer is disabled)
15
On-Delay Timer (TON)
TON – On-Delay Timer
TON
Timer On Delay
Timer
Preset
Accum
?
?
?
(EN)
(DN)
TON Operation
TON – On-Delay Timer Operation
A
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
0
(EN)
(DN)
The On-Delay Timer is placed on a rung with a single
XIC (NO contact) that has tag name “A”.
16
TON Operation
TON – On-Delay Timer Operation
A
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
0
(EN)
(DN)
The On-Delay Timer is placed on a rung with a single
XIC (NO contact) that has tag name “A”.
◦ The TON’s tag name is “LightTimer”, it has a
Preset value of 60,000 msec, and it has an initial
Accum value of 0 msec.
TON Operation
TON – On-Delay Timer Operation
A
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
0
(EN)
(DN)
The On-Delay Timer is placed on a rung with a single
XIC (NO contact) that has tag name “A”.
◦ The TON’s tag name is “LightTimer”, it has a
Preset value of 60,000 msec, and it has an initial
Accum value of 0 msec.
◦ When bit “A” is low (0), the rung-in-condition for
the TON is false  the TON is disabled.
17
TON Operation
TON – On-Delay Timer Operation
A
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
0
(EN)
(DN)
◦ When bit “A” goes high (1), the rung-in-condition for
the TON is true  the TON is enabled.
TON Operation
TON – On-Delay Timer Operation
A
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
23
(EN)
(DN)
◦ When bit “A” goes high (1), the rung-in-condition for
the TON is true  the TON is enabled.
◦ When the TON is enabled, the EN bit is set high (1)
and the timer begins counting.
18
TON Operation
TON – On-Delay Timer Operation
A
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
37192
(EN)
(DN)
◦ When bit “A” goes high (1), the rung-in-condition for
the TON is true  the TON is enabled.
◦ When the TON is enabled, the EN bit is set high (1)
and the timer begins counting.
◦ While enabled, the TON keeps counting until the
accumulator reaches the preset value.
TON Operation
TON – On-Delay Timer Operation
A
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
60000
(EN)
(DN)
◦ When the accumulator reaches 60,000 (60 sec), the
TON stops counting and the DN bit is set high (1).
19
TON Operation
TON – On-Delay Timer Operation
A
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
0
(EN)
(DN)
◦ When the accumulator reaches 60,000 (60 sec), the
TON stops counting and the DN bit is set high (1).
◦ At any time, if the “A” bit goes low (0), the TON is
disabled, the EN and DN bits are set low (0), and
the accumulator resets back to 0.
Reset (RES)
RES – Reset
?
RES
The Reset instruction is used to reset the accumulator of a
timer or counter.
20
Reset (RES)
RES – Reset
?
RES
The Reset instruction is used to reset the accumulator of a
timer or counter.
◦ This field is used to assign the tag name of the
accumulator (ACC) that the RES instruction is
being used to reset.
Reset (RES)
RES – Reset
LightTimer.ACC
RES
The Reset instruction is used to reset the accumulator of a
timer or counter.
◦ This field is used to assign the tag name of the
accumulator (ACC) that the RES instruction is
being used to reset.
For example, if the RES instruction is being used to
reset LightTimer’s accumulator, then it will be
assigned the tag name LightTimer.ACC.
21
Reset (RES)
RES – Reset
?
RES
TON Operation with RES
RES – Reset Example with On-Delay Timer
A
B
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
0
(EN)
(DN)
LightTimer.ACC
RES
The above figure contains both an On-Delay Timer and
a Reset instruction that is linked to the timer’s
accumulator.
22
TON Operation with RES
RES – Reset Example with On-Delay Timer
A
B
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
152
(EN)
(DN)
LightTimer.ACC
RES
◦ When bit “A” goes high, the TON is enabled and it
begins counting.
TON Operation with RES
RES – Reset Example with On-Delay Timer
A
B
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
0
(EN)
(DN)
LightTimer.ACC
RES
◦ When bit “A” goes high, the TON is enabled and it
begins counting.
◦ If bit “B” goes high, the RES is enabled, causing
LightTimer’s accumulator to reset to 0.
23
TON Operation with RES
RES – Reset Example with On-Delay Timer
A
B
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
0
(EN)
(DN)
LightTimer.ACC
RES
◦ When bit “A” goes high, the TON is enabled and it
begins counting.
◦ If bit “B” goes high, the RES is enabled, causing
LightTimer’s accumulator to reset to 0.
(Note that the TON remains enabled when its ACC is reset)
TON Operation with RES
RES – Reset Example with On-Delay Timer
A
B
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
2764
(EN)
(DN)
LightTimer.ACC
RES
◦ When bit “A” goes high, the TON is enabled and it
begins counting.
◦ If bit “B” goes high, the RES is enabled, causing
LightTimer’s accumulator to reset to 0.
◦ When bit “B” goes low, the RES is disabled and the
TON begins counting again.
24
TON Operation with RES
RES – Reset Example with On-Delay Timer
A
B
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
60000
(EN)
(DN)
LightTimer.ACC
RES
◦ If the TON’s accumulator reaches 60,000 (60 sec), it stops
counting and the DN bit is set high (1).
TON Operation with RES
RES – Reset Example with On-Delay Timer
A
B
TON
Timer On Delay
Timer
LightTimer
Preset
60000
Accum
0
(EN)
(DN)
LightTimer.ACC
RES
◦ If the TON’s accumulator reaches 60,000 (60 sec), it stops
counting and the DN bit is set to “1”.
◦ If bit “B” goes high again, the RES is re-enabled, causing
LightTimer’s accumulator to reset to 0, in-turn causing
its DN bit to reset to 0.
25
Comparison Instructions
Within the RSLogix environment, there are many logic
instructions available whose states are based on a
comparison of two values.
These instructions include:
◦ GRT – Greater Than
◦ GEQ – Greater Than or Equal To
◦ LES – Less Than
◦ LEQ – Less Than or Equal To
◦ EQU – Equal To
◦ NEQ – Not Equal To
Greater Than (GRT)
GRT – Greater Than
GRT
Greater Than (A>B)
Source A
?
??
Source B
?
??
The Greater Than instruction is used to compare the two
values A and B.
26
Greater Than (GRT)
GRT – Greater Than
GRT
Greater Than (A>B)
Source A
?
??
Source B
?
??
The Greater Than instruction is used to compare the two
values A and B.
◦ If A>B, then the GRT returns a “True” logic state.
◦ If A≤B, then the GRT returns a “False” logic state.
Greater Than (GRT)
GRT – Greater Than
GRT
Greater Than (A>B)
Source A
?
??
Source B
?
??
The Greater Than instruction is used to compare the two
values A and B.
◦ Source A – The tag name of the location that contains
the value of A or the value of A
27
Greater Than (GRT)
GRT – Greater Than
GRT
Greater Than (A>B)
Source A
?
??
Source B
?
??
The Greater Than instruction is used to compare the two
values A and B.
◦ Source A – The tag name of the location that contains
the value of A or the value of A
◦ If the Source A field contains a Tag name instead of
an actual value, then this field shows the value
currently stored in the location defined by the Tag.
Greater Than (GRT)
GRT – Greater Than
GRT
Greater Than (A>B)
Source A
?
??
Source B
?
??
The Greater Than instruction is used to compare the two
values A and B.
◦ Source B – The tag name of the location that contains
the value of B or the value of B
28
Greater Than (GRT)
GRT – Greater Than
GRT
Greater Than (A>B)
Source A
?
??
Source B
?
??
The Greater Than instruction is used to compare the two
values A and B.
◦ Source B – The tag name of the location that contains
the value of B or the value of B
◦ If the Source B field contains a Tag name instead of
an actual value, then this field shows the value
currently stored in the location defined by the Tag.
GRT Operation
GRT – Greater Than Operation
GRT
Greater Than (A>B)
Source A LightTimer.ACC
Source B
0
20000
The GRT shown above is configured to compare the value
stored in LightTimer’s ACC to 20,000.
29
GRT Operation
GRT – Greater Than Operation
GRT
Greater Than (A>B)
Source A LightTimer.ACC
Source B
0
20000
The GRT shown above is configured to compare the value
stored in LightTimer’s ACC to 20,000.
◦ As shown, the current value stored in LightTimer’s
accumulator is 0.
GRT Operation
GRT – Greater Than Operation
GRT
Greater Than (A>B)
Source A LightTimer.ACC
Source B
13294
20000
The GRT shown above is configured to compare the value
stored in LightTimer’s ACC to 20,000.
◦ If LightTimer is enabled and counting, the value shown
below Source A will be the current value of its ACC.
30
GRT Operation
GRT – Greater Than Operation
GRT
Greater Than (A>B)
Source A LightTimer.ACC
Source B
13294
20000
The GRT shown above is configured to compare the value
stored in LightTimer’s ACC to 20,000.
◦ If the value of Source A is less than that of Source B (A<B),
then the GRT will return a “False” logic state.
GRT Operation
GRT – Greater Than Operation
GRT
Greater Than (A>B)
Source A LightTimer.ACC
Source B
22684
20000
The GRT shown above is configured to compare the value
stored in LightTimer’s ACC to 20,000.
◦ If the value of Source A is less than that of Source B (A<B),
then the GRT will return a “False” logic state.
◦ If the value of Source A is greater than that of Source B
(A<B), then the GRT will return a “True” logic state.
31