Communications protocol
A simple text-based protocol is used. Commands are sent to the SMD4, checked and executed, and a response returned. Data are buffered on receipt and commands are evaluated and executed on a first in first out basis. Although not a requirement, it is usually easiest to send a command and evaluate the response before sending the next command.
Commands are in the form (Note that angle brackets are shown for clarity only, they are not part of the protocol):
<address prefix><mnemonic>,<argument 1>,<argument 2>,<argument n>…<CR><LF>
And responses are in the form:
<address prefix>,<SFLAGS>,<EFLAGS>,<data 1>,<data 2>,<data n>…<CR><LF>
If the command executed successfully, or:
<address prefix>,<SFLAGS>,<EFLAGS>,<error code><CR><LF>
If the command failed to execute correctly.
Where:
Item |
Description |
<address prefix> |
Optional prefix included when multiple SMD4s exist on the same bus. If not using addressing can be omitted. |
<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 SMD4 via a terminal program. |
<SFLAGS> |
Set of flags representing the status of the SMD4, 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 SMD4, such as invalid mnemonic, or motor over-temperature fault. |
<CR><LF> |
Message terminator; carriage return followed by line-feed (0x0D,0x0A) |
Addressing
This section is only applicable where multiple SMD4s are connected together on the same bus, using the serial interface in either RS232 or RS485 mode. The addressing logic described in this section works for all interfaces, but is redundant for USB and the network interface since those inherently implement addressing.
When multiple SMD4s exist on the same bus, a mechanism is required to allow them to be addressed uniquely or as a group. Likewise, only one device must use the bus at a time otherwise bus contention results when more than one device tries to drive the bus at a time.
This is accomplished via the address prefix, which is the at '@' symbol followed by a numeric address:
- 0 = Broadcast address, all SMD4s execute the command, but no response is sent
- 1 to 247 = Valid secondary address range. The addressed SMD4 executes the command and returns a response
- Any address outside this range is invalid, and the packet is silently ignored
Upon receipt of the first complete packet with an address prefix, the SMD4 enters addressing mode, and behaviour then changes as follows, until restart.
- Malformed packets are silently ignored. This includes any packet that does not include the addressing prefix but that is otherwise valid.
- Broadcast packets are silently parsed and executed. A response is not sent, and as such it cannot be determined whether the command executed successfully without submitting a further query addressed directly to the target SMD4.
- Packets that are otherwise correctly formed but having a target address that does not match that of the SMD4 are silently ignored.
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 except where addressing criteria are not met. 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.
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.
Data types
The SMD4 uses the following data types. Arguments sent to and from the SMD4 will be one of these types. Bracketed values are notes or converted values and not part of the data sent to or from the SMD4. Same applies to quotes.
Type | SMD4 accepts | SMD4 responds |
INT |
Integer value, with or without sign:
100, -3, +7 |
Sign only included for negative numbers:
200, -3, 7 |
UINT |
Unsigned integer value, no sign: 0, 7, 1000
Hexadecimal format is also accepted:
0x38e3 (14,563) 0x005F (95) |
Unsigned integer value, no sign:
100, 200
Status and error flags are returned in upper case 2-byte hexadecimal format, E.g. 0x1234, 0xA4DE |
FLOAT |
Real number, with or without sign:
100, 34.5, 89.234234
Scientific format may also be used:
100e-3, 2.454E+1, 2e+3 |
Scientific format, with variable places after the decimal point and a 2-digit exponent:
1.23000E+04, 5.761592342E-06 |
STRING |
ASCII string, consisting of characters 0x20 to 0x7E inclusive:
"hello", "1234 abc" |
|
BOOL |
Binary, true/false value:
0, 1 |
|
DOTTED DECIMAL |
IPV4 address or mask, four numbers separated by dots:
"192.168.0.1", "255.255.255.255" |
|
MAC |
12 hexadecimal characters grouped into pairs separated by a colon:
"44:b7:d0:c7:16:75" |
|
OTHER |
The data type is described in the command reference section |
Flags
Flags are reported by the device in hexadecimal format as explained above. E.g. a value of 0x0002 means bit 1 is set. The value of reserved flags is undefined and no particular value should be assumed.
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). Reset the fault using the clear command, or the reset fault input. The motor is disabled if one or more error flags are set.
Bit |
Name |
Description |
0 | Temperature sensor short | Selected temperature sensor is short-circuited (Not applicable to Thermocouple) |
1 | Temperature sensor open | Selected temperature sensor is open circuit |
2 | Motor over temperature | 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 | Reserved 7 | |
8 | Reserved 8 | |
9 | SDRAM | Memory self-test failed |
10 | Reserved 10 | |
11 | Reserved 11 | |
12 | Reserved 12 | |
13 | Reserved 13 | |
14 | Reserved 14 | |
15 | Motion control fault | One or more motion control features (EPC, ROML etc.) are in a fault state |
Status flags (SFLAGS)
Bit |
Name |
Description |
0 |
Joystick connected | Joystick is connected (determined via state of the |
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 | Limit input is active (Note that the polarity is configurable, so active can mean high or low signal level) |
3 |
External enable | External enable input state |
4 |
Ident | Ident mode is active, green status indicator is flashing to aid in identifying device |
5 |
EPC activity | Endpoint correction activity indicator; on when this feature is busy |
6 | ROML activity | Range of motion limiter activity indicator; true when this feature is busy |
7 |
Standby | Motor stationary. Check this bit before performing a function that requires the motor to be stopped first, such as changing mode |
8 |
Baking | Bake mode running |
9 |
Target Velocity Reached | Set when the motor is at target velocity |
10 |
GUARD activity | Guard activity indicator; true when this feature is busy |
11 |
Boost Operational | Internal 48 V to 67 V boost supply is operational |
12 |
Boost disable jumper | Boost supply disable jumper is fitted |
13 |
Boost UVLO | Boost supply is disabled because input voltage is too low (< 48 V approx.) |
14 |
Reserved 14 | |
15 |
Motion control warning | One or more motion control features (EPC, ROML etc.) are in a warning state |
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 stop, where 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 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. |
-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. |
-103 (Invalid Mnemonic) |
Command mnemonic is not valid |
-104 (Packet error) |
Packet is malformed |
Quick reference
Bake
Mnemonic |
Description |
R |
W |
Type |
Elapsed bake time in format h:mm:ss |
● |
|
STRING |
|
Start bake |
|
● |
|
|
Bake temperature setpoint |
● |
● |
UINT |
Boost
Mnemonic |
Description |
R |
W |
Type |
Boost enable | ● | ● | BOOL | |
Check if boost disable PCB jumper is fitted | ● | BOOL |
Coms
Mnemonic |
Description |
R |
W |
Type |
DHCP enable | ● | ● | BOOL | |
Gateway address | ● | ● | DOTTED DECIMAL | |
IP address | ● | ● | DOTTED DECIMAL | |
Summary of network configuration in human readable form | ● | STRING | ||
Ethernet interface link is up | ● | BOOL | ||
Ethernet interface MAC address | ● | MAC | ||
Ethernet subnet mask | ● | ● | DOTTED DECIMAL | |
Serial baud rate | ● | ● | UINT | |
Serial coms mode, RS232 or 485 | ● | ● | UINT | |
RS485 turnaround delay | ● | ● | UINT | |
Slave address | ● | ● | UINT | |
Enable RS485 line termination | ● | ● | BOOL |
Encoder
Mnemonic |
Description |
R |
W |
Arguments |
ENC:BSN | Encoder board serial number | ● | STRING | |
ENC:DAT | Encoder readout data | ● | OTHER | |
ENC:DPC | Encoder displacement per count | ● | ● | FLOAT |
ENC:FLIP | Reverse encoder direction | ● | ● | BOOL |
ENC:FLIP:AUTOSET | Auto configure flip | ● | ||
ENC:FW | Encoder firmware version | ● | STRING | |
ENC:INC:LIMITS:EN | Enable incremental PQ limits | ● | ● | BOOL |
ENC:INC:LIMITS:P:EN | Enable incremental P limit | ● | ● | BOOL |
ENC:INC:LIMITS:Q:EN | Enable incremental Q limit | ● | ● | BOOL |
ENC:INC:LIMITS:STOPMODE | Incremental PQ limits stop mode | ● | ● | UINT |
ENC:INC:LIMITS:SWAP | Incremental swap P and Q | ● | ● | BOOL |
ENC:INC:RSTZ | Incremental reset the Z counter | ● | ||
ENC:OFS | Encoder readout offset | ● | ● | FLOAT |
ENC:SEL | Select absolute or incremental encoder | ● | ● | |
ENC:USEINCE | Incremental use the E (error) signal | ● | ● |
Limit inputs
Mnemonic |
Description |
R |
W |
Arguments |
Global enable |
● |
● |
BOOL |
|
Limit positive (Limit 1) enable |
● |
● |
BOOL |
|
Limit negative (Limit 2) enable |
● |
● |
BOOL |
|
Limit polarity for both Limit positive (Limit 1) and negative (Limit 2), (0 for active high, 1 for active low) |
|
● |
BOOL |
|
Limit n polarity (0 for active high, 1 for active low) |
● |
● |
BOOL |
|
Limit n polarity (0 for active high, 1 for active low) |
● |
● |
BOOL |
|
How to stop on limit being triggered |
● |
● |
BOOL |
Motion control
Mnemonic |
Description |
R |
W |
Arguments |
Emergency stop. Stops the motor immediately |
|
● |
|
|
Mechanism presets |
● |
● |
UINT |
|
Execute negative nudge |
● |
● |
|
|
Execute positive nudge |
● |
● |
|
|
Nudge distance |
● |
● |
FLOAT |
|
Move motor absolute positioning mode |
|
● |
INT |
|
Start home mode procedure |
|
● |
STRING |
|
Move motor relative positioning mode |
|
● |
INT |
|
Move motor velocity mode |
|
● |
STRING |
|
MCON:SF:EPC |
Closed loop (Endpoint Correction, EPC) behaviour | ● | ● | UINT |
MCON:SF:EPC:N | Closed loop (Endpoint Correction, EPC) maximum iterations | ● | ● | UINT |
MCON:SF:EPC:T |
Closed loop (Endpoint Correction, EPC) tolerance | ● | ● | FLOAT |
MCON:SF:GUARD |
Guard behaviour | ● | ● | UINT |
MCON:SF:GUARD:1 |
Guard value one | ● | ● | FLOAT |
MCON:SF:GUARD:2 |
Guard value two | ● | ● | FLOAT |
MCON:SF:ROML |
Range of motion limiter behaviour | ● | ● | UINT |
MCON:SF:ROML:1 |
Range of motion limiter value one | ● | ● | FLOAT |
MCON:SF:ROML:2 |
Range of motion limiter value two | ● | ● | FLOAT |
MCON:SF:ROML:J |
Range of motion limiter, enable for step direction mode | ● | ● | BOOL |
Stop motor in 1 second on full step position independently of the current motion profile |
|
● |
|
|
Bring motor to a stop according to the current profile |
|
● |
|
|
MCON:U |
Mechanism displacement per step | ● | ● | FLOAT |
MCON:ZEROA |
Zero the absolute counter | ● | ||
MCON:ZEROAR |
Zero absolute and relative counters | ● | ||
MCON:ZEROR | Zero relative counter | ● |
Motor
Mnemonic |
Description |
R |
W |
Arguments |
Acceleration in Hz/s |
● |
● |
FLOAT |
|
Deceleration in Hz/s |
● |
● |
FLOAT |
|
Which edges of step input to generate a step on |
● |
● |
UINT |
|
Freewheel mode |
● |
● |
UINT |
|
Acceleration current in amps |
● |
● |
FLOAT |
|
Hold current in amps |
● |
● |
FLOAT |
|
Delay per current reduction step |
● |
● |
FLOAT |
|
Interpolate step input to 256 micro steps |
● |
● |
BOOL |
|
Run current in amps |
● |
● |
FLOAT |
|
Actual position |
● |
● |
FLOAT |
|
Power down delay in milliseconds |
● |
● |
FLOAT |
|
Relative position |
● |
● |
FLOAT |
|
Resolution |
● |
● |
UINT |
|
Step/direction mode |
● |
● |
UINT |
|
Temperature in °C |
● |
|
UINT |
|
Full step – micro stepping transition |
● |
● |
FLOAT |
|
Temperature sensor selection, T/C or RTD |
● |
● |
UINT |
|
Time to stop before moving again in seconds |
● |
● |
FLOAT |
|
Actual motor velocity |
● |
|
FLOAT |
|
Target motor velocity |
● |
● |
FLOAT |
|
Start velocity |
● |
● |
FLOAT |
|
Stop velocity |
● |
● |
FLOAT |
General
Mnemonic |
Description |
R |
W |
Arguments |
Get main board serial number |
● |
|
STRING |
|
Clear error flags |
|
● |
|
|
External enable used |
● |
● |
BOOL |
|
Get status and error flags |
● |
|
|
|
Get human readable summary of status and error flags |
● |
|
STRING |
|
Read main board firmware version number |
● |
|
STRING |
|
Set the status indicator flashing to help identify the device |
● |
● |
BOOL |
|
Enable or disable the joystick input |
● |
● |
BOOL |
|
Joystick mode |
● |
● |
UINT |
|
Load saved configuration |
|
● |
|
|
Load factory default settings |
|
● |
|
|
Mode of operation |
● |
● |
UINT |
|
Device name tag |
● |
● |
STRING |
|
Enter programming mode |
|
● |
|
|
Restart the SMD4 |
|
● |
|
|
SYS:SER | Product serial number | ● | STRING | |
SYS:STORE | Store settings | ● | ||
SYS:UNITS | Get or set the measurement unit | ● | ● | UINT |
SYS:UPTIME | Get the uptime in milliseconds | ● | UINT | |
SYS:UUID | Get a the products UUID (Universally Unique ID) | ● | STRING |
Command reference
In the examples red text is data transmitted to the SMD4, and blue text is data received from the SMD4. // Green text preceded by a double forward slash is a comment relating to that data. Arguments where present are given as an argument name in angle brackets.
Bake
BAKE:RUN – Start bake
Start bake. Configure the bake temperature setpoint using BakeTemperature.
BAKE:RUN<CR><LF>
Command: | BAKE:RUN<CR><LF> |
Examples
BAKE:RUN<CR><LF> 0x0000,0x0000<CR><LF> |
// Run bake
|
BAKE:ELAPSED – Elapsed bake time
Gets the elapsed bake time.
Query: |
BAKE:ELAPSED<CR><LF> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Response: | <duration> |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Data | Type | Description |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
duration | STRING |
Elapsed time in format h:mm:ss, where h is hours, m minutes and s seconds.
BAKE:T – Bake temperature setpointGets or sets the bake temperature setpoint. To run bake, select bake mode using the MODE, then start bake using the run bake command. Use stop command to end bake.
|