You are on page 1of 85

‫لتحميل المزيد من الكتب والمراجع باللغة العربية‬

‫تابعونا على‬

‫صفحة موسوعة الهندسة الكهربية على الفيس بوك‬


‫‪Electrical Engineering Encyclopedia-Arabic‬‬
‫‪www.facebook.com/EEE.Arabic‬‬
‫‪-------------------------------------------------------‬‬
‫جروب موسوعة الهندسة الكهربية على الفيس بوك‬
‫‪EEE-Arabic‬‬
‫‪www.facebook.com/groups/EEE.Arabic‬‬
Siemens S7 300,400

" # !

hassanheha@yahoo.com

http://hassanheha.forumn.net
Siemens S7 300,400 !" #$% &$'( ) * + ,- .% / 012

5 6' 5 7 '% 829 " : ;$%< ,1 # ,. % 3 4 3'.


C B @ !2 % C !7 D C B : A > < >?/ @ 1 ' & " ;$%< % @ ,1 # ,. % 3 4 / =
EEE
#F /3 G @ 1 ' " : ;$%< H% ,1 # ,. % 3 4 D =
I 6 '!J 2 1 ' " : ;$%< H% ,1 # ,. 4 : $
&( <: 5 7 '% %L<2 #( : > < >? 2 " : ;$%< H% ,1 # ,. MNO# 4 K
/ 1 !" $16 '. P / B. Q @ G< !" #F: ' R ;$%< H% ,1 # ,. % 3 4 2( 2
&$'% STU $1N VW ' 0%U (1X'' U Y Z < '

7 ( > #-' ) "'


4 &$'% /
) * + ,- 1# %: 1# %#%X [1W1 \ $(- ><# 012 A
] Y %: Z # 5 - [1X / ^ _ +$` Q - @1W1 M / ><# 012 A
a$% > >23 </ >= EEE A > $ a$% >2 @1W1 ! :/ 012 A
b : # '. @1W1 #1 < ] Y' $ 'F ' * N@` &1K` :< ' ('( ?< / 012 A
! < a$% ( : !" 5 b @' D . W1 M @ +$' c U ,1 # 012 * 5</3 %: A
Q@ X^ M2 ' I O/ $ <K !" R # d , < b @ ><# 012 & K` !" A
Xe ! ' B ?/ 5X' X^ TU Y- ( ! < M2$. 012' ! f L %#

%
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 &( <: O _7 m' I " % 012 '% #1 M MD Simatic manager g / '


EEEE C Open , new , close , save , save as , delete , print

4 MD 8 2 ? i K '. % 012 ] T
C Upload station , download , debug , Cross reference , new project , open project
EEEEE

&%@ 2 5?# 012 5 B. Q @ a' O ' Y- *% ++Q@ /1 #` %#%: % / 012'


&(% /1 #` O m' , d

c 5X Q @ g / M#F < n Y- I @ 0 :< D TK9# 1@ ` TU

Z"$. 012' ] Y V W1< ( * X Simatic manager g / @ D . M 6O !" *o F R$ Y-


Simatic manager g / Z :<# X #F /3 G ' $16 ' M 6O< p # _

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

I 2 _ %X1# winrar g / V<O# 012' I " ,'( g / M G < > " 6K g / @ .


free g / MG+' ] T I: M .' winimage g / M < 1 # 012' I @ dGW winimage
winimage M + 5 @ /1 #. M # _ % 012 M < g / * 5</ %: ' c U8 '
V<O# 012 _ TU Q @ dGW 6K _ !U'

<L 3 partition D $ <K K` $ <K3 <K ' extract >= image $ <K ' 7 Q - UY
OK >= partition c

Simatic s7 2 1 g / M @ O !" :" .% / 012 ,`


,. # #% ] T PLC M :< d 2' ,J #% ,1 # ,. g / M#F < ,. %: b' O
I < / 012 BT g / I " TO /

S7-300 [1 [' TU M: ' [' k'. * /- O !" .% / ,J '


BT ? ,. b <O %#% < 5@1/' 5 %L< / 012 !< Inputs/Outputs (%@ %#% < 1 / 3'. A
Outputs A \ K rt (%@' A Input A MK( st I #%
4!J o /1 %#% < 1 / 012 ] Y Q @ * A
Siemens - 5A ! 5 %5X $%6 u
CPU S7-314 &% ' u
Digital input module 16 input 24 VDC 0 wx MK( k1#(1 v (%@ u
Digital output module 16 output 24VDC/0.5A 0 wx \ K k1#(1 r (%@ u
I @ /1 n D< Rail c $ u
file --> new project 7 $ <L/' g / V<O 1 /

example1 ' %#% [' >2 MK%/


KI / X ,1 ' [' &T" / V<O#' example1 >23 %#%X [' V<O g / 1 # 012
s7-300 plc <K >= station <K insert 7

PLC S7-300 1? MD # Kj 2 [' >2 n 5?# 012

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/

a' $F ' I @ _ / Power supply %5 $%6 1 wA> $ , /1 MK%/ ] Y %: '


5 :<2 %5 $( 6 [ 1/. M 5 $ <Ko 7 V<O# 012 insert $ <L/ 7 5?
8 2 \ </
$ <K 7 V<O insert $ <L/' # a' dGN/' CPU &% 1 1 1U' r > $ , Q@_/
o#(1 $. c U CPU 314 B. >= CPU S7-300 5 $ <L/ 5 :<2 CPU [ 1/. M M
$` Q @ ,J F / 012 ES7 314-1AE04-0AA0x oD 5 &% ' M 5? 8 iK
: > $ , Y-' S7-300 MD # 15" v h > , Yz" vws !U U ES7x # Q @ =oD
MD # 15" r : > $ , Y-' CPU MD # 15" w : > $ , Y-' %5X $%6 MD # , t Oi
'. k1K( Analog B m k1#(1 MD # 15" v : > $ , Y-' \' K '. k1K( ! $ k1#(1
M G < %5X' $ %i^ > o@ 5 " < L $` . [1/ M f K 15" ( J > $ . \' K
,J 5 ><5/ *F H K` O Oi 1 '
M i1< % 1 & 1 5/. l K v > $ / L c </ r > $ / L !" CPU > $ K(. ,. %:
M # 1U ' SM300 $ <L/' insert >= # a' s > $ .% /' ] Y Q - X % @ c $ D.
;1 k1#(1 $ <L/ >= Digital input module $ <L/ 5 ' \ K^ ' k K(^ % ' X
Digital input module sm321 16/24VDC
k :<2 # = < * FX` !" I/. ? o /1 X !5< / ,. Q - # 8O M / >=
(1X' U$ <L/ !< /1 8O/ 5 " 5?# + MO2. &T" / (1X' ? o # ] T Copy/past
/1 M 5? !< Addresses M < 1 /' Address / L ,J 5 ><5/ 5 @ M i O
g / Q- /1 K(. % ,1 / T U' &T" Z G/ * 5</3 %:

Blocks Q # MK ( < / '. : '. g ST O %# / M ,. 0 :/ ,. % 3


4 ! J Simatic S7 !" &%#%@ [ 1/. 5 '
Organization blocks OB
Function blocks FB
Functions FC
Data blocks DB
System function SFC
System function blocks SFB
S% Q @ [1/ M p a$% TU !" b :</ 012'

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 / &$'(

6" N#. !U' Real time interrupts B$'( M M < yX O iK 1 c U'


OB40 Q< ' OB31 !U' :< CPU [1/ U(%@ ,1 #' OB
%L<2 ><# o: D ' g / > ( Y-' OB1 MK ( I < # ,. d g / , Y- #'
M + B9 OB1 !" 5 N ><# ,. Q @ X < o H K. [ 1/.

Hardware config /1 /9 /. ,. %: d " OB1 k :<2 g / k'. * /- d M .% ,J '


4Z a$% !"
: 5?#' blocks Q - M6/ Q< &% ' & | Q @ dGN MK%/ >= S{ / > BT Project V<O/ 3'.
4! < M

< + + V<O<" OK dGN/ OB1 / !U' < + 5? OB1 Q @ dGN % @'


OB1 MK (

4g / M @ O 'g / /1 b :< .% / 012 ,J '

4 G< [ 1/. 3'.


: 5 @ B / !< / [ 1/. !" N/ ,. % 3 [ 1/. [1/ B. M :< % @
'; N 'p ' @ 5 @ B / !< $` c U : oD "

,1 # Q< T U' L ]T ' # ' i' !U $` [ 1/. ,. / ,. @ X' T5 '


F < ' > !" #' < ( : !"
&%#%@ [ 1/. c U' / % ' [1/ Q @ : ,1 ,. % o" PLC g / M :< % :" ] T
1 @1W1 !U /

/ K wx '. Byte / K } '. Bit &% ' / K - 1U' G< / K (%@ 1U I b :< 2 > k'.
/ [1/ l . double word / K vr X'(F '. word

Binary type !7 D 4 k'` [1


1 Q @ ] Y < ><# [1 TU M :< % @' d " ON - OFF 5 '. d " w '. t TK9# 1U'
4!J
b#1001 0110 0011 0001 4 / K wx ,1 > $ M D
> !5" $` @1 .F < '> Mi O !U ~ o@' !7 = > ,. U : U b

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

Real ( floating point ) numbers # : $` 1U' 4 l D [1


4 J G6 Q@ < '
x.ye+/-z
&% ' / L B : > V 6 *F x l
B : > !" B *F y
wt > a. ! : e
a` &$ +- !U' A |
a` MD z
e+4r•v 4 ! J < oD rvttt ! :
e-2v•€s 4 < t•tv€s
A &$ +- I . < 2 , Y-' &$ +- I . < 3 X1 M > , Y-'

Timer type # < ! G< [1/ 4 1U' [1


s5t#100ms 4 ! J < #'
/ = ! wtt I< # S : > TU

date ‚#$ < M@ k%# G< 4 8 L [1


rtt} M# . } ‚#$ < d#2008-04-08 4 ! J < #'

time of day ! n ' G<


tod#23:30:24.500 oD tod#hh:mm:ss.ms 4 ! J < #'
time Z n ' G<
t#Od_10h_50m_28s_880ms oD t#Od_0h_0m_0s_0ms4 ! J < #'

4!J < #' ‚#$ ' n ' G<


DT#2008-04-08-20:25:30.850

M Q@ < ' ( %: c U ] T ƒxyzƒ P 6 o@ < ' String " G< c U'


c#897

! < 'g / !" 5 @ : * X- ;1 / [1/ % 9< 1U , TU !" ;1 '


g / !" 9 K q% # 3 Q< ] T 2 : %L<2

$ % &

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

) Digital outputs ' (


Q1.3 - Q7.6 - Q47.3 4 oD I 3% Q F ,. R oK% MD !U'

) 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

Ladder diagram LAD > M : MD


I0.0---------I0.1-------------Q1.2AAAAAAAA
„AAAAAA„ „AAAAAAAAAA„ „AAAAAAAAAAAAAA… †AAAAAAA„

Statement list STL (1 ? : MD


A I0.0
A I0.1
‡ Q1.2

Data type J [ 1/` Q @ Z !U'


I-Inputs , Q-Outputs, M-Memory flag, L-Local variable, D-Data block bit, T-
Timer, C-Counter

AN And Not

NC Z G !: :W' U% . : >< ' 5 ! 1< Q @ M i1< @ MD !U'


4 oD ! J k'%
z=A And Not B

A B B' z
AAAAAAAAAAAAAAAAAA
twtt
wwtw
ttwt
ttww

Ladder diagram LAD > M : MD


I0.0---------I0.1-------------Q1.2AAAAAAAA
„AAAAAA„ „AAAAAAAAAA„ „AAAAAAAAAAAAAA… †AAAAAAA„

Statement list STL (1 ? : MD


A I0.0
AN I0.1
‡ Q1.2

Data type J [ 1/` Q @ Z !U'


I,Q,M,L,D,T,C

O Or

% ' ,1 # ,. % 3 </ c U ,1 # ! : >< ' 5 B 1< Q @ M i1< @ MD !U'


wd"
4 oD ! J k'%
z=A Or B

ABz
AAAAAAAAAAAAAAAA
ttt
wtw
wwt
www

Statement list STL (1 ? : MD


O I0.0
O I0.1
‡ Q1.2

Data type J [ 1/` Q @ Z !U'


I,Q,M,L,D,C,T

ON Or Not

NC Uo '. U% . : >< ' 5 B 1< Q @ M i1< @ MD !U'


4 oD ! J k'%
z=A Or Not B

A B B' z
AAAAAAAAAAAAAAAA
wwtt
wwtw
ttwt
wtww

Statement list STL (1 ? : MD


O I0.0
ON I0.1
‡ Q1.2

Data type J [ 1/` Q @ Z !U'


I,Q,M,L,D,C,T

X Exclusive Or

,1 # 3 l ! 1 , = I [ " M : B 1 , @ " c U ,1 # l MK %< M i1< @ MD !U'


, O <L , =3 , Y- 3- </ c U
4 oD ! J k'%
z=A XOr B

ABz
AAAAAAAAAAAAAAAA
ttt
wtw
wwt
tww

Statement list STL (1 ? : MD


X I0.0
X I0.1
‡ Q1.2

Data type J [ 1/` Q @ Z !U'


I,Q,M,L,D,C,T
XN Exclusive Or Not

,1 # 3 l ! 1 , = I [ " M : B 1 , @ " c U ,1 # l MK %< M i1< @ MD !U'


, < , =3 , Y- 3- </ c U
4 oD ! J k'%
z=A XN Or B

ABz
AAAAAAAAAAAAAAAA
wtt
ttw
twt
www

Statement list STL (1 ? : MD


XN I0.0
XN I0.1
‡ Q1.2

Data type J [ 1/` Q @ Z !U'


I,Q,M,L,D,C,T

- Assign

[ 1/` ! @ Z # 1U' ‡ o@ ! # BT , 1 : !" n !< : </ M # . 1U'


I, Q, M, L, D
D ` !" S %L<2 ' Z 2

R Reset

I # BT , 1 : !" t #FL< 1 # 1U'


R Q0.1 - R M20.7 - R DB100.DBX2.1 4 MD

S Set

I # BT , 1 : !" w #FL< 1 # 1U'


S M10.2 - S Q3.1 - S DB10.DBX14.6 4 MD

NOT Negate RLO

tQ-w '. w Q - t n @ Kj </ 8 : 1 # 1U'

NOT 1U < #'

SET Set RLO --> 1

Result of Logic Operation RLO : </ , !" w #FL< 1 # 1U'


Set @ !" ] Y %L<2 , ^ ] Y'

4 oD
SET
Q10.3 ‡

CLR Clear RLO --> 0

RLO !" t #FL< 1 # 1U'

‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡

7 &*8 & 9 : ; < =3 > * & . / 01 231 4& 56


,?= 231 ' ( @A 5 ! * / B C DC counters & Timers * +
; E? * $ 4& 5/ F G*87 5? H I = H J,= 5? K L1 M
OP 7 , Q F OP 7 /R /5 ? $F 3 ? N 5?
; ; & : 5/ J, Q 5? D R?S 2*T L 5? UV W1 ; R? F
Y 5 G @ ? & F / * 8 8# 5 %? E & X= 2 & " 3 = X=
=1 R Z =

‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡

Timers # < Q - UT ,J '


4 ! J !U g / MK ( 5 %L<2 # !< ' 8 2 !" &(1X1 # < [ 1/.
On-Delay Timer : SD Kˆ M G # A
Off-Delay Timer : SF Kˆ M6" # A
Pulse Timer : SP !N / # A
Extended Pulse Timer : SE %< !N / # A
Retentive (Stored) On-Delay Timer : SS M Kˆ M G # A

) ; ( [ X3# 5 Q \X ] Q ^ &*; 0_

,1 # !< 1U #< \ L ' #< MG < S "1 X1 ‰ !U M G < &$ +- ,. b <O


4 t 1U # < d N n '' ON # < 5 "

&$ +- n/ Y- w Q - t \ L M < On-Delay Timer Kˆ M G 1U' " # [X !O"


M G < &$ +- t Q - w kF ' t F 5<# % n ' U(1X' n ' ' ' &(1X1 M G <

M G < &$ +- w Q - t \ L M < # Off-Delay Timer Kˆ M6" # 3 % [X !"'


t S$% F \ L !" t Q - w k </3 K9< t Q - w M G < &$ +- k </ % @'

U$ <2 ' w Q - t 5 </ B. M G < &$ +- (1X' % @ [1 TU !"' !N / # ` % [X '


t S$% %: t Q - w (1:# >= w k- t M < # # < \ K ,z" t # < d W .n1
t Q - w M < # # < \ K ,z" t M . M G < &$ +- (1X' , Y- ' N / M + Q @ B.
M G < &$ +-

n ' @ ? ŠG t S$% F # < N / \ L [1 TU !" %< !N / # 1U' 9 [X


\' L N &%#%X # % ! :# w Q - t M G < &$ +^ k </ M ,. ? o M G < &$ +- (1X'
$ <2 w M?# 012 # < \ K ,z" t M . F &$ < N / M G < &$ +- n/ Y- I/. B.

%: w Q - t #< \ K M < [1 TU !"' ,FL Kˆ M G # 1U' Y ( [X


%: ' SET . MD M G &$ +- $ <2 U ‰ < # 3' w Q - t M G < &$ +- k </ t S$%
t
CPU & Y !" / K wx /1 # M one word F ><# I/. > :

Accumulator- Q - STU M / #' !7 = M + !" n 1 ‹At / L P 6L ><# I/.'


] T \ < 3 % @ g / !" 5: M :< ] Y' Hexadecimal H, BCD M + !" 1
4 < Π6 H% z # < '. M #]T
W#16#txyz
/ K wx ,1 > $ ! : W#16 l
/ = wt C / = w C / = ! wtt C / = ! wt A ww C wt C tw C tt A n 1 ; # t
BCD M 5@ : n1 xyz

S5t#aH_bM_cS_dMS 4 M n 1 @ :< # '.


n1 F 1U H,M,S,MS ' / = ! d C !/ 1D c C Z7 % b C @ a ,. l

) * 9 2 &*; # ^ &*; 0_

FR Enable Timer

4!J M ,1 ' d " STL !" ,1 ` TU M G < : &$16 '


FR <Timer> where Timer --> T1,T2,...,T256

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

LC Load Current Timer Value into ACCU 1 as BCD

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

SE Extended Pulse Timer

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

SS Retentive On-Delay Timer

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

ACCU1 Q - Address !" &(1X1 / M < 1 # 1U'


!" &%#% / M ' ACCU2 Q - ACCU1 #1< M / ><# I/z" ! Load .c U, Y-'
M @ q% # B. ACCU1

Double Word '. Word '. Byte n/ * 12 / . B. Q @ Load ` Z #'

Digital output ,1 # '. …Digital input(Byte/Word/DWord ,1 # ,. # Address ,z" ] T


L ! K ( G< '. Data block '. Analogue input '. Memory '. # 8O
4 D.
L IB20
L MW200
L QD10
L PIW224
L DB50.DBD20

ACCU1 ; i L } Q - w / L !" 5 ><# I/z" Byte M > Y- I/. • o/ ,. #'


><# Word M > Y-' ttttttttAttttttttAtttttttt $ Oi. vr A ‹ / L ,1 '
Atttttttt $ Oi. 5 vr A w• / L ,1 ' ACCU1 !" wx Q - w / L !" 5
vrAw / L !" ACCU1 !" M > M >< " Double word M > Y-' tttttttt

Load status word into Accumulator-1 L STW `

Kj - %: CPU @ : !< ' Status word M < 1 # 15" ` >2 VW ' 1U '
,1 <" / L . } Q< ' w / L !" 5 ><#' ] T $ <K M @ !" R % @ @
$ Oi.

Load Address register-1 Or 2 From Accumulator-1 LAR1 , LAR2 `

ACCU1 ,ACCU2 #1< Q @ =ˆ# 3 1U' ] T %L< # ` TU


%< †& T (% *FX M :< 5 %6 # !< ' i L : !" ` TU %L< #'

ŽTransfer T <Address `

4 ,1 # ,. # BT ' Address ; I - $ , Q - ACCU1 #1< ‚ ` TU 1 #


QB/QW/QD/PQW/MB/MW/MD/L/DBB/DBW/DBD

4 D.
T QB10
T MW32
T DB20.DBD48
T PQW446
Transfer contents of Accumulator-1 into Status word T STW `

? ,'( : !" 5:W' !" R % @ Status word Q - k'` : < /L M 1 # 1U'


H K` g7 < Q -

Q" % < koK X ] Y 5?# 012' @ koK %L<2 '` D . U L,T , `'
S$'%

$1 ` >5" !" %L< &%@ p + B. Q@Z : <:# %: o D` X !" 4 m1


Comments

#% , < ,FL ' Accumulator-2 ' Accumulator-1 #1< 5 >< : STU


1 : 5 = # bit / K M /$ >< l Accumulator-1 !"

AW AND Word : 16-Bit

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 #' > & +

L IW20 //Load contents of IW20 into ACCU 1-LE


AW W#16#0FFF //Combine bits of ACCU 1-L with bit pattern of 16-bit constant
…wwww•wwww•wwww•tttt†by AND; store result in ACCU 1-LE
JP NEXT //Jump to NEXT jump label if result is unequal to zero, (CC 1 = 1…

OW OR Word :16-Bit

4 &$16 ` TK9#'
OW
OW 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
AwLE
OW //Combine bits from ACCU 1-L with ACCU 2-L by OR, store result in ACCU
AwLE
T MW8 //Transfer result to MW8

& + OR M @ ><#' ACCU1 !" Q '` M < ><# Constant n = OR M @ !"'


4 ! J MD ACCU1 !" g ,1 #' >

L IW20 //Load contents of IW 20 into ACCU 1-LE


OW W#16#0FFF //Combine bits of ACCU 1-L with bit pattern of 16-bit constant
…wwww•wwww•wwww•tttt†by OR; store result in ACCU 1-LE
JP NEXT //Jump to NEXT jump label if result is unequal to zero (CC 1 = 1…

XOW Exclusive OR Word : 16-Bit

4 &$16 ` TK9#'
XOW
XOW 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 ID24 into
ACCU 1-LE
XOW //Combine bits of ACCU 1-L with ACCU 2-L bits by XOR, store result in
ACCU
AwLE
T MW8 //Transfer result to MW8

XOR M @ ><#' ACCU1 !" Q '` M < ><# Constant n = XOR M @ !"'
4 ! J MD ACCU1 !" g ,1 #' > & +

L IW20 //Load contents of IW20 into ACCU 1-LE


XOW 16#0FFF //Combine bits of ACCU 1-L with bit pattern of 16-bit constant
…wwww•wwww•wwww•tttt†by XOR, store result in ACCU 1-LE
JP NEXT //Jump to NEXT jump label if result is unequal to zero, (CC 1 = 1…

AD AND Double Word : 32-Bit

ACCU1, ACCU2 #1< M B. / K vr H1< Q@ ' AW M : 1 # 1U'

4 &$16 ` TK9#'
AD
AD Constant

ACCU2 / D M ' ACCU1 !" Q '` M ` M ><# l


4kD
L ID20 //Load contents of ID20 into ACCU 1E
L ID24 //Load contents of ACCU 1 into ACCU 2. Load contents of ID24 into
ACCU
Ew
AD //Combine bits from ACCU 1 with ACCU 2 by AND, store result in ACCU
Ew
T MD8 //Transfer result to MD8

& + AD M @ ><#' ACCU1 !" Q '` M < ><# Constant n = AD M @ !"'


4 ! J MD ACCU1 !" g ,1 #' >

L ID 20 //Load contents of ID20 into ACCU 1E


AD DW#16#0FFF_EF21 //Combine bits of ACCU 1 with bit pattern of 32-bit
constant
…tttw•ttwt•wwww•wwwt•wwww•wwww•wwww•tttt†by AND; store result in
ACCU 1E
JP NEXT //Jump to NEXT jump label if result is unequal to zero, (CC 1 = 1…

OD OR Double Word : 32-Bit

4 &$16 ` TK9#'
OD
OD Constant

ACCU2 / D M ' ACCU1 !" Q '` M ` M ><# l


4kD
L ID20 //Load contents of ID20 into ACCU 1E
L ID24 //Load contents of ACCU 1 into ACCU 2. Load contents of ID24 into
ACCU 1E
OD //Combine bits from ACCU 1 with ACCU 2 bits by OR; store result in
ACCU 1E
T MD8 //Transfer result to MD8

& + OD M @ ><#' ACCU1 !" Q '` M < ><# Constant n = OD M @ !"'


4 ! J MD ACCU1 !" g ,1 #' >

L ID20 //Load contents of ID20 into ACCU 1E


OD DW#16#0FFF_EF21 //Combine bits of ACCU 1 with bit pattern of 32-bit
constant
…tttw•ttwt•wwww•wwwt•wwww•wwww•wwww•tttt†by OR, store result in
ACCU 1E

JP NEXT //Jump to NEXT jump label if result is not equal to zero, (CC 1‡
…w

XOD Exclusive OR Double Word : 32-Bit

4 &$16 ` TK9#'
XOD
XOD Constant

ACCU2 / D M ' ACCU1 !" Q '` M ` M ><# l


4kD
L ID20 //Load contents of ID20 into ACCU 1E
L ID24 //Load contents of ACCU 1 into ACCU 2. Load contents of ID24 into
ACCU 1E
XOD //Combine bits from ACCU 1 with ACCU 2 by XOR; store result in ACCU
Ew
T MD8 //Transfer result to MD8

XOD M @ ><#' ACCU1 !" Q '` M < ><# Constant n = XOD M @ !"'
4 ! J MD ACCU1 !" g ,1 #' > & +

L ID20 //Load contents of ID20 into ACCU 1E


XOD DW#16#0FFF_EF21 //Combine bits from ACCU 1 with bit pattern of 32-bit
constant
…tttw•ttwt•wwwt•wwww•wwww•wwww•wwww•tttt†by XOR, store result in
ACCU 1E
JP NEXT //Jump to NEXT jump label if result is unequal to zero, (CC 1 = 1

[ 1/. M 5 @ 1 !< >U` Π6 ' H K. Q - G i $` M#1 : STU


4 !U
Integer numbers 16 bits 6 $` A
Double integers 32 bits % O@ N 6 $` A
Real numbers # : $` A
Binary coded decimal BCD (1 5 @ : $` A

BTI BCD to Integer

ttt p' < $. v ,1 BCD G i Accumulator-1 #1< M#1 < 1 # ` TU'


4 oD V i > $ Q - ‹‹‹ C
tttt A twwt A wttt A wttw 4 / K $9 MD # > $ M BCD ?/ !" ! J ,1 # x}‹ >
tttt A ttwt A wtww A tttw 4 ! J ,1 # Integer G 6 Q - M#1 < % @'

4kD

L MW10 //Load the BCD number into ACCU 1-LE


BTI //Convert from BCD to integer; store result in ACCU 1-LE
T MW20 //Transfer result (integer number) to MW20
ITB Integer (16-Bit) to BCD

BCD &$16 Q - 6 &$16 > k1 # l : : 1 # ` TU'


4kD
L MW10 //Load the integer number into ACCU 1-LE
ITB //Convert from integer to BCD (16-bit); store result in ACCU 1-LE
T MW20 //Transfer result (BCD number) to MW20

BTD BCD to Integer-32 bits

Double integer G 6 Q - BCD G i / K vr > $ M#1 < 1 # ` TU


4!J 2 '. X1 ‹C‹‹‹C‹‹‹ 4 !U BCD > H16 ,1 '
wwwwAttttAttwtAttwwAtwtwAtwwtAtwttAwttt 4 ,1 # Arv€xs} >
wtttAttttAttttAttwwAwttwAwtttAwtttAtttt 4 V i Q - I #1 % @'

4kD

L MD10 //Load the BCD number into ACCU 1E


BTD //Convert from BCD to integer; store result in ACCU 1E
T MD20 //Transfer result (double integer number) to MD20

ITD Integer - 16 Bit to Double Integer - 32-Bit

" Wz ] Y' / K vr Q - / K wx V 6 &$1i Accumulator-1 #1< M#1 < 1 # 1U'


Accumulator-1 !" vw Q< ' wx / L Q - tttttttttttttttt $ Oi.
vr / L Q - wx / L &$ +^ / K M /'

4kD

L MW12 //Load the integer number into ACCU 1E


ITD //Convert from integer (16-bit) to double integer (32-bit); store result in
ACCU 1E
T MD20 //Transfer result (double integer) to MD20

DTB Double Integer (32-Bit) to BCD

BCD &$16 Q - / K vr O@ N ( Y i $` M#1 < 1 # 1U'


4kD

L MD10 //Load the 32-bit integer into ACCU 1E


DTB //Convert from integer (32-bit) to BCD, store result in ACCU 1E
T MD20 //Transfer result (BCD number) to MD20

DTR Double Integer - 32-Bit to Floating-Point - 32-Bit


IEEE-FP

# : &$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

L MD10 //Load the 32-bit integer into ACCU 1E


DTR //Convert from double integer to floating point (32-bit IEEE FP); store result
in ACCU 1E
T MD20 //Transfer result (BCD number) to MD20

INVI Ones Complement Integer -16-Bit

!" < #FL ' #1< B( ` a1 : Q - Accumulator-1 #1< M#1 < 1 # ` TU


Accumulator-1

4 oD t Q - w M ' w Q - t M 1U M B( ` a1 : '
twttAwwttAttwwAwtwt 4 >
wtwwAttwwAwwttAtwtw 4 ,1 #

4kD

L IW8 //Load value into ACCU 1-LE


INVI //Form ones complement 16-bitE
T MW10 //Transfer result to MW10
INVD Ones Complement Double Integer -32-Bit

Double integer / K vr H1< Q@ ' Z ` MD 1U'

4kD

L ID8 //Load value into ACCU 1E


INVD //Form ones complement (32-bitE…
T MD10 //Transfer result to MD10

NEGI Twos Complement Integer -16-Bit

!" #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

L IW8 //Load value into ACCU 1-LE


NEGI //Form twos complement 16-bitE
T MW10 //Transfer result to MW10

NEGD Twos Complement Double Integer -32-Bit

O@ N ( V i > $ / K vr B1< Q@ 'Z ` 8O/ 1U'

NEGR Negate Floating-Point Number -32-Bit, IEEE-FP

8 : ' A ,1 | n/ Y- … # : o: 'Y † B : > &$ +- 8 : 1 # ` TU !"

4kD

L ID8 //Load value into ACCU 1 example: ID 8 = 1.5E+02


NEGR //Negate floating-point number (32-bit, IEEE-FP); stores the result in
ACCU
Ew
T MD10 //Transfer result to MD10 example: result = -1.5E+02

CAW Change Byte Sequence in ACCU 1-L 16-Bit

Accumulator-1 ,. l Q '` Accumulator-1 / K W' M#% < 1 # ` TU'


Y-' Q O2' @ Bytes <@1 5 M ' … High and Low † Q O2' @ < (%@ ,1 <#
4!J 5 ,1 # Bytes s ,1 <# 15" 15O T5 Accumulator-1 Q - / ?/
ACCU1-H-H , ACCU1-H-L , ACCU1-L-H , ACCU1-L-L
bits / K } ,1 < @1 M
M#% < 1 # ` TU'ACCU1-L-H , ACCU1-L-L Q @ * ^ ACCU1-H-H , ACCU1-
H-L4 oD !U
4 ,1 CAW k :<62 %: wtwtAttttAttwtAwwtw
ttttAwtwtAttwtAwwtw

4kD

L MW10 //Load the value of MW10 into ACCU 1E


CAW //Reverse the sequence of bytes in ACCU 1-LE
T MW20 //Transfer the result to MW20

CAD Change Byte Sequence in ACCU 1 32-Bit

4 ! J Words , Bytes H1<


Q @ Accumulator-1 M#% <# 1 # ` TU'
4 ! i` < , Y-
ACCU1-H-H , ACCU1-H-L , ACCU1-L-H , ACCU1-L-L %: < ,1 # CAD
ACCU1-L-L , ACCU1-L-H , ACCU1-H-L , ACCU1-H-H

4 Accumulator-1 #1< n/ Y- oD
4 ! J CAD k :<2 %: ,1 tttwAwtwwAwwwwAttwt
ttwtAwwwwAwtwwAtttw

4kD

L MD10 //Load the value of MD10 into ACCU 1E


CAD //Reverse the sequence of bytes in ACCU 1E
T MD20 //Transfer the results to MD20

RND Round
Y-' V i > $ ; . Q - I #1< M#1 < 1 #' B @ > $ Accumulator-1 #1< <:# ` TU
!X'F > ,1 # # < ,z" !X' ' B( " $ " _6/ !" ,

Awtt Q - I # ><# Awtt•€ > ' wtt Q - I # ><# wtt•€ 4 > oD

4kD

L MD10 //Load the floating-point number into ACCU 1-LE


RND //Convert the floating-point number (32-bit, IEEE-FP) into an integer (32-bit…
and round off the resultE
T MD20 //Transfer result (double integer number) to MD20

TRUNC Truncate

0T ] Y' / K vr O@ N ( V i > $ Q - / K vr ( # : $` M#1 < 1 # ` TU'


Aw€t V 6# Aw€t•‹ > ' wtt V 6# wtt•• > oD

4kD

L MD10 //Load the floating-point number into ACCU 1-LE


TRUNC
Convert the floating-point number (32-bit, IEEE-FP) to an integer (32-bit…
and round result. Store the result in ACCU 1E
T MD20 //Transfer result (double integer number) to MD20

RND+ Round to Upper Double Integer

V i > $ Gi. Q - #1< # < 1 #' B @ > $ Accumulator-1 #1< <:# ` TU'
Accumulator-1 !" #1< ] #FL ' B : > B' # '. .

Awsw ,1 # Awsw•• > ' wsw ,1 # wst•€ > 4 oD

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' # '.

Awsw ,1 # Awst•v > ' wrt ,1 # wrt•s > oD

4kD

L MD10 //Load the floating-point number into ACCU 1-LE


RND- //Convert the floating-point number (32-bit, IEEE-FP) to an integer (32-bit…
and round result. Store result in ACCU 1E
T MD20 //Transfer result (double integer number) to MD20

Comparison instructions 3

!" ! # < 2 <# RLO G ' ACCU1 , ACCU2 #1< ,$ 5 '` STU
4! < p

4!J /$ J o: k :<2 ><#

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

I , D , R /$ o@ %: < #0 Z# @> (l /$ [1/ %#% ><# ] T


4!J

I Compare Integer 16-Bit


D Compare Double Integer 32-Bit
R Compare Floating-Point Number 32-Bit

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

L MW10 //Load contents of MW10 (16-bit integerE…


L IW24 //Load contents of IW24 (16-bit integerE…
ŽI //Compare if ACCU 2-L (MW10) is greater (>) than ACCU 1- L (IW24E…
‡M 2.0 //RLO = 1 if MW10 > IW24

4!J G< RLO #1< ,. ? o


w A !U RLO #1< ,1 ;1 ‰ Z Y-
t A !U RLO #1< ,1 ‰ Z <# > Y-

‰ ' 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

L MD10 //Load contents of MD10 (double integer, 32 bitsE…


L ID24 //Load contents of ID24 (double integer, 32 bitsE…
ŽD //Compare if ACCU 2 (MD10) is greater (>) than ACCU 1 (ID24E…
‡M 2.0 //RLO = 1 if MD10 > ID24

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

L MD10 //Load contents of MD10 (floating-point numberE…


L 1.359E+02 //Load the constant 1.359E+02E
ŽR //Compare if ACCU 2 (MD10) is greater (>) than ACCU 1 (1.359-E+02E…
‡M 2.0 //RLO = 1 if MD10 > 1.359E+02

/5 J R ?*; 0 # 0f

Nested operations K %< : 4 3'.

MK % c U , ` >?: !" /-' Z B 1 M i1 '. Z ! 1 M i1 : M n "


4 ! < k D MD c Y' TU d L !@%< # :
: ( .% /' < 2 2. OR !< @ AND @c UZ kD !O"

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 '

4! < kD MD 2 ORing @ g7 < ANDing M : 1 # ` TU'

AN( And Not with Nesting Open

!# ID ' †A ; i L o 6O< 8O/ ` T5 '


O( Or with Nesting Open
ON( Or Not with Nesting Open
X( Exclusive Or with Nesting Open
XN( Exclusive Or Not with Nesting Open

4! < ` a1 TU Z G G B. MD p1<O a1 I " MK % B. Z R # 5 !" ><#'

Nesting Closed …

(%: #' … ! <O (%@ ,1 # ,. % 3' • 1U a 1 ` MK % (%@ Q6 . ,. ? o #'


T O < !" 9 K g / ! :# 01 " 3-' † Z G

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

4TO< O Q@! < kD TO< !O m1 * (` >5O/ ! ' " 0 < 3 1U'

M + !" # ,1 # T5 ' d " g / T O &$'% (1X1 ,1 # \ L ,z" k D TU ? o '


g / T O &$'( k1 '. Impulse

FP Edge Positive

4TO< O Q@! < kD TO< !O m1 * (` >5O/ ! ' X1 " 0 < 3 1U'


Q @ >< !< : ,z" :# 2 & ? ' ( %: '. Counters M :</ _ : 0 :< ,J '
'. BCD M + !" - ( %: 5 - Mi' !< M '. MO2` %: '. Q @` %: - !U ( %:
2` !" M 6O< ] Y b :< / 012' ( %: O6 '. : Q @ ( %: d W '. Binary
4 <

FR Enable Counter

,1 # /-' %: *% 1U U (16 8 ' I # BT ‰ Z % @ ( %: M G !" *% ! :# 1U'


I @ >< !< : B` FU X ( %:

4kD

A I 2.0 //Check signal state at input I 2.0


FR C3 //Enable counter C3 when RLO transitions from 0 to 1

L Load Current Counter Value into ACCU 1

Q-M ACCU1 #1< M / ><# ,. %: ACCU1-L MK ( ( %: #1< M B.


ACCU2

4kD
L C3 //Load ACCU 1-L with the count value of counter C3 in binary format

ACCU1 Q - ( %: / M / O VW1# ! < M


LC Load Current Counter Value into ACCU 1 as BCD

BCD M + !" ACCU1 Q - I - $ ( %: / M # 'Z ` M @ 8O 1 # 1U'

4kD
LC C3 //Load ACCU 1-L with the count value of counter C3 in binary coded
decimal
format

BCD M + !" ACCU1 Q - C3 ( %: / M / O VW1# ! < M '


R Reset Counter

;1 ‰ Z %@I -$ ( %: MK ( “ t “ M < 1 # 1U'


4kD
A I 2.3 //Check signal state at input I 2.3
R C3 //Reset counter C3 to a value of 0 if RLO transitions from 0 to 1

S Set Counter Preset Value

;1 ‰ Z % @ BCD &$1i !" ,1 l ACCU1-L %: ( %: M < 1 #


A I 2.3 //Check signal state at input I 2.3
L C#3 //Load count value 3 into ACCU 1-L
S C1 //Set counter C1 to count value if RLO transitions from 0 to 1

CU Counter Up

> Q - k1i1 % @' “ ‹‹‹ “ M . ( %: ,. ‰ Z % @ “ w “ ( %: &( # B.


/ K Q @ “w “ \' K Q @` %: @ ( %: _ 1<#' * X^ T5 =9 B. %X1# 3 ( %: !" “ ‹‹‹ “
Status bit register : g7 </ / K Q @ OV - Overflow

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

,1 # ,. 1 #' label ; (% , Q - k </3 ><# w n/ Yz" RLO </ Q @ * ` TU !"'


block 8O/ MK ( k </3 ,1 # , ‰ ! , '. Z 2 , Q - k </3
4kD
A I 1.0
A I 1.2
JC JOVR //Jump if RLO=1 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

JCN Jump if RLO = 0

Format
JCN jump label
jump label Symbolic name of jump destination

Z ` Oi 1 8O/ I ' w 8 ' O6 RLO </ !" k </3 ><# ` TU !"'

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

JCB Jump if RLO = 1 with BR

Format
JCB jump label
jump label Symbolic name of jump destination

w '. Oi * 12 RLO BRbit d W JC . MD ` STU !"

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

JNB Jump if RLO = 0 with BR


Format
JNB jump label
jump label Symbolic name of jump destination

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

jump label Symbolic name of jump destination

Status !" BR G Q @ * label F (% g / !" : , Q - k </o ` TU'


w Q - register word

JNBI Jump if BR = 0

Format
JNBI jump label

jump label Symbolic name of jump destination


Description

t Q - BR / K G !" label F (% g / !" , Q - k </o 1U'

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

JN Jump if Not Zero


Format
JN jump label
jump label : Symbolic name of jump destination
label F (% , Q - k </3 ><# ! < ‰ Z Y-
…CC 1=0/CC 0=1 or CC 1=1/CC 0=0†
4kD
L IW8
L MW12
XOW
JN NOZE //Jump if the contents of ACCU 1-L are not equal to zero
AN M 4.0 //Program scan continues here if jump is not executed
S M 4.0
JU NEXT
NOZE: AN M 4.1 //Program scan resumes here after jump to jump label NOZE
S M 4.1
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

(% , Q - k </3 ><# CC 1 = 1 and CC 0 = 0 B. O6 . @ Kj </ !"


label F

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

(% , Q - k </3 ><# CC 1 = 0 and CC 0 = 1 B. O6 M. @ Kj </ !"


label F

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

JPZ Jump if Plus or Zero

Format
JPZ jump label
jump label : Symbolic name of jump destination

B. O6 B' '. . @ Kj </ !"


label F (% , Q - k </3 ><# …CC 1=0/CC 0=0 or CC 1=1/CC 0=0†

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

JMZ Jump if Minus or Zero

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

JUO Jump if Unordered

Format
JUO jump label
jump label : Symbolic name of jump destination

4 J 3 B. !" Z <# TU' CC 1 = 1 and CC 0 = 1 B. &(% R < !"


Oi Q @ %@A
… M :< † y K M . k :<2 % @ A
Format Z < !" 9 K (1X' !" # : $` /$ % @ A
label F (% , Q - k </3 ><# U% @'

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

><# & M !"' O6 . ACCU1-L #1< label F (% , Q - k </3 ><#


w $ % ACCU1-L #1< M
4kD
Example for calculating the factor of 5

L L#1 //Load the integer constant (32 bit) into ACCU 1


T MD20 //Transfer the contents from ACCU 1 into MD20 :initialization
L 5 //Load number of loop cycles into ACCU 1-L
NEXT: T MW10 //Jump label = loop start / transfer ACCU 1-L to loop counter
L MD20
D //Multiply current contents of MD20 by the current contents of MB10T u
MD20 //Transfer the multiplication result to MD20
L MW10 //Load contents of loop counter into ACCU 1
LOOP NEXT //Decrement the contents of ACCU 1 and jump to the NEXT jump
label if
ACCU 1-L > 0
L MW24 //Program scan resumes here after loop is finished
L 200

g / : *FX * 5/- '. : _7 m' * @%<2 R Z :< 5 b :</ 012 !< :< STU
. . M 6O< 5 b :/ 012'

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

BEC Block End Conditional

!" . RLO=1 ,1 B. I Z ‰ Z Y- 3- ST O ><# 3 I/. %@ Z MD ` TU'


T O < ><# 3 I/z" BEC ` Q@g / $' % @ RLO=0 ‰ Z %@

4kD

A I 1.0 //Update RLO


BEC //End block if RLO = 1
L IW4 //Continue here if BEC is not executed, RLO = 0
T MW10

BEU Block End Unconditional


RLO </ '. ‰ + Q @ ( <@3 ,'( Block * 5/z 1 # l BE ' I ” " %X. 3

CALL Block Call


Format
CALL : logic block identifier

4 ,1 # ,. # logic block identifier ,. l

FC : Function --> CALL FCn


SFC : System function --> CALL SFCn
FB : Function block --> CALL FBn1,DBn2
SFB : System function block --> CALL SFBn1,DBn2

$ <@3 !" W1 BF 5 2 '. 5 * 12 FC,FB,SFC,SFB * @%<23 %L< # ` TU'


` < # !" VW ' 1U FB , SFB M 6 Data Block DB > $ \ $(- ;1X'
$ <@ B. ,'( ;1 FC,FB,SFC,SFB Q - g / T O M 1 # 1U' 2` !"
g / !: M < !" Call . ! # BT Q - g / (1:# T O < 5</ %: ' I #1<

'. U{ /- ><# B. M:O &(1X1 k '( * @%<23 M :< # ` TU ,. $ <@3 !" W1 #]T
g / T O !" 9 K CPU ! : 3 Q< * @%<23 M 5X $(-

% Q- G< # @ : $` [ 1/` O m' ( B. * @%<2 % @ %X 5 $1 ` '


Passing parameters U(1X' !" O m1

4 J D` ] Y VN<# 012'

Example : Assigning parameters to the FC6 call

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<

Example : Calling FB99 with instance data block DB1

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

UT O %: ' RLO </ '. 5 #1< Q - ? ,'( FC [1 O m' ( * @%<23 %L< # ` TU


UF '. 5 2 U{ @%<2 # ] T !: M < M g / T O k <2 ><#

Passing parameters O m1 % Q- / #

X L 5X'' 5 oK% $( 6 %#% ><# ,. % * @%<2 % @ " G< ( M ,. l '


4 ! J k D MD 5

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

standard function blocks (SFBs) 8 2 i L O m1 k '% * @%<23 %L< # ` TU'


Q @ Z # 5 @ Z #' % 6 Data block %#% N#. #' supplied by Siemens
/ # ]T ' :<

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

standard functions (SFCs) supplied [1 8 2 \ </- O m' ( * @%<23 ` TU


[ 1/• I 1 Z 2 5 @ Z #' 5 @ g< # RLO </ '. U 1< ? ,'( by Siemens
/ # ] T ' O m1 k '% H K`

4kD

CALL SFC43 //Call SFC43 to re-trigger watchdog timer - no parameters

O Z # B / E* * ; &

Integer math instructions

%L< G< ' / [ 1/. !" ] Y /($'. ,. Z 2 6 $` , @1/ c U


S7 !"
Q ' / K vr % Y 6 $` ' Integers / K wx % Y 6 $` U'
Double or Long Integers
!" /L ] %L<2 #' ] Y # ! < k'% " : Status word =9 @ .
4 g / k' <

Add ACCU 1 and ACCU 2 as Integer -16-Bit : +I


ACCU1-L * 9D ACCU2-L X* B C ACCU1-L X* DC

Z k'% !" < Status word G< '

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

Subtract ACCU 1 from ACCU 2 as Integer -16-Bit : -I


ACCU1-L * 9D ACCU2-L X* 5 ACCU1-L X* g

Z k'% Status word #1< G< < '

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

Multiply ACCU 1 and ACCU 2 as Integer 16-Bit : *I


ACCU1 3 A de * 9D ACCU2-L X* ACCU1-L X* h D

Z k'% g7 < Status word =9 ? o

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

Divide ACCU 2 by ACCU 1 as Integer 16-Bit : /I


ACCU1- ` P ACCU1 * 9D ACC2-L X* B / ACCU1-L X* ;
; B / WX* ACCU1-H ; i 3 B / WX* L

4 ! < k'% < Status word =9 ? o


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
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

j ) Add Integer Constant 16-bit


=9< ,'( ACCU1-L !" < W'' ACCU1-L #1< Q - / K wx ( 'Y V i > $ " W-
Status word Q @
“ | Ž Integer ‘ “ 4 !U ` k :<23 : G 6
L IW10
Load the value of IW10 into ACCU 1-L
L MW14
Load the contents of ACCU 1-L to ACCU 2-L
Load the value of MW14 into ACCU 1-L
I|
Add ACCU 2-L and ACCU 1-L; store the result in ACCU 1-L
|r€
Add ACCU 1-L and 25; store the result in ACCU 1-L
T DB1.DBW25
Transfer the contents of ACCU 1-L (result) to DBW25 of DB1

Add ACCU 1 and ACCU 2 as Double Integer 32-Bit : +D


ACCU1 !" < W'' ACCU2 #1< Q - ACCU1 #1< " Wz ` TU 1 #'
Z *F !" k'% Status word G

“ |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

Subtract ACCU 1 from ACCU 2 as Double Integer 32-bit : -D


G ACCU1 !" < W'' ACCU2 #1< ACCU1 #1< p ` TU 1 #
Z k'% < Status word

“ 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

Multiply ACCU 1 and ACCU 2 as Double Integer 32-Bit : * D


G ACCU1 !" < W'' ACCU2 #1< !" ACCU1 #1< ; N ` TU 1 #
S YZ k'% < Status word

“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

MOD : Division Remainder Double Integer 32-Bit


' ACCU1 !" ACCU1 #1< Q @ ACCU2 #1< ! #FL< ` TU 1 #
S YZ k'% Status word G ><# <
“ MOD “ 4 !U • : G 6
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
MOD
Divide ACCU 2 by ACCU 1, store the result (remainder) in ACCU 1
T MD20
The contents of ACCU 1 (result) are transferred to MD20

j ) Add Integer Constant 32-Bit


!" < W'' ACCU1 #1< Q - / K vr &$1i !" V i n = " Wz ` TU 1 #
Status word Q @ =9< %@ ACCU1

“ | Ž 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

l k S& @& >Z # B/ ; &


Floating-Point Math Instructions

: < Status word G' / ('% k'%X b : 3'. .% /


5 p1 M .' Q6 9 f K 9 K B. MD 3 !< ' 1 ('% M # k'` *F "
< !" =( ' < Status word 0 6 MD " !/ D *F .

><#' ACCU1 !" U% . M ><# : Q @ >< !< ' : $` 2 2` : b : .% ,J '


,. ? o : * 5</ %: ACCU1 !" : </ #FL ><# >= ACCU2 !" KJ M
!" M U W'. ,. Z 2 !< ' # : $` ( !U' / K vr H1< Q @ >< U :
/ [ 1/. [1W1

Add ACCU 1 and ACCU 2 as a Floating-Point Number 32-Bit IEEE-FP : +R

!" < 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

Subtract ACCU1 from ACCU2 as a Floating-Point Number 32Bit IEEE-FP : - R

!" < W'' ACCU2 #1< ACCU1 #1< p 1 #' A 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 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

Multiply ACCU1 and ACCU2 as Floating-Point Numbers 32-Bit IEEE-FP : * R

!" < 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

Divide ACCU2 by ACCU1 as a Floating-Point Number 32-Bit IEEE-FP : / R

W'' ACCU1 #1< Q @ ACCU2 #1< 1#l R !U ` T5 : G 6


k'% ' < Status word G RLO Q @ =9< ,'( ACCU1 !" <
Z

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

Absolute Value of a Floating-Point Number 32-Bit IEEE-FP : ABS

'. O6 . X1 n/ * 12 … &$ +- R † Q @ k16 : STU'


Status =9< '. =9< ,'( d " > &(1: ' &$ +^ 0T 1#l O6 M. 2
word

w•€x ,1 # |w•€x > ' w•sv ,1 # Aw•sv > oD "

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

Generate the Square of a Floating-Point Number 32-Bit : SQR

!" < #FL ' ACCU1 #1< … I O/ – > ; W Mi † ; ` TU 1 #


Z k'% ' < Status word G RLO Q @ =9< ,'( ACCU2
$` ('% f L

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

Generate the Square Root of a Floating-Point Number 32-Bit : SQRT

O6 B' '. . ,1 ,. ‰ ACCU1 #1< !: < $T ; ` TU 1 #


' < Status word G ' RLO Q @ =9< %@ ACCU1 !" < #FL '
$ !" Z k'%
4kD

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

Generate the Exponential Value of a Floating-Point Number 32-Bit : EXP

ACCU1 !" < W' >= ACCU1 !" (1X1 > Exponential value ; 1 # ` TU
I -$ Z k'% ' < Status word G RLO Q @ =9< ,'(

a` Q - @1" r••w}•r}•w} > '. e !: n D !U 0' : 1U Exponential value


A x A a` Q - @1" A e A > ! : …Exp(x Q : (1X1

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

Generate the Natural Logarithm of a Floating-Point Number 32-Bit : LN

!" < #FL ' ACCU1 #1< … AeA a 2• † !: ><#$ R1 ; 1 # ` TU


k'% ' < Status word G RLO Q @ =9< %@ ACCU1
O6 . : I @ ><# BT > ,1 # ,. ‰ $` ('% f L Z

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

Generate the Sine of Angles as Floating-Point Numbers 32-Bit : SIN

#' @ :# ! > $ I/. $ <@ Q @ † ACCU1 #1< #' F X; 1 # ` TU


G ' RLO Q @ =9< %@ ACCU1 !" ] Y %: < W'' … X$% 8 ' B 7 % ?
$` ('% f L S Y Z k'% ' < Status word
4kD

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

Generate the Cosine of Angles as Floating-Point Numbers 32-Bit : COS

#' @ :# ! > $ I/. $ <@ † ACCU1 #1< #' F X; ` TU 1 #


G ' RLO !" =9< %@ ACCU1 !" < W'' … X$% 8 ' B 7 % ?
('% f L ' S Y Z k'% ' < Status word

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

Generate the Tangent of Angles as Floating-Point Numbers 32-Bit : TAN

:# ! > $ ACCU1 #1< ,. $ <@ † ACCU1 #1< #' F Mm ; 1# ` TU


Status G ' RLO !" =9< %@ ACCU1 !" < W'' … B 7 % ? #' @
S YZ ('% k'% ' < word
4kD

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

Generate the Arc Sine of a Floating-Point Number 32-Bit : ASIN

$ <@3 !" W1 B 7 % #% < ACCU1 #1< 5 X !< #' F ; 1 # ` TU


=9< ,'( ACCU1 !" < W'' |w B' # '. M .' Aw B' # '. . ,1 # > TU ,.
< ,1 ' $` ('% f L ' S Y Z k'% Status word G RLO Q @
pi=3.14159 l |pi/2 ' Api/2 &$16

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

4 J : ]#% ' — /$1 k'F: ] 2 , ' ; Function O m' (M @


… < ! † d1 A 1 : kF@ ,'% ] A
… kF: ! ] !D = † 1 : Q '` kF: ] 2A
… kF: ! ] l = † 1 : … X$ L † / D ] 2A
… < ! † 1 : kF: ! ] A
# @ &$1i … $ < . &$1i !" k1 ( %@ Z# @ ;1 † 1: ] k1 A
… : >2 > † D1 1 : Mi1 " D A
… : >2 > † D2 1 : Q '` kF: "D A
… : >2 > † D3 1 : … X$ L † / D kF: "D A
PI=3.14159 # < A

% 1 %X $

… < † I k1 &% ' , ' ; ( ] : M @ $16 ! : < &$16

oD FC1 5 $ , #. Function ( * /z 1 / 012 3'.


012' % Q -' / # < i L Declaration i @ %#% !" .% /' % V<O 1 / >=
% <2 l % > Q @. !" U%
4 ! J %L< / 012 l T U' Inputs , InOut , Outputs , Temp , Return

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

diameter3 Real diameter of wire with first layer


section1 Real Conductor cross section area
section2 Real First layer cross section area
section3 Real Second layer cross section area
thickness1 Real Thickness of first layer
thickness2 Real Thickness of second layer
weight1 Real Conductor weight
weight2 Real First layer weight
weight3 Real Second layer weight
pi Real pi Constant 3.14159
buffer1 Real Buffer for calculations
buffer2 Real Buffer for calculations
buffer3 Real Buffer for calculations
buffer4 Real Buffer for calculations
buffer5 Real Buffer for calculations

Outputs

totalW Real Total weight of wire

g / iL M : 1 / 012 5@ 1/.' 5 :< / 012 !< G< /(% ,. %: ,J '


4 ;1

Calculations of Conductor Cross section area in square cm

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

Then multiply by density to get weight of 1 cm

L #section1
L #density
uR
T #buffer1

To get weight of 1 m of conductor multiply by 100

L #buffer1
L 100.0
uR
T #buffer2

L #buffer2
L #length
uR
T #weight1

Now calculation of first layer cross section area

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

Then multiply by density then by 100 then by length

L #section2
L #density2
uR
T #buffer1

L #buffer1
L 100.0
uR
T #buffer2

L #buffer2
L #length
uR
T #weight2

Calculation of cross section of layer2

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

calculation of total weight

L #weight1
L #weight2
|R
T #buffer1

L #buffer1
L #weight3
|R
T #totalW
‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡‡
7 ( > #-' ) "'

hassanheha@yahoo.com

http://hassanheha.forumn.net

You might also like