Skip to main content

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

BAKE:ELAPSED

Elapsed bake time in format h:mm:ss


STRING

BAKE:RUN

Start bake



BAKE:T

Bake temperature setpoint

UINT

Boost

Mnemonic

Description

R

W

Type

BOOST:EN

Boost enable BOOL

BOOST:JUMPER

Check if boost disable PCB jumper is fitted
BOOL

Coms

Mnemonic

Description

R

W

Type

COMS:NET:DHCP

DHCP enable BOOL

COMS:NET:GATEWAY

Gateway address DOTTED DECIMAL

COMS:NET:IP

IP address DOTTED DECIMAL

COMS:NET:IPCONF

Summary of network configuration in human readable form
STRING

COMS:NET:LINK

Ethernet interface link is up
BOOL

COMS:NET:MAC

Ethernet interface MAC address
MAC

COMS:NET:NETMASK

Ethernet subnet mask DOTTED DECIMAL

COMS:SERIAL:BAUD

Serial baud rate UINT

COMS:SERIAL:MODE

Serial coms mode, RS232 or 485 UINT

COMS:SERIAL:RS485DEL

RS485 turnaround delay UINT

COMS:SERIAL:SLAVEADDR

Slave address UINT

COMS:SERIAL:TERM

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

LIMIT:EN

Global enable

BOOL

LIMIT:EN+

Limit positive (Limit 1) enable

BOOL

LIMIT:EN-

Limit negative (Limit 2) enable

BOOL

LIMIT:POL

Limit polarity for both Limit positive (Limit 1) and negative (Limit 2), (0 for active high, 1 for active low)

 

BOOL

LIMIT:POL+

Limit n polarity (0 for active high, 1 for active low)

BOOL

LIMIT:POL-

Limit n polarity (0 for active high, 1 for active low)

BOOL

LIMIT:STOPMODE

How to stop on limit being triggered

BOOL

Motion control

Mnemonic

Description

R

W

Arguments

MCON:ESTOP

Emergency stop. Stops the motor immediately

 

 

MCON:MPRESET

Mechanism presets

UINT

MCON:NUDGE:RUN:NEG

Execute negative nudge


MCON:NUDGE:RUN:POS

Execute positive nudge


MCON:NUDGE:VALUE

Nudge distance

FLOAT

MCON:RUNA

Move motor absolute positioning mode

 

INT

MCON:RUNH

Start home mode procedure

 

STRING

MCON:RUNR

Move motor relative positioning mode

 

INT

MCON:RUNV

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

MCON:SSTOP

Stop motor in 1 second on full step position independently of the current motion profile

 

 

MCON:STOP

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

MOTOR:AMAX

Acceleration in Hz/s

FLOAT

MOTOR:DMAX

Deceleration in Hz/s

FLOAT

MOTOR:EDGE

Which edges of step input to generate a step on

UINT

MOTOR:F

Freewheel mode

UINT

MOTOR:IA

Acceleration current in amps

FLOAT

MOTOR:IH

Hold current in amps

FLOAT

MOTOR:IHD

Delay per current reduction step

FLOAT

MOTOR:INTERP

Interpolate step input to 256 micro steps

BOOL

MOTOR:IR

Run current in amps

FLOAT

MOTOR:PACT

Actual position

FLOAT

MOTOR:PDDEL

Power down delay in milliseconds

FLOAT

MOTOR:PREL

Relative position

FLOAT

MOTOR:RES

Resolution

UINT

MOTOR:SDMODE

Step/direction mode

UINT

MOTOR:T

Temperature in °C

 

UINT

MOTOR:THIGH

Full step – micro stepping transition

FLOAT

MOTOR:TSEL

Temperature sensor selection, T/C or RTD

UINT

MOTOR:TZW

Time to stop before moving again in seconds

FLOAT

MOTOR:VACT

Actual motor velocity

 

FLOAT

MOTOR:VMAX

Target motor velocity

FLOAT

MOTOR:VSTART

Start velocity

FLOAT

MOTOR:VSTOP

Stop velocity

FLOAT

General

Mnemonic

Description

R

W

Arguments

SYS:BSN

Get main board serial number


STRING

SYS:CLR

Clear error flags

 


SYS:EXTEN

External enable used

BOOL

SYS:FLAGS

Get status and error flags



SYS:FLAGSV

Get human readable summary of status and error flags


STRING

SYS:FW

Read main board firmware version number


STRING

SYS:IDENT

Set the status indicator flashing to help identify the device

BOOL

SYS:JS:EN

Enable or disable the joystick input

BOOL

SYS:JS:MODE

Joystick mode

UINT

SYS:LOAD

Load saved configuration

 


SYS:LOADFD

Load factory default settings

 

 

SYS:MODE

Mode of operation

UINT

SYS:NAME

Device name tag

STRING

SYS:PROG

Enter programming mode



SYS:RESET

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>

DataTypeDescription
duration STRING

Elapsed time in format h:mm:ss, where h is hours, m minutes and s seconds.

Query:
Response:
DataTypeDescription

Tx: BAKE:ELAPSED<CR><LF>

Rx: 0x0000,0x0000,2:34:12<CR><LF>

 

// Bake has run for 2 hours 34 minutes and 12 seconds

BAKE:T – Bake temperature setpoint

Gets 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.

Command:BAKE:T,<setpoint><CR><LF>

