Sie sind auf Seite 1von 21

Introduction to IEC1131-3 Ladder Diagram

Origins of Ladder Diagram


The Ladder Diagram (LD) programming language originated from the graphical representation used to design an electrical control system
Control decisions were made using relays

After a while Relays were replaced by logic circuits


Logic gates used to ma e control decisions

OR

AND

!inally C"#s were added to ta e o$er the function of the logic circuits
%&' De$ices wired to buffer transistors Control decisions accomplished through programming

CPU

Relay Logic representation (or LD) was de$eloped to ma e program creation and maintenance easier
Computer based graphical representation of wiring diagrams that was easy to understand Reduced training and support cost

What is a Rung?
A rung of ladder diagram code can contain both input and output instructions
%nput instructions perform a comparison or test and set the rung state based on the outcome
(ormally left )ustified on the rung

'utput instructions e*amine the rung state and e*ecute some operation or function
%n some cases output instructions can set the rung state (ormally right )ustified on the rung
%nput %nstruction 'utput %nstruction

Series Vs Parallel Operations


Ladder Diagram input instructions perform logical A(D and 'R operations in and easy to understand format
%f all %nput %nstructions in series must all be true for outputs to e*ecute (A(D) %f any input instruction in parallel is true+ the outputs will e*ecute ('R)

"aralleling outputs allows multiple operations to occur based on the same input criteria
A C A(D ,ranches D -

, 'R

IF ((A OR B A!D (!O" # A!D D "$%! %&'( F&' %!D)IF

Ladder Logi* %+e*ution


Rungs of Ladder diagram are sol$ed from Left to right and top to bottom ,ranches within rungs are sol$ed top left to bottom right
La!!er R"n A B F I G D Branch H E

Left Power Rail

Ri ht Power Rail

P
J

S
K

!on Retenti,e #oils


The referenced bit is reset when processor power is cycled
Coil .( ).
/ets a bit when the rung is true(0) and resets the bit when the rung is false (1) "LC2 calls this an 'T- 'utput -nable

(egati$e coil .( & ).


/ets a bit when the rung is false(1) and resets the bit when the rung is True(0) (ot commonly supported because of potential for confusion

/et (Latch) coil .(/).


/ets a bit (0) when the rung is true and does nothing when the rung is false

Reset (#nlatch) Coil .(R).


Resets a bit (1) when the rung is true and does nothing when the rung is false

#onta*ts
(ormally 'pen Contact .3 3.
-nables the rung to the right of the instruction if the rung to the left is enabled and underlining bit is set (0)

(ormally Closed Contact .3&3.


-nables the rung to the right of the instruction if the rung to the left is enabled and underlining bit is reset (1)

"ositi$e transition contact .3"3.


-nables the right side of the rung for one scan when the rung on left side of the instruction is true Allen ,radley "LC2 uses .4'(/5.

(egati$e transition contact .3(3.


-nables the right side of the rung for one scan when the rung on left side of the instruction is false

Retenti,e Vs !on-retenti,e Operation


Definitions
Retenti$e $alues or instructions maintain their last state during a power cycle (on.retenti$e $alues or instructions are reset to some default state (usually 1) after a power cycle

%-C0060 permits $alues to be defined as retenti$e


A contradiction to this is ladder diagram where 6 instructions are classified as retenti$e %n most "LCs only timer and coil instructions operate as non.retenti$e

Retenti,e #oils
The referenced bit is unchanged when processor power is cycled
Retenti$e coil .(7).
/ets a bit when the rung is true(0) and resets the bit when the rung is false (1)

/et Retenti$e (Latch) coil .(/7).


/ets a bit (0) when the rung is true and does nothing when the rung is false "LC2 uses 'TL 'utput Latch

Reset Retenti$e (#nlatch) Coil .(R7).


Resets a bit (1) when the rung is true and does nothing when the rung is false "LC2 uses '#T 'utput #nlatch

"ransition Sensing #oils


"ositi$e transition.sensing coil .(").
/ets the bit bit (0) when rung to the left of the instruction transitions from off(1) to on(0) The bit is left in this state "LC2 use '/R ('ne /hot Rising)

(egati$e transition.sensing coil .(().


Resets the bit (1) when rung to the left of the instruction transitions from on(0) to off(1) The bit is left in this state "LC2 uses '/! ('ne /hot !alling)

I%# #omparison Instru*tions in Ladder


%f the rung input (-() is enabled+ the instruction performs the operation and sets the rung output (-(') based on the comparison
-*ample8 when -( is true+ -9 (:) function compares %n0 and to %n; and sets -('

Comprehensi$e instruction set


-9(:)+ <T (=)+ <- (=:)+ LT (>)+ L- (>:)+ (- (>=)
EQ EN Tank1_Level IN1 100.000 Tank_max IN2 78.251 ENO

"imers in Ladder Diagram


There three timer instructions in %-C0060
T" . "ulse timer T'( . Timer 'n Delay T'! . Timer 'ff Delay
Pump_Tmr TON IN T#200ms PT Q ET 178

Time $alues
Time base is 0msec (0&0111 of a sec) ?alues entered using duration literal format
Pump_Tmr TON IN ENO Q T#200ms PT ET Pump_Tmr_DN

Two possible $isuali@ations Depending on use of -(&-('


0st method reAuires e*tra programming if timer done status needs to be referenced on other rungs ;nd method sets a bit with 9 which can be referenced by other logic+ -(':-(

178

"imer Operation
%( : Rung input condition 9 : Comparison output results
?aries with timer types
%" Pulse ("P "iming I! .
"T 3 1

"T : "reset Time -T : -lapse Time

On-Dela/ ("O! "iming I! . %"


"T 3 1

Off-Dela/ ("OF "iming I! . %"


"T 3 1

#ounters in Ladder Diagram


There three counter instructions in %-C0060
CT# . Count #p Counter CTD . Count Down Counter CT#D . Count #p&Down Counter
& 200 P% L"a#_ n$ IN T! ENO Q % L"a#_ n$_DN

All three count rung transitions Two possible $isuali@ations Depending on use of -(&-('
0st method reAuires e*tra programming if timer done status needs to be referenced on other rungs ;nd method sets a bit with 9 which can be referenced by other logic+ -(':-(

178

L"a#_ n$ T! IN & 200 P% % 178 Q

#ounter Operation
"arameters
C#&CD : Count up&Down 9&9#&9D : Comparison 'utput R : Reset to Bero LD : Load C? with "? "? : "reset ?alue C? : Count ?alue
I! .
"? #V 3 1

#ount 0p (#"0 #ounter

###

###

#ount Do2n (#"D #ounter #ount 0p1Do2n (#"0D #ounter #0 .0 #D .D #V


"? 3 1

###

I! .
"? #V 3 1

###

###

###

LD

R LD

%+e*ution #ontrol %lements


Cump & Label %nstructions
Cump to a label s ips a bloc of code without it being scanned L,L . (amed target for a )ump operation C7" . "erforms a )ump when the rung conditions are true
| Skip_Calc | |-| |-------------(JMP)--| | ... | | Skip_Calc | |---[LBL]---...

CALL & R-T#R( %nstructions


#sed to encapsulate logic and call it as a subroutine Causes e*ecution to change between functions or subroutines CAL . "asses control to another named function
"LC2 uses C/R

R-T . -*its a function and returns control bac to the calling routine

CAL CAL RE$ RE$

Different Instru*tion Presentations


The loo and feel of %-C 0060.6 is somewhat different from the 07illionD "LCEs that Allen ,radley has running in factories throughout the world
ADD So"rce A So"rce B De&tination $an1+(In +**#*** Off&etr ,-#).+ $an1(Le2el +,-#).+ $ON $i%er Pre&et Acc"% P"%'($%r )**#*** +,-#).+ /EN0 /DN0

P"%'($%r $ON IN ENO 5 $4)**%& P$ E$ P"%'($%r(DN

EN $an1+(In +**#*** Off&etr ,-#).+

ENO $an1(Le2el +,-#).+

+,-

%-C places the input parameters on the outside of the instruction bloc $s the "LC2 where they are presented inside of the bloc

%+tending the I%#''3'-3 Instru*tion Set


%-C0060.6 "ro$ides a $ery basic set of instructions to do simple operations (F0 Ladder Diagram %nstructions)
Data Type Con$ersion . Trunc+ %ntGtoG/int+ DintGtoGReal+ ,cdGToG%nt H ,oolean 'perations . ,it Test+ ,it /et+ 'ne /hot+ /emaphores H Timers & Counters . Ton+ Tp+ Ctu+ Ctd+ Ctud /imple 7ath . Add+ /ub+ 7ul+ Di$+ 7od+ 7o$e+ -*pt 7iscI 7ath . Abs+ /Art+ Ln+ Log+ -*p+ /in+ Cos+ Tan+ Asin+ Acos+ Atan ,it /hift . /hl+ /hr+ Ror+ Rol Logic . And+ 'r+ Jor+ (ot /election . /el+ 7a*+ 7in+ Limit+ 7u* Compare . <T+ <-+ -9+ L-+ LT+ (/tring . Len+ Left+ Right+ 7id+ Concat+ %nsert+ Delete+ Replace+ !ind Control . C7"+ L,L+ C/R+ R-T

All comple* operations are left to the user or $endor to define


!ile 'perations+ "%D+ Diagnostic+ !or&(*t Loop+ /earch+ /ort are not in %-C0060.6 -*tensions to the instruction set are permitted so that $endors can add instructions that their customers need All $endors ha$e defined their own set of e*tensions Roc well Automation controllers ha$e significantly more capability with o$er 061 Ladder %nstructions

I%#''3'-3 Load FIFO Logi*

%+tensions to I%# pro,ide *ode optimi8ation and ease of use

Ro*42ell Automation FIFO Load Instru*tion

&
'' Rungs of Logi* '7 Instru*tions $ours to *ode and de6ug ' Rung of Logi* ' Instru*tion 5inutes to *ode and de6ug

Ro*42ell Automation Instru*tion %+tension to I%#''3'-3


!%!' K L%!' . !!L+ !!#+ L!L+ L!# !ile math and search . !AL+ !/C Table operations . /RT+ /TD+ A?/eAuencers . /9%+ /9L+ /9'+ /D/ Diagnostics . DDT+ D!A+ !,C Compare . C7"+ 7-9 Compute . C"T+ (-< Data mo$es . 7?7+ C'"+ ,TD "rogram Control . A!%+ ('"+ 7CR+ T(D %nterrupt /er$ices . #%D+ #%Retenti$e Timer . RT' Ladder Loop %nstruction . !'R+ (JT "rocess . "%D 7otion . 61D instructions to perform closed loop ser$o control

Das könnte Ihnen auch gefallen