Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Shift Registers
b it s s h if t r ig h t
e x a m p le
0 0 0
31
0 0 0 0 0 0 0 0 0 0 0 0 0
5
n e w _ b it
A
B
F
C
B
L
LSB
00
c .U L
SR
ile e x a m p le
o n tro l c
it a d d r e s s n e w _ b it
e n g th 5
B S L - s h if t s le f t f r o m t h e L S B t o t h e M S B . T h e L S B m u s t b e s u p p lie d
B S R - s im ila r t o t h e B S L , e x c e p t t h e b it is in p u t t o t h e M S B a n d s h if t e d t o t h e L S B
entry gate
FIFO
LIFO
exit gate
entry gate
FIFO
FFL
s o u r c e w o r d _ in
F I F O s ta c k [ 0 ]
C o n tr o l c
le n g t h 5
p o s it io n 0
FFU
F I F O s ta c k [ 0 ]
d e s t in a t io n w o r d _ o u t
C o n tr o l c
le n g t h 5
p o s it io n 0
exit gate
LIFO
LFL
s o u r c e w o r d _ in
L IF O s ta c k [ 0 ]
C o n tr o l c
le n g t h 5
p o s it io n 0
LFU
L IF O s ta c k [ 0 ]
d e s t in a t io n w o r d _ o u t
C o n tr o l c
le n g t h 5
p o s it io n 0
Sequencers
Allow multiple outputs to be
changed in fixed patterns
SQ O
F ile s e q u e n c e [ 0 ]
M ask 0 0 0 F
D e s t in a t io n o u t p u t _ lig h t s
C o n tro l c
L e n g th 4
P o s it io n 0
S Q O ( s t a r t , m a s k , d e s t in a t io n , c o n t r o l, le n g t h ) - s e q u e n c e r o u t p u t f r o m t a b le t o m e m o r y
S Q I ( s t a r t , m a s k , s o u r c e , c o n t r o l, le n g t h ) - s e q u e n c e r in p u t f r o m m e m o r y a d d r e s s t o t a b le
S Q L ( s t a r t , s o u r c e , c o n t r o l, le n g t h ) - s e q u e n c e r lo a d t o s e t u p t h e s e q u e n c e r p a r a m e t e r s
lig h t _ p a t t e r n [ 0 ]
lig h t _ p a t t e r n [ 1 ]
0
0
0
0
0
SQ O
F ile lig h t _ p a t t e r n
M ask 0 0 3 F h
D e s t in a t io n lig h t s _ o u t p u t
C o n tr o l c
L e n g th 4
P o s it io n 0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
1
1
1
0
0
0
1
0
0
0
0
0
1
0
0
1
0
0
1
1
N
N
N
E
E
E
S
S
S
W
W
W
- re d
- y e llo w
- g re e n
- re d
- y e llo w
- g re e n
Problem:
Design a sequencer program that will have lights travel left to right
then back along a string of 5 lights.
C
L
D
L a b e l_ 0 1
LBL
I f A is t r u e , t h e p r o g r a m
w ill j u m p t o L B L :0 1 .
I f A is f a ls e t h e p r o
g ra m g o e s to th e n e x t
lin e .
Subroutines
M a in P r o g r a m
J S R ( J u m p s u b r o u t in e )
R o u t in e N a m e : T e s t S u b r o u t in e
In p u t p a r A
In p u t p a r B
R e tu rn p a r C
A s e p a r a t e la d d e r lo g ic p r o g r a m is s t o r e d in p r o g r a m f ile 3 . T h is
t u r e a llo w s u s e r s t o c r e a t e t h e ir o w n f u n c t i o n s . I n t h is c a s e
t r u e , t h e n t h e p r o g r a m b e lo w w ill b e e x e c u t e d a n d t h e n w h e n
t h e la d d e r s c a n w ill c o n t in u e a f t e r t h e s u b r o u t in e in s t r u c t io n . T
n u m b e r o f d a t a v a lu e s p a s s e d a n d r e t u r n e d is v a r ia b le .
fe a
if A is
done
he
S B R ( s u b r o u t in e a r g u m e n t s )
In p u t p a r X
In p u t p a r Y
T e s t S u b r o u t in e
RET
R e tu r n p a r Z
For-Next Loop
A
FO R
R o u t in e N a m e : L o o p R o u t in e
in d e x i
in it ia l v a lu e 0
t e r m in a l v a lu e 9
s t e p s iz e 2
L o o p R o u t in e
SBR
A D D
S o urc e 1
S o urc e i
D est j
B
BRK
N o t e : if A is t r u e t h e n t h e lo o p w ill r e p e a t 1 0 t im e s , a n d t h e v a lu e o f i w ill b e in c r e a s e d
b y 1 0 . I f A is n o t t r u e , t h e n t h e s u b r o u t in e w ill n e v e r b e c a lle d .
TN D
EN D
W h e n t h e e n d ( o r E n d O f F ile ) is e n c o u n t e r e d t h e P L C w ill s t o p s c a n n in g t h e
la d d e r , a n d s t a r t u p d a t in g t h e o u t p u t s . T h is w ill n o t b e t r u e if it is a s u b r o u t in e
o r a s t e p in a n S F C .
la s t _ b it _ v a lu e
O N S
A
M a in P r o g r a m
Fault Interrupt
B
C PT
D e st n [1 ]
E x p r e s s io n
n [n [0 ]] + 1 0
M O V
S o urc e -1 0
D e st n [0 ]
G SV
O b je c t: P R O G R A M
In s ta n c e : T H IS
A t t r ib u t e : M A J O R F A U L T R E C O R D
D e s t : f a u lt _ d a t a ( N o t e : D I N T [ 1 1 ] )
R ecover
EQ U
S o u r c e A f a u lt _ d a t a [ 2 ]
S o urc e B 0 x2 1 0 4
M O V
S o urc e 0
D e s t N 7 :0
C LR
D e s t . f a u lt _ d a t a [ 2 ]
SSV
O b je c t: P R O G R A M
In s ta n c e : T H IS
A t t r ib u t e : M A J O R F A U L T R E C O R D
D e s t : f a u lt _ d a t a
Disabling Interrupts
A
U ID
FA L
C o n tr o l c
le n g t h 5
p o s it io n 0
M o d e a ll
D e s t in a t io n n [ 5 + c . P O S ]
E x p r e s s io n n [ c . P O S ] + 5
U IE
in p u t _ v a lu e . 0 3 o v e r h e a t s e n s o r
o u t p u t _ v a lu e . 0 1 r e a c t o r s h u t d o w n
IIN
in p u t _ v a lu e . 3
in p u t _ v a lu e
o u t p u t _ v a lu e . 1
o u t p u t _ v a lu e
IO T
T h e s e a d d e d s t a t e m e n t s c a n a llo w t h e la d d e r lo g ic t o e x a m in e a c r it ic a l
in p u t , a n d a d j u s t a c r it ic a l o u t p u t m a n y t im e s d u r in g t h e e x e c u t io n o f
la d d e r lo g ic t h a t m ig h t t a k e t o o lo n g f o r s a f e t y
.
N o t e : W h e n t h e s e in s t r u c t io n s a r e u s e d t h e n o r m a l a s s u m p t io n t h a t a ll in p u t s a n d
o u t p u t s a r e u p d a t e d b e f o r e a n d a f t e r t h e p r o g r a m s c a n is n o lo n g e r v a lid .