Language Reference Guide
Language Reference Guide
1
Language reference table of contents (continued)
2
Language reference table of contents (continued)
3
Language reference table of contents (continued)
4
Language reference table of contents (continued)
5
Language reference table of contents (continued)
UAI (as input value) Read I/O Port A Logic State 295
UBI (as input value) Read I/O Port B Logic State 300
6
Language reference table of contents (continued)
UFI (as input value) Read I/O Port F Logic State 322
UGA (as input value) Read I/O Port G As Analog Input 326
UGI (as input value) Read I/O Port G Logic Level State 327
7
Language reference table of contents (continued)
8
Language reference introduction
9
! (exclamation point)
Pause Program Execution
10
! (exclamation point) (continued)
Pause Program Execution
C10
c=c+1 'increment data set counter
'NOTE PRINT(#13) sends a carriage return
PRINT(#13,#13,"DATA SET ")
Rc
PRINT(#13,"Value of a ",a)
PRINT(#13,"Value of b ",b)
PRINT(#13,"Position ")
RP
PRINT("Velocity ")
RV
PRINT("Acceleration ")
RA
PRINT("Position Error ")
RPE
11
(Single Space Character)
Single Space Delimiter and String Terminator
equivalent:
n=7 o=2 p=8 q=56
t=6
aw[t] 63 44 98. '(Note spaces and period)
equivalent:
aw[6]=63 aw[7]=44 aw[8]=98
equivalent:
PRINT("a=1 b=2",#13)
'note carriage return as null terminator
Note: When sending commands via serial port from a PC or PLC or other controller, a space
character can be used as both a delimiter and a string terminator. It can be used equally and
interchangeably with a carriage return as a string terminator.
12
Direct Binary Mode Control
Binary Trajectory Data Format
EXAMPLE:
Set Buffered target position to 100 (P=100)
0xFE 0x00 0x00 0x00 0x64
Set Buffered target position to -2 (P=-2)
0xFE 0xFF 0xFF 0xFF 0xFE
13
Direct Binary Mode Control (continued)
Binary Trajectory Data Format
Related
Commands:
Set Buffered target velocity to 10000 (V=10000)
P
0xFD 0x00 0x00 0x27 0x10
V
Set Buffered target velocity to -10000 (V=-10000)
A
0xFE 0xFF 0xFF 0xD8 0xF0
Set Buffered target acceleration to 1024 (A=1024)
0xFD 0x00 0x00 0x04 0x00
Note: A<0 is not valid.
Since a direct mode command is always in a fixed format, it doesn’t require an end of
line character. However, to have the buffered values take effect, the G character may
be directly appended to the end of any direct mode command.
EXAMPLE:
Set Buffered target position to 100 and "Go" (P=100 G)
0xFE 0x00 0x00 0x00 0x64 0x47 0x20
Keep in mind, Proper Mode commands must be set up prior to binary command
strings in order to get predictable results. If Velocity Mode Is required, then first send
MV followed by the associated binary commands.
This would then allow for fast changes in speed once in velocity mode.
14
@P
Real-Time Actual Position
Note: @P follows the primary encoder used to close the loop. If you issue ENC1, it
will follow an external encoder. Please see ENC0 and ENC1 for more details.
15
@PE
Real-Time Actual Position Error
16
@V
Present Trajectory Velocity
17
@V (continued)
Present Trajectory Velocity
Related
Commands:
While Accelerating, the position error may increase as a result of the physical veloc-
V ity being less than the trajectory velocity. During the constant velocity slew phase, if
position error were constant, physical velocity would equal the trajectory velocity on
MV average.
RV Looking at time microscopically, within one PID sample, the limit of encoder measure-
@P ment is one encoder count, a velocity granularity of 65536 scaled counts, per sample.
This is in contrast to the macroscopic velocity, which has a granularity of one scaled
@PE count. In position or velocity mode, the macroscopic trajectory velocity with a granu-
larity of 1 scaled count per sample is returned by @V.
PIDn
In modes that do not generate a trajectory velocity, for example, torque mode, the
velocity must be gleaned from changes in the encoder each Sample, so the micro-
scopic value with a granularity of 65536 scaled counts per sample is returned by
@V.
RV, PRINT(@V), and the sequence a=@V Ra would transmit identical values, if it
were possible to execute all three command sequences simultaneously.
To display the user-specified buffered maximum velocity value V (V=expression),
as opposed to the present velocity, the sequences a=V Ra or equivalently PRINT(V)
would be used.
Example:
18
a..z
32-Bit Variables
19
a . . z (continued
32-Bit Variables
Related
Commands:
The following are other restrictions:
aa . . zzz
• If a+b exceeds 32 signed bits the operation c=a+b
al[index] will produce a wrong result. No error flag is set.
aw[index] • If a-b exceeds 32 signed bits the operation c=a-b
will produce a wrong result. No error flag is set.
ab[index]
• If a*b exceeds 32 signed bits the operation c=a*b
will produce a wrong result. The system flag Bd will bet set.
If one of these variables is used with a variable of another type, it will be appropri-
ately converted. In technical jargon, the variable will be type cast. For example, in the
equation where the variable on the left of the equal sign is a 16 bit one like aw[4],
all variables will be converted to 16 bit values and then operated on. Assigning the
variable aw[27] = y directly stores the 16 least significant bits of y into aw[27]. The
higher bits of the variable y are lost. Similarly, if the right hand variable is an 8 bit one
like ab[167], all variables will be converted to 8 bit values before being operated on.
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 temporarily "upgraded" to 32 bits. In the
equation c=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 lower case letters,
while functions and commands have at least one upper case character. The term a
is a general purpose variable, while A is the Acceleration function. Any user vari-
able can be assigned a value with an equation, as discussed above, but can also be
sequentially loaded by specifying the starting variable and the series of values to be
loaded.
EXAMPLE:
Suppose the following code:
c=123 'assign the value of 123 to "c"
d=345 'assign the value of 345 to "d"
e=-599 'assign the value of -599 to "e"
See Appendix C f=346 'assign the value of 346 to "f"
To describe the g=678678 'assign the value of 678678 to "g"
relationship between
user assigned The Sequential loading method equivalent is as follows:
variables, aa thru c 123 345 -599 346 678678. 'sequentially load data into
zzz, and variable 'variable c thru g
arrays, ab[ ], al[ ] Note: The last number MUST BE followed by a "." period.
and aw[ ] All user variables are initialized to the value of 0 at power up or upon execution of
the system reset command Z. Other than by direct assignment, this is the only way
that the SmartMotor sets all of the user variables to 0. Issuing a RUN command does
not perform this automatic initialization. For this reason, it is usually preferred to test
a program, whether it is auto-execution or not, by power cycling the SmartMotor or
issuing a system reset command Z.
20
aa . . zzz
32-Bit Variables
21
aa . . zzz (contined)
32-Bit Variables
EXAMPLE:
Suppose the following code:
cc=123 'assign the value of 123 to "cc"
dd=345 'assign the value of 345 to "dd"
ee=-599 'assign the value of -599 to "ee"
ff=346 'assign the value of 346 to "ff"
gg=678678 'assign the value of 678678 to "gg"
22
ab[index]
8-bit Array Variables
23
ab[index] (continued)
8-Bit Array Variables
The ab[ ] array is classified as read write, meaning that they can be assigned a value,
Related or can be assigned to some other variable or function. Another way of saying this, is
Commands: these variables can be left or right hand values.
a..z EXAMPLE:
aa . . zz ab[24]=ab[43]+ab[7]
aaa . . zzz The above is a valid equation, combining the contents of ab[43] and ab[7] and send-
ing the total into ab[24].
aw[index]
As signed 8 bit variables, they are subject to the usual restrictions of signed digital
al[index] words and values. The first bit is always a sign bit. They are limited to integer values
VST between -128 and 127. Math operations that result in decimal values are truncated,
or rounded down. If you assign or perform an operation that would normally result in
VLD a value outside of this range, the variable will "wrap," or take on the corresponding
modulo. As an example, because of this, 127+1=-128. The result "wrapped around"
to the negative extreme.
Bit Overflow Status (Bd System Status bit):
• If ab[1]+a exceeds 32 signed bits the operation c=ab[1]+a
will produce a wrong result. No error flag is set.
• If a-ab[1] exceeds 32 signed bits the operation c=a-ab[1]
will produce a wrong result. No error flag is set.
• If a*ab[1] exceeds 32 signed bits the operation c=a*ab[1]
will produce a wrong result. The system flag, Bd, will be set.
If one of these variables is used with a variable of another type, it will be appropriately
converted (the variable will be type cast).
EXAMPLE:
In the equation where the variable on the left of the equal sign is an 8 bit one like ab[4],
all variables will be converted to 8 bit values and then operated on. Assigning the vari-
able ab[27]=al[m] directly stores the 8 least significant bits of al[m] into aw[27]. The
higher bits of the variable al[m] are lost. Conversely, if the left hand value is a 32 bit
variable and the right hand side contains both 8 bit and 16 bit variables, the 8 bit and
16 bit variables will be temporarily "upgraded" to 32 bits. In the equation al[3]=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 lower case variables,
while functions and commands have at least one upper case character. The term ab[i]
is a general purpose variable, while A is the acceleration function. Any user variable
can be assigned a value with an equation, but can also be sequentially loaded by
specifying the starting variable and the series of values to be loaded.
24
ab[index] (continued)
8-Bit Array Variables
See Appendix C
To describe the
relationship between
user assigned
variables, aa thru
zzz, and variable
arrays, ab[ ], al[ ]
and aw[ ]
25
al[index]
32-Bit Array Variables
DEFAULT VALUE: 0
FIRMWARE VERSIONS: 4.00 and higher
DETAILED DESCRIPTION:
The SmartMotor™ has 8, 16 and 32 bit arrays. The 32 bit array takes the form
of the variables al[index]. These are general purpose 32 bit signed variables
that can be reported, used on either side of an equation, and used with vari-
ables other than 32 bit. Like all user variables, they are always lower case,
can be sequentially loaded and are automatically initialized at power up or
See Appendix C reset. All arrays share memory space with the variables aa through zz and
To describe aaa through zzz.
the relationship The syntax of the 32 bit array is al[index] (al stands for array long) and
between user accepts an index value between 0 and 49. This index can be specified explic-
assigned variables, itly or though another variable.
aa thru zzz, and
variable arrays, EXAMPLE:
ab[ ], al[ ] and
al[4] refers to the fifth element (count begins with zero) in the 32 bit array.
aw[ ]
The value of any array element al[ ] is reported with the R, PRINT( ) or
PRINT1( ) functions. For example to send the value of variable al[47] out the
primary serial port, u se the command Ral[47] or PRINT(al[47],#13). To send
the value of the variable al[37] out serial port 1, use PRINT1(al[37],#13).
The al[ ] array is classified as read write, meaning that they can be assigned a
26
al[index] (continued)
32-Bit Array Variables
Related value, or can be assigned to some other variable or function. Another way of saying
Commands: this, though more cryptically technocratic, is that these variables can be left or right
hand values.
a..z
EXAMPLE:
aa . . zz
al[24]=al[43]+al[7]
aaa . . zzz
is a valid equation, combining al[43] and al[7] and sending the total into al[24].
ab[index]
As signed 32 bit variables, they are subject to the usual restrictions of signed digital
aw[index] words and values. The first bit is always a sign bit. They are limited to integer val-
VST ues between -2147483648 to 2147483647. Math operations that result in decimal
values are truncated, or rounded down. 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, 2147483647+1=-
2147483648. The result "wrapped around" to the negative extreme.
Bit Overflow Status (Bd System Status bit):
• If al[1]+a exceeds 32 signed bits the operation c=al[1]+a
will produce a wrong result. No error flag is set.
• If a-al[1] exceeds 32 signed bits the operation c=a-al[1]
will produce a wrong result. No error flag is set.
• If a*al[1] exceeds 32 signed bits the operation c=a*al[1]
will produce a wrong result. The system flag, Bd, will be set.
If one of these variables is used with a variable of another type, it will be appropriately
converted (the variable will be type cast).
EXAMPLE:
In the equation where the variable on the left of the equal sign is a 16 bit one like
aw[4], all variables will be converted to 16 bit values and then operated on. Assign-
ing the variable aw[27]=al[m] directly stores the 16 least significant bits of al[m] into
aw[27]. The higher bits of the variable al[m] are lost. Similarly, if the left variable is
an 8 bit one like ab[167], all variables will be converted to 8 bit values before being
operated on. Conversely, if the left value is a 32 bit variable and the right side contains
both 8 and 16 bit variables, both 8 and 16 bit variables will be temporarily "upgraded"
to 32 bits. In the equation al[3]=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 lower case variables,
while functions and commands have at least one upper case character. The term
al[i] is a general purpose variable, while A is the Acceleration function. Any user
variable can be assigned a value with an equation, as discussed above, but can also
be sequentially loaded by specifying the starting variable and the series of values to
be loaded. (Continued on following page)
27
al[index] (continued)
32-Bit Array Variables
See Appendix C
To describe the
relationship between
user assigned
variables, aa thru
zzz, and variable
arrays, ab[ ], al[ ]
and aw[ ]
28
aw[index]
16-bit Array Variables
29
aw[index] (continued)
16-Bit Array Variable
Related some other variable or function. Another way of saying this, though more cryptically
Commands: technocratic, is that these variables can be left or right hand values.
a..z EXAMPLE:
aa . . zz aw[24]=aw[43]+aw[7]
aaa . . zzz The above is a perfectly valid equation, taking aw[43] and aw[7] and stuffing the sum
into aw[24].
al[index]
As signed 16 bit variables, they are subject to the usual restrictions of signed digital
ab[index] words and values. The first bit is always a sign bit. They are limited to integer values
VST between -32768 and 32767. Math operations that result in decimal values are trun-
cated, or rounded down. If you assign or perform an operation that would normally
VLD result in a value outside of this range, the variable will "wrap," or take on the cor-
responding modulo. As an example, because of this, 32767+1=-32768. The result
"wrapped around" to the negative extreme.
Bit Overflow Status (Bd System Status bit):
• If aw[1]+a exceeds 32 signed bits the operation c=aw[1]+a
will produce a wrong result. No error flag is set.
• If a-aw[1] exceeds 32 signed bits the operation c=a-aw[1]
will produce a wrong result. No error flag is set.
• If a*aw[1] exceeds 32 signed bits the operation c=a*aw[1]
will produce a wrong result. The system flag, Bd, will be set.
If one of these variables is used with a variable of another type, it will be appropri-
ately converted. In technical jargon, the variable will be type cast. For example, in
the equation where the variable on the left of the equal sign is an 8 bit one like ab[4],
all variables will be converted to 8 bit values and then operated on. Assigning the
variable aw[27]=al[m] directly stores the 16 least significant bits of al[m] into aw[27].
The higher bits of the variable al[m] are lost. Conversely, if the left value is a 32 bit
variable and the right side contains 16 bit variables, the 16 bit variables will tempo-
rarily revert to 32 bits. In the equation al[3]=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 lower case variables,
while functions and commands have at least one upper case character. The term
aw[i] is a general purpose variable, while A is the Acceleration function. Any user
variable can be assigned a value with an equation, as discussed above, but can also
be sequentially loaded by specifying the starting variable and the series of values to
be loaded.
30
aw[index] (continued)
16-Bit Array Variable
Appendix C
(Page ?)
uses tables to
describe the
relationship between
user assigned
variables, aa thru
zzz, and variable
arrays, ab[ ], al[ ]
and aw[ ]
31
A=expression
Set Acceleration
32
A=expression (continued)
Related
Commands:
Example:
D MP 'Set Mode Position
E A=5000 'Set Acceleration
G P=20000 'Set Absolute Position
V=100000 'Set Velocity
MP
G 'Start Motion
MV
Example:
PIDn
A=100 'set buffered acceleration
P V=750 'set buffered velocity
V MV 'set buffered velocity mode
X G 'Start motion
F=1
33
ADDR
Set Motor Address
LIMITATIONS: N/A
DETAILED DESCRIPTION:
Using ADDR within a program permits an identical program stored in different motors
to differentiate between motors and provide individual runtime controls.
SWITCH ADDR
CASE 1 ' motors 1,2 and 3 "GO"
CASE 2
CASE 3 G
BREAK
CASE 4 S ' motor 4 "STOP"
ENDS ' Start motion (or stop)
Note: ADDR=# syntax DOES NOT work with v4.40 SM2315 series motors!
SADDR# syntax must be used to assign the address.
34
AIN{address}{input}
Analog Input from I/O Device
Please refer to the associated Users Manuals for specifics about each optional
Analog I/O card.
35
AMPS=expression
Set Drive PWM Limit
Referencing The AMPS command effectively limits both the continuous torque and speed of the
against a hard stop SmartMotor™.
this way
To set the SmartMotor to use maximum available PWM, issue the command
can eliminate an
AMPS=1023. Setting AMPS=0 limits PWM to 0 thereby preventing any output torque.
additional switch
To conceptually understand what happens when you use values between 0 and 1023,
and cable.
consider the following torque-speed diagram:
The AMPS function essentially cuts the torque-speed characteristic of the motor
by slicing off the part of the curve to the right of the AMPS line. Note that there are
some values of AMPS that will limit
top speed but not peak torque. The
slope of the line is highly depen-
dent on the voltage of the power
source.
AMPS is often used to limited torque
and speed.
AMPS torque-speed
diagram
AMPS has no effect in torque mode
(MT, T) . In this mode, the value of
T controls the commanded torque
of the motor, without limitation by
AMPS.
36
AOUT{address},{value}
Analog Output to I/O Device
37
Ba
Peak-Over-Current Status Bit
38
Bb
Parity Error Status Bit
39
Bc
Communications Overflow Status Bit
40
Bd
Math Overflow Status Bit
41
Bd (continued)
Math Overflow Status Bit
Related Example:
Commands:
Mode Follow with Ratio permits the shaft to respond with a user defined
Zd scaling gain to the external encoder input. There is a limit to the magnitude
of the gain such that
ZS
-256 < GAIN < 256
RW
The system flag Bd is set if this GAIN restriction is violated.
RPW
The flag is set immediately after executing the MFR command.
Zd 'reset error flag
MFMUL=256 'Multiplier for incoming encoder counts
MFDIV=1 'Divisor for incoming encoder counts
RBd 'Response to host 0
MFR 'Calculate Mode Follow Ratio
RBd 'Response to host 1
The MFMUL parameter cannot exceed 256 * MFDIV.
Note: The Bd bit will only go out of range on multiplication of two numbers,
not addition. In other words, IF you add two numbers and the result exceeds
+/-231 in magnitude, the number will be bit rolled over.
Example:
a=2140000000
ZS
b=a+a
Rb -14967296
Under the above condition even though the value of "b" is not correct, the
Math overflow bit was not set.
42
Be
Excessive Position Error Status Bit
43
Bf
Communications Framing Error Status Bit
44
Bh
Overheat/RMS Over-Current Status Bit
45
Bh (continued)
Overheat/RMS Over-Current Status Bit
Related The RMS current monitor continuously calculates the equivalent Root-Mean-
Commands: Square current of the amplifier. If the RMS current is too high for longer than
THD servo samples, the amplifier will turn off, Bh will be set to 1, the motor off bit
TEMP Bo set to 1 and the trajectory bit cleared to 0 ALL at the same time!. If issued,
TH RMODE will return "O." The SmartMotor™ will reject any motion commands
for approximately 10 milliseconds. The biggest difference between the two
THD overheat mechanisms described will be that, if the RMS current monitor detects
and overheat, the SmartMotor may not physically feel hot.
Z
Once Bh is set to 1, the historical overheat flag is latched when read by RW,
OFF
RS or accessing S. If the overheat condition no longer exists, Bh will be reset to
RW zero upon reporting (RS, RW) or accessing the S value.
IF Bh
IF TEMP>69
PRINT("MOTOR TOO HOT") 'inform host
GOSUB123 'deal with condition
ELSE
PRINT("RMS Over Current Trip")
GOSUB123 'deal with condition
ENDIF
ENDIF
Example:
Test to measure approximate shut down time - not very accurate but illustrates
TH, THD, and TEMP.
46
Bi
Index-Position Captured Status Bit
49
Bl
Historical Left-Limit Status Bit
UDM Bl is the historical left limit flag. If the left limit is found to be active during any servo
sample, Bl is set to 1, and remains 1 until reset by the user. In addition, the motion will
UDO stop and the motor will either servo or turn the amplifier OFF, depending on the value
SLE of the F function. The historical left/negative limit flag Bl provides a latched value in
case the limit may have already been reached and overpassed but is not at presently
SLD active.
SLP The real time left/negative limit flag is Bm, which only remains set to 1 while the signal
level on the user pin D is active. Whenever Bm is set to 1, Bl is set to one. The polar-
SLN
ity of the signal that is considered active is determined by commands LIMH (Active
Zl High-To-Stop) and LIML (active Low-To_Stop) in all non-PLS firmware motors. PLS
firmware motors are always Active High asserted.
ZS
If the pin’s function is assigned to being general purpose I/O by use of the UDI or UDO
commands, neither Bm nor Bl will be affected by the pin state. Changing pin states
will not elicit limit behavior from the motor. It will be necessary to issue the UDM com-
mand to assign the pin’s function to being a limit switch, for the pin to again elicit limit
behavior, including the setting of Bl.
50
Bl (continued)
Historical Left-Limit Status Bit
Related
Commands:
Bm In non-PLS firmware motors, Bl is reset to zero under the following condi-
tions:
Bp
1. When the S status byte is accessed for assignment
Br
2. or reported via RS, PRINT(S,#13) or PRINT1(S,#13)
LIMH
3. or directly reset with Zl and ZS.
LIML
4. or a G command is issued AND the Bm bit is not set.
LIMD
LIMN
In PLS firmware motors, Bl is reset to zero under the following conditions:
RS
By issuing either Zl and ZS.
RPW
RW
Example code:
UCI
IF Bm
UCP PRINT("LEFT LIMIT PRESENTLY ACTIVE")
UCO ELSEIF Bl
PRINT("LEFT LIMIT Previously CONTACTED")
UDI ELSE
PRINT("LEFT LIMIT NEVER REACHED")
UDM ENDIF
UDO
SLE
SLD
SLP
SLN
Zl
ZS
53
Bp
Real-Time Right-Limit Status Bit
Related
Commands: APPLICATION: Monitor right limit switch
Bm DESCRIPTION: Right / Positive limit state
Bl EXECUTION: Sampled each PID update
Br CONDITIONAL TO: LIMH, LIML
LIMH LIMITATIONS: None
LIML REPORT COMMAND: RBp
LIMD READ/WRITE: Read only
LIMN LANGUAGE ACCESS: Expressions and conditional testing
RS UNITS: Binary flag
RPW RANGE OF VALUES: 0 or 1
RW VALUES BY STATE: 0= right/positive limit switch not active or pin not
assigned as a limit switch
UCI
1= right/positive limit switch is active
UCP
DEFAULT VALUE: 0
UCO
FIRMWARE VERSIONS: ALL
UDI
DETAILED DESCRIPTION:
UDM
Bp indicates if the right/positive pin is presently active. If Bp is set to 1, the
UDO historical right limit flag Br is also set to one. In non PLS firmware motors, the
SLE polarity of the signal that is considered active is determined by commands LIMH
and LIML. [PLS firmware has Active High Limits only! ]
SLD
Note on Programmable Software Limits (>=4.76 firmware)
SLP The Active/Real-Time status bit will be set to a one as long real time position is
beyond the programmed software limit position.
SLN
The Right/Positive Hardware Travel Limit may be disabled by being assigned
Zl
as a general purpose Input via UCI command or Output via UCO command.
ZS To Re-Enable the Right/Positve Hardware Travel Limit, issue UCP.
Example:
IF Br
PRINT("Right LIMIT PRESENTLY ACTIVE")
ELSEIF Bp
PRINT("Right LIMIT Previously CONTACTED")
ELSE
PRINT("Right LIMIT NEVER REACHED")
ENDIF
UDM Br is the historical right limit flag. If the right limit is found to be active during any servo
sample, Br is set to 1, and remains 1 until reset by the user. In addition, the motion will
UDO stop and the motor will either servo or turn the amplifier OFF, depending on the value
SLE of the F function. The historical right/positive limit flag Br provides a latched value in
case the limit may have already been contacted (active) but is not at presently active.
SLD
The real time Right/Positive limit flag is Bp, which only remains set to 1 while the signal
SLP level on the user pin C is active. Whenever Bp is set to 1, Br is set to one. The polar-
ity of the signal that is considered active is determined by commands LIMH (Active
SLN High-To-Stop) and LIML (active Low-To_Stop) in all non-PLS firmware motors. PLS
Zl firmware motors are always Active High asserted.
ZS If the pin’s function is assigned to being general purpose I/O by use of the UCI or UCO
commands, neither Bp nor Br will be affected by the pin state. Changing pin states
will not elicit limit behavior from the motor. It will be necessary to issue the UCP com-
mand to assign the pin’s function to being a limt switch, for the pin to again elicit limit
behavior, including the setting of Br.
(Continued on next page)
55
Br (continued)
Historical Right-Limit Status Bit
Related
Commands:
Bm
Bp
Bl In non-PLS firmware motors, Br is reset to zero under the following condi-
tions:
LIMH
1. When the S status byte is accessed for assignment
LIML
2. or reported via RS, PRINT(S,#13) or PRINT1(S,#13)
LIMD
3. or directly reset with Zr and ZS.
LIMN
4. or a G command is issued AND the Bp bit is not set.
RS
RPW
In PLS firmware motors, Br is reset to zero under the following conditions:
RW
By issuing either Zr and ZS.
UCI
UCP Example code:
UCO
IF Br
UDI PRINT("Right LIMIT PRESENTLY ACTIVE")
ELSEIF Bp
UDM
PRINT("Right LIMIT Previously CONTACTED")
UDO ELSE
PRINT("Right LIMIT NEVER REACHED")
SLE ENDIF
SLD
SLP
SLN
Zl
ZS
58
Bt (continued)
Trajectory-In-Progress Status Bit
Related Example 2:
Commands: MP 'buffer a position move request
BRKTRJ A=10
G V=440000
P=10000
OFF
G 'start the first buffered move
S WHILE Bt 'wait for first trajectory to be done
X LOOP 'Note: TWAIT could have been used!
A=20 'buffer another move
V=-222000
P=20000
G 'now begin the second move
Example 3:
MV 'Set to Velocity Mode
A=10
V=440000
G 'start moving
WHILE Bt 'Bt will remain 1 until commanded
LOOP 'otherwise or the motor
'errors out for some reason
59
Bu
Array Index Error Status Bit
Example:
Zu 'reset illegal index flag
t=0
WHILE t<60
al[t]=t 'initialize array members
t=t+1 'to values 0,1,2,3,4….
LOOP
RBu
60
Bw
Encoder-Wrap-Around Status Bit
61
Bw (continued)
Encoder-Wrap-Around Status Bit
Related
Commands:
Example to prevent wrap status while in Mode Follow continuously:
Z MF4 'Set to Mode Follow at default 1:1 ratio
WHILE 1
G IF @P>2147480000
MF0
Bi
ENDIF
RBx IF @P<-2147480000
MF0
RBi ENDIF
LOOP
I END
62
Bx
Real-Time Index Input Status Bit
IF Bx
PRINT("On Index Pulse",#13)
ENDIF
63
BASE
Cam Mode Master Cycle Length
64
BASE (continued)
Cam Mode Master Cycle Length
Related into a set of equally spaced intervals. Suppose BASE=1000 and SIZE=50. Each seg-
Commands: ment will then be of width BASE/SIZE or 20 counts. The cam motion is then defined
by providing the required SmartMotor™ positions corresponding to CTR= 0, 20, 40,
MC 60 …940, 960 and 980 and 1000. If the motion is truly periodic the required position
MC2 at CTR=0 will identical to the required position at CTR=1000.
MC4 The cam table is loaded into the aw[ ] array, beginning at aw[0] and ending with
aw[SIZE]. It is simplest to define the cam using position at CTR=0 to be encoder posi-
MC8 tion 0 by issuing MF0 and O=0 commands.
SIZE EXAMPLE:
Aw[index] A "saw tooth" cam with periodic motion every 2000 external encoder counts and the
motion interpolation divided into 25 (equal) segments.
MF1
MF2
MF3
MF4
The motor will now begin following the External (Master) encoder via the defined CAM
profile above.
65
BRKC
Brake Control Re-Direct to Port C
66
BRKENG
Brake Engage
It is important to SmartMotors™ may be purchased with optional internal zero backlash brakes used
turn the servo off to hold a load for safety purposes.
when the brake
They are Fail Safe Magnetic Clutch Disk Brakes. When power is lost the brake engag-
is engaged, or
es. The default with power on is to disengage the brake when ever the drive stage is
the motor could
turned on. The brake takes between 3 and 5 milliseconds to actuate or release.
be driving against
the brake and When BRKENG is issued, the brake is de-energized allowing the magnetic brake to
overheat. When lock the shaft in place.
the SmartMotor
powers up, or BRKENG terminates the brake control modes BRKSRV, BRKTRJ, and BRKRLS.
comes out of a soft NOTE: BRKENG is a manual over-ride to the BRKSRV and BRKTRJ commands. You
reset, the brake must subsequently issue either BRKSRV, BRKTRJ, or BRKRLS to allow any further
control is set to shaft movement !
BRKSRV by default
to automatically Example:
enforce this safety OFF ' turn motor off
rule. WHILE @V ' wait for zero velocity
LOOP ' before
BRKENG ' applying the brake (shaft locked)
67
BRKG
Brake Control Re-Direct to Port G
68
BRKI
Brake Control Re-Direct to Port I
69
BRKRLS
Brake Release
70
BRKSRV
Brake Engage When Not Servoing
NOTE: SmartMotors™ may be purchased with optional internal zero backlash brakes used
to hold a load for safety purposes.
A position error
will terminate both They are Fail Safe Magnetic Clutch Disk Brakes. When power is lost the brake engag-
the trajectory in es. The default with power on is to disengage the brake when ever the drive stage is
progress state and turned on. The brake takes between 3 and 5 milliseconds to actuate or release.
servo on state.
It is important to turn the servo off when the brake is engaged, or the motor could be
In this instance,
driving against the break and overheat. The BRKSRV command does this for you by
the brake would
releasing the brake automatically whenever the motor is on and engaging it whenever
then be asserted
the motor turns off for any reason. Another way of looking at this is, the brake will be
automatically.
applied whenever the motor off bit Bo is 1.
BRKSRV terminates the brake control modes BRKENG, BRKTRJ, and BRKRLS.
71
BRKTRJ
Brake Engage With No Active Trajectory
72
BRKTRJ (continued)
Brake Engage With No Active Trajectory
Related One consequence of BRKTRJ is that the trajectory flag is reset to zero immediately
Commands: when trajectory generator declares the trajectory to be over. At this instant, the
BRKTRJ will engage the brake (de-energize the brake)
BRKENG
BRKRLS BRKTRJ 'set brake mode to follow Bt bit.
MP 'set buffered mode
BRKSRV A=100 'set buffered acceleration
BRKC V=100000 'set buffered maximum velocity
C1 'program statement label
BRKG P=1000 'set buffered target position
G 'servo on, start trajectory
BRKI (The brake will automatically be energized and released)
TWAIT 'wait for trajectory to end
'now brake will be on and servo off
WAIT=4069 'brake on for ~one second
P=0 'set new buffered target position
G 'servo on, brake off, trajectory
WAIT=4069
GOTO1 'effective loop forever
Note: A position error will terminate the trajectory in progress state. In this case, brake
would then be asserted.
Once in BRKTRJ mode, the brake can be audibly hear clicking on at the beginning of
each move and clicking back off at the end of each move.
This is normal and gives assurance of proper operation.
73
BREAK
Program Flow Loop Exit Control
ENDS
If a=2, the SmartMotor™ will print "Lo there!" If a=1, however, the SmartMotor will print
both "Hiya!" and "Lo there!" There is no BREAK statement to stop the program from
running into case 2.
74
BREAK (continued)
Program Flow Loop Exit Control
Related
Commands:
BREAK could always be replaced by GOTO, and this is how it is actually executed
CASE using the precompiled program location. BREAK has the advantages of not requiring
a statement label to define the program branch location and conforming to structured
DEFAULT programming methodology.
ENDS BREAK is not a valid terminal command, it is only valid from within a user program. If
LOOP you want to be able to "break out of" a control block by remote (terminal) commands
you will need to use GOTO# or GOSUB# and appropriate statement labels. The exam-
SWITCH ple illustrates this concept.
WHILE EXAMPLE:
a=1
WHILE a
PRINT("I am still here …",#13)
WAIT=12000
IF a==100
BREAK 'a=100 could be sent via serial command
ENDIF
LOOP
GOTO20
C10
PRINT("EXITED with a==100",#13)
END
C20
PRINT("EXITED with a<0",#13)
END
75
C{statement_label_number}
Program Subroutine Label
The first compiled program (C0 . . END) will be much smaller than the second (C999
. . END), even though they behave exactly the same.
The program header is read whenever the SmartMotor™ powers up or is reset. This
means that the SmartMotor knows how to jump to any label location, even if the
76
C{statement_label_number} (continued)
Program Subroutine Label
Related program has never been run, and start executing the program from there. This is a
Commands: common means of making a single program that contains several routines that can
be invoked on demand from a host.
GOSUBnnn
EXAMPLE:
GOTOnnn
END
C0
PRINT("Routine 0",#13)
END
C1
PRINT("Routine 1",#13)
END
C2
PRINT("Routine 2",#13)
END
To run routine 1, the host simply issues GOTO1 to the SmartMotor™. If the host
issues GOTO3, routine 3 is run. You can use a similar technique to allow the host to
control where the program starts.
Using GOTOnnn to jump to a location within a SWITCH block may be syntacti-
cally valid but yield unexpected runtime program execution when CASE number is
encountered.
It is also possible to use IF, WHILE, and SWITCH to provide such multiple choice
program start points.
EXAMPLES:
IF a==6
C0
G
ENDIF
77
CCHN(type,channel)
Close Communications Channel
78
CHN
Combined Communications Error Flag
Bc EXECUTION: Immediate
79
CHN (continued)
Combined Communications Error Flag
Related Each of the four bits of CHN correspond to one of the four communica-
Commands: tions system status bytes:
Bb Bc= CHN bit 0
Bs
Bb= CHN bit 3
CHN0
CHN1
Zs
80
CHN0
Communications Error Flag (RS-232)
RANGE OF VALUES: 0 to 15
TYPICAL VALUES: 0
DEFAULT VALUE: 0
DETAILED DESCRIPTION:
CHN0 holds binary coded historical error information regarding the channel 0 com-
munications channel. It gives the 4 bit status of the primary, or channel 0, serial port,
broken down as follows:
If RCHN0 returns a 4, it means that a scan error was detected on channel 0. If CHN0
equals zero, no error has been detected since opening the channel.
CHN0 is read only, but cannot be assigned to a variable. It can be reported through
RCHN0, as already seen, and PRINT(CHN0,#13) and PRINT1(CHN0,#13) as well.
81
CHN0 (continued)
Communications Error Flag (RS-232)
Related Example:
Commands:
The host transmitted A=100 but the serial port actually received K=100
CHN then tried to execute K=100
PRINT(CHN0) 'responds to host with 4
CHN1
'since K= is invalid
RCHN
Example: (test individual flags)
RCHN0 IF CHN0&4
PRINT("HOST CHANNEL - scan error occurred")
RCHN1 ELSEIF CHN0&1
PRINT("HOST CHANNEL - buffer overflow")
ENDIF
IF CHN0
PRINT("SERIAL ERROR !!")
ENDIF
82
CHN1
Communications Error Flag (RS-485)
83
CHN1 (continued)
Communications Error Flag (RS-485)
Related Example:
Commands:
Host transmitted A=100 but the serial port actually received K=100 then tried to
CHN execute K=100
PRINT(CHN1) 'responds to host with 4
CHN0
'since K= is invalid
RCHN
Example: (test individual flags)
RCHN0 IF CHN1&4
PRINT("CHANNEL 1 - scan error occurred")
RCHN1 ELSEIF CHN1&1
PRINT("CHANNEL 1 - buffer overflow")
ENDIF
84
CLK
Hardware Clock Variable
Example 1:
The following two examples perform the same function, pause for one second:
WAIT=4069 'Pause for one sec
CLK=0 'Initialize clock
WHILE CLK<4069 'Loop one sec
LOOP
85
CLK (continued)
Hardware Clock Variable
Related The advantage of the second example is that you could write code within the WHILE
Commands: loop to execute during the pause.
RCLK
Example 2:
WAIT
CLK increments more slowly at PID2 than PID1 etc.
To most easily see the effect, load and run the following code.
PID1
a=5
WHILE a
a=a-1
CLK=20
WHILE CLK<4089 LOOP 'note nested whiles are permitted
PRINT("PID1",#13)
LOOP
a=5
PID2
WHILE a
a=a-1
CLK=20
WHILE CLK<4089 LOOP
PRINT("PID2",#13)
LOOP
PID4
a=5
WHILE a
a=a-1
CLK=20
WHILE CLK<4089 LOOP
PRINT("PID4",#13)
LOOP
PID1 'return to PID1
END
86
CMD
Accept Command Input RS-232
87
CMD (continued)
Accept Command Input RS-232
88
CMD1
Accept Command Input RS-485
89
CMD1 (continued)
Accept Command Input RS-485
90
CTR
Second Encoder/Step and Direction Counter
MF0 and MS0 will both set CTR to Zero without changing the mode of operation.
(Continued on next page)
91
Second Encoder/Step and Direction Counter
Related
Commands:
EXAMPLE:
ENC0
To better understand the meaning of CTR; try the following with a SmartMotor™.
ENC1 O=1234 'Set origin to zero
Then issue:
MC RP 'response will be 1234
Then issue:
MF ENC1 'make INTERNAL encoder the source of
MF0 CTR
Then issue:
MF1 RP 'response will be zero
RCTR 'response is also zero 0
MF2 'Physically turn the motor shaft and
'Query the position again
MF4 RP 'response should again be that
MFR 'NON ZERO response obtained before
RCTR 'response is another non zero number
MS ENC0 'return internal motor shaft encoder to
'Normal functioning
MS0
If you have an external encoder, attach it to a SmartMotor and repeat the above
MSR sequence or some similar sequence.
If in gear mode (Mode Follow via MF(n)) and you issue MF0 on the fly, CTR will be
set to zero while trajectory continues without any glitch in movement. This serves two
purposes. One, it gives a means to zero the counter while moving. Two, it allows the
user to prevent Wrap status from occurring should CTR exceed +/-2^31.
92
D=expression
Set R elative Distance
Related
Commands:
APPLICATION: Trajectory control
A
DESCRIPTION: Relative move distance for position mode
G
EXECUTION: Buffered pending a G command
MP
CONDITIONAL TO: Position mode. See MFR command for alternate
MF1 usage.
MFR LIMITATIONS: Encoder wrap around will produce a position error
P REPORT COMMAND: RD
V READ/WRITE: Read write
LANGUAGE ACCESS: Assignment, expressions and conditional testing
UNITS: Encoder counts
RANGE OF VALUES: -2147483648 to 2147483647
TYPICAL VALUES: N/A
DEFAULT VALUE: 0
FIRMWARE VERSIONS: ALL
DETAILED DESCRIPTION:
The D command
can be used D=expression commands a relative distance move from the present position and will
during gearing be repeated every time a G command is issued. It is a signed value allowing a relative
to implement move in either direction.
Dynamic Phase
Adjust If you command a D move while the motor shaft is moving, its starting point will be
the actual shaft position when the G command is executed. In other words, the D
(See MFR). move will be relative to the reception of the G command on-the-fly. This method will
result in accumulating drift.
The D command
can also be sued To avoid drift, If you issue the command D=100 and then enter the G command
in CAM mode to ten times each after the previous move has completed, you will travel a total of
implement a dwell precisely 1000 counts regardless of any following error at the end of the previous
between CAM moves. The D move starts from where you are supposed to be, regardless of the
cycles. present position error, avoiding the problem of position drift or accumulating errors
over several relative moves.
In downloaded code, you would use the TWAIT command prior to the next G com-
mand. In doing so, the next G will not be issued until the previous trajectory has
completed.
Relative Moves are subject to wrap status. If the next relative move causes the coun-
ter to exceed +/- 2^31 counts, the motor will error out. The following code example
will allow continuous indexing without exceeding maximum count.
Continued on next page
93
D=expression (continued)
Set Relative Distance
Related Example
Commands:
(Continuous Index Moves with no accumulated error or roll over)
P O=0 'reset origin A=100
'Set Acceleration V=100000
A 'Set Velocity D=20000
V 'Set Relative distance
G MP
'Set to Position Mode
MP WHILE 1 'While Forever.......
MF1 G
'Initiate Index Move
MFR TWAIT 'Wait until Move is Completed
In the above example, the motor counts will continuously increase to 20000
during each move and then be set back to zero at the end of each move. There
will be no accumulating error because the O=(expression) command accounts
for any following error that may be present after the trajectory has completed.
94
DAT
Accept Data Input Only (RS-232)
95
DAT (continued)
Accept Data Input Only (RS-232)
96
DAT1
Accept Data Input Only (RS-485)
97
DAT1 (continued)
Accept Data Input Only (RS-485)
98
DEFAULT
Switch-Case Structure Element
ENDS
The first line, SWITCH x, lets the SmartMotor™ know that it is checking the value of
the variable x. The second line, CASE 1:, begins the section of code that tells the
SmartMotor what to do if x is equal to 1. Similarly, the 8th line, CASE 3:, tells what to
do if x=3. Finally, DEFAULT, tells what to do if none of the CASE's match the value of
the x.
99
DEFAULT (continued)
Switch-Case Structure Element
Related If no CASE number equals the value of the SWITCH expression and there is no
Commands: DEFAULT case, program execution passes through the SWITCH control block
to the ENDS statement without explicitly performing any commands.
BREAK
There can only be one DEFAULT statement per SWITCH control block.
CASE
DEFAULT is not a valid terminal command, it is only valid within a user pro-
ENDS gram.
SWITCH Example 2:
a=20
WHILE a
SWITCH a-12
CASE -4 PRINT("-4 ") BREAK
CASE -3 PRINT("-3 ") BREAK
CASE -2 PRINT("-2 ") BREAK
CASE -1 PRINT("-1 ") BREAK
CASE 0 BREAK
CASE 1 PRINT("+1 ") BREAK
CASE 2 PRINT("+2 ") BREAK
CASE 3 PRINT("+3 ") BREAK
CASE 4 PRINT("+4 ") BREAK
DEFAULT PRINT("D ")
ENDS
a=a-1
LOOP
100
DIN{port}{channel}
Input Byte From I/O Device
101
DOUT{port}{channel}{expression}
Output Byte to I/O Device
102
E=expression
Set Allowable Position Error
Related Commands
G APPLICATION: Position Error Handling
103
ECHO
Echo Incoming RS-232 Data
104
ECHO_OFF
Turn RS-232 Echo Off
105
ECHO1
Echo Incoming RS-485 Data
106
ECHO_OFF1
Turn RS-485 Echo Off
107
ELSE
IF-Structure command flow element
ENDIF
The first line checks to see if g is equal to 43. If so, the string "Gee … 43!" is
sent out the primary serial port. The ELSE in line 3 tells the SmartMotor what
to do otherwise.
An IF control block can only have, at most, one ELSE. If such an ELSE exists
and the language interpreter evaluates the IF expression to be false (zero) and
there are no ELSEIF statements, then program will branch immediately to the
statement following the ELSE. If there are ELSEIF expression clauses within
the control block, all the ELSEIF clauses must precede the ELSE clause. In
these cases the ELSE clause is only executed in if both the IF expression is
false (zero) and all the ELSEIF expressions are false (zero).
108
ELSE (continued)
IF-Structure command flow element
Related
Commands:
ELSE is analogous to the DEFAULT case for a SWITCH control block.
ELSEIF exp ELSE is not a valid terminal command, it is only valid within a user
program.
ENDIF
EXAMPLE:
IF exp
ENDIF
EXAMPLE:
IF a==1 'only if a is NOT 1, 2, or 3
'will GOSUB5 be executed.
GOSUB2
ELSEIF a==2
GOSUB3
ELSEIF a==3
GOSUB4
ELSE
GOSUB5
ENDIF
109
ELSEIF
IF-structure command flow element
ENDIF
The first line checks to see if g is equal to 43. If so, the string "Gee … 43!" is
sent out the primary serial port and the IF control block terminates. If g is not
43, the program goes on to test if g is 43000. If it is, "43 grand for me." is sent
out the primary serial port and the IF control block terminates. Similarly, if g
is not 43000, the program goes on to test if g is -2. If it is, "-2?" is sent out the
primary serial port and the IF control block terminates.
An IF control block can have multiple ELSEIF statements. If such an ELSEIF
clause exists and the language interpreter evaluates the IF expression to be
false (zero) the program will branch immediately to first ELSEIF expression.
110
ELSEIF (continued)
IF-structure command flow element
Related If the associated expression is true, then the following clause is exe-
Commands: cuted until an ELSEIF, ELSE or ENDIF is encountered and then execu-
tion branches to the ENDIF of the present IF control block. If the first
ELSE ELSIF clause is not executed, then program execution continues at the
next ELSEIF expression and so on until all the ELSEIF expressions have
ENDIF been tested. In the case all ELSEIFs have false expressions and an
ELSE clause exists that clause will be executed.
IF exp
The ELSEIF statement is similar to the CASE number case for a
SWITCH control block. Note the difference - ELSEIF handles expres-
sions, CASE only handle a fixed number.
ELSEIF is not a valid terminal command, it is only valid within a user
program.
Example:
a=3
IF a==2 'expression will be found false
PRINT("222"
ELSEIF a==3 'expression will be found true
PRINT("333" 'so "3333" will be printed.
ENDIF
Example:
IF a==1 'only if a is NOT 1, 2, or 3
'will GOSUB5 be executed.
GOSUB2
ELSEIF a==2
GOSUB3
ELSEIF a==3
GOSUB4
ELSE
GOSUB5
ENDIF
111
ENC0
Set/Restore Internal Encoder for Servo
LIMITATIONS: N/A
READ/WRITE: N/A
UNITS: N/A
DETAILED DESCRIPTION:
The SmartMotor™ can accept inputs from either the internal integrated encoder or
an external source. ENC0 will cause the SmartMotor to read its position from the
internal encoder, while ENC1 uses the secondary (external) encoder. When ENC0
is active, the external encoder input will be tracked by the CTR variable and @P will
track the internal encoder.
EXAMPLE:
ENC1 'Servo from external encoder
ENC0 'restore default encoder behavior
112
ENC1
Select External Encoder for Servo
EXECUTION: Immediate
LIMITATIONS: N/A
If the external encoder is not connected or connected wrong, the motor may
run away. If this happens, use the RP command to check the position. If by
rotating the shaft you can change the position, then the encoder is connected,
but the A and B signals likely need to be swapped to reverse the direction
described by the quadrature phasing of the A and B signals.
EXAMPLE:
ENC1 'Servo from external encoder
ENC0 'restore default encoder behavior
113
END
End Program Code Execution
Note: All PLS firmware Motors automatically issue END upon receiving any of the
following error conditions:
Be (Position Error)
Bl (Left Travel Lmit)
Br (Right Travel Limit)
Bh (Over Temperature/RMS Over Current)
Please consult PLS firmware documentation for more details and options around
this.
114
ENDIF
End IF Statement
Every IF Each control block commencing with IF expression … must have a corresponding
structure must ENDIF block exit statement. The program statement following ENDIF is the common
be terminated with exit point branched to upon processing the IF … ENDIF control block regardless of
an ENDIF the execution path thought the control block at run time. There can only be one ENDIF
statement for each IF statement. The common exit point following ENDIF is branched
to upon the following:
1. Processing a true IF expression clause and encountering ELSEIF,
ELSE, or ENDIF.
2. Processing a true ELSEIF expression and encountering another
ELSEIF, ELSE, or ENDIF.
3. Processing an ELSE expression and encountering ENDIF.
4. If all IF and ELSIF expressions are false and there no ELSE
clause.
ENDIF is not a valid terminal command, it is only valid within a user program.
Example:
IF a==1
PRINT("ok",#13)
ENDIF
PRINT("EXIT",#13)
115
ENDS
End SWITCH Statement
116
EPTR=expression
Set Data EEPROM Pointer
117
ES400
Set EPROM Read/Write Speed
118
ES400 (continued)
Set EPROM Read/Write Speed
Related Example:
Command:
The following simple test program may well abort if ES400 is unreliable.
ES1000 PRINT("TEST ES400 & ES1000")
a=1000
WHILE a
a=a-1
ES400 'slower data rate
PRINT(#13,"ES400 ",a)
GOSUB5
ES1000 'faster data rate
PRINT(#13,"ES1000 ",a)
GOSUB5
LOOP
PRINT(#13,"TEST RAN TO COMPLETION")
PRINT(#13,"NO DATA ERROR DETECTED")
END
C5
WAIT=100
c=a
b=a
IF c!=b
PRINT("DATA PROBLEM - ABORT TEST")
ENDIF
RETURN 'add many GOTO10 statements here
GOTO10 'to fill up your program EEPROM
C10
PRINT(#13,"PROGRAM POINTER ERROR - ABORT TEST")
END
119
ES1000
Set EPROM Read/Write Speed
EXECUTION: Immediate
READ/WRITE: None
DETAILED DESCRIPTION:
ES1000 controls the transmit and receive bit rate while communicating between the
EEPROMS and the microprocessor. There are two settings - ES400 and ES1000.
ES1000 is the preferable higher data transfer rate for read and writing user programs
and data, and is the default data rate of version 4 SmartMotors™ and later. The ES400
command is used with older EEPROMs. If you have an "older" EEPROMs and Smart-
Motors of differing versions, you may wish to consider upgrading the EEPROMs.
120
ES1000 (continued)
Set EPROM Read/Write Speed
Related
Command:
Example:
ES400
The following simple test program may well abort if ES1000 is unreliable.
PRINT("TEST ES400 & ES1000")
a=1000
WHILE a
a=a-1
ES400 'slower data rate
PRINT(#13,"ES400 ",a)
GOSUB5
ES1000 'faster data rate
PRINT(#13,"ES1000 ",a)
GOSUB5
LOOP
PRINT(#13,"TEST RAN TO COMPLETION")
PRINT(#13,"NO DATA ERROR DETECTED")
END
C5
WAIT=100
c=a
b=a
IF c!=b
PRINT("DATA PROBLEM - ABORT TEST")
ENDIF
RETURN 'add many GOTO10 statements here
GOTO10 'to fill up your program EEPROM
C10
PRINT(#13,"PROGRAM POINTER ERROR - ABORT TEST")
END
121
F
Load PID Filter
122
F=expression
Motor Function Control
123
F=expression (continued)
Motor Function Control
F=1 Decelerate to stop on limit switch input (as opposed to just
Related turning off)
Command:
F=2 * Invert Commutation (Changes Shaft rotation)
None
F=16 * Mode Cam positions are relative for each re-entry into CAM
table (from either direction)
F=128 * Internal Slave Counter = base + dwell modulo while in CAM Mode
124
F=expression (continued)
Motor Function Control
END
Example using F=64 for C2 subroutine call and F=1024 Index Re-direct for posi-
tion capture
125
G
Start Motion (GO)
Related 9. Begin Host Mode (MD).motion prior to filling all buffered data slots.
Command:
(See Users Guide for Host Mode)
A
10. Initiate a phase Offset Move while in Electronic Gear Ratio in either Mode-
D Follow or Mode-Step
E MF0 MFMUL=1 MFDIV=10 MFR G WAIT=2000 D=2000 V=100 G
MC On Power-Up, the Motor defaults to the Off state with MP (Mode Position buffered
MD in with no Velocity or Acceleration values. As a result, if G is issued the motor will
immediately servo in place.
MFR Mode Follow (MS1, MF1, MF2 and MF4), Mode Step (MS), Mode Torque (MT),
MP and Amplifier Mode (MD50) are immediately active, they do not wait for any G com-
mand.
MV
If a G command is transmitted and no motion results, any of the following may be
P the cause:
UG
• E=0 or too small
UGI
• A=0 or 1
UGO
• V=0 or so small motion is not visible to naked eye
V • Target position equals present position
• D=0
• Bh=1 the motor is hotter than max permitted temperature TH
• AMPS=0 or too small
• T=0 or too small
• Motor is in Torque Mode
• LIMD is in effect and the "wrong" limit input switch is active
• Issued MF0 or MS0 instead of MFn or MS
• External encoder signal not present or not changing (in follow modes)
• Motor is part of a daisy chain that hasn't been properly set up
• Serial communications are good but target motor is not addressed
• Serial communications at incorrect baud rate
• Serial communications cable not attached or poorly connected
• Motor has no drive power
• Motor has a prior fault that needs to be cleared first (PLS firmware)
• Motor has no connections to limit switch inputs on boot-up and therefor has
travel limit fault (PLS firmware)
127
G (continued)
Start Motion (GO)
Related Command:
A
D
E
MC Example:
MD A=100 'Set buffered Acceleration
V=10000 'Set buffered Velocity
MFR P=1000 'Set buffered Position
MP 'Set buffered Position Mode
MP
G 'load buffered move, Start Motion
MV
To servo in place:
P P=@P 'Set buffered position equal to actual position
G 'Servo in place
UG
The execution time for G command varies with the computational burden of the mode
UGI or on the fly move. In the some cases, the G command computation may take longer
UGO than expected, and may result in motion profiles of poor quality or erroneous move-
ment. This can happen in very tight loops that don't allow the G command to fully
V process with each cycle, such as the following:
Example:
C10 'Place a label
P=CTR 'Set position equal to CTR
G 'Issue GO command
GOTO10 'Loop back to label
This type of code practice is not recommended because it forces a re-calculation over
and over again and will cause abrupt jerks or small glitches in the move profile.
128
GETCHR
Get Character from main RS-232
129
GETCHR1
Get Character From RS-485
Example:
130
GOSUB{number}
Subroutine Call
DETAILED DESCRIPTION:
The STACK control flow command explicitly and deliberately destroys the RETURN
Subroutines address history. Thus, if you issue STACK, take care that the program execution
present a great does not encounter a RETURN before the next GOSUB.
opportunity to
The GOSUB command is valid from both the serial channels and within the a user
partition and
organize your program. Do not, however, issue GOSUB{number} unless the corresponding
code. C{number} label exists within the stored program. Otherwise you willg et a memory
pointing error.
Note: If an attempt to issue a nonexistent GOSUB call is done via serial port, the
motor will respond with "+/-" which basically means a memory error.
131
GOSUB{number} (continued)
Subroutine Call
Related Example:
Command: GOSUB20 'run subroutine 20
GOSUB21 'run subroutine 20
C{number} a=3
GOSUB25 'run subroutine 20
GOTO{number} END 'End code execution
STACK
C20 'nested subroutine
GOSUB30
PRINT("20",#13)
RETURN
C21 'nested subroutine
GOSUB30
PRINT("21",#13)
RETURN
C25 'recursive subroutine
PRINT(" 25:",a)
a=a-1
IF a==0
RETURN
ENDIF
GOSUB25
RETURN
C30 'normal subroutine
PRINT(#13,"Subroutine Call ")
RETURN
Subroutine Call 20
Subroutine Call 21
132
GOTO{number}
Branch Program Flow to a Label
READ/WRITE: N/A
Novice programmers use IF statements and GOTOs to create elaborate and sophis-
ticated programs that quickly become impossible to read or debug. Force yourself to
use GOSUBs for program control. You'll be glad you did.
133
I (capital i)
Encoder Index Pulse Location
134
I (continued)
Encoder Index Pulse Location
Note: >=v4.95 has the ability to redirect Port G to the Index register input trig-
ger allowing high speed position capture via Port G this capture time occurs at
CMOS level and is typically around 3 to 5 microseconds.
All the same rules apply to arming and clearing the index as stated above.
The Re-Direct to Port G is accomplished with the F command. See F= in this
programmers guide for more detail.
135
IF expression
Conditional Program Code Execution
Every "IF" struc- Expression is a test condition, Both mathematical comparisons and boolean logic
ture must be bit wise comparisons can be used. Each must evaluate to be true.
terminated with an
IF a==b (If a equals b) IF a!=b (If a does not equal b)
"ENDIF".
IF a<b (If a is less than b) IF a<=b (If a is less than or equal to b)
IF a>b (If a is greater than b) IF a>=b (If a is greater than or equal to b)
IF a&b (If a AND b, bit-wise) IF a|b (If a OR b, bit wise comparison)
IF a (If a does not equal zero, common shortcut to IF a==1)
All above examples must be True to allow code beginning below the IF command
to run. If they are not true, the code execution will jump down to the nearest ELSE,
ELSEIF or ENDIF and continue from there.
136
IF expression (continued)
Conditional Program Code Execution
Related
Commands:
Example 1: Simple case of: IF true, run some code.
ELSE
IF @P>12345 'If Position is above 12345
ELSEIF
PRINT("position is greater than 12345",#13)
ENDIF ENDIF
'This is the next line of code to be executed
'whether it is true or not.
Example 2: If true, run some code, ELSE if false run some other code...
IF @P>12345 'If Position is above 12345
PRINT("position is greater than 12345",#13)
ELSE 'If it is no true
PRINT("position is not greater than 12345",#13)
ENDIF
'This is the next line of code to be executed
Example 4: Test for two conditions and default to another line of code:
IF @P>100 'If Position is above 100
PRINT("position is greater than 100",#13)
ELSEIF @P<=0 'If it less than or equal to zero
PRINT("position is <= to zero",#13)
ELSE
PRINT("position is between zero and 100",#13)
ENDIF
137
IF expression (continued)
Conditional Program Code Execution
Related
Commands:
Example 5: Binary Bit Mask Comparison:
ELSE
a=10 'binary 1010
ELSEIF b=5 'binary 0101
c=7 'binary 0111
ENDIF d=1 'binary 0001
e=0 'binary 0000
138
KA=expression
PID Acceleration Feed Forward
DETAILED DESCRIPTION:
KA sets the buffered acceleration feed forward gain. The acceleration feed forward
term helps the PID filter to cope with the predictable effects of acceleration and
inertia.
The KA gain factor is only applied in position (MP) and velocity (MV) moves. Issuing
a new KA parameter is not effective until it is loaded into the present PID filter by
the F command. The default value for KA is 0, and acceptable values range from 0
to 65,535.
PRINT(KA,#13) and RKA both report the value of KA through the primary serial
port, while PRINT1(KA, #13) sends it out channel 1. KA is valid with any expres-
sion, and can be treated as if it were any read-write variable. The motion or servo
characteristics are unaffected until KA is applied by the F function.
Example:
KA=200 'set buffered acceleration feed forward
F 'update PID filter
139
KD=expression
PID Derivative Compensation
140
KG=expression
PID Gravity Compensation
141
KI=expression
PID Integral Compensation
142
KL=expression
PID Integral Limit
143
KP=expression
PID Proportional Compensation
144
KS=expression
PID Derivative Term Sample Rate
145
KV=expression
PID Velocity Feed Forward
Example :
KV=1000 'Set buffered velocity feed forward
F 'Update Filter
146
LEN
Main RS-232 data buffer fill level
Example:
147
LEN1
RS-485 data buffer fill level
Example:
148
LIMD
Enable Directional Travel Limits
149
LIMH
Travel Limits Active High
Related Command:
APPLICATION: Travel Limit Switch Control
LIMD
DESCRIPTION: Limits are active high to stop motion
LIML
EXECUTION: Immediate
LIMN
CONDITIONAL TO: N/A
UCP
LIMITATIONS: N/A
UDM
REPORT COMMAND: N/A
READ/WRITE: N/A
LANGUAGE ACCESS: N/A
UNITS: N/A
RANGE OF VALUES: N/A
TYPICAL VALUES: N/A
DEFAULT PROPERTY: Limits are active low
FIRMWARE VERSIONS: 4.15 and 4.40. (not available in PLS firmware)
DETAILED DESCRIPTION:
The limit switches are associated with the I/O C and I/O D pins. Following a power up
or reset (the Z command), the limit inputs are active LOW by default. This means if
the logic state goes low, the motor will stop.
LIMH defines the limit inputs to be active HIGH. This means if the logic state level
goes high, the motor will stop.
NOTE: The limit input pins have 5K Ohm pull-ups meaning they are seen as logic high
when there is no connection to them.
LIML defines them back to active low.
Associated with the limit switches are the system flags:
Command Command to Command to
Hardware Travel Limit Overview Status Bits
to Clear Disable Enable
Port Pos/Neg Plus/Minus Left/Right Real Time Historical Historical Bit Travel Limit Input Travel Limit Input
Port C Positive PLUS RIGHT Br Bp Zr, or ZS UCI or UCO UCP
150
LIML
Travel Limits Active Low
151
LIMN
Enable Non-Directional Travel Limits
152
LOAD
Download Compiled User Program to Motor
153
LOAD (continued)
Download Compiled User Program to Motor
Note: If you were to open an SMX file in NotePad to look at it and then save
it, Notepad will automatically add carriage return characters at the end of each
line it sees. The resultant file will not work. Each carriage return would have to
be stripped back out prior to download. So do not alter the smx file in any way
from how SMI generated it.
154
LOCKP
Prevent User Program Upload
NOTE: LOCKP modifies the contents of the header file portion of the downloaded Program
in the motor's EEPROM to prevent the contents from being uploaded. That is, the
(For motors commands UP and UPLOAD will not actually be able to upload the program body or
with a plug-in contents. This does not prevent the downloading of another program.
Memory Module)
It is suggested that the LOCKP command is used after program development and
Once LOCKP has testing is complete.
been invoked the
Memory Module LOCKP is intended as a serial command only. It should be issued from the terminal
EEPROM cannot screen.
be unlocked and
It should not be in the actual downloaded code.
the module must be
replaced to return to Once LOCKP is issued, issuing UP or UPLOAD will no longer produce results.
an unlocked
condition.
155
LOOP
Return to WHILE Program Flow Control
156
LOOP (continued)
Return to WHILE Program Flow Control
Related Example:
Command:
BREAK b=1
WHILE WHILE b<5
PRINT(#13,"b=",b)
b=b+1
LOOP
PRINT(#13,"Exit Loop")
END
b=1
b=2
b=3
b=4
b=5
Exit Loop
157
MC
Enable Mode-CAM (Electronic Camming)
The Cam Mode, like any other position mode, is subject to the error band defined
by the E value, and subject to limit switch inputs. While in motion during Cam
Mode, flag Bo will be 0, flag Bt will be 1 and flag Be will be 0.
Note: PLS version Firmware allow the ability to run a relative CAM mode vice
Absolute. Please consult the Firmware addendum documents for more detail.
159
MC2
Mode CAM 2X Multiplier
160
MC4
Mode CAM 4X Multiplier
161
MC8
Mode CAM 8X Multiplier
162
MD50
Enable Direct Analog-Input Drive-Mode
163
MF0
Enable Quadrature-Input Counter Mode
164
MF0 (continued)
Enable Quadrature-Input Counter Mode
Related
Command:
EXAMPLE: (This example will print to the main channel)
RCTR
CTR b=4 'b high for initial print
C1 'Switch watch routine
MF1 a=CTR&3 'a will recycle 0-3
IF a!=b 'See if new a
MF2 PRINT("SELECT: ",a,#13)
b=a 'Update b, no re-prnt.
MF4 ENDIF
IF UGI==0 'Look for button
GOSUB20 'Sub. to use a
ENDIF
GOTO1 'Infinite loop
165
MF1
Enable Mode-Follow, Raw Resolution
166
MF2
Enable Mode-Follow Half-Quadrature
167
MF4
Enable Mode Follow Full Quadrature
Related Command: APPLICATION: Motion mode control
CTR DESCRIPTION: Mode Follow 1 external counts per 1 count of shaft
motion.
MC
EXECUTION: Immediate
MC2
CONDITIONAL TO: External encoder inputs present
MC4
LIMITATIONS: Do not issue MF0 while in mode MF4
MC8
REPORT COMMAND: RMODE
MF0
READ/WRITE: Associated external encoder is read only
MF1
LANGUAGE ACCESS: N/A
MF2
UNITS: N/A
MS
RANGE OF VALUES: N/A
TYPICAL VALUES: N/A
DEFAULT MODE: MP
FIRMWARE VERSIONS: All except 4.40 series
DETAILED DESCRIPTION:
MF4 causes the SmartMotor™ to instantly and precisely follow a second, external,
encoder signal from input pins A and B, resetting the external encoder CTR value
to zero. For each 4 external encoder counts (in the same direction) received by the
SmartMotor, the motor shaft will be requested to follow, moving 1 internal encoder
count in the same direction. Velocity and acceleration feed-forward gains are not
computed during this mode. Issuing any other mode such as MT or MP followed by G
will take the SmartMotor™ out of this following behavior.
MF4 instantly turns on the servo and resets any position error. The servo off flag Bo
is set to 0, the trajectory flag Bt is set to 1, and the position error flag Be is reset to
0. The motion is restricted by the present E value. Issuing E=0 will immediately cause
a position error after 4 encoder counts, in the same direction, are received from the
external encoder. The motion is also subject to the currently defined activity of the
limit switches.
Example:
MF4 'Reset CTR and Set follow mode
RMODE 'RESPONSE is "F"
WAIT=100000 'Follow for a while
MP 'Revert to position mode
A=100 'Set acceleration
V=537*1000 'Set velocity
P=0 'Set destination for home
G 'Terminate following start position move
RMODE 'RESPONSE is "P"
168
MFDIV
Set Mode-Follow Divisor
171
MFR (continued)
Calculate/Enable Mode-Follow-Ratio
172
MP
Enable Position-Mode
173
MP (continued)
Enable Position-Mode
Related
Command:
Due to integer math truncation, A is effectively rounded down to the next even number.
A A value of 1 or 0, therefore, produce a net acceleration of ZERO. In these instances,
requests to change the current velocity produce no change in velocity until A>=2 is
D requested and a new G command issued.
E Example:
G
MV 'Velocity Mode
MV
A=1000 'Set Acceleration
P V=50000 'Set Velocity
G 'Start Motion
V WAIT=6000 'Wait 6000 samples
MP 'Position Mode
A=50 'Set Acceleration
V=40000 'Set Velocity
P=1000 'Set Position
G 'Start (change) Motion
WAIT=200 'Wait 200 samples
V=45000 'Change Velocity
P=0 'Update Position
G 'Start Motion
174
MS
Enable Mode-Step
175
MS (continued)
Enable Mode-Step
Related MS will immediately turn on the servo and reset any position error. The servo off Bo
Command: is set to 0, the trajectory flag Bt is set to 1, and the position error flag Be is reset to 0.
The motion is restricted by the present E value. Issuing E=0 would immediately cause
CTR
a position error upon any encoder pulse being received from the external encoder.
RCTR The motion is also subject to the currently defined activity of the limit switches.
RMODE As with most stepping systems, opto-isolation modules are suggested when using
Step and Direction to assure robust operation.
MFDIV
Example 1: Immediate Mode Step, 1:1
MFMUL
MS 'Reset CTR and step and direction mode
MSR 'Motor will immediately start following pulses at 1:1
RMODE 'RESPONSE is "S"
WAIT=100000 'Follow for a while
MP 'Revert to position mode
P=0 'Set destination for home
A=100 'Set acceleration
V=50000 'Set velocity
G 'Terminate following start position move
RMODE 'RESPONSE is "P"
176
MS0
Enable Step/Direction Counter Mode
177
MSR
Calculate/Enable Mode-Step-Ratio
DEFAULT MODE: MP
DETAILED DESCRIPTION:
To use MSR, you will need to define the specific relationship (ratio) of the external
encoder input to shaft position, represented by the primary internal encoder count.
The command MSR must be issued after both MFMUL and MFDIV have been speci-
fied. Both MFMUL and MFDIV may be positive or negative; use this fact to control the
resulting direction of shaft motion. Overly large ratio gains are flagged by the firmware
setting the system flag Bd, and may be unstable. The error flag Bd will be set by
MFR if the magnitude of MFMUL/MFDIV is 256 or greater. MFR does NOT reset Bd
if already set by a prior procedure.
MSR followed by G will immediately turn on the servo and reset any position error.
The servo off Bo is set to 0, the trajectory flag Bt is set to 1, and the position error
flag Be is reset to 0. The motion is restricted by the present E value. Issuing E=0
would immediately cause a position error upon a single count of output motion
being required. The motion is also subject to the currently defined activity of the limit
switches.
The fractional ratio is accurate to 23 binary places, this means that if the external
encoder displacement during the motion exceeds 256*256*64 or 4,000,000 counts
the G command should be reissued. Within this limitation, the calculated requested
trajectory position is to within one count of mathematical precision.
178
In some applications, it may be necessary to introduce a phase shift to achieve proper
MSR (continued)
Calculate/Enable Mode-Step-Ratio
Related alignment during MFR following. To perform this shift, parameters D and V are
Command: employed to superimpose the corrective phase. During a phase shift RD will
report the remaining phase difference.
Bd
CTR As with most stepping systems, opto-isolation modules are suggested when
using Step and Direction to assure robust operation.
D
Example:
G Zd 'reset Bd system flag
MFDIV=-10 'Numerator = 21
MF1 MFMUL=21 'Numerator = 21
MSR 'Calculate Ratio
MF2
'input 21 external counts
MF4 'resulting motion -10 counts
D=0 'No phase shift
MFDIV IF Bd GOTO5 ENDIF 'gain too large
179
MT
Enable Torque-Mode
180
MT (continued)
Enable Torque-Mode
The above example will track an incoming analog signal from 0 to 5 Volts
UAA= 0 to 1023
Note: Do not attempt to regulate speed with Torque Mode. It is not designed
for that and will give poor results. In like manner, it is difficult at best to attempt
to place a speed limit on Torque mode. If the load decreases, the motor shaft
speed will increase to a new equilibrium with th lighter load because Power
must remain the same.
181
MTB
Enable Mode Torque Brake
DETAILED DESCRIPTION:
MTB places the SmartMotor™ into dynamic brake mode. In this mode, the motor
coils are shorted together. Any motion of the shaft would normally produce Back EMF
somewhat proportional to speed. Bt having the windings shorted out causes this Back
EMF to be dissipated immediately. he result is a magnetic damping counter force to
any attempted motion of the shaft for an external source.
IF MTB is issued while moving at a given speed, the shaft will come to a gradual stop
at a rate proportional to the Back-EMF that was being generated at the time of issu-
ing the MTB command. The shaft doesn’t stop at any predetermined or commanded
position and its trajectory is uncontrolled.
While in MTB, the motor will not produce any external DC bus voltage rise if the shaft
is rotated because all windings are shorted back to themselves. As a result, the DC
bus is protected against bus over voltage to within the drive stage current limits.
MTB is the default mode of operation for all motors with >=4.765 firmware. MTB is
automatically issued any time the motor faults on over temp, position errors or travel
limit crash.
The only mean to prevent this automatic action is to issue BRKRLS and OFF in that
sequence,.
182
MV
Enable Velocity-Mode
DEFAULT MODE: MP
DETAILED DESCRIPTION:
The MV command enables velocity mode. In velocity mode, the value of V, the tar-
get velocity, can be negative or positive. In contrast, position mode only uses the
magnitude of the velocity parameter. Acceleration and velocity can be changed at
any time, even during motion. The G command will initiate "on the fly" changes to
any of the parameters.
If the actual velocity is greater that the value defined by V, then, upon reception of
the next G command, the motor shaft will decelerate at the rate set by A until the
excess velocity is removed. Conversely, if the actual velocity is less than V when
the G command is entered, then the motor shaft motion will accelerate at the rate
set by A until the requested velocity is attained. Similarly, if the actual velocity is in
the opposite direction of V when the G command is entered, then the motor shaft
motion will decelerate and then accelerate at the rate set by A until the requested
velocity is attained.
Once the commanded velocity V is attained, motion continues at this rate, i.e. uni-
form velocity, indefinitely until the commanded velocity is changed or the mode is
otherwise terminated. The encoder may wrap around during this mode, but no posi-
tion error will be declared during the wrap.
In all firmware pror to 4.76, MV followed by G will immediately turn on the servo and
reset any position error. The servo off Bo is set to 0, the trajectory flag Bt is set to
1, and the position error flag Be is reset to 0. The motion is restricted by the present
183
MV (continued)
Enable Velocity-Mode
Related E value. Issuing E=0 would immediately cause a position error upon a single
Command: count of output motion being required The motion is subject to the currently
defined activity of the limit switches. RMODE will respond with a V.
A
D In firmware ==4.76 if ay prior errors exist, Zs r th appropriate command must
be used to clear the associated error status bit flag.
E
Due to arcane digital math, A is effectively rounded down to the next even
G number. A values of 1 and 0 therefor produce a net acceleration of zero. In
MV these instances, requests to change the current velocity produce no change in
velocity until A>=2 is requested and a new G command issued.
P
Example:
V MV 'buffer velocity mode request
A=2 'set the minimum possible buffered acceleration
PID loop V=44444 'set buffered velocity
G 'apply buffered motion parameter and mode
WAIT=V 'do not use TWAIT since move is forever
RMODE 'response is "V"
V=-V 'prepare to reverse velocity direction
A=2*A 'with double the present acceleration
G 'reverse direction
V=V/4 'prepare to slow to one quarter
'of original velocity
WAIT=V*V 'this is a valid expression
G 'slow to one quarter original velocity
WAIT=4096*10 'Wait 10 seconds
'(4069 servo samples = 1 second)
X 'decelerate to stop at acceleration set by "A"
END
184
O=expression
Set Main Position Counter
185
O=expression (continued)
Set Main Position Counter
Related Example: (reassigning origin does not destroy P and P buffered values)
Command: A=20
V=100000
RP P=5000
MP
MS0 O=-1000 'present position set to negative 10000
MF0 GOSUB5
O=12345 'present position set to 12345
GOSUB5
D=5000
O=3000 'present position set to 3000
GOSUB5
END
C5
PRINT(#13,"Move origin is ",@P)
G
WHILE Bt LOOP
WAIT=4000
PRINT(#13,"Position is ")
RP
RETURN
186
OCHN
Open /Set-up Communications Channel
187
OFF
Turn Off Drive Stage
Note: In all firmware -4.76, the OFF command may result in switching to: MTB (Mode
Torque Brake) depending on settings. If the otor is in default settings, MTB would be
the default "Off-State mode when OFF is issued.
Please see MTB command for more details
188
P=expression
Set Commanded Absolute Position
E REPORT COMMAND: RP
189
P=expression (continued)
Set Commanded Absolute Position
Related
Command:
Example:
@P MP 'Change to position mode (default power-up mode)
@PE P=1000 'Set buffered position to 1000 encoder counts
A=100 'Set acceleration
A V=32212*50 'Set velocity
G 'Start Motion
D TWAIT 'Wait for move to be performed
P=2000 'set a new buffered absolute target position
E G
G TWAIT
P=-2000 'Set a new (negative) buffered target position.
MP G
TWAIT
V P=-1000
G
TWAIT
P=0
G
190
PID#
P.I.D. Tuning Filter Control
191
PID# (Continued)
P.I.D. Tuning Filter Control
Related
Command:
A
V
Example:
WAIT
CLK 'For a 2000 count encoder SmartMotor™:
'Using three fixed values under each of the PID settings
v=128504 'use to Set commanded Velocity
a=3167 'use to Set commanded Acceleration
w=32552 'use to set Wait time
'
PID1 'Return to Default PID
WAIT=w 'Wait time = 8 seconds
END
As can be seen above, although the values used for Velocity, Acceleration, and Wait
times remained the same, their effect was changed by a factor for the PID setting.
As a result, much care should be taken if changes are made in the middle of a
program.
The PID parameter can be changed from PID1 to PID8 while the motor is sitting still
to increase I/O scanning efficiency or other code execution and then returned to
PID1 just prior to the next move. This is a technique used to increase response time
for input triggers or mathematical calculations while there is no trajectory in progress.
192
PRINT( )
Print to Primary Communications Port
193
PRINT( ) (continued)
Print to Primary Communications Port
Related Example:
Command: OFF
KP=100 'Set Proportional Gain
BAUD O=1234 'Set origin to 1234
a=1 b=2
PRINT("Demonstration:",#13)
CCHN PRINT("a=",a)
PRINT(" and b=",b,#13)
CMD PRINT("a+b=",a+b,#13)
PRINT("Position:",@P,#13)
DAT WAIT=10 'Allow time for serial buffer processing
PRINT("KP=",KP,#13)
F=4 PRINT("Hello World",#13,#13)
PRINT("Run Subroutines",#13)
OHCN WAIT=10
PRINT(#128,"GOSUB5 ",#13) 'tell all motors to run subroutine 5
PRINT1 WAIT=10
PRINT(#129,"GOSUB10",#13) 'Tell Motor-1 to run subroutine 10
PRINTA.. WAIT=10
PRINT(#130,"GOSUB20",#13) 'Tell Motor-2 to run subroutine 20
..PRINTH WAIT=10
PRINT(#131,"GOSUB30",#13) 'Tell Motor-3 to run subroutine 30
x=123
PRINT(#132,"GOSUB",x,#13) 'Tell Motor-4 to run subroutine 123
v=100000
a=100
p=2000
PRINT(#130,"A=",a," V=",v,#13) 'Set speed and accel in motor 2
WAIT=10
PRINT(#130,"MP P=",p, " G",#13) 'Command Motor-2 to position
2000
WAIT=10
PRINT(#13,#13,"End of Demonstration.",#13)
END
----------------------------------------------------
Output:
Demonstration:
a=1 and b=2
a+b=3
Position:1234
KP=100
Hello World
Run Subroutines
GOSUB5
GOSUB10
GOSUB20
GOSUB30
GOSUB123
A=100 V=100000
MP P=2000 G
End of Demonstration.
194
PRINT1( )
Print to Secondary Communications Port
195
PRINT1( ) (continued)
Print to Secondary Communications Port
Example:
Related OFF
KP=100 'Set Proportional Gain
Command: O=1234 'Set origin to 1234
a=1 b=2
BAUD PRINT1("Demonstration:",#13)
PRINT1("a=",a)
CCHN PRINT1(" and b=",b,#13)
PRINT1("a+b=",a+b,#13)
CMD PRINT1("Position:",@P,#13)
WAIT=10 'Allow time for serial buffer
DAT processing
PRINT1("KP=",KP,#13)
OCHN PRINT1("Hello World",#13,#13)
PRINT1("Run Subroutines",#13)
PRINT WAIT=10
PRINT1(#128,"GOSUB5 ",#13) 'tell all motors to run
PRINTA . . subroutine 5
WAIT=10
. . PRINTH PRINT1(#129,"GOSUB10",#13) 'Tell Motor-1 to run subroutine
10
WAIT=10
PRINT1(#130,"GOSUB20",#13) 'Tell Motor-2 to run subroutine
20
WAIT=10
PRINT1(#131,"GOSUB30",#13) 'Tell Motor-3 to run subroutine
30
x=123
PRINT1(#132,"GOSUB",x,#13) 'Tell Motor-4 to run subroutine
123
v=100000
a=100
p=2000
PRINT1(#130,"A=",a," V=",v,#13) 'Set speed and accel in
motor 2
WAIT=10
PRINT1(#130,"MP P=",p, " G",#13) 'Command Motor-2 to
position 2000
WAIT=10
PRINT1(#13,#13,"End of Demonstration.",#13)
END
----------------------------------------------------
Output:
Demonstration:
a=1 and b=2
a+b=3
Position:1234
KP=100
Hello World
Run Subroutines
GOSUB5
GOSUB10
GOSUB20
GOSUB30
GOSUB123
A=100 V=100000
MP P=2000 G
End of Demonstration.
196
PRINTA( ) . . . PRINTH( )
Print to External LCD Display
197
PRINTA( ) . . . PRINTH( ) (continued)
Print to External LCD Display
Related
Command:
In SMI, the character " ‘ " is a comment delimiter. As such, if you put a " ‘ " inside
BAUD of the PRINT statement, the SMI debugger will think that are commenting out
the rest of the PRINT statement and flag it as an error. The SmartMotor™,
CCHN however, doesn’t use comments, and will transmit the " ‘ " as a character. The
CMD easiest thing to do is simply not use " ‘ " within a print string.
DAT Please consult manual for LCD display products for more
on the following example.
OCHN
Example: (printing output to an AniLink LCD with port address A)
PRINT
PRINTA(#56,#14,#6,#1) '#56 initialize LCD,
PRINT1 #14 turns on cursor
#6 sets cursor
direction
#1 clears LCD and
resets position to
first character of
first line
PRINTA(#128,"I AM LCD ADDRESS A") 'Print stating
from character block
128, far left character
of first line
PRINTA(#192,"2nd. TEXT LINE") 'Print starting from
character block 192, far
left character of second
line of LCD
PRINTA(#148,"3rd. TEXT LINE") 'Print starting from
character block 148, 1st
character 3rd line. Four
line LCD4X20 only)
PRINTA(#212,"4th. TEXT LINE") 'Print starting from
character block 212, 1st
character fourth line.
Four line LCDX20 only
198
Q
Report Host-Mode Status
199
Ra . . . Rz
Report 32-Bit Variable Data Value
It is recommended Ra reports the signed value of the variable a to the primary serial channel. A minus
that you use sign will precede negative values, no leading zeros are transmitted, and an ASCII
the alternative carriage return terminates the transmitted data value. The equivalent PRINT( )
"PRINT( )" command is PRINT(a,#13). Use similar PRINT commands for Rb, Rc, through Rx,
command when Ry, Rz.
printing from In versions 4.15, 4.75, 4.41 and later, this has been changed to report through the
your embedded current active serial channel and not just the primary port. That is, if Ra is received
programs because through channel 0, the response is sent through channel 0. If Ra is received
of its greater through channel 1, the response goes out channel 1.
completeness
and versitility. In SmartMotors so equipped, if F=4 has been commanded, this report is redi-
rected to serial channel 1 and the reported value is not be "seen" output the
primary or currently active serial channel. Following F=4, the equivalent to Ra is
PRINT1(a,#13). F=0 resets report commands to again be sent out the primary or
currently active serial port.
200
Ra . . . Rz (continued)
Report 32-Bit Variable Data Value
Related Example:
Command:
F=0 'use HOST channel
PRINT( ) PRINT(#13,"F=0 ")
GOSUB5
F=4 'redirect report output
PRINT(#13,"F=4 ")
GOSUB5
F=0 'reset to default
END
C5
a=123
b=456
c=789
PRINT(a,b,c)
Ra
Rb
Rc
END
Host terminal only "sees" the following program output, Take note of the carriage
returns (not explicitly shown here)
F=0 123456789123
456
789
201
Raa . . . Rzz
Report 32-Bit Variable Data Value
REPORT VALUE: aa
READ/WRITE: N/A
UNITS: Number
DEFAULT VALUE: 0
DETAILED DESCRIPTION:
Raa reports the signed value of the variable aa to the primary serial channel. A minus
sign will precede negative values, no leading zeros are transmitted, and an ASCII
carriage return terminates the transmitted data value. The equivalent PRINT( ) com-
mand is PRINT(aa,#13). Use similar PRINT commands for Rbb, Rcc, through Rxx,
Ryy, Rzz.
In versions 4.15, 4.75, 4.41 and later, this has been changed to report through the
current active serial channel and not just the primary port. That is, if Raa is received
through channel 0, the response is sent through channel 0. If Raa is received through
channel 1, the response goes out channel 1.
202
Raa . . . Rzz (continued)
Report 32-Bit Variable Data Value
Related Example:
Command:
F=0 'use HOST channel
PRINT(#13,"F=0 ")
N/A GOSUB5
F=4 'redirect report output
PRINT(#13,"F=4 ")
GOSUB5
F=0 'reset to default
END
C5
rr=123
ss=456
tt=789
PRINT(rr,ss,tt)
Rrr
Rss
Rtt
END
Host terminal only "sees" the following program output. Take note of the carriage
returns (not explicitly shown here).
F=0 123456789123
456
789
203
Raaa . . . Rzzz
Report 32-Bit Variable Data Value
204
Raaa . . . Rzzz (continued)
Report 32-Bit Variable Data Value
Related Example:
Command:
F=0 'use HOST channel
PRINT(#13,"F=0 ")
N/A GOSUB5
F=4 'redirect report output
PRINT(#13,"F=4 ")
GOSUB5
F=0 'reset to default
END
C5
iii=123
jjj=456
kkk=789
PRINT(iii,jjj,kkk)
Rii
Rjj
Rkk
END
Host terminal only "sees" the following program output. Note the carriage returns
(not explicitly shown here).
F=0 123456789123
456
789
205
Rab[index]
Report 8-Bit Array Data Value
206
Rab[index] (continued)
Report 8-Bit Array Data Value
Related Example 1:
Command: a=0 'assign test values
WHILE a<=6
ab[a]=a
N/A
a=a+1
LOOP
p=2 q=3 u=1 v=5
PRINT(ab[0]," ") Rab[0] 'report ab[0]
PRINT(ab[1]," ") Rab[1] 'report ab[1]
PRINT(ab[2]," ") Rab[p] 'report ab[2]
PRINT(ab[3]," ") Rab[q] 'report ab[3]
PRINT(ab[4]," ") Rab[v-u] 'report ab[4]
PRINT(ab[5]," ") Rab[v] 'report ab[5]
PRINT(ab[6]," ") Rab[v+u] 'report ab[6]
END
Example 2:
a=254 'assign test values
WHILE a<=258
i=a-252
ab[i]=a 'assignment truncated to only 8 bits
Rab[i] 'reported values are -2 -1 0 1 and 2
a=a+1
LOOP
END
Example 3:
Rab[201] 'sets Bs
'fails to report a value but instead
'emits a syntax error message
'if syntax reports active
Example 4:
v=605
Rab[v] 'sets Bs
'fails to report a value but instead
'emits a syntax error message
207
Ral[index]
Report 32-Bit Array Data Value
208
Ral[index](continued)
Report 32-Bit Array Data Value
Related Example 1:
Command: a=0 'assign test values
WHILE a<=6
al[a]=a
N/A
a=a+1
LOOP
p=2 q=3 u=1 v=5
PRINT(al[0]," ") Ral[0] 'report al[0]
PRINT(al[1]," ") Ral[1] 'report al[1]
PRINT(al[2]," ") Ral[p] 'report al[2]
PRINT(al[3]," ") Ral[q] 'report al[3]
PRINT(al[4]," ") Ral[v-u] 'report al[4]
PRINT(al[5]," ") Ral[v] 'report al[5]
PRINT(al[6]," ") Ral[v+u] 'report al[6]
END
Example 2:
Ral[51] 'sets Bs
'fails to report a value but instead
'emits a syntax error message
'if syntax reports active
Example 3:
H=222
al[h] 'sets Bs
'fails to report a value but instead
'emits a syntax error message
'if syntax reports active
209
Raw[index]
Report 16-Bit Array Data Value
210
Raw[index] (continued)
Report 16-Bit Array Data Value
Related Example 1:
Command: a=0 'assign test values
WHILE a<=6
aw[a]=a
N/A
a=a+1
LOOP
p=2 q=3 u=1 v=5
PRINT(aw[0]," ") Raw[0] 'report aw[0]
PRINT(aw[1]," ") Raw[1] 'report aw[1]
PRINT(aw[2]," ") Raw[p] 'report aw[2]
PRINT(aw[3]," ") Raw[q] 'report aw[3]
PRINT(aw[4]," ") Raw[v-u] 'report aw[4]
PRINT(aw[5]," ") Raw[v] 'report aw[5]
PRINT(aw[6]," ") Raw[v+u] 'report aw[6]
END
Example 2:
a=65534 'assign test values
WHILE a<=65538
i=a-65534
aw[i]=a 'assignment truncated to only 16 bits
Rwb[i] 'reported values are -2 -1 0 1 and 2
a=a+1
LOOP
END
Example 3:
Raw[101] 'sets Bs
'fails to report a value but instead
'emits a syntax error message
'if syntax reports active
Example 4:
v=-605
aw[v] 'sets Bs
'fails to report a value but instead
'emits a syntax error message
'if syntax reports active
211
RA
Report Commanded Acceleration
212
RAIN{port}{input}
Report Expanded Analog Input Value
213
RAMPS
Report Allowable PWM Limit
214
RBa
Report PEAK-Over-current Status Bit
END
215
RBb
Report Communications Parity Error Status Bit
216
RBc
Report Communications Overflow Status Bit
217
RBd
Report Math Overflow Status Bit
Example 2:
Zd 'reset Bd
MFMUL=257 'initialize Mode Follow with Ratio
MFDIV=1
MFR
RBd 'returns 1 => MFR gain too large
If a standard 32 bit hand held calculator, in decimal mode, is used, it would also report
an error.
218
RBe
Report Position Error Status Bit
220
RBh
Report Over-Heat/RMS Over-Current Status Bit
221
RBi
Report Index-Captured Status Bit
222
RBk
Report EEPROM Checksum Status Bit
223
RBl
Report Real-Time Left-Over-Travel-Limit State
224
RBm
Report Historical Left-Over-Travel-Limit Status Bit
225
RBo
Report Motor-Off Status Bit
226
RBp
Report Historical Right-Over-Travel-Limit Logic State
227
RBr
Report Real-Time Right-Over-Travel-Limit State
228
RBs
Report Syntax-Error Status Bit
230
RBu
Report Array Index Error Status Bit
232
RBx
Report Real-Time Index Pulse Logic State
RBx
Output will be 1
233
RBy
Report Step/Direction Change Over-Run Status
Note: IEEE standard states that the Direction bit should be looked at while the stp bit
is low. If th direction bit transitions at the exact same time as the stp bit the By bit will
be set.
234
RCHN
Report Serial Communications Status Flags
235
RCHN0
Report Primary Serial Port Status
236
RCHN0 (continued)
Report Primary Serial Port Status
237
RCHN1
Report Secondary Serial Port Status
238
RCHN1 (continued)
Report Secondary Serial Port Status
239
RCS
Report Primary Serial Port Checksum
241
RCTR
Report Secondary Encoder Counter
MF0
RCTR 'responds with 0
242
RD
Report Commanded Relative Distance Value
G
D=2266 'buffered D value
RD 'response is 2266
243
RDIN{port}{channel}
Report Expanded Input Logic Status
Example:
RDINK0 'invalid port
RDINA66 'invalid channel
RDINC 244
RE
Report Maximum Allowable Position Error
245
RETURN
Return-From-Subroutine Program Flow Control
DETAILED DESCRIPTION:
Example:
PRINT("WAIT FOR HOST TERMINAL COMMANDS",#13)
GOSUB10 'start of subroutine 10
PRINT("PROGRAM RECEIVED EXTERNAL RETURN")
END
C10 'start of subroutine 10
WHILE 1 'wait for terminal commands
WAIT=100 'report terminal errors
IF Bs
PRINT(#13,"SCAN ERROR",#13)
Zs
ENDIF
LOOP
RETURN 'return to line just below GOSUB10 command 246
RI
Report Last-Captured Index Pulse Location
247
RKA
Report Acceleration-Feed-Forward Gain Tuning Value
248
RKD
Report Derivative-Gain Tuning Value
249
RKG
Report Gravitational Compensation Gain Tuning Value
250
RKI
Report Integral-Gain Tuning Value
251
RKP
Report Proportional-Gain Tuning Value
252
RKS
Report Inertial Time Constant Tuning Value
253
RKV
Report Velocity-Feed-Forward Tuning Value
254
RP
Report Real Time Position
255
RPE
Report Real-Time Position Error
256
RPE (continued)
Report Real-Time Position Error
END
257
RS
Report 8-Bit System Status Byte
258
RS (continued)
Report 8-Bit System Status Byte
Related Example:
Command: O=10000 'Set current shaft position
'as position 10000, set up move
RPW P=0
A=222
RW V=33333
MP
G 'go
WHILE Bt
GOSUB5 'monitor for status change
LOOP
PRINT(#13,"FINAL REPORT",#13)
GOSUB5 'final report
END
C5 'subroutine 5
PRINT(#13,"STATUS BYTE VALUE ") RS
IF S&32 'logical AND status byte "S"
'and position error status bit (0010 0000)
PRINT(#13,"POSITION ERROR !!!")
ENDIF
IF S&16 'logical AND status byte "S"
'and wraparound status bit (0001 0000)
PRINT(#13,"WRAP AROUND !!!")
ENDIF
IF S&1 'logical AND status byte "S"
'and trajectory error status bit (0000 0001)
PRINT(#13,"TRAJECTORY IN PROGRESS")
ENDIF
RETURN
259
RS2
Restore Port G normal control
260
RS4
Set Port G to RS-485 R/W Control Pin
261
RSP
Report CPU speed and Firmware Revision
RSP 24576/440C
262
RT
Report Commanded Torque Value
263
RUN
Start/Re-Start Program Execution
DETAILED DESCRIPTION:
The RUN command will start a stored (downloaded) user EEPROM program.
Issuing a RUN command does not reset any motion, variable or I/O states.
It does reset the program execution pointer (Stack Pointer) to zero, and resets the
internal GOSUB stack.
To test your program with a truly "fresh" start use the Z command to completely reset
the motor as if it were newly powered up.
To prevent this, make RUN? the first program statement of your user program, or if
you wish, place RUN? anywhere in your program. Upon encountering a RUN? the
program interpreter, execution machine, recalls whether or not the RUN command
was previously issued, and if RUN was not issued, program execution ceases. This
is similar to to encountering an END statement, except that a subsequent RUN com-
mand causes the program to take up after the RUN? statement.
264
RUN (continued)
Start/Re-Start Program Execution
Related liseconds after power up or reset. In versions 4.15, 4.75 and onwards, the
Command: stored program is aborted if the serial character string "EE", or subset "EE"
of "EEEEEEEEEEEE …." during the first 500 milliseconds after power up or
END
reset.
RUN?
Example: (user program with possible halt)
PRINT(" LOADING TRAJECTORY")
A=100
V=1000000
P=1000000
MP
PRINT(" Type RUN to start",#13 'Prompt user for
"RUN" command
RUN? 'Run command requested. Stop program
'execution until "RUN" command is received.
PRINT(" EXECUTING TRAJECTORY")
G
END
265
RUN?
Halt Program Execution until RUN Received
267
RW
Report System 16-Bit Status Word
If RW is reported the historical limit and overheat flags are immediately reset after
the request command operation is completed. The value W cannot be assigned to a
variable.
268
S (as command)
Stop Motion Quickly
A=100
V=1000000
P=5000000
G
WHILE Bt
IF UAI 'E-stop if PIN A high
S 'Stop Abruptly
PRINT("Emergency Stop")
ENDIF
LOOP
269
S (as status byte)
8-Bit System Status Byte
270
S (as status byte) (continued)
8-Bit System Status Byte
Related Example:
Command: O=10000 'set up move
P=0
RPW A=222
V=33333
RS MP
RW G 'go
WHILE Bt
GOSUB5 'monitor for status change
LOOP
PRINT(#13," FINAL REPORT",#13)
GOSUB5 'final report
END
C5
ss=S 'READ VALUE ONCE
'to record historical latches
'before reset !
PRINT(#13," STATUS BYTE VALUE ", ss)
IF ss&32
PRINT(#13," POSITION ERROR !!!")
ENDIF
IF ss&16
PRINT(#13," WRAP AROUND !!!")
ENDIF
IF ss&1
PRINT(#13," TRAJECTORY IN PROGRESS")
ENDIF
RETURN
271
SADDR#
Set Motor Address
272
SADDR# (continued)
Set Motor Address
Related EXAMPLE:
Command: 'Example Auto Addressing for 4 SmartMotors™ via SADDR command
'on an RS-232 Daisy chain
ADDR 'This program code would be run at the same time
'in all motors on the chain at power-up.
'Note: At this point, each motor will have run the exact same code
'causing successive motors downstream to receive the same command
string
'from the number of motors upstream.
CASE 3
SADDR3 ' Set Address to 3
GOSUB30
BREAK
CASE 4
SADDR4 ' Set Address to 4
GOSUB40
BREAK
ENDS
END
RETURN
C20 'MOTOR 2 CODE
RETURN
C30 'MOTOR 3 CODE
RETURN
C40 'MOTOR 4 CODE
RETURN
273
SILENT
Silence Primary Port Outgoing Communications
LIMITATIONS: N/A
READ/WRITE: N/A
DETAILED DESCRIPTION:
These commands
are almost always The SILENT command causes the SmartMotor™ to suppress all internally originating
sent from a host, serial communication messages intended for the channel 0 primary port. It does
rather than existing not prevent the SmartMotor from sending messages in response to incoming serial
within a program. report commands from the host, and it does not interfere with ECHOing received
serial communication over channel 0.
This command is most commonly used when sending a new program to an individual
SmartMotor mounted in a networked system. In order to guarantee that the program
arrives as sent, it is required that all other motors in the array be silent during
download.
The TALK command negates the effect of SILENT and restores the motor's primary
port to it's default state of operation.
274
SILENT1
Silence Secondary Port Outgoing Communications
LIMITATIONS: N/A
READ/WRITE: N/A
DETAILED DESCRIPTION:
The SILENT1 command causes the SmartMotor™ to suppress all internally originating
serial communication messages intended for the channel 1 secondary port. It does
not prevent the SmartMotor from sending messages in response to incoming serial
report commands from the host..
This command is most commonly used when sending a new program to an individual
SmartMotor mounted in a networked system. In order to guarantee that the program
arrives as sent, it is required that all other motors in the array be silent during
download.
The TALK1 command negates the effect of SILENT1 and restores the motor's
secondary port to it's default state of operation.
275
SIZE=expression
Set Number of CAM Table Data Points
276
SIZE=expression (continued)
Set Number of CAM Table Data Point
Related
Command:
Example:
BASE
A "saw tooth" cam with periodic motion every 2000 external encoder counts
G and the motion interpolation divided into 25 (equal) segments.
MC
The motor will now begin following the External (Master) encoder via the defined
CAM profile above.
277
SLEEP
Ignore Incoming Commands on Primary Port
READ/WRITE: N/A
DETAILED DESCRIPTION:
The SLEEP command is used to put a SmartMotor™ into Sleep Mode with respect
The SLEEP and to channel 0 serial commands. While in Sleep Mode, a SmartMotor will continue to
WAKE commands echo (if in ECHO mode) all characters received over the network, but will ignore all
are only sent from commands other than a WAKE command. A sleeping SmartMotor will also ignore
a host, never part a G-line input "go" request, but will be responsive to other input’s dedicated func-
of a SmartMotor™ tions.
program.
The most common use of the SLEEP command is to keep daisy-chained SmartMotors
from responding to commands in a program which is being downloaded to another
SmartMotor™ in the same chain.
If a program is running when a SmartMotor receives the SLEEP command, the pro-
gram will continue to run. Messages originating from within the running program of a
sleeping SmartMotor will be transmitted unless the motor is also in SILENT mode.
SLEEP may be issued from the terminal or within a user program. SLEEP mode is
terminated by the WAKE command.
278
SLEEP1
Ignore Incoming Commands on Secondary Port
279
STACK
Clear Stack Pointer Register
280
STACK (continued)
Clear Stack Pointer Register
Related
Command:
Example:
END
GOSUB C0
GOTO1
RUN
C7
RUN? PRINT(#13, "NO PROGRAM CRASH")
RETURN
END
GOSUB1
C1 GOSUB2
C2 GOSUB3
C3 GOSUB4
C4 GOSUB5
C5 GOSUB6 'sixth GOSUB without return
C6
STACK 'reset internal stack
GOSUB7 'allowing a seventh GOSUB
PRINT(#13,"RETURN FROM GOSUB7 OK")
END
The example above is not a good way to write code. It is just a means to
explain where the STACK command would be used to prevent program
crashes.
Often times, the STACK command is used after an error or motor protection
fault is detected. Then immediately after the STACK command, either RUN,
END or GOTO(location near top of program) is issued to recover.
281
SWITCH expression
Selectable Program Flow Control
282
SWITCH expression (continued)
Selectable Program Flow Control
The first line, SWITCH v, lets the SmartMotor™ know that it is checking the
value of the variable v. Each following CASE begins the section of code that
tells the SmartMotor what to do if v is equal to that "case".
Example:
a=-3 'test value
WHILE a<4
PRINT(#13,"a=",a," ")
SWITCH a 'test expression
CASE 3
PRINT("MAX VALUE",#13)
BREAK
CASE -1 'negative test values are valid
CASE -2 'note no BREAK here
CASE -3
PRINT("NEGATIVE")
BREAK 'note use of BREAK
284
T=expression (continued)
Set Open Loop Commanded Torque Value
Related Amplifier mode MD50 DOES EFFECT the value of T. To change from mode
Command: MD50 to mode MT, issue the sequence OFF T=value MT.
MT
RT Example:
UAI 'Set I/O A as Input
T=0 'Initialize T=0
MT 'Enter Mode Torque
C1 'Label 1, Loop Forever
a=UAA-512 'Read User defined I/O pin
'10 bit analog reading range
'is 0 to 1023 from 0 to 5VDC
'[ 2.5 V = 0 Torque ]
T=2*a
' Result: -1023 to +1023 values from 0 to 5VDC
END
The above example will track an incoming analog signal from 0 to 5 Volts
(UAA=0 to 1023) and assign it to the T torque value of -1023 to 1023.
285
TALK
Enable Outgoing Messages on Primary Port
286
TALK1
Enable Outgoing Messages on Secondary Port
287
TEMP
Read Motor Temperature
Motors with version 4.11 and higher permit the user to set the overheat temperature
trip point with the command TH=expression, and to set the time (THD=expression)
for which the overheat condition must exist before the servo is shut off. A motor in the
overheat condition will not turn on the servo even if commanded to do so.
If the motor were operating in Torque Mode at TEMP>TH for 4 seconds, the motor
would shut off. It would not restart until both the condition TH-TEMP>5 were true and
then MT command reissued.
a=-5
WHILE a<=10
TH=TEMP+a
WAIT=4000
G
WAIT=4000
IF Bt
BREAK
ENDIF
a=a+1
LOOP
PRINT("MOTOR RESTARTED WHEN TH-TEMP=",a)
END
a=5
WHILE a>-5 'vary TH about the present TEMP
TH=TEMP-a
WAIT=2000
GOSUB10 'observe Bh flag change from o to 1
a=a-1 'as TH is reduced to TEMP value and
less
LOOP
END
C10
PRINT(#13,"Read the temperature ",TEMP)
PRINT(#13,"Read TH overheat value ",TH)
PRINT(#13,"Read Bh overheat flag ",Bh)
RETURN
289
THD
Set Overheat Delay Timer
291
UA=expression
Set I/O Port A Out t Logi c State
292
UAA
Read I/O Port A as Analog Input
User I/O line A can serve as a 10 bit analog to digital input. The A to D reference is
5VDC and the returned data is between 0 and 1023. A value of 0 corresponds to
0 volts and 1023 to 5 volts. UAA is read only, and can be accessed with the state-
ment variable=UAA, PRINT(UAA,#13) or WHILE UAA>200 . . . LOOP. The analog
read occurs once at the time the UAA command is executed. Assigning the variable
a=UAA will perform the analog read once and store it into the variable a.
All user I/O pins have in internal 5K pull-up resistor, as well as current limiting and
other protection mechanisms. Any analog voltage source, then, should be rated to
adequately drive a 5K ohm input impedance.
The analog to digital conversion is always available on its corresponding I/O pin. That
is, regardless of whether the pin is being used as an input, output or other function, a
10 bit analog reading of I/O that pin is always available.
Example:
PRINT(#13,"PRINT UAA = ",UAA)
b=UAA
PRINT(#13,"REPORT UAA = ")
Rb
293
UAI (as command)
Set I/O Port A to Input
294
UAI (as input value)
Read I/O Port A Logic State
295
UAO (as command)
Set I/O Port A to Output
296
UBexpression
Set I/O Port B Output Logic State
297
UBA
Read I/O Port B as Analog Input
298
UBI (as command)
Set I/O Port B to Input
299
UBI (as input value)
Read I/O Port B Logic State
300
UBO (as command)
Set I/O Port B to Output
301
UCexpression
Set I/O Port C Output Logic State
302
UCA
Read I/O Port C as Analog Input
303
UCI (as command)
I/O COMMAND
304
UCI (as input value)
Read I/O Port C to Input
305
UCO (as command)
Set I/O Port C to Output
306
UCP
Set I/O Port C as Positive Over Travel Limit
307
UDexpression
Set I/O Port D Output Logic State
308
UDA
Read I/O Port D as Analog Input
309
UDI (as command)
Set I/O Port D to Input
310
UDI (as input value)
Read I/O Port D to Input
311
UDM
Set I/O Port D as Negative Over Travel Limit
312
UDO (as command)
Set I/O Port D to Output
313
UEexpression
Set I/O Port E Output Logic State
314
UEA
Read I/O Port E as Analog Input
315
UEI (as command)
Set I/O Port E to Input
316
UEI (as input value)
Set I/O Port E to Input
317
UEO (as command)
Set I/O Port E to Input
318
UFexpression
Set I/O Port F Output Logic State
319
UFA
Read I/O Port F as Analog Input
320
UFI (as command)
Set I/O Port F to Input
321
UFI (as input value)
Read I/O Port F Logic State
322
UFO (as command)
Set I/O Port F to Output
323
UG
Enable/Re-Enable Port G Sync Functionality
324
UGexpression
Set I/O Port G Output Logic State
325
UGA (as input value)
Read I/O Port G As Analog Input
326
UGI (as input value)
Read I/O Port G Logic Level State
327
UGI (as command)
Set I/O Port G to Input
328
UGO (as command)
Set I/O Port G to Output
329
UP
Complied User Program and Header Upload
330
UPLOAD
Standard User Program Upload
WARNING The UPLOAD command will upload only the text portion of the SmartMotor’s™
program as it appeared in your original source file. In contrast, the UP command
Do not use the will upload the text along with all of the binary information created by the
UPLOAD compiler that allows the program to run faster.
command within
a user program. UPLOAD immediately terminates any running user program. The program
counter is lost. UPLOAD does not terminate the present motion mode or
It will terminate trajectory, or change motion parameters such as E, A, V, KP, etc., or alter the
the program. present value of the users variables.
When communicating over a terminal use the UPLOAD command to verify the
program is the expected one. The comments in your original source code do not
appear when you UP or UPLOAD a program. The comments were removed by
the compiler, as is usual for any compiled computer program.
When uploading a program from a SmartMotor in a daisy chain, prevent the
other SmartMotors in the chain from issuing unexpected characters by using
the SILENCE and SLEEP commands. After the upload is complete, you can
re-enable normal communications with WAKE and TALK.
Example: (try the following program, down load it and then RUN)
PRINT(" PERFORM UPLOAD CMD")
UPLOAD
PRINT(" ANY MORE ?")
END
Velocity is held to 32 bits, 16 bits integer and 16 bits fractional. The units are counts
per sample period, shifted by the 16 bits (65,536).
32,212= (2,000counts/revolution)(65,536)
(4,069samples/second)
332
VLD(variable, number)
Data EEPROM READ/WRITE COMMAND
335
VST(variable, number) (continued)
DATA-EEPROM READ/WRITE COMMAND
'
PID1 'Return to Default PID
WAIT=w 'Wait time = 8 seconds
337
WAKE
Enable Open Communications on Primary Port
338
WAKE1
Enable Open Communications on Secondary Port
339
WHILE expression
Conditional Program Loop Flow Control
DETAILED DESCRIPTION:
The WHILE loop creates a program loop that repeatedly executes as long as a cer-
tain condition is true or non zero.
EXAMPLE:
LOOP
The "expression" is evaluated the first time WHILE is encountered, and each time
program execution is sent back to the WHILE by its corresponding LOOP statement.
If the "expression" value is zero or false, program execution re-directs to the code
just below the LOOP command. Any valid standard Animatics expression can be
used. In particular, WHILE 1 . . . LOOP is a standard loop forever control block.
WHILE is not a valid terminal command, it is only valid within a user program.
340
WHILE expression (continued)
program flow structures
Related Example:
Command: WHILE Bt 'While trajectory still in progress
'More efficient than Bt==1
BREAK UB=1 'Set output high
UB=0 'Set output low
LOOP LOOP 'Loop back to While
IF
Example:
SWITCH
a=0
WHILE a<7
b=a<3 'this is valid syntax !
IF b
PRINT("T ") 'true !
ELSE
PRINT("F ") 'false !
ENDIF
a=a+1 'increment loop index
LOOP
END
'output is "T T T F F F F "
LOOP
PRINT("Port C was grounded"),#13)
END 341
X
Decelerate Shaft to a Relative Position
342
Z
Total CPU Reset
WARNING! The Z command should not be used at or near the top of program
code. In doing so, it may cause a continuous and repetitive resetting of the CPU and
lock out the motor. IF this does happen, the Communications Lockup recovery tool
may be used to regain access to the motor.
343
Za
Reset Peak Over Current Flag
IF Ba 'Test flag
PRINT("Over Current")
Za 'Reset flag
ENDIF
WAIT=4000
IF Ba 'Retest flag
PRINT("Over Current still in effect")
ENDIF
344
Zb
Reset Comms Parity Error Flag
IF Bb 'Test flag
PRINT(" Parity Error ")
Zb 'Reset flag
ENDIF
345
Zc
Reset Comms Buffer Overflow Flag
346
Zd
Reset Math Overflow Error Flag
IF Bd 'Test flag
PRINT("Math Overflow")
Zd 'Reset flag
ENDIF
347
Ze
Reset Position Error Flag
IF Be 'Test flag
PRINT("Following Error")
Ze 'Reset flag
ENDIF
348
Zf
Reset Comms Framing Error Flag
IF Bf 'Test flag
PRINT("Framing Error")
Zf 'Reset flag
ENDIF
349
Zl
Reset Historical Left Limit Flag Flag
IF Bl 'Test flag
PRINT("Left Limit Latched ")
Zl 'Reset flag
ENDIF
350
Zr
Reset Historical Right Travel Limit Flag
IF Br 'Test flag
PRINT("Right Limit Latched")
Zr 'Reset flag
ENDIF
351
Zs
Reset Command Syntax Error Flag
IF Bs 'Test flag
PRINT("Syntax Error")
Zs 'Reset flag
ENDIF
352
Zu
Reset Array Index Error state Flag
IF Bu 'Test flag
PRINT("Array Error")
Zu 'Reset flag
ENDIF
353
Zw
Reset Encoder Wrap Status Flag
IF Bw 'Test flag
PRINT("Wraparound Occurred")
Zw 'Reset flag
ENDIF
354
ZS
Global Reset System State Flags
355
ZS (cont)
Reset System state Flag
Related Example:
Command: ZS 'reset all error and limit flag latches
'useful for debugging new programs
Za 'but not satisfactory for real time control
'consider the following
Zb C900 'Error Report Subroutine
Zc IF Ba 'Test flag
PRINT("Over Current")
Zd ENDIF
IF Bb 'Test flag
Zf PRINT("Parity Error")
ENDIF
Zl IF Bc 'Test flag
Zr PRINT("Buffer Overflow")
ENDIF
Zs IF Bd 'Test flag
PRINT("Math Overflow")
Zu ENDIF
IF Bf 'Test flag
Zw PRINT("Framing Error")
ENDIF
IF Bl 'Test flag
PRINT("Left Limit")
ENDIF
IF Br 'Test flag
PRINT("Right Limit")
ENDIF
IF Bs 'Test flag
PRINT("Syntax Error")
ENDIF
IF Bu 'Test flag
PRINT("Array Error")
ENDIF
IF Bw 'Test flag
PRINT("Wraparound Occurred")
ENDIF
ZS 'Reset all tested flags. Faulty !!!
356
Array Variable Memory Map
Page 1 of 2
MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB
ab[0] ab[28] ab[56] ab[84]
aw[0] LSB aw[14] LSB aw[28] LSB aw[42] LSB
MSB MSB MSB MSB
ab[1] ab[29] ab[57] ab[85]
aa al[0] LSB LSB hh al[7] LSB LSB oo al[14] LSB LSB vv al[21] LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB
ab[2] ab[30] ab[58] ab[86]
aw[1] LSB aw[15] LSB aw[29] LSB aw[43] LSB
MSB MSB MSB MSB
ab[3] ab[31] ab[59] ab[87]
LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB
ab[4] ab[32] ab[60] ab[88]
aw[2] LSB aw[16] LSB aw[30] LSB aw[44] LSB
MSB MSB MSB MSB
ab[5] ab[33] ab[61] ab[89]
bb al[1] LSB LSB ii al[8] LSB LSB pp al[15] LSB LSB ww al[22] LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB
ab[6] ab[34] ab[62] ab[90]
aw[3] LSB aw[17] LSB aw[31] LSB aw[45] LSB
MSB MSB MSB MSB
ab[7] ab[35] ab[63] ab[91]
LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB
ab[8] ab[36] ab[64] ab[92]
aw[4] LSB aw[18] LSB aw[32] LSB aw[46] LSB
MSB MSB MSB MSB
ab[9] ab[37] ab[65] ab[93]
cc al[2] LSB LSB jj al[9] LSB LSB qq al[16] LSB LSB xx al[23] LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB
ab[10] ab[38] ab[66] ab[94]
aw[5] LSB aw[19] LSB aw[33] LSB aw[47] LSB
MSB MSB MSB MSB
ab[11] ab[39] ab[67] ab[95]
LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB
ab[12] ab[40] ab[68] ab[96]
aw[6] LSB aw[20] LSB aw[34] LSB aw[48] LSB
MSB MSB MSB MSB
ab[13] ab[41] ab[69] ab[97]
dd al[3] LSB LSB kk al[10] LSB LSB rr al[17] LSB LSB yy al[24] LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB
ab[14] ab[42] ab[70] ab[98]
aw[7] LSB aw[21] LSB aw[35] LSB aw[49] LSB
MSB MSB MSB MSB
ab[15] ab[43] ab[71] ab[99]
LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB
ab[16] ab[44] ab[72] ab[100]
aw[8] LSB aw[22] LSB aw[36] LSB aw[50] LSB
MSB MSB MSB MSB
ab[17] ab[45] ab[73] ab[101]
ee al[4] LSB LSB ll al[11] LSB LSB ss al[18] LSB LSB zz al[25] LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB
ab[18] ab[46] ab[74] ab[102]
aw[9] LSB aw[23] LSB aw[37] LSB aw[51] LSB
MSB MSB MSB MSB
ab[19] ab[47] ab[75] ab[103]
LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB
ab[20] ab[48] ab[76] ab[104]
aw[10] LSB aw[24] LSB aw[38] LSB aw[52] LSB
MSB MSB MSB MSB
ab[21] ab[49] ab[77] ab[105]
ff al[5] LSB LSB mm al[12] LSB LSB tt al[19] LSB LSB aaa al[26] LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB
ab[22] ab[50] ab[78] ab[106]
aw[11] LSB aw[25] LSB aw[39] LSB aw[53] LSB
MSB MSB MSB MSB
ab[23] ab[51] ab[79] ab[107]
LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB
ab[24] ab[52] ab[80] ab[108]
aw[12] LSB aw[26] LSB aw[40] LSB aw[54] LSB
MSB MSB MSB MSB
ab[25] ab[53] ab[81] ab[109]
gg al[6] LSB LSB nn al[13] LSB LSB uu al[20] LSB LSB bbb al[27] LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB
ab[26] ab[54] ab[82] ab[110]
aw[13] LSB aw[27] LSB aw[41] LSB aw[55] LSB
MSB MSB MSB MSB
ab[27] ab[55] ab[83] ab[111]
LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB
357
Array Variable Memory Map
Page 2 of 2
MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB
ab[112] ab[140] ab[168] ab[196]
aw[56] LSB aw[70] LSB aw[84] LSB aw[98] LSB
MSB MSB MSB MSB
ab[113] ab[141] ab[169] ab[197]
ccc al[28] LSB LSB jjj al[35] LSB LSB qqq al[42] LSB LSB xxx al[49] LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB
ab[114] ab[142] ab[170] ab[198]
aw[57] LSB aw[71] LSB aw[85] LSB aw[99] LSB
MSB MSB MSB MSB
ab[115] ab[143] ab[171] ab[199]
LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB MSB
ab[116] ab[144] ab[172] ab[200]
aw[58] LSB aw[72] LSB aw[86] LSB aw[100] LSB
MSB MSB MSB MSB
ab[117] ab[145] ab[173] ab[201]
ddd al[29] LSB LSB kkk al[36] LSB LSB rrr al[43] LSB LSB yyy al[50] LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB
ab[118] ab[146] ab[174] ab[202]
aw[59] LSB aw[73] LSB aw[87] LSB aw[101] LSB
MSB MSB MSB MSB
ab[119] ab[147] ab[175] ab[203]
LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB MSB
ab[120] ab[148] ab[176]
aw[60] LSB aw[74] LSB aw[88] LSB
Note:
MSB MSB MSB
ab[121] ab[149] ab[177] The "zzz" memory location
eee al[30] LSB LSB lll al[37] LSB LSB sss al[44] LSB LSB zzz is used for SWITCH-CASE
MSB MSB MSB MSB MSB MSB calculations.
ab[122] ab[150] ab[178] Do not use it if the
aw[61] LSB aw[75] LSB aw[89] LSB SWITCH command is
MSB MSB MSB being used in user code.
ab[123] ab[151] ab[179]
LSB LSB LSB LSB LSB LSB LSB LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB MSB
ab[124] ab[152] ab[180]
aw[62] LSB aw[76] LSB aw[90] LSB
MSB MSB MSB
ab[125] ab[153] ab[181]
fff al[31] LSB LSB mmm al[38] LSB LSB ttt al[45] LSB LSB
MSB MSB MSB MSB MSB MSB
ab[126] ab[154] ab[182]
aw[63] LSB aw[77] LSB aw[91] LSB
MSB MSB MSB
ab[127] ab[155] ab[183]
LSB LSB LSB LSB LSB LSB LSB LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB MSB
ab[128] ab[156] ab[184]
aw[64] LSB aw[78] LSB aw[92] LSB
MSB MSB MSB
ab[129] ab[157] ab[185]
ggg al[32] LSB LSB nnn al[39] LSB LSB uuu al[46] LSB LSB
MSB MSB MSB MSB MSB MSB
ab[130] ab[158] ab[186]
aw[65] LSB aw[79] LSB aw[93] LSB
MSB MSB MSB
ab[131] ab[159] ab[187]
LSB LSB LSB LSB LSB LSB LSB LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB MSB
ab[132] ab[160] ab[188]
aw[66] LSB aw[80] LSB aw[94] LSB
MSB MSB MSB
ab[133] ab[161] ab[189]
hhh al[33] LSB LSB ooo al[40] LSB LSB vvv al[47] LSB LSB
MSB MSB MSB MSB MSB MSB
ab[134] ab[162] ab[190]
aw[67] LSB aw[81] LSB aw[95] LSB
MSB MSB MSB
ab[135] ab[163] ab[191]
LSB LSB LSB LSB LSB LSB LSB LSB LSB
MSB MSB MSB MSB MSB MSB MSB MSB MSB
ab[136] ab[164] ab[192]
aw[68] LSB aw[82] LSB aw[96] LSB
MSB MSB MSB
ab[137] ab[165] ab[193]
iii al[34] LSB LSB ppp al[41] LSB LSB www al[48] LSB LSB
MSB MSB MSB MSB MSB MSB
ab[138] ab[166] ab[194]
aw[69] LSB aw[83] LSB aw[97] LSB
MSB MSB MSB
ab[139] ab[167] ab[195]
LSB LSB LSB LSB LSB LSB LSB LSB LSB
358