A
ppend
ix
Moog Animatics SmartMotor™ Developer's Guide, Rev. L
Page 863 of 909
These operations are illustrated in the following examples:
A
B
A&B
A|B
A!|B
0
0
0
0
0
0
1
0
1
1
1
0
0
1
1
1
1
1
1
0
Knowing how the binary data works will allow you to write shorter and faster code. The
following are two code examples written to check if both limit inputs are high. One does this
without taking advantage of a binary operator, while the second shows how using a binary
operator makes the code shorter and faster.
Example 1:
IF
Bm
'Look for - limit high
IF
Bp
'Look for + limit high
GOSUB100
'Execute subroutine
ENDIF
ENDIF
Example 2:
IF
(
W
(0)&49152)==49152
'Look at both limits, bits 14 & 15,
'w/bit mask 49152 = 32768 + 16384
GOSUB100
'Execute subroutine
ENDIF
Both examples will execute subroutine 100 if both limit inputs are high. Example 2 uses less
code than Example 1 and will run faster as a part of a larger program loop.
The next two examples show how the use of an I/O word and mask can improve program size
and execution speed:
Example 3:
IF
IN
(0)
'Look for input 0
GOSUB200
'Execute subroutine
ENDIF
IF
IN
(1)
'look for input 1
GOSUB200
'Execute subroutine
ENDIF
Example 4:
IF
IN
(
W
,0,3)
'Look at both inputs 0 and 1
GOSUB200
'Execute subroutine
ENDIF
Both examples 3 and 4 accomplish the same task with different levels of efficiency.
Appendix: Binary Data