Professional Documents
Culture Documents
دورة تدريبية من سيمنز - الجزء الثانى PDF
دورة تدريبية من سيمنز - الجزء الثانى PDF
تابعونا على
hassanheha@yahoo.com
http://hassanheha.forumn.net
You can use the Shift instructions to move the contents of the low word of
accumulator 1 or the contents of the whole accumulator bit by bit to the left or the
right (see also CPU Registers)
Shifting by n bits to the left multiplies the contents of the accumulator by ”2 n+*
For example, if you shift the binary equivalent of the decimal value 3 to the left by
3 bits, you end up with the binary equivalent of the decimal value 24 in the
accumulator
If you shift the binary equivalent of the decimal value 16 to the right by 2 bits, you
end up with the binary equivalent of the decimal value 4 in the accumulator
The number that follows the shift instruction or a value in the low byte of the low
word of accumulator 2 indicates the number of bits by which to shift
The bit places that are vacated by the shift instruction are either filled with zeros or
with the signal state of the sign bit (a 0 stands for positive and a 1 stands for
negative G
The shift operations are unconditional, that is, their execution does not depend on
any special conditions
RLO %( 3 DP. - X
RLO ( 0YR X#
O 6'$ M'!O 24 J-" F" - 7 Analogue inputs i !%$ F 4 PLC F& , "$
: n M'!W . F" - ; ! ;! #
PIW 8&
PQW S0
: 0< 2 n 3 9 z0 L%
'! !" j | L" { Q# a !4 Bd ( ) 0LO " 0 K PIW 324 ( ) O!" M0 K " "# <" { Q
j 8 <hI PLC " _0&X M' N) 0 K D$ Reference H 0I '! ! j l /! p #
PQW 334_0 ( PLC _#0& ;! #
AN I 0.1
JC m001
L PIW 324
T PQW 334
JU m002
m001 : L PIW 324
L -1
*I
T PQW 334
m002 : BEU
" O 3 # # Analogue ' N " F" - 8 M'# " F" V `US , 04) 7 k!
• ` N ;) J-" F" - 2 # l
Shift Sign Integer (16-Bit) : SSI
3 9" :
L MW4
//Load value into ACCU1//
SSI 6
//Shift bits with sign in ACCU1 six places to the right//
T MW8
//Transfer result to MW8//
5e3 9"
L +3
//Load value +3 into ACCU1//
L MW20
//Load contents of ACCU 1 into ACCU 2. Load value of MW20 into ACCU1//
SSI
//Shift number is value of ACCU2-L-L => Shift bits with sign in ACCU1-L//
//three places to the right; fill free places with state of sign bit//
JP NEXT
//Jump to NEXT jump label if the bit shifted out last (CC 1) = 1//
Shift Sign Double Integer (32-Bit) : SSD
L MD4
Load value into ACCU 1
SSD 7
Shift bits in ACCU 1 seven places to the right, according to the sign
T MD8
Transfer result to MD8
5e 3 9"
L +3
Load value +3 into ACCU 1
L MD20
Load contents of ACCU1 into ACCU2 Load value of MD20 into ACCU1
SSD
Shift number is value of ACCU2-L-L => Shift bits with sign in ACCU1 three
places to the right, fill free places with state of sign bit
JP NEXT
Jump to NEXT jump label if the bit shifted out last ( CC 1) = 1
Shift Left Word (16-Bit) : SLW
Be 3 9"
[left]
L MW4
Load value into ACCU1
SLW 5
Shift the bits in ACCU1 five places to the left
T MW8
Transfer result to MW8
5e 3 9"
L +3
Load value +3 into ACCU1
L MW20
Load contents of ACCU1 into ACCU2. Load value of MW20 into ACCU1
SLW
Shift number is value of ACCU2-L-L => Shift bits in ACCU1-L three places
to the left
JP NEXT
Jump to NEXT jump label if the bit shifted out last (CC 1) = 1
Shift Right Word (16-Bit) : SRW
ACCU1-L ! " ;=4 % & BC ' < . ACCU1-L 24 ,!S! 760 ) 7 ~) ^%$ ƒ 8" "
CC0=0 , CC1=0 , OV=0 ;=4 EV f dddd G €hW
Be 3 9"
L MW4
Load value into ACCU1
SRW 6
Shift bits in ACCU1-L six places to the right
T MW8
Transfer result to MW8
5e 3 9"
L +3
Load value +3 into ACCU1
L MW20
Load contents of ACCU1 into ACCU2. Load value of MW20 into ACCU1
SRW
Shift number is value of ACCU2-L-L => Shift bits in ACCU1-L three places
to the right
SPP NEXT
Jump to NEXT jump label if the bit shifted out last (CC 1)=1
Shift Left Double Word (32-Bit) : SLD
EV# 0LO €hW ACCU1 ! " 6 ;=4 SLD 3 - . 3 ( ) % & :5 76' ) 7 ~)#
CC1=0 , CC0=0 , OV=0
Z 9"$
Example 1
L MD4
Load value into ACCU1
SLD 5
Shift bits in ACCU 1 five places to the left
T MD8
Transfer result to MD8
Example 2
L +3
Load value +3 into ACCU1
L MD20
Load the contents of ACCU1 into ACCU2
Load value of MD20 into ACCU1
SLD
Shift number is value of ACCU2-L-L => Shift bits in ACCU1 three places
to the left
JP NEXT
Jump to NEXT jump label if the bit shifted out last CC1=0
Shift Right Double Word (32-Bit) : SRD
EV# 0LO ACCU1 ! " €hW % & :5 , -. ACCU1 ! " ) 7 ~) ^%$ ƒ 8" "
CC1 , CC0 , OV
Z 9"$
Example 1
L MD4
Load value into ACCU1
SRD 7
Shift bits in ACCU1 seven places to the right
T MD8
Transfer result to MD8
Example 2
L +3
Load value +3 into ACCU1
L MD20
Load contents of ACCU 1 into ACCU 2. Load value of MD20 into ACCU1
SRD
Shift number is value of ACCU2-L-L => Shift bits in ACCU1 three places
to the right
JP NEXT
Jump to NEXT jump label if the bit shifted out last (CC 1)=1
ACCU1 '(
0# - M04! 0" #c
; V ~)# NOP ^%PV F" - 0"c ;=4 ‰ d ‰ D# 760 ; V ~)# :5 2Q ˆnumber‡ 760 6 (W6$
Oc < D# 2] J 760 ;=4 :5 760
RLD €1! 2 F
Z 9"$
Example 1
L MD2
Load value into ACCU1
RLD 4
Rotate bits in ACCU 1 four places to the left
T MD8
Transfer result to MD8
Example 2
L +3
Load value +3 into ACCU1
L MD20
Load contents of ACCU1 into ACCU2. Load value of MD20 into ACCU1
RLD
Rotation number is value of ACCU2-L-L => Rotate bits in ACCU1
three places to the left
JP NEXT
Jump to NEXT jump label if the bit rotated out last (CC1) = 1
Rotate Right Double Word (32-Bit) : RRD
"$ RRD 0"c 2 DE 760 D# " % & , -. % ACCU1 ! " 0 # . 0"c EQ !<
2 CC1 " ACCU2-L-L ! D# " % & , -. 0 # 7 4 ,0L " 0"c ( $ ~)
7 2 % <. 3 % JK 0L 7 2 % `F" 7 # J ) 7 % & 0&T 6 ( D!
% J )
r 84 :5 760 ; V ~)# NOP ^%$ ( F" - 0"c ;=4 0LO RRD 0"X -. 760 ; V ~) † $
ACCU1 ! " 6 24 0 K
Z 9"$
Example 1
L MD2
Load value into ACCU1
RRD 4
Rotate bits in ACCU1 four places to the right
T MD8
Transfer result to MD8
Example 2
L +3
Load value +3 into ACCU1
L MD20
Load contents of ACCU1 into ACCU2. Load value of MD20 into ACCU1
RRD
Rotation number is value of ACCU2-L-L => Rotate bits in ACCU1 three places
to the right
JP NEXT
Jump to NEXT jump label if the bit rotated out last (CC1) = 1
Rotate ACCU 1 Left via CC 1 (32-Bit) : RLDA
CC0,OV " FV 0 LW # 3 ()M # % & CC1 " ACCU1 ! " 0 # . 0"c EQ !<
EL F N €1! 2 F
Z 3 9"
L MD2
Load value of MD2 into ACCU1
RLDA
Rotate bits in ACCU1 one place to the left via CC1
JP NEXT
Jump to NEXT jump label if the bit rotated out last (CC1) = 1
Z 3 9"
L MD2
Load value of MD2 into ACCU1
RRDA
Rotate bits in ACCU1 one place to the right via CC1
JP NEXT
Jump to NEXT jump label if the bit rotated out last (CC 1) = 1
/0
V 0VE . b&$# % W 24 M,!S!" V 2-6 # _~! % !Q %)# 21 0 4 3 9" l H hp
Y " O D$ #$ ` .0JV 8. V #$ {8 $ O J. 2
Z2 F . F. V J M0 h. J 7 V jEQ ;$ q
M1-M2-M3-M4-M5 V0 " & 4 3#c F " €1 # !Q V#
Z 2 n V JL] \#
Z n € L D! FK € L" !
Emergency stop - Stop - Start - Jog forward - Jog reverse - Traverse right
Traverse left - Traverse reverse direction - Fault reset
Z n ; h h ( D! #
Emergency stop - Machine fault - Machine ready - Machine run - Traverse right
Traverse left
1 2( " 3 4
Z . O 8& Z X#$
Emergency stop button
Reset fault button
M1 drive fault
M2 drive fault
M3 Overload
M4 Overload
M5 Overload
Z0 ! FK ' N) Z X#$
Main motor M1 Run
Main Motor M1 JOG forward
Main motor M1 JOG Reverse
Z Indication lamps ; h h Z %Y
Fault lamp
Ready lamp
Run lamp
Traverse to right lamp
Traverse to left lamp
Z2n F 2Q#
Z Analogue outputs 0\ S0
Z2n F #
7 W 24 ( #c 0 a EJ.#
1 2( #$ 4
Z -4 " 8 %! 2Q % 9 0
Z 2 n <. hƒ U k! #
Rail : 6ES7390-1AB60-0AA0
Power supply PS 307 10A : 6ES7307-1KA00-0AA0
CPU 314 : 6ES7314-1AE01-0AB0
Digital input module SM321 ( 32DI x 24 VDC ) : 6ES7321-1BL00-0AA0
Digital input module SM321 ( 32DI x 24 VDC ) : 6ES7321-1BL00-0AA0
Digital output module SM322 ( 32DO x 24 VDC 0.5 A ) : 6ES7322-1BL00-0AA0
Analogue input module 8 channel SM331 ( AI 8x13 bit ) : 6ES7331-1KF00-0AB0
Analogue output module 4 channel SM332 ( AO 4x12 bit ) : 6ES7332-5HD00-0AB0
Z 2 n V Digital outputs # #
Z 2 n V Analogue inputs # ;! #
PIW 304
PIW 306
PIW 308
PIW 310
PIW 312
PIW 314
PIW 316
PIW 318
Z 2 n V Analogue outputs # ;! #
PQW 320
PQW 322
PQW 324
PQW 326
89" -L !"0 " 2S' F O! 2Q M!p
Z2 F 24 FC1 ! "F N
Z2n F #FK F #$ M0 h U J 2Q -
3 # 'E 3#U%# 4' e
3#U Q0 0 # F M0 h ; 'E H u# € 4 e
Z n s#0 . 7 - jEQ
f M 1.0 G Fp D$ { Q ;! X ;$ .X e
Q $ •<4 3#U # 40 89" a6! lL% 24 ; . < " ; 7 Xe
fFK 24 a G L6! " V ;! ;$ .X e
E , Limit switch " V0 2J e
M0 h < X ( FL c ; 'E 1# 24 ( ) 7 X € L e
S1,S2 -. F" ;! ;$ .X D$ } O0 ,# ( F" ;$ I 7 X H K # € L e
- . < FC2 ` %) 7
Z ~ E L 3 9" €1! n 3 Nc
2n FK 7Y m # "x # M0 h F K X#$
jE L |06 2 4#
EQ 7 # QE L 7 4 X)# QE L 7 ( OB1 24 J . V 7 2 0" #c jEQ FV 2 % ;$ 2<.
f I h jEJ. J . 24 '!"c ;! ;$ '$# G 2 F ( 24 ` X
Q •K1 F
' & 7Y M'!W 24 €1! ' &X H 0I Simatic manager H 0I t" %0h 47
m
% *(5 6 3 78 9 :'
L \! 3 # " L i !%c ` e
OB1 F& , function blocks FBs, SFBs or functions FCs, SFCs
( -" ~ J V# Bytes A #$ Words 5 #$ bit :5 !Q Data block %! " " F" - (W6c 7
f < 40- G F 9 24 < 0I M'# . 24 1#$# Hh V 0 K i !%$ " i!% F # #
Bit , Word , DoubleWord ! " ( F" - % %=4 Data block " F" - #
Data block 10 Z 89"
DB10.DBX2.0 Z 2 n V ;! Bit
DB10.DBW2 Z 2 n V ;! Word V #
Lower ;$ ƒ 8" " " € O EJ4 MW0+MW1 " ;! MD0 ;$ }!W . ^ 0V~ " EV
MW0 l # MW1 ;! word
data block 24 Double Word #$ Word 76' !J4 <h " 0V~ V Address M ] 4#
O I 20.0
O I 20.1
O I 20.2
O I 20.3
O I 20.4
O I 20.5
O I 20.6
O I 20.7
R M 10.0
AN I 20.0
AN I 20.1
AN I 20.2
AN I 20.3
AN I 20.4
AN I 20.5
AN I 20.6
AN I 20.7
S M 10.0
Z 0"c
L IB 20
L0
@@I
S M 10.0
L IB 20
L0
ˆ‡I
R M 10.0
L STW 3
RND 3
Bd ( ) 0< 7 Bd‹Œ Z 89" 2S# € O 76' /06c 0< 7 mW% D$ " d‹Œ 0 ; V ;)#
E Q# B5 ( ) ^h 0< 7 4 BB‹Œ "$
L PIW 3 @ L IW 3
F< . !< # Digital input module 2 6' 3! ,!" " Digital input word F . !< L IW 0"c
Accumulator-1 24 <
Accumulator-1 F& , integer F N 24 Analogue input word F . !< 4 L PIW 0"c "$
multiple jump 3
# ACCU1-L-L 24 ' 0< ~ 7 J ` .2 < F 7 ^%=4 multiple jump 0"c
5ŒC J (W6c # Word a # Byte 2J4 S ~ ƒ 8"
l # •<4 t" %0h 24 V "c !"' ,0 " 2J4 LSTX , SEG0 , SEG1 , COMM , SEG3 !"0
0&T wN D$ ( 3! " D$ J
Status word
7 <p " 0&T % U 7 q Result of Logic Operation 3 ' W & 2Q# RLO 89"
E Q# AND,OR,NOT,XOR 4#0- <p - " D$ " J 4 QE L
AB ,CD 9 :'
7 <p " 0&n <hI J 6 0 K q Result of Logic Operation Q -"# RLO % & J "
RLO 6 ;! ‰ d ‰ a% V ~)# ‰B ‰ # " RLO 6 ;! ‰ B‰ a% V ~=4 QE L
‰d‰ # "
0" #$ " 0"$ FV " Q0VE. !<% 0 K jEQ FV# t] <hI 0 K „0&$ % & † $ J 4#
"0h
Jump )
"F " F . jE L 7 DE # t" %0h 2- hp F p6 !Q J V Jump 0" #$ " 2 ]0 k J
'0 - M'# 24 ^ 1! 7 DE 0 u 0&T F . € 1! Q 3# $ k! # ^ DE 7Y 0p 3#$
8 lL%
t" %0h 24 , " 0&T ; " ( ) 3 < %X # t" %0h 2- hp F p6 !Q 6 V k J 4
;#, 3 < %X H< q s#0 " 0 u #$ -" s0N H< ( 2 h" ^%$ D$ I#0 " 3 < %X EQ ;! 6#
s#0N Dc 0ƒ
Z 0"c . ph 0" M0 9V ` N$ " .84 Q 2 .#
a001: NOP 0
JU a001
AN I 0.1
JC a001
JU a002
a001: L 100
T PQW 220
JU a003
a002: L 500
T PQW 220
JU a003
a003: NOP 0
BE
3 < %X #$ JZ 0LO a% V ;) 3 < %X F9" RLO 0 u „0&$ s#0N ( - „0&$ i !%$ { Q#
( - " Q0 u# JN h a% V ! #$ JP hS!" a% V ! #$ JNZ 0LO 7 ;)
“' 24 F O L ( ) i!S0 # CC0,CC1,BR 2Q# Status word 24 „0&c %
J V 0" #c .}
L DBW25 3
SRW 1 3
BOOL
Q0 u# AND-OR-NOT-XOR J "#
L MW20
L MW22
AW
T MW8
0" #c " ! "F "F EQ # D, - And 0"c ^. !< " ^ L% !Q 0"c EQ ^. !< " ;=4
Z2nV
Z 2 n V 1! ;! 4, - And 0"c . <. -.'c '!p D ! " . V %,'$ !
A M20.0
A M22.0
@M 8.0
A M20.1
A M22.1
@M 8.1
A M20.2
A M22.2
@M 8.2
A M20.3
A M22.3
@M 8.3
A M20.4
A M22.4
@M 8.4
A M20.5
A M22.5
@M 8.5
A M20.6
A M22.6
@M 8.6
A M20.7
A M22.7
@M 8.7
A M21.0
A M23.0
@M 9.0
A M21.1
A M23.1
@M 9.1
A M21.7
A M23.7
@M 9.7
Accum-1 F& , j -. 2 < F<% 7 Load 0"$ 3#$ ;=4 Accumulator1,2 ! " }!W . "$
F& , M < F . !< # Accum-2 ( ) Accum-1 ! " F< 2 Load 0"c #
jEQ 24 Fƒ # Accum-1 F& , ^ U 7 4 AW F9" M0 &c - t % "$# Accum-1
0 K ;#, Accum-2 ! "
FR 3
M'!W 24 ^-† 760 24 j . !< " a%$ , # € O 76' F . !< %$ W< a V ! "$
q BCD F N E&P 2 # a6! . O Word F& , ; h F N ! 40-" "U J4 h
^ 4' ( ) . 0 760 . ’’’ ‘ ddd . |# 0 # a6! 6 F9 2 # 6'$ : " ;!
J 6 X# " " 0 u bit-14,bit-15 . bit-12,bit13 Q# a6! M 6 ;89 ; % &
Z2 ! ( bits-12,13 6 ( ` . a6! M 6 7 #
msBd ˆee dd
msBdd ˆee dB
sB ˆee Bd
sBd ˆee BB
0 Bd 2 ! 0 ", 7 % %$ Ž 8% ;$ X#$
Program control t" %0h ^ S! 3 N$ " M0 9V 3 NP. ~ 4 PLC F& , EJ. E L "$
" HI " Bd ( ) Data block 7 < 7Y Bd ( B " 6'$ ` p ) 4 instructions
6 ( ` . Jump €hW q . Structure F N 24 J #F lL% J
muliple #FK " 8 % h FV F . !< DE # t 76' ( 3 0W -
jump
( H / (+ / ? In FA J / ^ -) J \#) _ #
;C N( ` U O' J 54 1( ( Ia ( H Outputs O * 1R 8 J G'C(
5 J 8(+ 1( ( X N( b H \ ' V.# O * FA J *(+
Buffers +'
< JD #$ O 8 K UO j 54 # ) ' F$
y=ax^2+bx+c
< H 6'
y1=(-b+SQRT(b^2-4ac)/2a,y2=(-b-SQRT(b^2-4ac)/2a
) =:' " / UH 0 # k ;C
In FA a,b,c 1
Out O * y1,y2 1
temp Z' ; G'C ( ,A 5 J *(+ 1( U \ 'H
o ) h ,CD % p( 1 I # qh K) U . 1( F TU . 1( KU 'J OB )
OB r( ' 4) h
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
] , 7V )# • <4#
hassanheha@yahoo.com
http://hassanheha.forumn.net