Query:

BAKE:T <CR><LF>

Response:<setpoint>

DataTypeDescription
setpoint UINT

[Default:   150 °C]

Min.          0 °C

Max.         200 °C

Command:
Query:
Response:
DataTypeDescription

Examples

BAKE:T,100<CR><LF>

0x0000,0x0000,100<CR><LF>

BAKE:T<CR><LF>

0x0000,0x0000,100<CR><LF>

// Set bake setpoint to 100 °C

 

// Query

Boost

BOOST:EN – Boost enable

Gets or sets a value indicating whether the boost supply should be enabled. The boost supply steps up the input voltage from 48 V to 67 V to maximise motor dynamic performance. Enable for best performance. Regardless of this setting, the boost supply is disabled when input voltage falls below 48 V, and or the boost disable jumper is fitted.  

Command:BOOST:EN,<state><CR><LF>

Query:

BOOST:EN <CR><LF>

Response:<state>

Data Type Description
state BOOL

0:     Disable

[1:    Enable]

Command:
Query:
Response:

Examples

BOOST:EN,1<CR><LF>

0x0000,0x0000,1<CR><LF>

BOOST:EN<CR><LF>

0x0000,0x0000,1<CR><LF>

// Enable boost

 

// Query

 

BOOST:JUMPER – Boost disable PCB jumper

Gets a value indicating whether the boost supply disable jumper is fitted. If the jumper is fitted, the boost supply is disabled and the maximum voltage supplied to the motor will equal the input voltage to the SMD4. This will compromise motor dynamic performance.

Query:

BOOST:JUMPER <CR><LF>

Response:<state>

Data Type Description
state BOOL

0:    Jumper is not fitted, boost supply is enabled provided input voltage criteria met

1:    Jumper is fitted, boost supply is disabled

Query:
Response:

Coms: Network

COMS:NET:DHCP – DHCP

Gets or sets a value indicating whether DHCP is enabled. If enabled, DHCP (Dynamic Host Configuration Protocol) will be used to automatically assign network configuration, such as IP address and gateway, to the device.

Command:COMS:NET:DHCP,<state><CR><LF>

Query:

 COMS:NET:DHCP<CR><LF>

<state> 
Data Type Description

Command:
Query:
Response:<state>

DataTypeDescription
state BOOL

0: Disable

[1: Enable]

Examples

COMS:NET:DHCP,1<CR><LF>

0x0000,0x0000,1<CR><LF>

COMS:NET:DHCP<CR><LF>

0x0000,0x0000,1<CR><LF>

// Enable DHCP

 

// Query

COMS:NET:GATEWAY – Gateway

Gets or sets the gateway address. When DHCP is enabled, the value read back will be the value assigned by DHCP rather than any value you might have set. Any value set however is retained, and will apply if DHCP is disabled at a later time.

Command:COMS:NET:GATEWAY,<address><CR><LF>
Query:COMS:NET:GATEWAY<CR><LF>
<address> Data Type Description address DOTTED DECIMAL Gateway address

Command:
Query:
Response: <address>

DataTypeDescription
addressDOTTED DECIMALGateway address

Examples

COMS:NET:DHCP<CR><LF>

0x0000,0x0000,1<CR><LF>

COMS:NET:GATEWAY,192.168.1.1<CR><LF>

0x0000,0x0000,10.0.96.1<CR><LF>

 

COMS:NET:DHCP,0<CR><LF>  

0x0000,0x0000,0<CR><LF>

COMS:NET:GATEWAY<CR><LF>

0x0000,0x0000,192.168.1.1<CR><LF>

// Query DHCP state and find that it's enabled

 

// Set the gateway; the returned value is that assigned by DHCP // not the value we just set

 

// Turn DHCP off

 

// Query gateway again

// Now DHCP is off, our assigned gateway value is used

COMS:NET:IP – IP Address

Gets or sets the IP address. When DHCP is enabled, the value read back will be the value assigned by DHCP rather than any value you might have set. Any value set however is retained, and will apply if DHCP is disabled at a later time.

Command:COMS:NET:IP,<address><CR><LF>
Query:COMS:NET:IP<CR><LF>
<address> Data Type Description address DOTTED DECIMAL IP address

Command:
Query:
Response: <address>

DataTypeDescription
addressDOTTED DECIMALIP address

Examples

Tx: COMS:NET:IP<CR><LF>

Rx: 0x0000,0x0000,10.0.97.70<CR><LF>

// Query the IP address

 

COMS:NET:IPCONF – Get network config summary

Outputs a summary of network configuration in human readable form.

Query:COMS:NET:IPCONF<CR><LF>
Response:<summary>

Data Type Description
summary STRING ASCII table summarizing the network configuration, see example.

Query:
Response:

Examples

Tx: COMS:NET:IPCONF<CR><LF>

Rx: 0x0000,0x0000,<CR><LF>

Ethernet interface:<CR><LF>

    IPv4 Address. . . . . . . . . . . :10.0.97.70<CR><LF>

    Subnet Mask . . . . . . . . . . .:255.255.248.0<CR><LF>

    Default Gateway . . . . . . . :10.0.96.1<CR><LF>

    DHCP State. . . . . . . . . . . . :Enabled<CR><LF>

 

 

Gets a value indicating whether the ethernet interface link is up. This will read back as false when the LAN connector is unplugged for example.