







|
 
|
S100SMC Communications Protocol
The S100SMC Communications Protocol was designed to be simple and efficient, and yet allow for advanced motion control features
such as half-stepping, ramping acceleration and deceleration, and the return of positional information.
This page will explain the protocol so that you can use any programming language or device capable of RS-232 communications
to control stepper motors with the S100SMC.
Communications Setup
The S100SMC uses RS-232 communications to receive and transmit data. All that is necessary to execute commands on the controller is to
send the appropriate bytes of data and then receive the data sent by the controller upon completion of the requested task. To start with,
the communications settings used by the S100SMC are:
| Baud Rate |
Parity |
Word Length |
Stop Bits |
Xon/Xoff Handshaking |
| 9600 bps |
None |
8 data bits |
1 |
Off |
If your communications match these specifications, you should be able to communicate with the controller, regardless of the device or language
being used. The port will just be the port to which the serial cable from the S100SMC is connected. By default our software uses Comm1, but
the board will operate the same on any comm port.
Data Sent To The S100SMC
To execute any command on the S100SMC, you must send 21 bytes of data. Upon receiving the last of these bytes, the S100SMC
performs a number of initialization tasks (taking up < 3 milliseconds at most) and then immediately executes the task.
Each of the 21 bytes is listed in the table below and described in detail further down the page. Click on any of the byte #'s to
jump to that byte's description. The bytes that must be sent are:
| Byte |
Description |
| 1 |
Motor 0 Number Of Steps High Byte |
| 2 |
Motor 0 Number Of Steps Low Byte |
| 3 |
Motor 1 Number Of Steps High Byte |
| 4 |
Motor 1 Number Of Steps Low Byte |
| 5 |
Motor 2 Number Of Steps High Byte |
| 6 |
Motor 2 Number Of Steps Low Byte |
| 7 |
Motor 0 Minimum Delay High Byte |
| 8 |
Motor 0 Minimum Delay Low Byte |
| 9 |
Motor 1 Minimum Delay High Byte |
| 10 |
Motor 1 Minimum Delay Low Byte |
| 11 |
Motor 2 Minimum Delay High Byte |
| 12 |
Motor 2 Minimum Delay Low Byte |
| 13 |
Motor 0 Maximum Delay High Byte |
| 14 |
Motor 0 Maximum Delay Low Byte |
| 15 |
Motor 1 Maximum Delay High Byte |
| 16 |
Motor 1 Maximum Delay Low Byte |
| 17 |
Motor 2 Maximum Delay High Byte |
| 18 |
Motor 2 Maximum Delay Low Byte |
| 19 |
Motor 0 Rotation Mode Byte |
| 20 |
Motor 1 Rotation Mode Byte |
| 21 |
Motor 2 Rotation Mode Byte |
How The S100SMC Works
During rotation, the S100SMC starts each motor at its maximum delay value (bytes 13 - 18) and ramps up the speed (by decreasing
the delay) until the motor is rotating at its minimum delay value (bytes 7 - 12). Once the motor has reached its minimum delay value,
it rotates at this speed for the number of steps specified (bytes 1 - 6). After this number of steps has been completed, the delay for
the motor begins to increase until it again equals the maximum delay value that it started with.
The increase and decrease in rotation speed happens at a rate of 1 decrease or increase in delay value for every one step completed.
Therefore, if you instruct the board that a motor's number of steps is 10, its minimum delay value is 30, and its maximum delay value is 35,
the motor will executed the steps as follows:
- Beginning at a delay value of 35, the motor will execute 5 steps, decreasing the delay with each step until the delay equals 30.
- After the delay value has reached 30, the motor will execute 10 steps at this speed.
- Once these steps are completed, the motor will increase the delay value by 1 for each step until after 5 more steps the delay
value again reaches 35.
A total of 20 steps were executed: (35 - 30) x 2 + 10 = 20
To rotate the motors without any ramping acceleration or deceleration, simply send identical values for the minimum and maximum delay bytes.
In every case the maximum delay value must be greater than or equal to the minimum delay value, or the rotation will be unpredicitable.
In infinite mode, the motor begins at the maximum delay value and decreases the delay value by 1 for each step completed until the delay
value equals the minimum delay. At that time, the motor continues to rotate until a byte is sent to cause the rotation to stop.
Each motor requires 2 bytes for the number of steps, 2 bytes for the minimum delay value, 2 bytes for the maximum delay value, and also one
byte that serves as a rotation mode byte. This byte handles the motor position (in terms of which phase was energized last), half stepping,
infinite mode, and direction of rotation. More on the rotation mode bytes can be found below.
Number Of Steps Bytes (Bytes 1 - 6)
The S100SMC is capable of executing up to 65535 steps per command, or an infinite number of steps when in
infinite mode. The number of steps to be executed is sent as two 8-bit (one byte) values,
and a value of 0 steps (0 for each of the two bytes) is valid.
The Number of Steps High Byte is a value from 0 to 255 representing
the 8 most significant bits in a 16-bit step value. Similarly, the Number of Steps Low Byte is a value from 0 to 255
representing the 8 least significant bits in a 16-bit step value. Thus, the number of steps executed by the
S100SMC is equal to the (Number of Steps High Byte x 256) + (Number of Steps Low Byte).
For example, to have motor 0 execute 5000 steps, send 19 for the first byte, and 136 for the second byte:
19 x 256 = 4864
136 x 1 = 136
4864 + 136 = 5000
Therefore, if you want Motor 0 to execute 5000 steps, Motor 1 to execute 5001 steps, and Motor 2 to execute 5003 steps,
you would send the following bytes as the first six bytes: 19, 136, 19, 137, 19, 138.
Minimum Delay Bytes (Bytes 7 - 12)
Bytes 7 - 12 represent the minimum delay values that will be used by each of the three motors during rotation. During rotation, the S100SMC
begins each motor at its maximum delay value (bytes 13 - 18) and ramps up the speed (by decreasing the delay) until the motor is rotating
at its minimum delay value. This minimum delay value can be from 1 to 65535. Also, each delay value is equal to
0.0002604 seconds, and thus a delay of 1 will equal 3840 steps per second.
To send the manimum delay value, it must be expressed as two bytes. The first byte (byte #7 for motor 0) is the high byte, and the second byte
(byte #8 for motor 0) is the low byte.
Thus, to instuct the board that the minimum delay value for motor 0 is 600, you would send 2 for the first byte, and 88 for the second byte:
2 x 256 = 512
88 x 1 = 88
512 + 88 = 600
Therefore, if you want Motor 0 to have a minimum delay value of 600, Motor 1 to have a minimum delay value of 601, and Motor 2 to have
a minimum delay value of 602, you would send the following bytes for bytes 7 - 12: 2, 88, 2, 89, 2, 90
Maximum Delay Bytes (Bytes 13 - 18)
Bytes 13 - 18 represent the maximum delay values that will be used by each of the three motors during rotation. During rotation, the S100SMC
begins each motor at its maximum delay value (bytes 13 - 18) and ramps up the speed (by decreasing the delay) until the motor is rotating
at its minimum delay value. The maximum delay value can be from 1 to 65535. Also, each delay value is equal to
0.0002604 seconds, and thus a delay of 1 will equal 3840 steps per second.
To send the maximum delay value, it must be expressed as two bytes. The first byte (byte #13 for motor 0) is the high byte, and the second byte
(byte #14 for motor 0) is the low byte.
Thus, to instuct the board that the maximum delay value for motor 0 is 605, you would send 2 for the first byte, and 88 for the second byte:
2 x 256 = 512
93 x 1 = 93
512 + 93 = 605
Therefore, if you want Motor 0 to have a maximum delay value of 605, Motor 1 to have a minimum delay value of 606, and Motor 2 to have
a minimum delay value of 607, you would send the following bytes for bytes 13 - 18: 2, 93, 2, 94, 2, 95
Rotation Mode Bytes (Bytes 19 - 21)
In addition to the 2 number of steps bytes, the 2 minimum delay bytes, and the 2 maximum delay bytes, each motor requires one byte to serve as
a rotation mode byte. The rotation byte is broken down into a 3-bit value that corresponds with a position, one bit for rotation direction,
one bit for infinite mode, and one bit for half-stepping. The 4th and 8th bits are not used at this time. Thus, the maximum meaningfull
value for the rotation mode byte of each motor is 119 (Binary 1110111).
The 3 least significant bits of the byte refer to a position in a rotation table inside the microcontroller on
the S100SMC. The 3 bits can represent any value from 0 to 7 (Binary 000 to Binary 111), and in the rotation table
values 0, 2, 4, and 6 represent full steps, and values 1, 3, 5, and 7 represent half steps. These positions actually refer to
which of the 4 "phases" of the motor are energized, and thus you can start you initial rotation with any value -- 0, 2, 4, or 6
if you would like to rotate in full-step mode, and 0, 1, 2, 3, 4, 5, 6, if you would like to rotate the motor in half step mode
(both full and half-step positions in the table are used for half-stepping).
To ensure that the motors do not skip positions from one rotation execution to the next, the position information is sent back from the
S100SMC after the completion of each rotation, allowing you to send the same position value back to the controller when the next
rotation begins.
The 4th bit of the rotation mode byte is not used at this time.
The 5th bit of the rotation mode byte corresponds to the rotation direction of the motor. For Clockwise Rotation, leave this bit as 0. For
Counter-Clockwise Rotation, set this bit to 1 (done by adding 16 to the rotation mode byte). Note: The direction of rotation varies depending
on how each motor is connected to the board.
The 6th bit of the rotation mode byte corresponds to whether or not the motor is rotating in infinite mode. In this mode, the motor will begin
rotation at its maximum delay value, increase in speed to its minimum delay value, and then rotate indefinitely until a stop byte is sent (covered
below). If the motor is rotating in normal mode, then leave this bit as 0. If the motor is rotating in infinite mode, set this bit to 1 (done
by adding 32 to the rotation mode byte).
The 7th bit of the rotation mode byte corresponds to whether the motor is rotating in half-stepping or full-stepping mode. If the motor is
rotating in full-stepping mode, leave this bit as 0. If the motor is rotating in half-stepping mode, set this bit to 1 (done by adding
64 to the rotation mode byte).
For example, if you want Motor 0 to start at position 0 in the rotation table, with counter-clockwise rotation, in infinte mode, and half-stepping,
you would send the value of 0 + 16 + 32 + 64 = 112 to the S100SMC for the 19th byte (Motor 0 Rotation Mode Byte).
Each of the 3 motors has a rotation mode byte--19th byte for Motor 0, 20th byte for Motor 1, and 21st byte for Motor 2. Each of these bytes
must be computed as described above for each motor.
Final Example
As a final example, if you would like to rotate the 3 motors as follows:
- Motor 0: number of steps at minimum delay speed = 5000, minimum delay value = 600, maximum delay value = 605, start at position 0 in rotation table,
counter-clockwise rotation, infinite mode off, and half-stepping.
- Motor 1: number of steps at minimum delay speed = 5001, minimum delay value = 601, maximum delay value = 606, start at position 0 in rotation table,
counter-clockwise rotation, infinite mode off, and half-stepping.
- Motor 2: number of steps at minimum delay speed = 5002, minimum delay value = 602, maximum delay value = 607, start at position 0 in rotation table,
counter-clockwise rotation, infinite mode off, and half-stepping.
You would send the following 21 bytes to the S100SMC:
19, 136, 19, 137, 19, 138, 2, 88, 2, 89, 2, 90, 2, 93, 2, 94, 2, 95, 80, 80, 80
Data Received From The S100SMC
Upon completion of a rotation, the S100SMC sends back 12 bytes. These bytes are listed in the following table:
| Byte |
Description |
| 1 |
Motor 0 Rotation Table Position |
| 2 |
Motor 1 Rotation Table Position |
| 3 |
Motor 2 Rotation Table Position |
| 4 |
Motor 0 Number Of Steps Completed Low Byte |
| 5 |
Motor 0 Number Of Steps Completed Middle Byte |
| 6 |
Motor 0 Number Of Steps Completed High Byte |
| 7 |
Motor 1 Number Of Steps Completed Low Byte |
| 8 |
Motor 1 Number Of Steps Completed Middle Byte |
| 9 |
Motor 1 Number Of Steps Completed High Byte |
| 10 |
Motor 2 Number Of Steps Completed Low Byte |
| 11 |
Motor 2 Number Of Steps Completed Middle Byte |
| 12 |
Motor 2 Number Of Steps Completed High Byte |
Rotation Table Position Byte
This byte corresponds to the position in the S100SMC rotation table that the motor ended on. The value sent back from the S100SMC
is not in the range of 0 - 7, as was the rotation table position component of the rotation mode byte that was sent to the S100SMC. The value
sent back by the S100SMC must be decreased by 56 to convert it to a value from 0 to 7. Once the value has been decreased it is ready to be
included in the rotation mode byte when the next rotation command is executed.
By using this rotation table position value to start the next rotation you can ensure that no steps are missed by the motors on the start of a new
rotation.
Number of Steps Completed Bytes
After the 3 rotation table position bytes are sent, the S100SMC sends 3 bytes for each motor that represent how many steps were executed during the
last rotation. These values give the number of steps completed at any point during the rotation--during acceleration, max speed, or deceleration.
These values are given as a 3 byte value, with the lowest byte coming first, the middle byte second, and the high byte last. Thus, to know how
many steps were executed by Motor 0 on the last rotation: (Byte 4 x 1) + (Byte 5 x 256) + (Byte 6 x 65536)
Final Data Sent To The S100SMC
After the rotation table position and steps completed bytes have been received from the S100SMC, there are three final bytes to send to the
controller. These three bytes are basically rotation table position bytes, and are as follows:
| Byte |
Description |
| 1 |
Motor 0 Rotation Position Table Byte |
| 2 |
Motor 1 Rotation Position Table Byte |
| 3 |
Motor 2 Rotation Position Table Byte |
Rotation Position Table Bytes
These last three bytes tell the controller which phases of the motor to energize after the command has been completed. They are the means
by which you can cause the motors to be locked into position, applying the holding-torque of the motor, or you can de-energize the windings
so that power is not used by the motors, they do not overheat, and the shafts are not locked into place.
To lock the motors into place in their current position, simply send the rotation table position byte that you received from the controller (bytes 1 - 3
in the previous section). Doing this will cause the same windings that were energized on the completion of the last step to remain energized. Please note
that the value should not be converted by decreasing it by 56 before you send it back to the controller. Decreasing that byte by 56 is only necessary
before it is added into the new rotation mode byte to be sent to the controller on the next rotation.
To turn the windings of all of the motors off, send a value of 67 to the motors. This corresponds to a special position in the rotation table of the
S100SMC that turns off all of the motor windings. This can be done to conserve power while the motors are not moving and to avoid overheating the motors.
Stopping Rotation During A Command
When the S100SMC is rotating a motor in infinite mode or when a command needs to be interrupted before it is completed,
you can send a single byte with a value of 255. This causes the board to stop all motor rotation immediately, and send
the 12 bytes of data that it normally sends at the completion of a rotation.
After receiving the 12 bytes of rotation table and positional information you will still need to send three final bytes
to the board to cause the motors to either remain energized or de-energize the windings, as described above.
We are constantly updating our products and thus this protocol is subject to change at any time. If you have any questions
about any of the information found here or elsewhere on our site, or if you have any feedback or suggestions, please let us
know by either emailing us at info@steppercontrol.com or by filling out our
contact form.
 
|
 
|

|