Professional Documents
Culture Documents
دورة تدريبية من سيمنز - الجزء الأول PDF
دورة تدريبية من سيمنز - الجزء الأول PDF
تابعونا على
" # !
hassanheha@yahoo.com
http://hassanheha.forumn.net
Siemens S7 300,400 !" #$% &$'( ) * + ,- .% / 012
%
Simatic M G < g / '. M : h ] T ' Hardware ; _# :< Q - &$'% [1W1 > # 012
Simatic S7 PLC L<2 ] Y %: ' manager
Simatic manager M : h
I: kF/ BT ' V5.4 1U U Kj Simatic s7 M G < g / 8 2 + $ %i %X1#
# License 6K$ Q - \ < 5 g ' SP3 1U 8 2 1 Q @ U Kj l#% < D
hassanheha@yahoo.com !/' < ^ %# Z# @ ] Y !" &%@ !< 2
4 MD 8 2 ? i K '. % 012 ] T
C Upload station , download , debug , Cross reference , new project , open project
EEEEE
U g / p +_ M
g / ] W' > % I/. Q - *o F &1K` > @ d / PLC 1? /1 Q - :# 2 W : ,. %:
W' > ] T k'9 3'. q % ` # : ' M < H%< Q @ Siemens simatic step 7 V5.4 SP3
M 6O< 6K M#F O p O _ ' 8 2 6K ]
M G < ' ]O winrar g / k :<2 ><# Siemens simatic step 7 V5.4 SP3 g / M %:
dGN CD-1 g / n D ><# CD-1 , CD-2 $% 1" r (%@ Q @ (1X1 g / ,. ? o
TU ' B. skip $ <K > " 6K + + Q - M6/ Q< : < ] Y %: >= setup _ Q @
!5< # Q< i 1 ] Y %: > >= ] Y %: M < ,J
<L 3 partition D $ <K K` $ <K3 <K ' extract >= image $ <K ' 7 Q - UY
OK >= partition c
I :< / 012 BT 1U' Hardware configuration &$' &T" !" 5?# 012 I @ dGW
M U / <K !< ? /1 / k K(^
/1 k K(^ , 5 &%#%X &T" / V<O# 012 Hardware configuation Q @ dGW
insert 7 y+ k'.
, ww 5 Rail MD &T" / V<O# 012 Rail $ <L/
OB-Organization block
N< > g / '. : B. T O ><# 3' g / ' CPU d 21 MD # M 1U'
&$'( M ST O ><# M # 1U' OB1 1U g / M # BT !2 2` c1 ' OB B. !" M
T O n '' ] Y %: T O < ( :# >= k'9 3'. M < M g / T O ><# l g / T O $'(
one cycle time I @ Z # g / &$'(
/ K wx '. Byte / K } '. Bit &% ' / K - 1U' G< / K (%@ 1U I b :< 2 > k'.
/ [1/ l . double word / K vr X'(F '. word
Integer numbers 6 $` 4 !/ D [1
!7 = > $ vr '. > $ wx ( - !U' i # @ $. !U'
wrt oD # @ o@ ,'( B( : B : ? !" < < / K wx % Y $`
signed integers &$ +^ Y $` !" |vr•x• Q - Avr•x} p' < !U'
unsigned integers 6 X1 $` !" |x€€v€' t p' <'
4!J M 5 < / 5< < % :" double integers 6 / K vr % Y $` .
L#150
$ % &
M - 15" ! < ' bit &% ' / K 'Y G< H1< Q @ >< !< !U 7 D :
012' M w 5< W' '. t 5< W' '. 5 ?/ H K. 5 @ M : B. Z '. / K
bit &% 1 / L H1< Q @ >< !< : U T/
4 Addressing o : /1 : b :</ ,. % 3 : MD M
4 Digital inputs oK%
CPU k Q6 ` % Q< ' t p' < !U' Byte > $ x ' k1K( I/. F $ I l Ix.y 4 M TK9
•'t p' <#' Byte MK ( bit / L > $ !5" y . r€€ '. wr• ,1 # ,. # :<
I0.2 - I10.7 - I127.5 4 oD
) Memory flags * + ,
M100.0 - M4.5 - M0.7 4 oD M F TK9 '
)Counters &
C1 - C10 - C126 4 oD CPU [1 ( %: > @1 < C F TK9 '
) Timers *+
T2 - T10 - T70 4 oD CPU [1 #< > @1 < T F TK9 '
4 / 1 Data block
DByDBXz.u 4 ! J M TK9 '
bit / L > $ u ' Data byte > $ z ' / c1 > $ 1U y l
DB10.DBX1.2 - DB100.DBX10.7 - DB120.DBX34.6 4 oD
A And
w , =3 ,1 # ,. % 3 </ c U ,1 # ! : >< ' 5 ! 1< Q @ M i1< @ MD !U'
4 oD ! J k'%
z=A And B
ABz
AAAAAAAAAAAAAAAA
ttt
ttw
twt
www
w 5 : A , B , 3- w 5 Z ,1 # 3 k'% TU
AN And Not
A B B' z
AAAAAAAAAAAAAAAAAA
twtt
wwtw
ttwt
ttww
O Or
ABz
AAAAAAAAAAAAAAAA
ttt
wtw
wwt
www
ON Or Not
A B B' z
AAAAAAAAAAAAAAAA
wwtt
wwtw
ttwt
wtww
X Exclusive Or
ABz
AAAAAAAAAAAAAAAA
ttt
wtw
wwt
tww
ABz
AAAAAAAAAAAAAAAA
wtt
ttw
twt
www
- Assign
R Reset
S Set
4 oD
SET
Q10.3 ‡
‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡
‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡
) ; ( [ X3# 5 Q \X ] Q ^ &*; 0_
) * 9 2 &*; # ^ &*; 0_
FR Enable Timer
4 oD
A I0.1•
FR T2
L Load Current Timer Value into ACCU 1 as Integer
4 1U ` TU M G < : &$16
L <Timer> where Timer : T1,T2,...,T256
Integer V i > $ M + !" Accumulator-1 !" # < M < M :< #'
4 oD
L T1
4 1U ` TU M G < : &$16
LC <Timer> where Timer : T1,T2,...,T256
BCD M + !" Accumulator-1 !" # < M < M :< #'
4 oD
LC T1
R Reset Timer
4 1U ` TU M G < : &$16
R <Timer> where Timer : T1,T2,...,T256
! '` W1 Q - # < W' &( @-' # < 0 #^ M :< #'
4 oD
A I2.3
R T25
SP Pulse Timer
4 1U ` TU M G < : &$16
SP <Timer> where Timer : T1,T2,...,T256
!N / # M G < M :< #'
4kD
A I 2.0
FR T1 //Enable timer T1E
A I 2.1
L S5T#10s //Preset 10 seconds into ACCU 1E
SP T1 //Start timer T1 as a pulse timerE
A I 2.2
R T1 //Reset timer T1E
A T1 //Check signal state of timer T1E
‡Q 4.0
4 1U ` TU M G < : &$16
SE <Timer> where Timer : T1,T2,...,T256
%< !N / # M G < M :< #'
4kD
A I 2.0
FR T1 //Enable timer T1E
A I 2.1
L S5T#10s //Preset 10 seconds into ACCU 1E
SE T1 //Start timer T1 as an extended pulse timerE
A I 2.2
R T1 //Reset timer T1E
A T1 //Check signal state of timer T1E
‡Q 4.0
L T1 //Load current timer value of timer T1 as binaryE
T MW10
LC T1 //Load current timer value of timer T1 as BCDE
T MW12
SD On-Delay Timer
4 1U ` TU M G < : &$16
SD <Timer> where Timer : T1,T2,...,T256
Kˆ M G # M G < M :< #'
4kD
A I 2.0
FR T1 //Enable timer T1E
A I 2.1
L S5T#10s //Preset 10 seconds into ACCU 1E
SD T1 //Start timer T1 as an on-delay timerE
A I 2.2
R T1 //Reset timer T1E
A T1 //Check signal state of timer T1E
‡Q 4.0
L T1 //Load current timer value of timer T1 as binaryE
T MW10
LC T1 //Load current timer value of timer T1 as BCDE
T MW12
4 1U ` TU M G < : &$16
SS <Timer> where Timer : T1,T2,...,T256
,FL Kˆ M G # M G < M :< #'
4kD
A I 2.0
FR T1 //Enable timer T1E
A I 2.1
L S5T#10s //Preset 10 seconds into ACCU 1E
SS T1 //Start timer T1 as a retentive on-delay timerE
A I 2.2
R T1 //Reset timer T1E
A T1 //Check signal state of timer T1E
‡Q 4.0
L T1 //Load current time value of timer T1 as binaryE
T MW10
LC T1 //Load current time value of timer T1 as BCDE
T MW12
SF Off-Delay Timer
4 1U ` TU M G < : &$16
SF <Timer> where Timer : T1,T2,...,T256
Kˆ M6" # M G < M :< #'
4kD
A I 2.0
FR T1 //Enable timer T1E
A I 2.1
L S5T#10s //Preset 10 seconds into ACCU 1E
SF T1 //Start timer T1 as an off-delay timerE
A I 2.2
R T1 //Reset timer T1E
A T1 //Check signal state of timer T1E
‡Q 4.0
L T1 //Load current timer value of timer T1 as binaryE
T MW10
LC T1 //Load current timer value of timer T1 as BCDE
T MW12
&% ' & T $' \ K^ % ' Q -' k K(^ % ' / M / 2' !U :< STU ,. > :
R : 5/. Q @ TO !5" N#.' 5 O/ & T MK ( / M %L< ] T #F :
5#( O # 3' k'9 3'. UT O >< " ! < ' : RLO </ Q @ % <: 3 !5" '
g / !" > < : b @ % @ I !" I b :</ 012' Kj , Q - T O < I X1< 3-
Load L
ŽL <Address
Kj - %: CPU @ : !< ' Status word M < 1 # 15" ` >2 VW ' 1U '
,1 <" / L . } Q< ' w / L !" 5 ><#' ] T $ <K M @ !" R % @ @
$ Oi.
ŽTransfer T <Address `
4 D.
T QB10
T MW32
T DB20.DBD48
T PQW446
Transfer contents of Accumulator-1 into Status word T STW `
Q" % < koK X ] Y 5?# 012' @ koK %L<2 '` D . U L,T , `'
S$'%
4 &$16 ` TK9#'
AW
AW Constant
ACCU2 / D M
' ACCU1 !" Q '` M ` M ><# l
4kD
L IW20 //Load contents of IW20 into ACCU 1-LE
L IW22 //Load contents of ACCU 1 into ACCU 2. Load contents of IW22 into
ACCU 1-LE
AW //Combine bits from ACCU 1-L with ACCU 2-L bits by AND; store result in
ACCU
AwLE
T MW 8 //Transfer result to MW8
AND M @ ><#' ACCU1 !" Q '` M < ><# Constant n = AND M @ !"'
4 ! J MD ACCU1 !" g ,1 #' > & +
OW OR Word :16-Bit
4 &$16 ` TK9#'
OW
OW Constant
4 &$16 ` TK9#'
XOW
XOW Constant
XOR M @ ><#' ACCU1 !" Q '` M < ><# Constant n = XOR M @ !"'
4 ! J MD ACCU1 !" g ,1 #' > & +
4 &$16 ` TK9#'
AD
AD Constant
4 &$16 ` TK9#'
OD
OD Constant
JP NEXT //Jump to NEXT jump label if result is not equal to zero, (CC 1‡
…w
4 &$16 ` TK9#'
XOD
XOD Constant
XOD M @ ><#' ACCU1 !" Q '` M < ><# Constant n = XOD M @ !"'
4 ! J MD ACCU1 !" g ,1 #' > & +
4kD
4kD
4kD
# : &$16 Q - O@ N ( 6
G6 Accumulator-1 #1< M#1 < 1 # 1U'
4!J M
A |x.ye+/-z
A|'B : *F y ' > V 6 *F 15" x . > : &$ +^ !U x M A | l
4 oD > $ 6<K %: wt > a. !U z ' a` &$ +- !U / D
Ae+4w•trs€€ 4 ! J MD Awtrs€•€
4kD
4 oD t Q - w M ' w Q - t M 1U M B( ` a1 : '
twttAwwttAttwwAwtwt 4 >
wtwwAttwwAwwttAtwtw 4 ,1 #
4kD
4kD
!" #1< #FL ' > !7 D a1 : Q - Accumulator-1 #1< M#1 < 1 # 1U'
Accumulator-1
w | B( ` a1 : 1U M !7 D a1 : '
wtwtAtttwAwttwAwtww 4 > oD
twtwAwwwtAtwwtAtwtt 4 B( `
twtwAwwwtAtwwtAtwtw 4 !7 D
4kD
4kD
4kD
4 Accumulator-1 #1< n/ Y- oD
4 ! J CAD k :<2 %: ,1 tttwAwtwwAwwwwAttwt
ttwtAwwwwAwtwwAtttw
4kD
RND Round
Y-' V i > $ ; . Q - I #1< M#1 < 1 #' B @ > $ Accumulator-1 #1< <:# ` TU
!X'F > ,1 # # < ,z" !X' ' B( " $ " _6/ !" ,
4kD
TRUNC Truncate
4kD
V i > $ Gi. Q - #1< # < 1 #' B @ > $ Accumulator-1 #1< <:# ` TU'
Accumulator-1 !" #1< ] #FL ' B : > B' # '. .
4kD
L MD10 //Load the floating-point number (32-bit, IEEE-FP) into ACCU 1-LE
RND+ //Convert the floating-point number (32-bit, IEEE-FP) to an integer (32-bit…
and round result. Store output in ACCU 1E
T MD20 //Transfer result (double integer number) to MD20
RND- Round to Lower Double Integer
Gi. V i > $ . Q - 5 #1 < 1 #' B @ > $ Accumulator-1 #1< <:# N#. ` TU'
Accumulator-1 !" g #FL ' B : > B' # '.
4kD
Comparison instructions 3
!" ! # < 2 <# RLO G ' ACCU1 , ACCU2 #1< ,$ 5 '` STU
4! < p
Comparison signs /$ o@
‡‡ACCU1 is equal to ACCU2
Ž‘ACCU1 is not equal to ACCU2
ŽACCU1 is greater than ACCU2
‘ACCU1 is less than ACCU2
‡ŽACCU1 is greater than or equal to ACCU2
‡‘ACCU1 is less than or equal to ACCU2
3 A ab > O Z # 3
Compare Integer 16-Bit - ? I
Format’
‡‡I, <>I, >I, <I, >=I, <=I
RLO G ' / K wx V i > $ &$1i !" ACCU1 , ACCU2 #1< /$ >< U'
<
4kD
‰ ' o: n/ #.
3 A de Q/ c > O Z # 3
Compare Double Integer 32-Bit
Format
‡‡D, <>D, >D, <D, >=D, <=D
G ' / K vr O@ N ( 'Y V i > $ &$1i !" ACCU1 , ACCU2 #1< /$ >< U'
< RLO
4kD
3 A de > S& Z # 3
Compare Floating-Point Number 32-Bit
Format
‡‡R, <>R, >R, <R, >=R, <=R
RLO G ' / K vr ( 'Y B @ > $ &$1i !" ACCU1 , ACCU2 #1< /$ >< U'
<
4kD
/5 J R ?*; 0 # 0f
O And before Or
O 4 !U 5 : G6 '
4! < Q D TU VN<#' 2 ANDing @ g7 </ Q @ ORing M @ ><# STU !"
A( And with Nesting Open
†A 4 5 : G6 '
Nesting Closed …
4 &$ +^ " (16 0 : &$16 Q - 3'. ? / ` >5O ' &$ +- " 0 < '. Q - ,J '
/ D ' X1 " '. Positive edge Q ' w Q - t k </3 % @ !U' Q '` " /% @ 5"
4!J G< TU 0 < 3 . c U' " Negative egde Q ' t Q - w k </3 % @
FN Edge Negative
FP Edge Positive
FR Enable Counter
4kD
4kD
L C3 //Load ACCU 1-L with the count value of counter C3 in binary format
4kD
LC C3 //Load ACCU 1-L with the count value of counter C3 in binary coded
decimal
format
CU Counter Up
4kD
A I 2.1 //If there is a positive edge change at input I 2.1
CU C3 //Counter C3 is incremented by 1 when RL0 transitions from 0 to 1
CD Counter Down
Yz" “ t “
. ( %: ' ;1 ‰ Z % @ “ w “ ( %: #1< f /z 1 # 1U'
2 > % . %:# 3' , 6 @ _ 1<# ( %: ,z" O6 Q - ( %: n i'
4kD
L C#14 //Counter preset value
A I 0.1 //Preset counter after detection of rising edge of I 0.1
S C1 //Load counter 1 preset if enabled
A I 0.0 //One count down per rising edge of I 0.0
CD C1 //Decrement counter C1 by 1 when RL0 transitions from 0 to 1 depending
on input
I 0.0
AN C1 //Zero detection using the C1 bit
Q 0.0 //Q 0.0 = 1 if counter 1 value is zero
I X1 c U # > < B. < << ,1 # g / T O ,z" 2 O
* g / !: M < q% # l U I @ q% </ 1U' : y+ TO g / ‰'
BT %#% , T5 , 1 @ Z# @ S%#% ><# Kj , Q - T O < I X1 >< : ‰ + </ Q @
I - UT#
Z# @ I - ; UT ><# BT , 1 : %L<2 ><# < !"' Loop ' Jump U , < @ #% U'
Q @ , ` % <:#' 0 .% ,. Q @ : $. U(%@ $` ' 0' @1 ,1 Label
M i O< ! # "' RLO T O < : </
JU Jump Unconditional
Format
JU jump label
jump label : Symbolic name of jump destination
B. </ Q - ? ,'( label , Q - k </3 ' g / T O < !: M < ><# : STU !"
block 8O/ !" label ' JU ` (1X' &$' W ? o @
4kD
A I 1.0
A I 1.2
JC DELE //Jump if RLO=1 to jump label DELEL MB10
INC 1
T MB10
JU FORW //Jump unconditionally to jump label FORW
DELE: L 0
T MB10
FORW: A I 2.1 //Program scan resumes here after jump to jump label FORW
JL Jump to Labels
Format
JL jump label
Ejump label Symbolic name of jump destination
(% # BT 1U' r€x ' t >$ %#% ><# l multiple jump (%:< =1 I @ Z # 1U'
< % @' =1 5X' %#% ><# ACCU1-L-L Byte #1< Q @ * I/. l =1 @ </
><# BT , label F @1 < JL ,1 # k'` $1 2 &%@ Q @ I< < ><# I/z" ` TU
#1< !" I - k </3 ><# BT , F @1 < JU ! < ,1 #' I - k </3
T U' w #1< n/ Y- I - k </3 ( # BT , F @1 < JU l D ' O6 ACCU1-L-L
D . ! < k D VW1# 012' w ; W <"3 #1< Q6 ` % M . K` ,1 # Q<
4
L MB0 //Load jump destination number into ACCU 1-L-L
JL LSTX //Jump destination if ACCU 1-L-L > 3
JU SEG0 //Jump destination if ACCU 1-L-L = 0
JU SEG1 //Jump destination if ACCU 1-L-L = 1
JU COMM //Jump destination if ACCU 1-L-L = 2
JU SEG3 //Jump destination if ACCU 1-L-L = 3
LSTX: JU COMM
SEG0: * //Permitted instruction
u
JU COMM
SEG1: * //Permitted instruction
u
JU COMM
SEG3: * //Permitted instruction
u
JU COMM
COMM: * //Permitted instruction
JC Jump if RLO = 1
Format
JC jump label
jump label Symbolic name of jump destination
Format
JCN jump label
jump label Symbolic name of jump destination
4kD
A I 1.0
A I 1.2
JCN JOVR //Jump if RLO = 0 to jump label JOVR
L IW8 //Program scan continues here if jump is not executed
T MW22
JOVR: A I 2.1 //Program scan resumes here after jump to jump label JOVR
Format
JCB jump label
jump label Symbolic name of jump destination
4kD
A I 1.0
A I 1.2
JCB JOVR //Jump if RLO = 1 to jump label JOVR. Copy the contents of the RLO
bit into the BR bit
L IW8 //Program scan continues here if jump is not executed
T MW22
JOVR: A I 2.1 //Program scan resumes here after jump to jump label JOVR
4kD
A I 1.0
A I 1.2
JNB JOVR //Jump if RLO = 0 to jump label JOVR. Copy RLO bit contents into the
BR bit
L IW8 //Program scan continues here if jump is not executed
T MW22
JOVR: A I 2.1 //Program scan resumes here after jump to jump label JOVR
JBI Jump if BR = 1
Format
JBI jump label
JNBI Jump if BR = 0
Format
JNBI jump label
JO Jump if OV = 1
Format
JO jump label
jump label Symbolic name of jump destination
w Q - … Overflow B. † OV / K G !" label F (% g / !" , Q - k </o 1U'
4kD
L MW10
L3
“I //Multiply contents of MW10 by "3u
JO OVER //Jump if result exceeds maximum range OV=1
T MW10 //Program scan continues here if jump is not executed
A M 4.0
R M 4.0
JU NEXT
OVER: AN M 4.0 //Program scan resumes here after jump to jump label OVER
S M 4.0
NEXT: NOP 0 //Program scan resumes here after jump to jump label NEXT
JOS Jump if OS = 1
Format
JOS jump label
jump label Symbolic name of jump destination
w Q - OS / L !" label F (% , Q - k </3 1U'
4kD
L IW10
L MW12
Iu
L DBW25
I|
L MW14
IA
JOS OVER //Jump if overflow in one of the three instructions during
calculation OS=1
See Note
T MW16 //Program scan continues here if jump is not executed
A M 4.0
R M 4.0
JU NEXT
OVER: AN M 4.0 //Program scan resumes here after jump to jump label OVER
S M 4.0
NEXT: NOP 0 //Program scan resumes here after jump to jump label NEXT
Note
In this case do not use the JO instruction. The JO instruction would only check the
previous -I instruction if an overflow occurred
JZ Jump if Zero
Format
JZ jump label
jump label : Symbolic name of jump destination
label F (% W1 Q - k </3 ><# CC 0 = 0 ' CC 1 = 0 !"
4kD
L MW10
SRW 1
JZ ZERO //Jump to jump label ZERO if bit that has been shifted out = 0
L MW2 //Program scan continues here if jump is not executed
INC 1
T MW2
JU NEXT
ZERO: L MW4 //Program scan resumes here after jump to jump label ZERO
INC 1
T MW4
NEXT: NOP 0 //Program scan resumes here after jump to jump label
NEXT
JP Jump if Plus
Format
JP jump label
jump label : Symbolic name of jump destination
4kD
L IW8
L MW12
I //Subtract contents of MW12 from contents of IW8A
JP POS //Jump if result >0 that is, ACCU 1 > 0
AN M 4.0 //Program scan continues here if jump is not executed
S M 4.0
JU NEXT
POS: AN M 4.1 //Program scan resumes here after jump to jump label POS
S M 4.1
NEXT: NOP 0 //Program scan resumes here after jump to jump label NEXT
JM Jump if Minus
Format
JM jump label
jump label : Symbolic name of jump destination
4kD
L IW8
L MW12
I //Subtract contents of MW12 from contents of IW8A
JM NEG //Jump if result < 0 that is, contents of ACCU 1 < 0
AN M 4.0 //Program scan continues here if jump is not executed
S M 4.0
JU NEXT
NEG: AN M 4.1 //Program scan resumes here after jump to jump label NEG
S M 4.1
NEXT: NOP 0 //Program scan resumes here after jump to jump label NEXT
Format
JPZ jump label
jump label : Symbolic name of jump destination
4kD
L IW8
L MW12
I //Subtract contents of MW12 from contents of IW8A
JPZ REG0 //Jump if result >=0 that is, contents of ACCU 1 >= 0
AN M 4.0 //Program scan continues here if jump is not executed
S M 4.0
JU NEXT
REG0: AN M 4.1 //Program scan resumes here after jump to jump label
REG0
S M 4.1
NEXT: NOP 0 //Program scan resumes here after jump to jump label NEXT
Format
JMZ jump label
jump label : Symbolic name of jump destination
Q - k </3 ><# CC 1=0/CC 0=0 or CC 1=0/CC 0=1 B. O6 B' # '. M. < !"
label F (% ,
4kD
L IW8
L MW12
I //Subtract contents of MW12 from contents of IW8A
JMZ RGE0 //Jump if result <=0 that is, contents of ACCU 1 <= 0
AN M 4.0 //Program scan continues here if jump is not executed
S M 4.0
JU NEXT
RGE0: AN M 4.1 //Program scan resumes here after jump to jump label RGE0
S M 4.1
NEXT: NOP 0 //Program scan resumes here after jump to jump label NEXT
Format
JUO jump label
jump label : Symbolic name of jump destination
L MD10
L ID2
D //Divide contents of MD10 by contents of ID2
JUO ERRO //Jump if division by zero that is, ID2 = 0
T MD14 //Program scan continues here if jump is not executed
A M 4.0
R M 4.0
JU NEXT
ERRO: AN M 4.0 //Program scan resumes here after jump to jump label ERRO
S M 4.0
NEXT: NOP 0 //Program scan resumes here after jump to jump label NEXT
LOOP Loop
Format
LOOP jump label
jump label : Symbolic name of jump destination
BE Block End
'. FC '. OB , * 12 T O < % Block * 5/z 1 # 1U' < !" BE G 6 TK9# ` TU'
,z" OB1 !" oD TU , 1 ' g / M G !" ! < ` Q - & + M < #' [1/ B. '. FB
! M T O < k <2 %@' H K. & Block k'. T O < *% ! :# TU
4kD
A I 1.0
JC NEXT //Jump to NEXT jump label if RLO = 1 , I 1.0 = 1
L IW4 //Continue here if no jump is executed
T IW10
A I 6.0
A I 6.1
S M 12.0
BE //Block end
NEXT: NOP 0
Continue here if jump is executed
4kD
'. U{ /- ><# B. M:O &(1X1 k '( * @%<23 M :< # ` TU ,. $ <@3 !" W1 #]T
g / T O !" 9 K CPU ! : 3 Q< * @%<23 M 5X $(-
4 J D` ] Y VN<# 012'
CALL FC6
Formal parameter Actual parameter
NO OF TOOL := MW100
TIME OUT := MW110
FOUND := Q 0.1
ERROR := Q 100.0
&(% > - !5" ”$ ` ,1 . FB MK ( I< ><# !U ` ,1 G< ,. l
TO< 1 > ] Q @ B1< # BT , 1 : '. G<
CALL FB99,DB1
Formal parameter Actual parameter
MAX_RPM := #RPM1_MAX
MIN_RPM := #RPM1
MAX_POWER := #POWER1
MAX_TEMP := #TEMP1
Call FB
Format
CALL FB n1, DB n1
* @%<23 ><#' g / / i Z# @ 5 @ > !< FB O m1 k '% * @%<23 %L< # ` TU
6 Data block DB %#% U #' 5 #1< RLO < ? ,'( d " address , 1 :
M !" U%: Q - UT O %: g / #l ! < M 8O O m1 % T O ,1 #' 5
Symbol F $ U{ @- > Y- UF '. 5 2 % * @%<2 #' !: g /
Passing parameters O m1 % Q - / #
X L 5X'' 5 oK% $( 6 %#% ><# ,. % * @%<2 % @ " G< ( M ,. l '
4 ! J k D MD 5
CALL FB99,DB1
Formal parameter Actual parameter
MAX_RPM := #RPM1_MAX
MIN_RPM := #RPM1
MAX_POWER := #POWER1
MAX_TEMP := #TEMP1
4 Kj k D
CALL FB99,DB2
Formal parameter Actual parameter
MAX_RPM := #RPM2_MAX
MIN_RPM := #RPM2
MAX_POWER := #POWER2
MAX_TEMP := #TEMP2
Call FC
Format
CALL FC n
Passing parameters O m1 % Q- / #
CALL FC6
Formal parameter Actual parameter
NO OF TOOL := MW100
TIME OUT := MW110
FOUND := Q0.1
ERROR := Q100.0
Call SFB
Format
CALL SFB n1, DB n2
4kD
CALL SFB4,DB4
Formal parameter Actual parameter
IN: I0.1
PT: T#20s
Q: M0.0
ET: MW10
Call SFC
Format
CALL SFC n
4kD
O Z # B / E* * ; &
4kD
L IW10
Load the value of IW10 into ACCU 1-L
L MW14
Load the contents of ACCU1-L into ACCU2-L
Load the value of MW14 into ACCU1-L
I|
Add ACCU 2-L and ACCU 1-L; store the result in ACCU 1-L
T DB1.DBW25
The contents of ACCU 1-L (result) are transferred to DBW25 of DB1
4kD
L IW10
Load the value of IW10 into ACCU 1-L
L MW14
Load the contents of ACCU 1-L into ACCU 2-L
Load the value of MW14 into
ACCU 1-L
IA
Subtract ACCU 1-L from ACCU 2-L; store the result in ACCU 1- L
T DB1.DBW25
The contents of ACCU 1-L (result) are transferred to DBW25 of DB1
4kD
L IW10
Load the value of IW10 into ACCU 1-L
L MW14
Load contents of ACCU 1-L into ACCU 2-L
Load contents of MW14 into ACCU1-L
Iu
Multiply ACCU 2-L and ACCU 1-L, store result in ACCU 1
T DB1.DBD25
The contents of ACCU 1 (result) are transferred to DBW25 in DB1
L IW10
Load the value of IW10 into ACCU 1-L
L MW14
Load the contents of ACCU 1-L into ACCU 2-L
Load the value of MW14 into ACCU 1-L
I
Divide ACCU 2-L by ACCU 1-L
store the result in ACCU 1: ACCU 1-L: quotient, ACCU 1-H: remainder
T MD20
The contents of ACCU 1 (result) are transferred to MD20
“ |D “ 4 !U %L<2o : G6
4kD
L ID10
Load the value of ID10 into ACCU1
L MD14
Load the contents of ACCU1 to ACCU2
Load the value of MD14 into ACCU1
D|
Add ACCU2 and ACCU1; store the result in ACCU1
T DB1.DBD25
The contents of ACCU 1 (result) are transferred to DBD25 of DB1
“ A D “ 4 !U • : G6
4kD
L ID10
Load the value of ID10 into ACCU 1
L MD14
Load the contents of ACCU 1 into ACCU 2
Load the value of MD14 into ACCU 1
DA
Subtract ACCU 1 from ACCU 2; store the result in ACCU 1
T DB1.DBD25
The contents of ACCU 1 (result) are transferred to DBD25 of DB1
“uD“4 • : G6
4kD
L ID10
Load the value of ID10 into ACCU 1
L MD14
Load contents of ACCU 1 into ACCU 2
Load contents of MD14 into ACCU1
Du
Multiply ACCU 2 and ACCU 1; store the result in ACCU 1
T DB1.DBD25
The contents of ACCU 1 (result) are transferred to DBD25 in DB1
Divide ACCU 2 by ACCU 1 as Double Integer 32-Bit : / D
g ACCU1 !" < W' ACCU1 #1< Q @ ACCU2 #1< ` TU 1 #
' < Status word G ! Kj . c U l ! 8 ' d "
Z k'%
“ D“4 • : G6
4kD
L ID10
Load the value of ID10 into ACCU 1
L MD14
Load the contents of ACCU 1 into ACCU 2
Load the value of MD14 into ACCU 1
D
Divide ACCU 2 by ACCU 1; store the result (quotient) in ACCU 1
T MD20
The contents of ACCU 1 (result) are transferred to MD20
“ | Ž Integer 32-bit ‘ “ 4 !U ` T5 : G6
4kD
L MD20
L MD24
|D
Add ACCU 1and ACCU 2; store the result in ACCU 1
L#-200|
Add ACCU 1 and -200; store the result in ACCU 1
T MD28
!" < W'' ACCU2 #1< Q - ACCU1 #1< " Wz |R : I<G i' ` TU 1 #
Z k'% < Status word G RLO Q @ =9< ,'( ACCU1
4kD
OPN DB10
L ID10
Load the value of ID10 into ACCU1
L MD14
Load the value of ACCU 1 into ACCU2
Load the value of MD14 into ACCU1
R|
Add ACCU2 and ACCU1; store the result in ACCU1
T DBD25
The content of ACCU1 (result) is transferred to DBD25 in DB10
4kD
OPN DB10
L ID10
Load the value of ID10 into ACCU1
L MD14
Load the value of ACCU 1 into ACCU2
Load the value of MD14 into ACCU1
RA
Subtract ACCU1 from ACCU2; store the result in ACCU1
T DBD25
The content of ACCU1 (result) is transferred to DBD25 in DB10
!" < W'' ACCU2 #1< !" ACCU1 #1< ; N 1 #' u R : I<G i ` TU
Z k'% ' < Status word G RLO Q @ =9< ,'( ACCU1
4kD
OPN DB10
L ID10
Load the value of ID10 into ACCU1
L MD14
Load the value of ACCU1 into ACCU2
Load the value of MD14 into ACCU1
Ru
Multiply ACCU2 and ACCU1; store the result in ACCU1
T DBD25
The content of ACCU1 (result) is transferred to DBD25 in DB10
4kD
OPN DB10
L ID10
Load the value of ID10 into ACCU1
L MD14
Load the contents of ACCU1 into ACCU2
Load the value of MD14 into ACCU1
R
Divide ACCU2 by ACCU1; store the result in ACCU1
T DBD20
The content of ACCU1 (result) is transferred to DBD20 in DB10
4kD
L ID8
Load value into ACCU1 - example: ID8 = -1.5E+02
ABS
Form the absolute value; store the result in ACCU1
T MD10
Transfer result to MD10 - example: result = 1.5E+02
4kD
OPN DB17
Open data block DB17
L DBD0
The value from data double word DBD0 is loaded into ACCU1
This value must be in the floating-point format
SQR
Calculate the square of the floating-point number 32-bit, IEEE-FP in ACCU1
Store the result in ACCU1
AN OV
Scan the OV bit in the status word for - 0
JC OK
If no error occurred during the SQR instruction, jump to the OK jump label
BEU
Block end unconditional, if an error occurred during the SQR instruction
OK: T DBD4
Transfer the result from ACCU 1 to data double word DBD4
L MD10
The value from memory double word MD10 is loaded into ACCU1
This value must be in the floating-point format
SQRT
Calculate the square root of the floating-point number 32-bit IEEE-FP
in ACCU1 Store the result in ACCU1
AN OV
Scan the OV bit in the status word for - 0
JC OK
If no error occurred during the SQRT instruction, jump to the OK jump label
BEU
Block end unconditional, if an error occurred during the SQRT instruction
OK: T MD20
Transfer the result from ACCU1 to memory double word MD20
ACCU1 !" < W' >= ACCU1 !" (1X1 > Exponential value ; 1 # ` TU
I -$ Z k'% ' < Status word G RLO Q @ =9< ,'(
4kD
L MD10
The value from memory double word MD10 is loaded into ACCU1
This value must be in the floating-point format
EXP
Calculate the exponential value of the floating-point number 32-bit, IEEE-FP
in ACCU1 at base e. Store the result in ACCU1
AN OV
Scan the OV bit in the status word for - 0
JC OK
If no error occurred during the EXP instruction, jump to the OK jump label
BEU
Block end unconditional, if an error occurred during the EXP instruction
OK: T MD20
Transfer the result from ACCU 1 to memory double word MD20
4kD
L MD10
The value from memory double word MD10 is loaded into ACCU1
This value must be in the floating-point format
LN
Calculate the natural logarithm of the floating-point number 32-bit, IEEE-FP
in ACCU1, Store the result in ACCU1
AN OV
Scan the OV bit in the status word for - 0
JC OK
If no error occurred during the instruction, jump to the OK jump label
BEU
Block end unconditional, if an error occurred during the instruction
OK: T MD20
Transfer the result from ACCU 1 to memory double word MD20
L MD10
The value from memory double word MD10 is loaded into ACCU1
This value must be in the floating-point format
SIN
Calculate the sine of the floating-point number 32-bit, IEEE-FP
in ACCU1 Store the result in ACCU1
T MD20
Transfer the result from ACCU1 to the memory double word MD20
4kD
L MD10
The value from memory double word MD10 is loaded into ACCU1
This value must be in the floating-point format
COS
Calculate the cosine of the floating-point number 32-bit, IEEE-FP
in ACCU1 Store the result in ACCU1
T MD20
Transfer the result from ACCU 1 to memory double word MD20
L MD10
The value from memory double word MD10 is loaded into ACCU1
This value must be in the floating-point format
TAN
Calculate the tangent of the floating-point number 32-bit, IEEE-FP
in ACCU1 Store the result in ACCU1
AN OV
Scan the OV bit in the status word for -0
JC OK
If no error occurred during the TAN instruction, jump to the OK jump label
BEU
Block end unconditional, if an error occurred during the TAN instruction
OK: T MD20
Transfer the result from ACCU 1 to memory double word MD20
4kD
L MD10
The value from memory double word MD10 is loaded into ACCU1
This value must be in the floating-point format
ASIN
Calculate the arc sine of the floating-point number 32-bit,IEEE-FP
in ACCU1 Store the result in ACCU1
AN OV
Scan the OV bit in the status word for -0
JC OK
If no error occurred during the ASIN instruction, jump to the OK jump label
BEU
Block end unconditional, if an error occurred during the ASIN instruction
OK: T MD20
Transfer the result from ACCU 1 to the memory double word MD20
ACCU1 #1< 5 X !< #' F ; ACOS Q @ Z # o 8O/
ACCU1 #1< 5 m !< #' F ; ATAN '
X ('% 8O/ < X ('% . ACCU1 #1< ('% %X1 o" #' F M? I/. R
|w ' A w p' <# B' F
S7 Q *( ; 3? C
4 ;1
% 1 %X $
Inputs
diameter1 Real diameter of conductor
diameter2 Real diameter of insulated wire
density1 Real Density of conductor
density2 Real Density of First layer
density3 Real Density of Second layer
length Real Length of wire
Temp
Outputs
L 3.14159
T #pi
L #diameter1
SQR
T #buffer1
L #buffer1
L #pi
uR
T #buffer2
L #buffer2
L 4.0
R
T #buffer3
L #buffer3
L 1000.0
R
T #section1
L #section1
L #density
uR
T #buffer1
L #buffer1
L 100.0
uR
T #buffer2
L #buffer2
L #length
uR
T #weight1
L #diameter3
L #diameter1
AR
T #buffer1
L #buffer1
L #3.0
R
T #thickness2
L #thickness2
L 2.0
uR
T #thickness1
L #thickness1
L #diameter1
|R
T #diameter3
L #diameter3
SQR
T #buffer1
L #diameter1
SQR
T #buffer2
L #buffer1
L #buffer2
AR
T #buffer3
L #buffer3
L #pi
uR
T #buffer4
L #buffer4
L 4.0
R
T #buffer5
L #buffer5
L 1000.0
R
T # section2
L #section2
L #density2
uR
T #buffer1
L #buffer1
L 100.0
uR
T #buffer2
L #buffer2
L #length
uR
T #weight2
L #diameter2
SQR
T #buffer1
L #diameter3
SQR
T #buffer2
L #buffer1
L #buffer2
AR
T #buffer3
L #buffer3
L #pi
uR
T #buffer4
L #buffer4
L 4.0
R
T #buffer5
L #buffer5
L 1000.0
R
T #section3
L #section3
L #density
uR
T #buffer1
L #buffer1
L 100.0
uR
T #buffer2
L #buffer2
L #length
uR
T #weight3
L #weight1
L #weight2
|R
T #buffer1
L #buffer1
L #weight3
|R
T #totalW
‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡
7 ( > #-' ) "'
hassanheha@yahoo.com
http://hassanheha.forumn.net