SmartMoto Users Guide
SmartMoto Users Guide
Series 4
User's Guide
Revision 5
©2001, 2002, 2003, 2004, 2005, 2007, 2008 Animatics Corp.
All rights reserved
Animatics SmartMotor™ Series 4 User's Guide, Revision 5.
Please let us know if you find any erorrs or omissions in this manual
so that we can improve it for future readers. Such notifications should
be sent by e-mail with the words "User's Guide" in the subject line
sent to: [email protected]. Thank you in advance for your
contribution.
Contact Us:
Animatics Corporation
3200 Patrick Henry Drive
Santa Clara, CA 95054
USA
Tel: 1 (408) 748-8721
Fax: 1 (408) 748-8725
www.animatics.com
2
TABLE OF CONTENTS
QUICK START 9
Software Installation 10
SmartMotor Background 10
A quick look at the SmartMotor Interface 11
3
TABLE OF CONTENTS
Monitor Window 88
Chart View 89
Macros 89
Tuner 90
SMI Options 92
SMI Help 92
APPENDIX A 95
ASCII Character Set 95
APPENDIX B 97
Binary Data 97
APPENDIX C 101
Commands 101
APPENDIX D 111
Data Variables Memory Map 111
APPENDIX E 113
Example Programs 113
Moving back and forth 113
Moving back and forth with watch 113
Homing against a hard stop 114
Homing to the index 114
Analog Velocity 115
Long term variable storage 116
Look for errors and print them 116
Changing speed upon digital input 116
Pulse output upon a given position 117
4
TABLE OF CONTENTS
APPENDIX F 125
F= Commands 125
5
This page has been intentionally left blank.
6
SMARTMOTOR THEORY OF OPERATION
The SmartMotor is an entire servo control system built inside of a servo motor.
It includes a controller, an amplifier and an encoder. All that is required for it
to operate is power, and either an internal program, or serial commands from
outside (or both). To make the SmartMotor move, the program or serial host
must state a target position, a maximum velocity at which to travel to that
target, and a maximum acceleration. Once these three parameters are set, a
"Go" signal, or statement will start the motion profile.
Communication Functions
Each industrial network imposes standards for operation and the SmartMotors
are designed to conform to those particular standards, where industrial
fieldbusses are used.
Commands arriving over the serial channels have priority over internal
program commands. As a command comes in over the serial channel, it is
serviced "next" and then execution is returned to the SmartMotor's program,
if it exists and is running. If a request is made for data, such as a request for
position: "RP", for example, the current position is output in the form of ASCII
text to the main channel, regardless of whether the request was made over
the main channel serial network, or by internal program. If a request for data
arrives from the secondary serial channel, or other serial network, however,
the data is reported to that channel. The SmartMotor uses both Spaces and
Carriage Returns as delimiters.
I/O Functions
The SmartMotor's I/O (Input/Output) ports are extremely flexible and provide
a variety of Digital and Analog Input and Output capability. Each I/O point
has a corresponding pre-assigned variable name within the programming
environment and can be read from, or written to by placing it on the right, or
left side of an equation, respectively.
8
QUICK START
9
QUICK START
Connecting a
SM2320D
SmartMotor using
a CBLSM1-10
cable assembly
and PS24V8A
power supply
SOFTWARE INSTALLATION
Follow standard procedures for software installation using either the Animatics
SMI CD-ROM or files downloaded from the Animatics Website at
www.animatics.com.
After the software is installed, be sure to reset your computer before running the
SMI program.
With the SMI Software loaded and your SmartMotor connected as shown above,
you are ready to start making motion. Turn the SmartMotor's power on and start
the SMI Program.
SMARTMOTOR BACKGROUND
The SmartMotor is an entire Servo Control System in a single component. Of
course, it's shaft position, velocity and acceleration are programmable but there
is much more. The SmartMotor also has analog and digial I/O and can be pro-
grammed to operate by itself in a language similar to Basic. The same com-
mands one would use to program a SmartMotor can be sent to it over RS-232,
or RS-485, depending on your product selection. These commands, explained
later in this guide, can be sent using most any host terminal software, but the
SMI "SmartMotor Interface" program does this and much more.
10
QUICK START
"Close" button at the bottom and launch the SMI development software.
12
QUICK START
The larger
SmartMotors
Initiating motion can shake and
To get the motor to make a trajectory, enter the following into the Terminal. move suddenly
and should be
A=100 ‘sets the Acceleration restrained for
V=1000000 ‘sets the maximum Velocity safety.
P=300000 ‘sets the target Absolute Position
G ‘Go, initiates motor movement
After the final G command has been entered, the SmartMotor will accelerate
up to speed, slew and then decelerate to a stop at the absolute target position.
The progress can be seen in the MotorView.
13
QUICK START
Finally, you will be presented with options relating to runing the program. Simply
select Run. If the motor makes only one move, that is probably because it was
already at position 300000. Press the RUN ( ) button on the toolbar and the
motor should make both moves.
Since the program ends before the return move is finished, you can try running
the program during a return move and learn a bit about how programs and
motion work within the SmartMotor.
To better see the motion the new program is producing, press the Poll button in
the MotorView window and run the program.
With the program now downloaded into the SmartMotor, it is important to note
that it will remain until replaced. This program will execute every time power is
applied to the motor. To get the program to operate continuously, you will need
to write a "loop", described later on.
A program cannot be "erased"; it can only be
Tuning the Motor replaced. To effectively replace a program
Most SmartMotors with nothing, download a program with only
show more than one command: END.
adequate
performance with Looking at the Position Error and feeling the
the same tuning motor shaft will show that the motion, so far, is
parameters. This is a bit sloppy. That is because the motor's PID
largely due to the Filter is tuned by default to be stable in almost
all-digital design. any start-up environment. Try issuing the following commands in the Terminal
and run the program again:
By running the program with the MotorView on, you will see improved results.
Note the lower Position Error. For most applications, these parameters will suf-
fice, but if still greater precision is required, more can be found on the topic of
tuning later in this manual in the section on tuning. Also, the Tools menu has
a Tuning utility that can be further useful. Whether you accept the preceding
values, or you come up with different ones on your own, you should consider
putting the preceding commands at the top of your program, with the F com-
mand to put them to work. Alternatively, if you are operating a system with no
programs in the motors, be sure to send the commands promptly after power-up
or reset.
Many are surpised at the vast array of different paramters the SmartMotor
finds stable. SmartMotors are so much more forgiving than traditional controls
because of their all-digital design. While traditional controls also boast very fast
PID rates, the conventional analog input servo amplifier has several calculations
worth of delay in the analog signaling, making them difficult to tune. By virtue
of it's all-inclusive design, the SmartMotor requires no analog circuitry or asso-
ciated noise immunity circuitry, and so the amplifier portion conveys all of the
responsiveness the controller can deliver.
15
This page has been intentionally left blank.
16
PROGRAMMING TABLE OF CONTENTS
CREATING MOTION 21
A=exp Set absolute acceleration 21
X Decelerate to stop 23
MP Position mode 24
MV Velocity mode 24
MT Torque mode 24
MD Contouring mode 25
PROGRAM FLOW 31
RUN Execute stored user program 31
C# Subroutine label 31
VARIABLES 39
Arrays 39
Storage of Variables 41
REPORTING COMMANDS 42
Report to Host Commands 42
MF0, MS0 47
MC Mode Cam 48
CI Cam Initialize 49
The G port 58
COMMUNICATIONS 69
Daisy Chaining RS-232 70
OCHN 73
20
CREATING MOTION
On power-up the motor defaults to position mode. Once Acceleration PLUS and
(A) and Velocity (V) are set, simply issue new Position (P) commands, ServoStep
followed by a G (Go) command to execute moves to new absolute locations. Firmware requires
The motor does not instantly go to the programmed position, but follows a the added
trajectory to get there. The trajectory is bound by the maximum Velocity overhead of
disabling limits (if
and Acceleration parameters. The result is a trapezoidal velocity profile, or a
none are
triangular profile if the maximum velocity is never met.
connected) and
Position, Velocity and Acceleration can be changed at any time during clearing errors
or between moves. The new parameters will only apply when a new G before a G can be
command is sent. accepted.
Do not disable
All SmartMotor commands are grouped by function, with the following
limits if such a
notations:
thing could cause
# Integer number damge or injury.
var Variable
The relative distance will be added to the current position, either during or
after a move. It is added to the desired position rather than the actual position
so as to avoid the accumulation of small errors due to the fact that any servo
motor is seldom exactly where it should be at any instant in time.
G Go, start motion
The G command does more than just start motion. It can be used dynamically G also resets
during motion to create elaborate profiles. Since the SmartMotor allows several system
position, velocity and acceleration to change during motion, “on-the-fly”, the state flags
G command can be used to trigger the next profile at any time. With PLUS
or ServoStep Firmware, the G will not work until all errors are cleared. The With PLUS and
ZS command clears all errors in these cases. ServoStep
Firmware, errors
S Abruptly stop motion in progress must be reset
before G will
If the S command is issued while a move is in progress it will cause an function. ZS will
immediate and abrupt stop with all the force the motor has to offer. After the reset all errors.
stop, assuming there is no position error, the motor will still be servoing. The
S command works in both Position and Velocity modes.
X Decelerate to stop
If the X command is issued while a move is in progress it will cause the motor
to decelerate to a stop at the last entered A= value. When the motor comes
to rest it will servo in place until commanded to move again. The X command
works in both Position and Velocity modes.
MP Position Mode
Position mode is the default mode of operation for the SmartMotor. If the
mode were to be changed, the MP command would put it back into position
mode. In position mode, the P# and D# commands will govern motion.
For further expediency, the commands can be appended with the G command
to start motion immediately. Two examples are as follows (the ASCII value
for G is 71):
P=0 G 254 000 000 000 000 071 032
V=512 G 253 000 000 002 000 071 032
MV Velocity Mode
Velocity mode will allow continuous rotation of the motor shaft. In Velocity
mode, the programmed position using the P or the D commands is ignored.
Acceleration and velocity need to be specified using the A= and the V=
commands. After a G command is issued, the motor will accelerate up to
the programmed velocity and continue at that velocity indefinitely. In velocity
mode as in Position mode, Velocity and Acceleration are changeable on-the-
fly, at any time. Simply specify new values and enter another G command
to trigger the change. In Velocity mode the velocity can be entered as a
negative number, unlike in Position mode where the location of the target
position determines velocity direction or sign. If the 32 bit register that holds
position rolls over in velocity mode it will have no effect on the motion.
MT Torque Mode
In torque mode the motor shaft will simply apply a torque independent of
position. The internal encoder tracking will still take place, and can be read
by a host or program, but the value will be ignored for motion because the
PID loop is inactive. To specify the amount of torque, use the T= command,
followed by a number between -1023 and 1023.
24
CREATING MOTION
The basic principle of operation takes advantage of the fact that each
SmartMotor has a very accurate time base. Absolute position-time pairs of
data get sent to the SmartMotor to fill buffers that facilitate continuous motion.
The SmartMotor will adjust its own Velocity and Acceleration to be certain to
arrive at the specified position at the exact specified time without slowing to
a stop. As new position-time pairs arrive, the motor transitions smoothly from
one profile to the next producing smooth, continuous motion. In a multiple
axis configuration, different positions can be sent to different motors, with
the same time intervals resulting in smooth, continuous multiple axis motion.
The key is for the host to regulate the volume of data in each of the
different motor's buffers. The position-time pairs of data are preceded with an
identification byte and then four bytes for position and four for time. Time is
in units of servo samples and is limited to 23 bits. Time is further constrained
to be even powers of 2 (i.e. 1, 2, 4, 8, ..., 32768). 25
CREATING MOTION
The coordinating host can send the Q command to solicit status information
on the coordination process. Upon receiving the Q command, the SmartMotor
will return status, clock and space available in the dedicated circular buffer.
The response to Q takes two forms, one while the mode is running with
trajectory in progress and no errors having occurred and another when the
mode is not running. Both responses conform to the overall byte format of:
As absolute position and time data is sent to the SmartMotor, differences are
calculated what are referred to as "deltas". A delta is the difference between
the latest value and the one just prior. Time deltas are limited to 16 bits while
Position deltas are limited to 23 bits in size.
The host should send data pairs only when at least 3 empty data slots are
available. MD responds to limit switches with an aborted trajectory. The MD
mode uses KV feed forward for improved performance.
The byte flag that precedes and marks a position is of decimal value 250. The
byte flag that precedes and marks a time is of decimal value 251.
The following is an example of the decimal byte values for a series of constant
speed motion segments. Firmware versions 4.16 and higher do not need
time values after the first two if the time delta is not changing. The byte
transfers terminate with a carriage return (13).
26
CREATING MOTION
Position 250 000 000 000 000 013 Position = 0 This example does
not include
Time 251 000 000 000 000 013 Time = 0 addressing bytes.
Position 250 000 000 016 000 013 Refer to the section
on Addressing
Time 251 000 000 001 000 013 Time delta = 256 SmartMotors to
learn the most
Position 250 000 000 032 000 013 efficient way to
address different
Position 250 000 000 048 000 013
motors.
Position 250 000 000 052 000 013 Reduce position delta
Time 251 000 000 003 064 013 Reduce time delta
What is not shown in the these codes are the addressing bytes that would
be used to differentiate multiple motors on a network. As described ahead
in this manual (see the SADDR command), a network of SmartMotors can
be sorted out by sending a single address byte. When communicating to a
particular motor, the address byte need only be sent once, until all of the
communications to that particular motor are complete and another motor
needs to be addressed. The byte patterns in the previous example would
need to be preceded with an address byte (to a properly addressed motor) for
multiple axis contouring. In the addressing scheme, there is a global address
provision for sending data to all motors at once. By zeroing out the clocks
before starting the contouring, the motors will by synchronized and single time
values can then be sent to all motors at once, increasing overall bandwidth.
Also, as mentioned earlier, SmartMotors with version 4.16 or higher do not
need time data past the first two, if there is no change in the time delta.
Note that Time Data is the same for all motors and should be sent once to all
motors at the same time, preceded by the global address byte (128).
The basis for contouring using this format is to keep the rate at which data
is sent to each motor constant (and as fast as possible). That means that
in order to accelerate axes, absolute positions need to be sent that invoke
progressively larger position deltas, and to keep constant velocity, absolute
positions need to be sent that are equidistant.
With all of the communications to send data and receive status, it would be
outstanding to have a bandwidth on a two axis system of 64 samples, or
16ms. Typically, with a three or four axis system a bandwidth of 128 servo
samples or 32ms is achievable. This would be at a baud rate of 38.4k.
Keep in mind that during this time the SmartMotor is micro interpolating. The
motion will be very smooth and continuous.
In contouring mode, all of the binary contouring data goes into the motor's 27
CREATING MOTION
buffers. While this is true, regular commands will still be recognized and they
will operate normally. This will take some time, however, and it is up to the
programmer to assure that the buffers never underflow due to neglect.
With Non-PLUS Firmware, contouring mode can be exited in only two ways.
One way is to simply stop sending data, causing the buffers to underflow.
This is effective, but leaves the motors off altogether. Alternatively, contouring
mode can be terminated by sending a long time delta to the motor while
holding position, estimating when the motor would be executing the long time
delay and sending a G command, and likely a P=(last host mode position), to
execute the next buffered mode.
At this point the motors will come to a rest. If the motor is at speed when
leaving Host Mode, then it will decelerate to rest and then return to the exact
position where Host Mode was terminated. One could just as well exit Host
Mode in Velocity Mode and maintain a constant speed.
28
CREATING MOTION
BRAKE COMMANDS
BRKRLS Brake release
BRKENG Brake engage
BRKSRV Release brake when servo active, engage when not
BRKTRJ Release brake when running a trajectory, engage under
all other conditions. Turns servo off when the brake is
engaged
Many SmartMotors are available with power safe brakes. These brakes will
apply a force to keep the shaft from rotating should the SmartMotor lose
power. Issuing the BRKRLS command will release the brake and BRKENG
will engage it. There are two other commands that initiate automated
operating modes for the brake. The command BRKSRV engages the brake
automatically, should the motor stop servoing and holding position for any
reason. This might be due to loss of power or just a position error, limit
fault, over-temperature fault.
Finally, the BRKTRJ command will engage the brake in response to all of
the previously mentioned events, plus any time the motor is not performing a
trajectory. In this mode the motor will be off, and the brake will be holding
it in position, perfectly still, rather than the motor servoing when it is at
rest. As soon as another trajectory is started, the brake will release. The
time it takes for the brake to engage and release is on the order of only
a few milliseconds.
When BRKRLS is followed by OFF, MTB will become inactive until the next
MTB command is issued. Issuing BRKENG will not activate MTB.
The RMODE command will report a "B" when MTB is active.
30
PROGRAM FLOW
The following are commands that can be used in your program to control how
it flows and how it makes decisions:
The above code will print only the first message upon power-up, but both
messages when a RUN command is received over the serial line.
Once the program is running, there are a variety of commands that can
redirect program flow and most of those can do so based on certain
conditions. How these conditional decisions are setup determines what the
programmed SmartMotor will do, and exactly how “smart” it will actually be. 31
PROGRAM FLOW
32
PROGRAM FLOW
By pulling sections of code out of a main loop and encapsulating them into
subroutines, the main code can also be easier to read. Organizing code into
multiple subroutines is a good practice.
With PLUS or
F=32, F=64, RETURNF , RETURNI (PLUS and ServoStep only)
ServoStep
SmartMotors with PLUS firmware and ServoStep motors have automatic Firmware, any
interrupt based GOSUB capabilities. After an F=32 mode bit is set, the motor protection
program will go immediately to the subroutine "C1" when a motor protection fault will result in
fault occurs. Subroutine C1 should terminate with the RETURNF command program
termination unless
rather than the standard RETURN. After the RETURNF is reached, program
the F=32 bit is set
execution will take up precisely where it had been previously diverted. The
and a C1
following faults will trigger subroutine C1 in this mode: subroutine exists.
Be: Position Error
Bh: Over Temperature or Over Current Error
Bp: Real time Positive Limit via software or hardware limits
Bm: Real time Negative Limit via software or hardware limits
It is important to note that without the F=32 mode bit set (in PLUS and
ServoStep only), and a C1 routine present, any of the motor fault errors will
result in program termination. The motor will stop under full MTB (Mode
Torque Brake), where all coils of the motor are internally grounded. Once a
motor protection fault as occured, the G command will have no effect until the 33
PROGRAM FLOW
fault has been cleared. The ZS command clears all faults at once.
Setting the F=64 mode bit similarly causes program execution to jump to label
C2 when the I/O pin G goes from a high to a low. The RETURNI is used
to terminate the C2 subroutine.
The WAIT command is the only motor instruction that will be truncated
automatically when interrupted. Wherever the WAIT command is in its timing
cycle, it will be terminated upon return and so is at risk of being shortened
in the event of an F=64 interrupt. Since F=64 uses the G port, it would be
necessary that you turn off the G port's default action, which is to start motion.
To deactivate the start function, issue a UGI. Note also that the BRKG
command routes automated brake functions to the G port.
If both F=32 and F=64 need to be used at the same time, then be aware that
these are bits in a broader configuration byte. It is best to use a shadow
variable to store the byte and set them this way:
When used together, the C1 subroutine has higher priority than the C2
subroutine. If the C2 subroutine is executing and there is an error, the C1
subroutine will execute and then return execution to the C2 subroutine when
finished. If this is not desired, the C2 subroutine shoud clear the F=32 mode
bit in the beginning and reset the bit at the end of the C2 code.
The STACK and END commands clear the tracking of subroutine nesting,
even with interrupt subroutines.
Variable b will only get set to one if variable a is equal to one. If a is not
equal to one, then the program will continue to execute using the command
following the ENDIF command.
34 Notice also that the SmartMotor language uses a single equal sign (=) to
PROGRAM FLOW
ELSE, ELSEIF
The ELSE and ELSEIF commands can be used to add flexibility to the IF
statement. If it were necessary to execute different code for each possible
state of variable a, the program could be written as follows:
There can be many ELSEIF statements, but at most one ELSE. If the
ELSE is used, it needs to be the last statement in the structure before the
ENDIF. There can also be IF structures inside IF structures. That's called
“nesting” and there is no practical limit to the number of structures that can
nest within one another.
The commands that can conditionally direct program flow to different areas
use a constant [#] like 1 or 25, a variable like a or al[#] or a function involving
constants and/or variables a+b or a/[#]. Only one operator can be used in a
function. The following is a list of the operators:
+ Addition
- Subtraction
* Multiplication
/ Division
!= Not equal
WHILE, LOOP
The most basic looping function is a WHILE command. The WHILE is
followed by an expression that determines whether the code between the
WHILE and the following LOOP command will execute or be passed over.
While the expression is true, the code will execute. An expression is true
when it is non-zero. If the expression results in a “zero” then it is false. The
following are valid WHILE structures:
The task or tasks within the WHILE loop will execute as long as the function
remains true.
The BREAK command can be used to break out of a WHILE loop, although
that somewhat compromises the elegance of a WHILE statement’s single test
point, making the code a little harder to follow. The BREAK command should
be used sparingly or preferably not at all in the context of a WHILE.
If it's necessary for a portion of code to execute only once based on a certain
condition then use the IF command.
36
PROGRAM FLOW
Just as a rotary switch directs electricity, the SWITCH structure directs the
flow of the program. The BREAK statement then jumps the code execution to
the code following the associated ENDS command. The DEFAULT command
covers every condition other than those listed. It is optional.
The above code example will check if port A ever goes low, while it is waiting
for the CLK variable to count up to 1000.
One possible use of the STACK command might be if the program used
one or more nested subroutines and an emergency occurred, the program
or operator could issue the STACK command and then a GOTO command
which would send the program back to a label at the beginning. Using
this method instead of the RESET command would retain the states of the
variables and allow further specific action to resolve the emergency.
C5 ‘Subroutine 5
G ‘Start Motion
TWAIT ‘Wait for motion to stop
IF Bo ‘Check to see if there was an error
STACK ‘Clear the nesting stack
RUN ‘Begin the program, retaining variables
ENDIF ‘Never reached, but necessary for comp.
RETURN ‘Never reached, but necessary for comp.
38
VARIABLES
Variables are data holders that can be set and changed within the program
or over one of the communication channels. All variables are 32-bit signed
integers and are all lower case only. They are stored in volitile memory,
meaning they are lost when power is removed and default to zero upon
power-up. If they need to be saved, they can be stored in EEPROM, non
volitile memory using the VST command.
There are three sets of variables containing 26 in each. The last 52 can also
be accessed as byte, short or long array elements.
The first 26 variables are accessed with the lower case letters of the alphabet,
a, b, c, . . . x, y, z.
A variable can be set to an expression with only one operator and two
operands. The operators can be any of the following:
+ Addition
- Subtraction
* Multiplication
/ Division
a=b&c a=b&8
a=b|c a=b|15
ARRAYS
In addition to the first 26, there are 52 more long integer variables accessible
with double and triple lower case letters: aa, bb, cc, . . . xxx, yyy, zzz. The
memory space that holds these 52 variables is more flexible, however. This
same variable space can be accessed with an array variable type. An array
variable is one that has a numeric index component that allows the numeric
selection of which variable a program is to access. This memory space is
further made flexible by the fact that it can hold 51 thirty two bit integers,
39
VARIABLES
or 101 sixteen bit integers, or 201 eight bit integers (all signed). The array
variables take the following form:
See Appendix D The same array space can be accessed with any combination of variable
for a table types. Just keep in mind how much space each variable takes. We can
describing even go so far as to say that one type of variable can be written and another
overlapping read from the same space. For example, if the first four eight bit integers
memory allocation are assigned as follows:
for
User Assigned ab[0]=0
Array Variables.
ab[1]=0
ab[2]=1
ab[3]=0
They would occupy the same space as the first single 32 bit number, and due
to the way binary numbers work, would make the thirty two bit variable equal
to 256. The order is most significant to least with ab[0] being the most.
A common use of the array variable type is to set up what is called a buffer.
In many applications, the SmartMotor will be tasked with inputting data about
an array of objects and to do processing on that data in the same order,
but not necessarily at the same time. Under those circumstances it may
be necessary to “buffer” or “store” that data while the SmartMotor processes
it at the proper times.
40
VARIABLES
STORAGE OF VARIABLES
Every SmartMotor has its own little solid-state disk drive for long term storage
of data. It is based on EEPROM technology and can be written to, and read
from, more than a million times.
The SMI program uses variables to undertake certain functions as well. This
can be useful to know as it may impact your program development.
42
REPORTING COMMANDS
The SmartMotor has a wealth of data that can be retrieved over the RS-232
or RS-485 ports simply by asking. Data and status reporting commands can
be tested by issuing them in the SMI
Terminal window. In the example to
the right, The command is shown on
the left and the SmartMotor's response
is shown in the middle. The SMI host
software uses these commands to
implement the Motor View and Monitor
View tools. Data that does not
have direct report commands can be
retrieved either of two ways, by embed-
ding the variable in a PRINT command, or by setting a variable equal to the
parameter and then reporting the variable. The following are commands, that
when sent to the SmartMotor, will return valuable data:
45
REPORTING COMMANDS
Three very valuable pieces of data do not have direct report commands,
these are Temperature, Voltage and Current.
The number returned by the above example is in units of tenths of Volts. So,
for example, if you read 259, that will mean 25.9 Volts.
Through the two pins, A and B of the I/O connector, quadrature or step The SM2315D
and direction signals can be fed into the SmartMotor at high speeds and does not have
be followed by the motor itself. This feature brings about the following Quadrature
Encoder following
capabilities:
capability.
1 Mode Follow
2 Mode Step and Direction
3 Mode Follow with ratio
4 Mode Step and Direction with ratio
5 Mode Cam
When the SmartMotor is in one of the above five modes it may also run
internal programs and communicate with a host, all at the same time.
MF0, MS0
The MF0 and MS0 commands must not be issued during one of the other
follow modes. They are used for an entirely different purpose. If it is not
desired to directly follow an incoming encoder or step signal, but rather, just
to track them and use the counter value within a program or from a host, then
issuing MF0 or MS0 utilizes the maximum resolution available and makes the
value available through the CTR variable. Issuing MF0 or MS0 will zero that
variable and incoming encoder or step signals will increment or decrement
the signed, 32-bit CTR variable value.
After the appropriate MF# command is issued, or the MS command has been
issued, a floating point ratio can further be applied by the firmware. Since the
SmartMotor is an integer machine, that floating point ratio is accomplished by
dividing one number by another.
47
ENCODER AND PULSE TRAIN FOLLOWING
Once in a ratio mode the V=# and D=# commands will still work. They will
invoke a phase shift of length D at a relative rate determined by V. For that
reason, D must be zeroed out before issuing an MFR or MSR command or
unexpected shifting could be taking place. In applications such as a Web
Press, this ability to phase shift can be very useful.
MC Mode Cam
A cam is a basically round but irregular shape that rotates and causes a
follower to move up and down in a profile determined by the shape of the
cam’s exterior.
last and the first as the cam progresses through the end of the table and back
to the beginning. The cam table entries occupy the same space as variables Do not use variable
aa through yyy which is the same space as the array variables. Invoking aa through zzz
Cam Mode is done as follows: while camming.
Because of the binary nature of the F variable, care must be taken when
setting a bit so that other bits in the F variable are not changed. The best
way to keep track of F is to keep a shadow variable, say "f" for example. To
set the 16 value bit, issue the following commands.
49
ENCODER AND PULSE TRAIN FOLLOWING
To clear the 16 value bit, subtract 16 from 255 (255 - 16 = 239), then logically
AND the result with the shadow variable:
For more information about how binary numbers work, please refer to the
appendix.
The following diagram shows how in Relative Position Mode, cam position
adopts the cycle ending point as the next cycle's starting point.
50
ENCODER AND PULSE TRAIN FOLLOWING
Changed values F=16 and F=128 will not take effect in cam mode, even
though the change has been made in F=, until the CI command is issued
and there is a zero-point crossing. Changing F= values on-the-fly requires
careful consideration of the effect.
The following example shows the dynamic changing of the cam function to
vary the length of material cut-off:
F=144 ‘F=16+128, rel. (F=16), antiwrap (F=128)
BASE=2000 ‘Quick cutoff of rough end as belt begins
D=100 ‘Soon afterward, begin a cammed cutoff
MC2 ‘Double-wide first cutoff
G
BASE=10000 ‘Normal cutoff profile
D=107525 ‘Now allow normal length between cuts
MC2 ‘Recalculate base/size, set to mode cam.
CI ‘Init. cam params at zero-point crossing
UAI ‘Input pin A button makes longer
UBI ‘Input pin B button makes shorter
WHILE 1
IF UAI
D=D+1 ‘Make longer
MC2 ‘Recalculate base/size
CI ‘Update at next zero point crossing
ENDIF
IF UBI
D=D-1 ‘Make shorter
MC2 ‘Recalculate base/size
CI ‘Update at next zero point crossing
ENDIF
WAIT=100 ‘Max length change of 40 per second
52 LOOP
ENCODER AND PULSE TRAIN FOLLOWING
53
This page has been intentionally left blank.
54
SYSTEM STATE FLAGS
The following binary values can be tested by IF and WHILE control flow
expressions, or assigned to any variable. They may all be reported using
RB{bit} commands. Some may be reset using Z{bit} commands and some
are reset when accessed. The first 8 states are reported in combination
by the RS command. RW reports sixteen of these flags in combination.
Be aware that the lower 8 bits of RW do not match RS; in RS, the limits
are reported Real Time.
Bh Excessive temperature
Bw Wraparound occurred
Bt Trajectory in progress
If action is taken based on some of the error flags, the flag will need to
be reset in order to look out for the next occurrence, or in some cases
depending on how the code is written, in order to keep from acting over
and over again on the same occurrence. The flags that need to be
reset are listed. Their letter designator is preceded by the letter Z in
the following list:
55
SYSTEM STATE FLAGS
An example of where one would use a System State Flag would be to replace
the TWAIT command. The TWAIT command pauses program execution until
motion is complete. Instead of using TWAIT, a routine could be written that
does much more. To start with, the following code example would perform
the same function as TWAIT:
Alternatively, the above routine could be augmented with code that took
specific action in the event of an index signal as is shown in the following
example:
WHILE Bt ‘While trajectory
IF Bi ‘Check index
GOSUB500 ‘call subroutine
ENDIF ‘end checking
LOOP ‘Loop back
56
INPUTS AND OUTPUTS
The standard SmartMotor brings out 5 volt power and ground, as well as
seven I/O points. Each one has multiple functions. They are UA, UB, UC,
UD, UE, UF and UG and have the following functions:
UA Digital Input, TTL, 0 to 5 volts
Digital Output, TTL, 0 to 5 volts
Analog Input, 10 bit, 0 to 1023
External Encoder A Input* *ServoStep breaks
Step and Direction, Step Input* these signals out
to different pins.
UB Digital Input, TTL, 0 to 5 volts
External Encoder
Digital Output, TTL, 0 to 5 volts input is not
Analog Input, 10 bit, 0 to 1023 available as stan-
External Encoder B Input* dard on SMXXX5
Step and Direction, Direction Input* SmartMotors
57
INPUTS AND OUTPUTS
MC Mode Cam
58
INPUTS AND OUTPUTS
Zl, Zr Reset Left & Right Limit Faults (Plus and ServoStep
Firmwares require limit faults to be reset before
motion is allowed)
59
INPUTS AND OUTPUTS
Note that the c=GETCHR1 Get byte from buffer into variable c
secondary RS-485
PRINT1(“Char Rcd:”,c,#13) Print text, data and ASCII code
port is non-isolated
and not properly ECHO1 ECHO back all received characters
biased by the two
internal 5k Ohm SILENT1 Suppress print messages
pullups. It is
suitable to talk to SLEEP1 Ignore all commands except WAKE
a bar code reader WAKE1 Consider all following commands
or light curtain, but
not to cascade
motors because of PORTS E AND F AS GENERAL I/O
the heavy biasing
UEI Set port E to input (UFI for port F)
and ground bounce
resulting from UEO Set port E to output (UFO for port F)
variable shaft
loading. UE=0 Set port E Low (UF=0 or port F, or UF=c to set
to variable c)
UE=1 Set port E High (UF=1 or port F)
60
INPUTS AND OUTPUTS
61
This page has been intentionally left blank.
62
INPUTS AND OUTPUTS
The UAA, UBA, UCA, UDA, UEA, UFA and UGA variables reflect the analog
voltages at the port pins regardless of how the pins are configured. The
analog voltage of any pin can be read without effecting it's current mode of
operation in any way. For example, a pin could be used as an output and
then the analog input value could be read to see if it happened to be shorted,
or RS-485* signal bias could be monitored at ports E and F.
The encoder and step counting capabilities of ports A and B are described in
the section on External Encoder Modes. The serial data capabilities of ports
E and F are described in the section on communications.
63
INPUTS AND OUTPUTS
OUTPUT ASSIGNMENTS
AOUT{address},exp Output byte to analog address=A-H
INPUT ASSIGNMENTS
var=AIN{address}{input} 8 bit analog input from network,
address=A-H, and input=1-4
var=DIN{address}{ch} 8 bit digital in from network,
address=A-H, and ch=0-63
65
INPUTS AND OUTPUTS
Motor Connector
Pin
Identifications
66
INPUTS AND OUTPUTS
Motor Connector
Locator
67
INPUTS AND OUTPUTS
68
COMMUNICATIONS
While there are a variety of options, the default mode for communicating with
a SmartMotor is serial RS-232 for the main port, except for the ServoStep When using I2C,
who's main port is Isolated RS-485. Most SmartMotors are equipped with the SmartMotor is
a secondary serial port called the AniLink port. The AniLink port on a always the bus
SmartMotor can be configured to communicate with either RS-485 or I2C. master. You cannot
The I2C connects SmartMotor peripherals like LCD displays, I/O cards, etc., communicate
between
while the RS-485 will interface bar code readers, light curtains, and other
SmartMotors via
“intelligent” peripherals including other SmartMotors if desired. SmartMotor
I2C.
models SMXXX5 do not have RS-485 capability in their AniLink ports. Series
4 ServoStep motors have neither secondary RS-485 nor AniLink.
There is a sixteen-byte input buffer for the primary port and another for
the secondary RS-485 port where it exists. These buffers ensure that no
arriving information is ever lost, although when either port is in data mode,
it is the responsibility of the user program within the SmartMotor to keep
up with the incoming data.
By default, the primary channel, which shares a connector with the incoming
power in some versions, is set up as a command port with the following
default characteristics:
If the cable used is not provided by Animatics, make sure the SmartMotor's
power and RS-232 connections are correct. RS-232 SmartMotors connect as
follows (look further for RS-485 SmartMotors and ServoSteps):
The CBLSM1-10
makes quick work
of connecting to
your first RS-232
based SmartMotor.
69
COMMUNICATIONS
Because of the buffers on both sides there is no need for any hand shaking
protocol when commanding the SmartMotor. Most commands execute in
less time than it would take to receive the next one. Be careful to allow
processes time to complete, particularly relatively slow processes like printing
to a connected LCD display or executing a full subroutine. Since the EEPROM
long term memory is slow to write, the terminal software does employ two way
communication to regulate the download of a new program.
Be sure to use
shielded cable to
connect RS-232
ports together, with
the shield ground
connected to
ground (pin 5) of
the PC end only.
Telling a motor to sleep causes it to ignore all commands except the WAKE
command. This feature can often be useful, particularly when establishing
unique addresses in a chain of motors. The 1 at the end of the commands
specify the AniLink RS-485 port (not available in SM2315D and ServoStep).
SmartMotors can
be made to
automatically
ECHO received
characters to the
next SmartMotor in
a Daisy Chain.
Never use ECHO If a daisy chain of SmartMotors have been powered off and back on, the
with ServoStep following commands can be entered into the SmartMotor Interface to address
SmartMotors or the motors (0 equals 128, 1 equals 129, etc.). Some delay should be inserted
you will crash the between commands when sending them from a host computer.
RS-485 bus.
0SADDR1
1ECHO
1SLEEP
0SADDR2
2ECHO
2SLEEP
0SADDR3
3ECHO
0WAKE
Commanded by a user program in the first motor, instead of a host, the same
daisy chain could be addressed with the following sequence:
72
COMMUNICATIONS
OCHN
Options:
Type: RS2, RS4 RS-232 or RS-485
Channel: 0, 1 or 2 0=Main, 1=AniLink
Parity: N, O or E None, Odd or Even Molded cable
Bit rate: 2400, 4800, 9600, 19200, 38400 baud assemblies make
wiring simple and
Stop bits: 0, 1 or 2 reliable for
Data bits: 7 or 8 ServoStep
Mode: C or D Command or Data SmartMotors.
OCHN(RS4,0,N,38400,1,8,D)
73
COMMUNICATIONS
The following are all valid print statements and will transmit data through
the main RS-232 channel:
PRINT( ) commands.
The following is a very useful routine for confirming RS-232 noise. Start the
program from the SMI terminal and then sequentially activate and deactivate
every other system in the machine while watching the terminal window. If
the SmartMotor gets so much as a single byte of noise, the program will
advance to the print statement:
A subroutine that printed the errors to an LCD display would look like the
following:
C911
IF CHN0 ‘If CHN0 != 0
DOUT0,1 ‘Home LCD cursor
IF CHN0&1
PRINTA(“BUFFER OVERFLOW”)
ENDIF
IF CHN0&2
PRINTA(“FRAMING ERROR”)
ENDIF
IF CHN0&4
PRINTA(“COMMAND SCAN ERROR”)
ENDIF
IF CHN0&8
PRINTA(“PARITY ERROR”)
ENDIF 75
COMMUNICATIONS
The buffer is a standard FIFO (First In First Out) buffer. This means that if the
letter A is the first character the buffer receives, then it will be the first byte
offered to the GETCHR command. The buffer exists to make sure that no
data is lost, even if the program is not retrieving the data at just the right
time. Two things are very important when dealing with a data buffer for
the protection of the data:
The LEN variable holds the number of characters in the buffer. A program
must see that the LEN is greater than zero before issuing a command like:
a=GETCHR. Likewise, it is necessary to arrange the application so that,
overall, data will be pulled out of the buffer as fast as it comes in.
The ability to configure the communication ports for any protocol as well as
to both transmit and receive data allows the SmartMotor to interface to a vast
array of RS-232 and RS-485 devices. Some of the typical devices that would
interface with SmartMotors over the communication interface are:
1) Other SmartMotors
2) Bar Code Readers
3) Light Curtains
4) Terminals
5) Printers
an external device (in this case another SmartMotor) and then takes a number
back from the device as a series of ASCII letter digits, each ranging from 0
to 9. A carriage return character will mark the end of the received data. The
program will use that data as a position to move to.
The ASCII code for zero is 48. The other nine digits count up from there so
the ASCII code can be converted to a useful number by subtracting the value
of 0 (ASCII 48). The example assumes that the most significant digits will be
returned first. Any time it sees a new digit, it multiplies the previous quantity
by 10 to shift it over and then adds the new digit as the least significant. Once
a carriage return is seen (ASCII 13), motion starts. After motion is started, P
(Position) is reset to zero in preparation for building up again. P is buffered
so it will not do anything until the G command is issued.
77
This page has been intentionally left blank.
78
THE PID FILTER
KI, in most cases, is used to compensate for friction. Without it the SmartMotor
will never exactly reach the target. Begin with KI equal to zero and KL equal
to 1000. Move the motor off target and start increasing KI and KL. Keep KL
at least ten times KI during this phase.
80
THE PID FILTER
Continue to increase KI until the motor always reaches its target, and once
that happens add about 30% to KI and start bringing down KL until it hampers
the ability for the KI term to close the position precisely to target. Once that
point is reached, increase KL by about 30% as well. The Integral term needs
to be strong enough to overcome friction, but the limit needs to be set so that
an unruly amount of power will not be delivered if the mechanism were to jam
or simply find itself against one of its ends of travel.
E=expression Set maximum position error
The difference between where the motor shaft is and where it is supposed
to be is appropriately called the “error”. The magnitude and sign of the error
is delivered to the motor in the form of torque, after it is put through the PID
filter. The higher the error, the more out of control the motor is. Therefore, it
is often useful to put a limit on the allowable error, after which time the motor
will be turned off. That is what the E command is for. It defaults to 1000
encoder counts, but can be set from 1 to 32,000.
There are still more parameters that can be utilized to reduce the position error
of a dynamic application. Most of the forces that aggravate a PID loop through
the execution of a motion trajectory are unpredictable, but there are some that
can be predicted and further eliminated preemptively.
81
THE PID FILTER
82
THE PID FILTER
83
This page has been intentionally left blank.
84
SMI ADVANCED FUNCTIONS
SMI SOFTWARE
The Quick Start section of this guide describes the minimum SMI functionality neces-
sary to talk to SmartMotors as well as create, download and test SmartMotor programs.
SMI as a whole, however, has much greater capability.
SMI PROJECTS
In applications with more than one When working with
SmartMotor and possibly more than multiple motors,
one program or communications port, programs or ports,
it is helpful to organize all of the ele- creating a PROJECT
ments as a PROJECT, rather than can be a great way of
deal with individual files. Projects organizing and using
can be created from the FILE menu. all of the individual
When starting a new project, you have elements.
the option of SMI2 exploring the net-
work of motors and setting up the
project automatically, or to do it manu-
ally by double clicking on the specific communication ports or motors exhibited in the
Information Window.
TERMINAL WINDOW
The Terminal Window acts as a Real Time portal between you and the SmartMotor.
By typing commands in the Terminal, you can set up and execute trajectories, execute
subroutines of downloaded programs and request data to be reported back.
Specific Communication
Ports can be selected using
the tabs. If multiple
SmartMotors are on a single
Communication Port and
individually addressed, com-
mands can be routed to any
or all of them by making the
appropriate selection from
the pull-down menu just
below the tabs. The SMI pro-
gram will automatically send the appropriate codes to the network to route the data to
the intended motors. Commands can be entered in the white text window or the blue
screen. If data is flooding back from the motor, then the white text window will be more
convenient.
85
SMI ADVANCED FUNCTIONS
CONFIGURATION WINDOW
The Configuration Window both shows the current configuration and allows access to
specific ports and motors to alter properties. Press "Find Motors", or the Address Button
The to detect and analyze your system. Once that is
Configuration accomplished, you can double click on any port
Window is to get instant access to its properties. You can
essential to also double click on any motor to immediately
keeping multiple- bring up the "Motor View" tool for that motor.
SmartMotor By Right Clicking the motor, you have immedi-
systems ate and convenient access to its properties along
organized. with various other tools.
PROGRAM EDITOR
SmartMotor programs are written in the SMI Program Editor before being scanned for
errors and downloaded to the motor. To get the Program Editor to appear, simply
go to the FILE menu and select NEW or simply press the button on the toolbar.
As you write your program, the
editor will highlight commands it
recognizes in different colors.
Once a program is complete, you can simply scan it for errors by pressing the button
on the toolbar or scan and download it at one time by pressing the button. If errors
are found, the download will be aborted and the problems will be identified in the Infor-
mation WIndow located at the bottom of the screen.
86
SMI ADVANCED FUNCTIONS
INFORMATION WINDOW
The Information Window shows program status. When a program is scanned and
errors are found, they are listed in the Information Window preceded by an .
87
SMI ADVANCED FUNCTIONS
The can display serial data in a variety of formats and can be a useful tool in debugging
communications. For non-intrusive "sniffing" of data, a special cable can be configured
to connect the host receive pin and ground to the data channel to be monitored.
MOTOR VIEW
The SMI Motor View WIndow enables the user to view multiple parameters related to
the motor, in real time. It is most conveniently accessible by double clicking the motor
MotorView of interest in the configuration
provides a window window.
into the inter
workings of a Press the "Poll" button to ini-
SmartMotor, in tiate the real-time scanning of
Real-Time. motor parameters.
Newer SmartMotors have built-in provisions to allow them to be identified by the SMI
software. If a motor is identified, a picture of it will appear in the lower left corner of the
MotorView Window. Tabs across the top offer a wealth of additional information.
report commands, fully custom items can be added by entering the specific commands
appropriate to getting the data reported, like making a variable equal to the parameter
and then reporting the variable for example.
CHART VIEW
For Graphical Monitoring of data, go to the Tools Menu and select Chart View.
Like the Monitor View Window,
Sometimes, the
polling items for Chart View can
best way to
be added by pressing the
understand a data
button.
trend is by seeing
The Fields and Options are iden- it graphically. The
tical to those from the Monitor SMI Chart View
tool. provides Graphical
Access to any
Adjustable upper and lower readable
limits for each polled parameter SmartMotor
allow them to be scaled to fit the parameter.
space.
MACROS
For the SMI User's convenience, the programmer can associate a command or series of
commands with a Ctrl-# key. This is done by selecting "Macro.." from the Tool Menu.
89
SMI ADVANCED FUNCTIONS
To add a macro, start by pressing the ADD button in the Macro Window.
TUNER
Tuning a SmartMotor is far more simple than tuning traditional servos, but it can be even
easier using the SMI Tuner to see the actual results of different tuning parameters.
For information on how to tune a SmartMotor, refer to the preceding section "The PID
Filter". Each SmartMotor has very soft default tuning. Increasing the stiffness of that
tuning can increase the accuracy of the machine the SmartMotor is controlling. To bring
90
SMI ADVANCED FUNCTIONS
up the SMI Tuner, select "Tuner" from the SMI Tools Menu.
The Tuner shows the Step Response of the SmartMotor, graphically. The Step Response
is the SmartMotors actual reaction to the request for a small but instantaneous change in
position. Rotor Inertia prevents the SmartMotor from changing its position in zero time,
but how valiant the effort is shows a lot about how well in-tune the motor is.
Before running the Tuner, be sure the motor, and what ever it is connected to is free
to move about 1000 encoder counts or
more, and that the device is able to safely
withstand an abrupt jolt. If that is the
case, then press the "Run Tuning" button
at the bottom of the Tuning Window. If
the SmartMotor was connected, on and
still, you should see something like what
is depicted to the right. The upper curve
with the legend on the left is the Smart-
Motor's actual position over time. Notice
that it overshot its target position before
settling in.
Normally, this process involves repeated trials, again, exercising the procedure outlined
in the previous section on "The PID Filter".
In this example, we stiffened up the tuning by raising KP and increased the KD (or damp-
ening) to keep the motor stable.
91
SMI ADVANCED FUNCTIONS
Once you are happy with the results, the best parameters can be added to the top of
your program in the SmartMotor, or in applications where there are no programs in the
motors, sent by a host after each power-up. Whether from a host, or in a program, the
tuning parameters would be set using the tuning commands:
KP=250
KI=28
KD=1500
KL=20
F
SMI OPTIONS
The SMI Terminal Software can be customized in general by way of the Options choice
in the Tools menu.
A key option to consider is the Firmware Version. Since different SmartMotor firmware
have subtle differences, the program scanner needs to know which firmware is being uti-
lized so it can know what are legal commands and what are commands that are unsup-
ported.
SMI HELP
The most complete and up-to-date information available for SMI functions is available
within the programs extensive HELP facility. The easiest way to get instant access to
92 help on any feature is by clicking on the button in the main toolbar. After clicking on
SMI ADVANCED FUNCTIONS
the button, click on the item you want to learn about and information will be presented
on that item.
93
This page has been intentionally left blank.
94
APPENDIX A: THE ASCII CHARACTER SET
0 NUL 35 # 70 F 105 i
1 SOH 36 $ 71 G 106 j
2 STX 37 % 72 H 107 k
3 ETX 38 & 73 I 108 l
4 EOT 39 ‘ 74 J 109 m
5 ENQ 40 ( 75 K 110 n
6 ACK 41 ) 76 L 111 o
7 BEL 42 * 77 M 112 p
8 BS 43 + 78 N 113 q
9 HT 44 , 79 O 114 r
10 LF 45 - 80 P 115 s
11 VT 46 . 81 Q 116 t
12 FF 47 / 82 R 117 u
13 CR 48 0 83 S 118 v
14 SO 49 1 84 T 119 w
15 SI 50 2 85 U 120 x
16 DLE 51 3 86 V 121 y
17 DC1 52 4 87 W 122 z
18 DC2 53 5 88 X 123 {
19 DC3 54 6 89 Y 124 |
20 DC4 55 7 90 Z 125 }
21 NAK 56 8 91 [ 126 ~
22 SYN 57 9 92 \ 127 Del
23 ETB 58 : 93 ]
24 CAN 59 ; 94 ^
25 EM 60 < 95 _
26 SUB 61 = 96 ’
27 ESC 62 > 97 a
28 FC 63 ? 98 b
29 GS 64 @ 99 c
30 RS 65 A 100 d
31 US 66 B 101 e
32 SP 67 C 102 f
33 ! 68 D 103 g
34 “ 69 E 104 h
95
This page has been intentionally left blank.
96
APPENDIX B: BINARY DATA
97
APPENDIX B: BINARY DATA
If all their values are added together the result is 255. By leaving particular
bits out any sum between zero and 255 can be created. Look at the following
example bytes and their decimal values:
Byte Value
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1
0 0 0 0 0 0 1 0 2
0 0 0 0 0 0 1 1 3
0 0 0 1 0 0 0 0 16
1 0 0 0 0 0 0 0 128
1 0 0 0 0 0 0 1 129
1 1 1 1 1 1 1 1 255
Consider the following two bytes of information:
Byte Value
0 0 1 1 1 1 0 0 60
0 0 0 1 1 1 1 0 30
To make use of the limited memory available with micro controllers that
can fit into a SmartMotor, there are occasions where every bit is used.
One example is the status byte. A single value can be uploaded from a
SmartMotor and have coded into it, in binary, eight or sixteen independent
bits of information.
The following is the status byte and its coded information:
Name Description Bit Value
Bo Motor OFF 7 128
Bh Excessive temp. 6 64
Be Excessive pos. err. 5 32
Bw Wraparound 4 16
Bi Index reportable 3 8
Bm Real time neg. lim. 2 4
Bp Real time pos. lim. 1 2
Bt Trajectory going 0 1
There are two useful mathematical operators that work on binary data, the “&”
(and) and the ”|” (or). The “&” compares two bytes, words or longs and looks
for what they have in common. The resulting data has ones only where there
were ones in both the first byte and the second. The “|” looks for a one in the
same location of either the first data field or the second. Both functions are
illustrated in the following example:
A B A&B A|B
0 0 0 0
0 1 0 1
98 1
1
0
1
0
1
1
1
APPENDIX B: BINARY DATA
Knowing how the binary data works will enable shorter and faster code to be
written. The following are two code examples that are looking to see if both
limit inputs are high. One does this without taking advantage of the binary
operator while the second shows how using the binary operator makes the
code shorter, and therefor faster.
Example 1:
IF Bm ‘Look for - lim high
IF Bp ‘Loof for + lim high
GOSUB100 ‘Execute subroutine
ENDIF
ENDIF
Example 2:
IF S&6 ‘Look at both lim
GOSUB100 ‘Execute subroutine
ENDIF
Both examples will execute subroutine 100 if both limit inputs are high. By
“anding” the status byte (S) by six, the second routine filters out all of the other
status information. If either limit is high, then the result will be non-zero and
subroutine 100 will execute. Example two uses much less code than example
one and will run much faster as a part of a larger program loop.
The next two examples show how the use of the “|” operator can improve
program size and execution speed:
Example 3:
IF UAI ‘Look for input A
GOSUB200 ‘Execute subroutine
ENDIF
IF UBI ‘look for input B
GOSUB200 ‘Execute subroutine
ENDIF
Example 4:
IF UAI|UBI ‘Look at both A,B
GOSUB200 ‘Execute subroutine
ENDIF
Both examples 3 and 4 accomplish the same task with different levels of
efficiency.
99
This page has been intentionally left blank.
100
APPENDIX C: COMMANDS
! (exclamation point)
(space) Single space between user variables
@P Current position
@PE Current position error
@V Current velocity
a...z User variables
aa . . . zzz More user variables
al[index] Array variable 32 bit
aw[index] Array variable 16 bit
ab[index] Array variable 8 bit
A=exp Set acceleration
ADDR Motor’s self address variable
AIN{port}{channel} Assign input byte from module
AMPS=expression Set PWM drive signal limit
AOUT{port}{expression} Output analog byte to module
Ba Over current status bit
Bb Parity error status bit
Bc Communication overflow status bit
Bd Math overflow status bit
Be Excessive position error status bit
Bf Communications framing error status bit
Bh Excessive temperature status bit
Bi Index captured status bit
Bk EEPROM data integrity status bit
Bl Historical left limit status bit
Bm Real time left limit status bit
Bo Motor off status bit
Bp Real time right limit status bit
Br Historical right limit status bit
101
APPENDIX C: COMMANDS
110
APPENDIX D: DATA VARIABLES MEMORY MAP
111
APPENDIX D: DATA APPENDIX
VARIABLESD:MEMORY MAP
DATA VARIABLES MEMORY MAP
112
APPENDIX E: EXAMPLE PROGRAMS
113
aPPendix e: examPle Programs
116
Appendix E: Example Programs
volts.
c=CLK-c
c=c*1000
c=c/4069
c=c-d ‘Subtract off the main loop time
Rc ‘Report the actual time, in MicroSeconds
‘ the command takes to execute
END ‘End program
C200 ‘STAT
PRINT(“STAT: “)
RS
PRINT(#13)
PRINT(“CCS: “,tt,#13) ‘Print Command Checksum
PRINT(“TCS: “,ss,#13) ‘Print Total Checksum
PRINT(“ICS: “,zz,#13) ‘Print Incomming Checksum
RETURN
C300 ‘END
PRINT(“ENDING...”,#13)
PRINT(“CCS: “,tt,#13) ‘Print Command Checksum
PRINT(“TCS: “,ss,#13) ‘Print Total Checksum
PRINT(“ICS: “,zz,#13) ‘Print Incomming Checksum
122
APPENDIX E: EXAMPLE PROGRAMS
C400 ‘ZERO
PRINT(“ZEROING”,#13)
PRINT(“CCS: “,tt,#13) ‘Print Command Checksum
PRINT(“TCS: “,ss,#13) ‘Print Total Checksum
PRINT(“ICS: “,zz,#13) ‘Print Incomming Checksum
O=al[0] ‘Reset origin, if al[0]
‘ was not set, then
‘ default zero
RETURN
123
APPENDIX E: EXAMPLE PROGRAMS
124
APPENDIX F: F= COMMANDS
For purposes of efficiency, the SmartMotor utilizes a byte of memory (8 bits) for
the setting of certain modes. The byte if accessed through the F= command.
Because of its Binary nature, bits must be set and cleared with an understand-
ing of how Binary works. If you want help understanding binary data, please
refer to Appendix A, or for just the facts relevant to F=, refer to the end of this
section.
Not all F= bit controlled modes relate to each other, but still, here is the total list
for reference (in one place):
F=1 Causes the motor to decelerate to a stop upon the trigger
of a soft or hard limit, whereas the default action is to simply
turn the amplifier off and allow the motor to free wheel (PLUS
& ServoStep only).
F=2 Reverses the shaft direction. All shaft motion commands
and modes will cause motion in the opposite direction they
would have otherwise (PLUS & ServoStep only).
F=4 Redirects user program prints and report commands to
channel 1 rather than the main communications port, channel 0.
F=8 Causes the PID integral term to clear at the end of each
trajectory. This eliminates what is referred to as "wind up"
and can be useful in some applications.
F=16 Causes CAM mode to use Relative Positioning (PLUS &
ServoStep only).
F=32 Causes faults to call subroutine C1 (PLUS & ServoStep only).
F=64 Makes low transitions of port G trigger subroutine C2 (PLUS
& ServoStep only).
F=128 Resets the value of "@P", "RP" and external counter "CTR"
to zero at modulo "BASE" plus dwell "D" in Relative Cam
Mode (PLUS & ServoStep only).
The best way to load F= is with a shadow variable, like "f" for example. To set
bit value 8, you could issue the command "F=8", but what you would also be
doing is clearing all of the other bits of F=. A better way is to issue these com-
mands:
f=f|8 ‘Set F=8 bit in the shadow variable
See Appendix B
F=f ‘Set the F= byte
to get a better
The above example sets bit value 8 without disturbing the others. understanding of
Binary Data
Clearing bit 8 is a bit more convoluted. The bit value must first be subtracted
from the maximum byte value of 255. For example 255 - 8 = 247. By "anding"
the shadow variable with 247, all bits will remain except for bit value 8. Here is
how that would be done:
f=f&247 ‘Set F=32 bit in the shadow variable
125
APPENDIX F: F= COMMANDS
126