ladder funtion

16
pter - Advanced Ladder Logic Functions

Upload: moddy-cavallindo

Post on 31-Jan-2016

225 views

Category:

Documents


0 download

DESCRIPTION

PLS

TRANSCRIPT

Page 1: LADDER FUNTION

Chapter - Advanced Ladder Logic Functions

Page 2: LADDER FUNTION

Shift Registers

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

B S RF ile e xa m p leC o ntro l cB it a d d re ss ne w _ b itL e ngth 5

e xa m p le

3 1L S B0 0

5

b its shift right

ne w _ b it c .U L

B S L - shifts le ft fro m the L S B to the M S B . T he L S B m us t b e sup p lie dB S R - s im ila r to the B S L , e xc e p t the b it is inp ut to the M S B a nd shifte d to the L S B

A

Page 3: LADDER FUNTION

FIFO

LIFO

entry gate exit gate

Lines and Stacks

Page 4: LADDER FUNTION

entry gate exit gateFIFO

F F Lso urc e w o rd _ inF IF O s ta c k [0 ]C o ntro l cle ngth 5p o s itio n 0

F F UF IF O s ta c k [0 ]d e s tina tio n w o rd _ o utC o ntro l cle ngth 5p o s itio n 0

A

B

Page 5: LADDER FUNTION

LIFO

L F Lso urc e w o rd _ inL IF O s ta c k [0 ]C o ntro l cle ngth 5p o s itio n 0

L F UL IF O s ta c k [0 ]d e s tina tio n w o rd _ o utC o ntro l cle ngth 5p o s itio n 0

A

B

Page 6: LADDER FUNTION

Sequencers

Allow multiple outputs to bechanged in fixed patterns

S Q O (s ta rt,m a sk ,d e s tina tio n,c o ntro l,le ngth) - se q ue nc e r o utp ut fro m ta b le to m e m o ryS Q I(s ta rt,m a sk ,so urc e ,c o ntro l,le ngth) - se q ue nc e r inp ut fro m m e m o ry a d d re ss to ta b leS Q L (s ta rt,so urc e ,c o ntro l,le ngth) - se q ue nc e r lo a d to se t up the se q ue nc e r p a ra m e te rs

S Q OF ile se q ue nc e [0 ]M a sk 0 0 0 FD e s tina tio n o utp ut_ lightsC o ntro l cL e ngth 4P o s itio n 0

A

Page 7: LADDER FUNTION

Traffic Light Example

S Q OF ile light_ p a tte rnM a sk 0 0 3 F hD e s tina tio n lights_ o utp utC o ntro l cL e ngth 4P o s itio n 0

0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0

0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0

0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1

0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1

light_ p a tte rn[0 ]

light_ p a tte rn[1 ]

NS - red

NS - yellow

NS - green

EW

- redE

W - yellow

EW

- green

0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1

a d va nc e

Page 8: LADDER FUNTION

Problem:

Design a sequencer program that will have lights travel left to rightthen back along a string of 5 lights.

Page 9: LADDER FUNTION

Jumps and Labels

A

L B L

JM PL a b e l_ 0 1

If A is true , the p ro gra mw ill jum p to L B L :0 1 .If A is fa lse the p rogra m go e s to the ne xtline .

B

CL

DU

X

Y

Y

EZ

L a b e l_ 0 1

Page 10: LADDER FUNTION

Subroutines

A JS R (Jum p sub ro utine )

te s t

M a inP ro gra m

Te stS ub ro utine

R o utine N a m e : T e s tS ub ro utineInp ut p a r AInp ut p a r BR e turn p a r C

S B R (sub ro utine a r g um e nts )Inp ut p a r X

A se p a ra te la d d e r lo gic p ro gra m is s to re d in p ro gra m file 3 . T his fe ature a llo w s use rs to c re a te the ir o w n f u n c t io n s . In this c a se if A istrue , the n the p ro gra m b e lo w w ill b e e xe c ute d a nd the n w he n d o nethe la d d e r sc a n w ill c o ntinue a fte r the sub ro utine ins truc tio n. T henum b e r o f d a ta va lue s p a sse d a nd re turne d is va ria b le .

If ’ te s t’ is true the sub ro utine w ill re turn a nd the va lue s lis te d w illb e re turne d to the re turn p a r . F o r this e xa m p le the va lue tha t is in’Z ’ w ill b e p la c e d in ’C ’.

R E TR e turn p a r Z

Inp ut p a r Y

Page 11: LADDER FUNTION

For-Next Loop

F O RR o utine N a m e : L o o p R o utineind e x iinitia l va lue 0te rm ina l va lue 9s te p s ize 2

A D DS o urc e 1S o urc e iD e s t j

A

N o te : if A is true the n the lo o p w ill re p e a t 1 0 tim e s , a nd the va lue o f i w ill b e inc re a se db y 1 0 . If A is no t true , the n the sub ro utine w ill ne ve r b e c a lle d .

B R KB

L o o p R o utineS B R

Page 12: LADDER FUNTION

Ends and Temporary Ends

A

E N D

B X

W he n the e nd (o r E nd O f F ile ) is e nc o unte re d the P L C w ill s to p sc a nning thela d d e r , a nd s ta rt up d a ting the o utp uts . T his w ill no t b e true if it is a sub ro utineo r a s te p in a n S F C .

CT N D

DY

Page 13: LADDER FUNTION

One Shot Instructions

A

O N S

la s t_ b it_ va lue

B

A

B

Page 14: LADDER FUNTION

Fault Interrupt

C PTD e st n[1 ]E xp re ss io nn[n[0 ]] + 1 0

A

E Q US o urc e A fa ult_ d a ta [2 ]S o urc e B 0 x2 1 0 4

C L RD e st. fa ult_ d a ta [2 ]

M a inP ro gra m

R e c o ve r

M O VS o urc e 0D e s t N 7 :0

M O VS o urc e - 1 0D e s t n[0 ]

B

G S VO b je c t: P R O G R A MIns ta nc e : T H ISA ttrib ute : M A JO R F A U LT R E C O R DD e st: fa ult_ d a ta (N o te : D IN T [1 1 ])

S S VO b je c t: P R O G R A MIns ta nc e : T H ISA ttrib ute : M A JO R F A U LT R E C O R DD e st: fa ult_ d a ta

Page 15: LADDER FUNTION

Disabling Interrupts

U ID

XA

U IE

FA LC o ntro l cle ngth 5p o s itio n 0M o d e a llD e s tina tio n n[5 + c .P O S ]E xp re ss io n n[c .P O S ] + 5

B

Page 16: LADDER FUNTION

Immediate Inputs and Outputs

e .g. C he c k fo r nuc le a r re a c to r o ve rhe a t inp ut_ va lue .0 3 o ve rhe a t se nso ro utp ut_ va lue .0 1 re a c to r shutd o w n

inp ut_ va lueIIN

IO To utp ut_ va lue

T he se a d d e d s ta te m e nts c a n a llo w the la d d e r lo gic to e xa m ine a c ritic a linp ut, a nd a d jus t a c ritic a l o utp ut m a ny tim e s d uring the e xe c utio n o fla d d e r lo gic tha t m ight ta k e to o lo ng fo r sa fe ty .

inp ut_ va lue .3o utp ut_ va lue .1

N o te : W he n the se ins truc tio ns a re use d the no rm a l a ssum p tio n tha t a ll inp uts a ndo utp uts a re up d a te d b e fo re a nd a fte r the p ro gra m sc a n is no lo nge r va lid .