Moog Animatics SmartMotor™ Developer's Guide,Rev. L
Page 289 of 909
EXAMPLE:
aw[47]=20'Assign the value of 20 to aw[47]
Raw[47]'Report the value of aw[47] to the primary serial port
PRINT("aw[47]=",aw[47],#13)'Print to the primary serial port
PRINT1("aw[47]=",aw[47],#13)'Print to the secondary serial port
END
Program output is:
20
aw[47]=20
The aw[] array is classified as read/write, meaning that it can be assigned a value, or it can
be assigned to some other variable or function. In other words, these variables can be left- or
right-hand values.
EXAMPLE:
aw[24]=aw[43]+aw[7]
The above is a valid equation, combining the contents of aw[43] and aw[7] and sending the
total into aw[24].
As signed 16-bit variables, they are limited to whole numbers ranging from -32768 and 32767.
Math operations that result in digits after the decimal point are truncated toward zero. So a
value of 2.9 becomes 2, and a value of -2.9 becomes -2.
If you assign or perform an operation that would normally result in a value outside of this
range, the variable will "wrap," or take on the corresponding modulo. As an example, because
of this, 32767+1=-32768. The result "wrapped around" to the negative extreme.
The following are other restrictions:
l
If aw[1]+a exceeds 32 signed bits, the operation c=aw[1]+a will abort and an error flag
is set.
l
If a-aw[1] exceeds 32 signed bits, the operation c=a-aw[1] will abort and an error flag
is set.
l
If a*aw[1] exceeds 32 signed bits, the operation c=a*aw[1] will abort and an error flag
is set.
The system flag, Bs, is set. Note that many different types of command errors will also
set the Bs bit. The RERRC command can be used to retrieve the last command error. For
a math overflow, that is error code 23. For details on the RERRC command, see ERRC on
page 441.
If one of these variables is used with a variable of another type, it will be appropriately
converted (the variable will be "type cast").
If the left-hand variable is a 16-bit one like aw[100], only the lowest 16 bits are preserved.
The sign is determined by bit 15 of the value on the right-side of the equals sign.
Conversely, if the left-hand value is a 32-bit variable and the right-hand side contains 16-bit
variables, the 16-bit variables will be "upgraded" to 32-bits. The sign is preserved when
casting to a longer format. In the equation cc=ab[4]-aw[7], both ab[4] and aw[7] are
converted into 32-bit numbers before the subtraction occurs.
In the SmartMotor language, all user variables are written as lowercase letters, while
functions and commands have at least one uppercase character. The term "a" is a
Part 2: Commands: aw[index]=formula