USB interface
The SMD3 appears as a virtual COM port when plugged into a PC. Configuration and control may be performed via the provided SMD3 software, your own application or any terminal program.
This section is only relevant if you are using terminal software or writing your own application. The provided SMD3 software interacts with the SMD3 in the same way and requires no specialist knowledge to use. A C# API is also provided, allowing you to easily integrate communication with the SMD3 into your own C# .NET application. This is available from our website, at https://arunmicro.com/products/smd3-stepper-motor-drive/.
Configuration
The SMD3 uses a USB Type-C connector, which is both robust and reversible (it may be inserted either way up). The device appears as a virtual COM port on your PC. Configure the serial port as follows:
- 115200 baud
- 1 Stop bit
- No parity
- No flow control
Protocol
A simple text-based protocol is used. Commands are sent to the SMD3, checked and executed, and a response returned. Wait for a response to the previous command before sending the next to avoid buffer overflow in the SMD3. Commands are in the form (Note that angle brackets are shown for clarity only, they are not part of the protocol):
<mnemonic>,<argument 1>,<argument 2>,<argument n>…<CR><LF>
And responses are in the form:
<SFLAGS>,<EFLAGS>,<data 1>,<data 2>,<data n>…<CR><LF>
If the command executed successfully, or:
<SFLAGS>,<EFLAGS>,<error code><CR><LF>
If the command failed to execute correctly.
Where:
Item |
Description |
<mnemonic> |
Short sequence of characters representing a command, case insensitive |
<argument n> |
Zero or more command arguments |
<data n> |
Zero or more response data items |
<error code> |
An error code, see section Error Codes. This includes both a number and text description of the error to aid when using the SMD3 via a terminal program. |
<SFLAGS> |
Set of flags representing the status of the SMD3, such as the state of the limit inputs or whether the joystick is connected. See section Status Flags |
<EFLAGS> |
Set of flags representing the error state of the SMD3, such as invalid mnemonic, or motor over-temperature fault. See 0 |
<CR><LF> |
Message terminator; carriage return followed by line-feed (0x07,0x0D) |
Comma separation
All elements are comma-separated, except for the message terminator which immediately follows the last item. A response is always sent on receipt of a message terminator. If an argument was supplied with a command, for example, to set a value, the value set will be returned in the response and serves as an additional confirmation of the command having executed as expected.
Many commands accept a real number argument when the underlying quantity is an integer, or finite set of real numbers. In this case, the supplied value being otherwise acceptable is rounded to the closest integer or real number from the allowed set, and it is this value that is returned in the response.
White space
Additional white space (tabs and spaces) are ignored except where they are surrounded by characters comprising the data item, in which case they will be considered as part of the data item itself.
No data items to return
If there are no data items as part of a response, only the SFLAGS and EFLAGS are returned. If an error occurred, then this will be reflected in the EFLAGS.
Argument types
Arguments may be one or a mix of the following types, depending on the command. Data returned by the SMD3 uses the same types, which are always presented as indicated in the “SMD3 response” column.
Type |
Name |
Description |
Example argument values |
SMD3 response |
INT |
Integer |
Integer value, with or without sign |
100, -10, +7 |
Sign included for negative values only. E.g. 100, -10 |
UINT |
Unsigned integer |
Unsigned integer value, no sign. Hexadecimal representation may also be used, case insensitive |
99, 1000, 0xA74F, 0xd7 |
Numeric format E.g. 100, 200 Except for status and error flags which are returned in upper case 2-byte hexadecimal format, E.g. 0x1234, 0xA4DE |
FLOAT |
Real number |
Real number, with or without sign. Scientific format may also be used, case insensitive |
10.23, 100e-3, 100E4, 10 |
Scientific format, with 5 places after the decimal point and a E.g. 1.23000E+04, 5.76159E-10 |
STRING |
ASCII string |
ASCII string, consisting of characters 0x20 to 0x7E inclusive |
Abc123 78-%^A |
ASCII string, E.g. “1234 abc”, “10%” |
BOOL |
Boolean |
Binary, true/false value |
0, 1 |
E.g. 0, 1 |
Flags
Error flags are reported by the SMD3 in hexadecimal format as explained above. E.g. a value of 0x0002 means bit 1 is set (TOPEN), indicating that the SMD3 has been disabled due to an open circuit temperature sensor.
Error flags (EFLAGS)
These indicate error conditions and are latching (i.e. remain set even after the error condition that caused them no longer persists). Clear using the CLR command or by using the reset fault input. The motor is disabled if one or more error flags are set.
Bit |
Name |
Description |
0 |
TSHORT |
Selected temperature sensor is short-circuited (Not applicable to Thermocouple) |
1 |
TOPEN |
Selected temperature sensor is open circuit |
2 |
TOVR |
Selected temperature sensor is reporting temperature > 190 °C and power has been removed from the motor to protect the windings |
3 |
MOTOR SHORT |
Motor phase to phase or phase to ground short has been detected |
4 |
EXTERNAL DISABLE |
Motor disabled via external input |
5 |
EMERGENCY STOP |
Motor disabled via software |
6 |
CONFIGURATION ERROR |
Motor configuration is corrupted |
7-15 |
Reserved |
Reserved, read as ‘0’ |
Status flags (SFLAGS)
Bit |
Name |
Description |
0 |
JSCON |
Joystick is connected |
1 |
LIMIT NEGATIVE |
Limit input is active (Note that the polarity is configurable, so active can mean high or low signal level) |
2 |
LIMIT POSITIVE |
|
3 |
EXTEN |
External enable input state |
4 |
IDENT |
Ident mode is active, green status indicator is flashing to aid in identifying SMD3 |
5 |
Reserved |
Reserved, read as ‘0’ |
6 |
STANDBY |
Motor stationary. Check this bit before performing a function that requires the motor to be stopped first, such as changing mode |
7 |
BAKE |
Bake mode running |
8 |
ATSPEED |
Set when the motor is at target velocity |
9-15 |
Reserved |
Reserved, read as ‘0’ |
Error codes
Error |
Description |
-1 (Stop motor first) |
Several actions, such as changing resolution or operating mode require that the motor is stopped first. Trying to run such a command before the motor has come to a stop and the standby flag in the status register is set will result in this error. |
-2 (Argument validation) |
An argument supplied to the command is invalid, for example, it is outside the allowable range. |
-3 (Unable to get) |
The command is write-only, read is not valid. This applies to commands such as RUNV where a read would have no meaning. |
-5 (Action failed) |
The command failed to execute due to an internal error, for example, the internal flash in which settings are stored has reached the end of life and data cannot be reliably written to it. |
-6 (Not possible in mode) |
The command is not applicable to this mode, for example, trying to start bake using RUNB when not in bake mode. |
-7 (Not possible when motor disabled) |
The motor is disabled (due to a fault, or external enable) and the command is one that starts motion, for example RUNV. |
-101 (Argument type) |
The argument is of the wrong type, for example a non-integer value was given where an integer value was required. |
-102 (Argument count) |
The argument count is incorrect, either too few or too many arguments have been supplied. |
Quick reference
General
Mnemonic |
Description |
R |
W |
Arguments |
SER |
Read the serial number |
● |
|
|
FW |
Read the firmware version number |
● |
|
|
CLR |
Clear error flags |
|
● |
|
LOAD |
Load saved configuration |
|
● |
|
STORE |
Store configuration |
|
● |
|
LOADFD |
Load factory defaults |
|
● |
|
Identify SMD3 by blinking the status indicator |
|
● |
BOOL |
|
Mode of operation |
● |
● |
UINT |
|
Joystick mode |
● |
● |
UINT |
|
Auto switch to Joystick mode on JS connect |
● |
● |
BOOL |
|
External enable used |
● |
● |
BOOL |
|
FLAGS |
Returns ascii table of status and error flag states |
● |
|
|
Command movement
Mnemonic |
Description |
R |
W |
Arguments |
Move motor velocity mode |
|
● |
STRING |
|
Move motor absolute positioning mode |
|
● |
INT |
|
Move motor relative positioning mode |
|
● |
INT |
|
Activate bake mode |
|
● |
|
|
Start home mode procedure |
|
● |
STRING |
|
Bring motor to a stop according to the current profile |
|
● |
|
|
SSTOP |
Stop motor in 1 second on full step position independently of the current motion profile |
|
● |
|
ESTOP |
Emergency stop. Stops the motor immediately |
|
● |
|
Motor
Mnemonic |
Description |
R |
W |
Arguments |
TSEL |
Temperature sensor selection, T/C or RTD |
● |
● |
UINT |
TMOT |
Temperature in °C |
● |
|
|
IR |
Run current in amps |
● |
● |
FLOAT |
IA |
Acceleration current in amps |
● |
● |
FLOAT |
IH |
Hold current in amps |
● |
● |
FLOAT |
PDDEL |
Power down delay in milliseconds |
● |
● |
FLOAT |
IHD |
Power down ramp delay in milliseconds |
● |
● |
FLOAT |
F |
Freewheel mode |
● |
● |
UINT |
RES |
Resolution |
● |
● |
UINT |
Limit inputs
Mnemonic |
Description |
R |
W |
Arguments |
L |
Global enable |
● |
● |
BOOL |
L+ |
Limit positive (Limit 1) enable |
● |
● |
BOOL |
L- |
Limit negative (Limit 2) enable |
● |
● |
BOOL |
LP+ |
Limit n polarity (0 for active high, 1 for active low) |
● |
● |
BOOL |
LP- |
● |
● |
BOOL |
|
LP |
Limit polarity for both Limit positive (Limit 1) and negative (Limit 2), (0 for active high, 1 for active low) |
|
● |
BOOL |
LSM |
How to stop on limit being triggered |
● |
● |
BOOL |
Profile
Mnemonic |
Description |
R |
W |
Arguments |
AMAX |
Acceleration in Hz/s |
● |
● |
FLOAT |
DMAX |
Deceleration in Hz/s |
● |
● |
FLOAT |
VSTART |
Start frequency in Hz |
● |
● |
FLOAT |
VSTOP |
Stop frequency in Hz |
● |
● |
FLOAT |
VMAX |
Target step frequency in Hz |
● |
● |
FLOAT |
VACT |
Actual frequency in Hz |
● |
|
|
PACT |
Actual position in steps |
● |
● |
FLOAT |
PREL |
Relative position in steps |
● |
● |
FLOAT |
TZW |
Time to stop before moving again in seconds |
● |
● |
FLOAT |
THIGH |
Full step – micro stepping transition |
● |
● |
FLOAT |
Step/Direction
Mnemonic |
Description |
R |
W |
Arguments |
EDGE |
Which edges of step input to generate a step on |
● |
● |
UINT |
INTERP |
Interpolate step input to 256 micro steps |
● |
● |
UINT |
Bake
Mnemonic |
Description |
R |
W |
Arguments |
BAKET |
Bake temperature setpoint |
● |
● |
UINT |
Command reference
General
IDENT - Blinks status indicator
Set or query enable blinking of that status indicator to aid in identifying the SMD3 among others.
Query: |
Arguments
The enable state.
[0: |
Disable] |
1: |
Enable |
Returns
The enable state, as above.
Examples
Tx: IDENT,1<CR><LF> Rx: 0x0000,0x0000,1<CR><LF> Tx: IDENT<CR><LF> Rx: 0x0000,0x0000,1<CR><LF> |
// Set ident function on
// Query state of ident function
|
MODE - Choose mode of operation
Set or query the operating mode. See section Operating Modes for an explanation of each mode.
Arguments
The operating mode.
0: |
Step/direction |
1: |
Step/direction triggered velocity |
[2: |
Remote] |
3: |
Joystick |
4: |
Bake |
5: |
Home |
Returns
The mode, as above, followed by a space and the name of the mode in brackets.
Remarks
If the motor is moving when attempting to change the mode, a stop motor first error is returned and the mode is unchanged.
Examples
Tx: MODE,2<CR><LF> Rx: 0x0000,0x0000,2 (Remote)<CR><LF> Tx: MODE<CR><LF> Rx: 0x0000,0x0000,1 (Remote)<CR><LF> |
// Set mode to remote
// Query state of mode
|
JSMODE – Joystick mode
Set or query the joystick mode. Choose between single step, which allows precise single steps or continuous rotation, or continuous which requires only a single button press to make the motor move.
Arguments
The joystick mode.
[0: |
Single step] |
1: |
Continuous |
Returns
The mode, as above.
Remarks
Set requires the motor to be in standby, otherwise, a stop motor first error will be returned.
In single step mode, a brief button press (< 0.5 s) will execute one step in that direction, while pressing the button for > 0.5 s will cause the motor to accelerate up to slewing speed and continue to rotate in that direction until the button is released, at which point the motor will decelerate to a stop.
In continuous mode, a brief button press will trigger the motor to accelerate up to slewing speed. A subsequent press of the same button causes it to decelerate to a stop. If, for example, the clockwise button is pressed while the motor is rotating anti-clockwise, the motor will first decelerate to a stop before changing direction.
Examples
Tx: JSMODE,1<CR><LF> Rx: 0x0000,0x0000,1<CR><LF> Tx: JSMODE<CR><LF> Rx: 0x0000,0x0000,1<CR><LF> |
// Set JSMODE to continuous
// Query state of JSMDOE
|
AUTOJS – Auto switch to joystick mode
Set or query auto switching to joystick mode. When enabled the SMD3 switches automatically to joystick mode and reverts to the previous mode on disconnection of the joystick.
Arguments
The enable state.
0: |
Disable |
[1: |
Enable] |
Returns
The Enable, as above.
Examples
Tx: AUTOJS,1<CR><LF> Rx: 0x0000,0x0000,1<CR><LF> Tx: AUTOJS<CR><LF> Rx: 0x0000,0x0000,1<CR><LF> |
// Set AUTOJS on
// Query state of AUTOJS function
|
EXTEN – External enable used?
Set or query whether the external enable signal should be used.
Arguments
External enable signal.
[0: |
False] |
1: |
True |
Returns
True if the external enable signal is used.
Remarks
The external enable input requires a voltage to be applied between SDE COM and EN on the I/O connector which may be inconvenient if you do not wish to use the enable input. In that case, disable the enable input by sending this command with the argument set to false.
Examples
Tx: EXTEN,1<CR><LF> Rx: 0x0000,0x0000,1<CR><LF> Tx: EXTEN<CR><LF> Rx: 0x0000,0x0000,1<CR><LF> |
// Set EXTEN on
// Query state of EXTEN function
|
Command movement
RUNV – Run, velocity
Command to move the motor using velocity mode.
Arguments
Direction velocity motion.
‘+’: |
Positive |
‘-’: |
Negative |
Remarks
Ensure the profile is set.
Examples
Tx: RUNV,+<CR><LF> Rx: 0x0000,0x0000<CR><LF> Tx: RUNV,-<CR><LF> Rx: 0x0000,0x0000<CR><LF> |
// Start velocity mode to the positive direction
// Start velocity mode to the negative direction |
RUNA – Run, absolute position
Command to move the motor to an absolute position using the positioning mode.
Arguments
Minimum: |
-223-1 |
Maximum: |
223-1 |
Remarks
Ensure the profile is set.
Examples
Tx: RUNA,1000<CR><LF> Rx: 0x0000,0x0000<CR><LF> Tx: RUNA,-1000<CR><LF> Rx: 0x0000,0x0000<CR><LF> |
// Start absolute positioning mode, move to the step position 1000 // Start absolute positioning mode to the step position -1000 |
RUNR - Run, relative position
Command to move the motor to a relative position using the positioning mode.
Arguments
Minimum: |
-223-1 |
Maximum: |
223-1 |
Remarks
Command requires the motor to be in standby, otherwise, a stop motor first error will be returned. Ensure the profile is set.
Examples
Tx: RUNR,2000<CR><LF> Rx: 0x0000,0x0000,1<CR><LF> Tx: RUNR,-2000<CR><LF> Rx: 0x0000,0x0000,1<CR><LF> |
// Start relative positioning mode, move 2000 steps to the positive direction // Start relative positioning mode, move 2000 steps to the negative direction |
RUNB – Run bake
Command to start the bake mode.
Remarks
Set mode to bake first. To stop the bake mode send the STOP command.
Examples
Tx: RUNB<CR><LF> Rx: 0x0000,0x0000<CR><LF> Tx: STOP<CR><LF> Rx: 0x0000,0x0000<CR><LF> |
// Start bake mode
// Stop bake mode |
RUNH – Home to a limit switch
Command to start the home procedure, in which the motor will move in the specified direction until the limit switch for that direction is triggered, at which point a homing procedure is initiated, see section Limits.
Arguments
Direction velocity motion.
‘+’: |
Positive |
‘-’: |
Negative |
Remarks
Ensure the profile is set and the mode is Home mode.
Examples
Tx: RUNH,+<CR><LF> Rx: 0x0000,0x0000<CR><LF> Tx: RUNH,-<CR><LF> Rx: 0x0000,0x0000<CR><LF> |
// Start homing mode to the positive direction
// Start homing mode to the negative direction |
STOP – Stop motor
Command motor to stop moving according to the current profile.
Remarks
During the deceleration phase that stops the motor, any modifications to the acceleration or deceleration interrupt the stopping phase. Re-send the command to restart the motor stopping phase.
Examples
Tx: STOP<CR><LF> Rx: 0x0000,0x0000<CR><LF> |
// Stop the motor
|