11. USB command encoding

As described in Section 8, the Tic’s USB commands each use one of four formats: quick, 7-bit write, 32-bit write, and block read (except for the “set setting” command that uses its own unique format, also described below). This section explains how these four command formats are encoded as USB control transfer requests.

For a reference implementation of this protocol, see our Tic Stepper Motor Controller software source code.

All of the Tic’s USB commands are implemented as vendor-defined control transfers on endpoint 0. The tables below show what data is sent in the SETUP packet and the data phase of the control transfer.

Quick

bmRequestType bRequest wValue wIndex wLength Data
0x40 command 0 0 0 (none)

A quick command sends no data and is a request that simply contains the command byte in the bRequest field.

Example: Halt and hold

bmRequestType bRequest
command
wValue wIndex wLength Data
0x40 0x89 0 0 0 (none)

7-bit write

bmRequestType bRequest wValue wIndex wLength Data
0x40 command data 0 0 (none)

A 7-bit write command is a request that contains the command byte in bRequest and a 7-bit value in the wValue field (the upper byte of wValue and the the most-significant bit of the lower byte are always 0).

Example: Set step mode to 1/8 step

bmRequestType bRequest
command
wValue
data
wIndex wLength Data
0x40 0x94 0x0003 0 0 (none)

32-bit write

bmRequestType bRequest wValue wIndex wLength Data
0x40 command data[15:0] data[31:16] 0 (none)

A 32-bit write command is a request that contains the command byte in bRequest and a 32-bit value split between the wValue field (lower two bytes) and the wIndex field (upper two bytes).

Example: Set target position to 1,234,567,890

bmRequestType bRequest
command
wValue
data[15:0]
wIndex
data[31:16]
wLength Data
0x40 0xE0 0x02D2 0x4996 0 (none)

Write value: 1,234,567,890 = 0x4996 02D2

Block read

bmRequestType bRequest wValue wIndex wLength Data (in)
0xC0 command 0 offset length response data (length bytes)

A block read command reads a block of data from the Tic. The bRequest field holds the command byte, the offset in wIndex specifies the offset within the data that the response should start at, and wLength specifies how many bytes of data the response should include. The length must be between 1 and 128. Any multi-byte values contained in the response are in little-endian order (starting with the least-significant byte).

Example: Get variable “target position” (32 bits)

bmRequestType bRequest
command
wValue wIndex
offset
wLength
length
Data (in)
response data
0xC0 0xA1 0 0x000A 0x0004 0x4996 02D2

Read value: 0x4996 02D2 = 1,234,567,890

Set setting

bmRequestType bRequest wValue wIndex wLength Data
0x40 command data offset 0 (none)

The “set setting” command uses a unique format. This request contains the command byte in bRequest, an 8-bit value in wValue (the upper byte is always 0), and an offset in wIndex.

Example: Set setting “step mode” to 1/8 step

bmRequestType bRequest
command
wValue
data
wIndex
offset
wLength Data
0x40 0x13 0x0003 0x0041 0 (none)

Related Products

Tic T825 USB Multi-Interface Stepper Motor Controller (Connectors Soldered)
Tic T825 USB Multi-Interface Stepper Motor Controller
Tic T834 USB Multi-Interface Stepper Motor Controller (Connectors Soldered)
Tic T834 USB Multi-Interface Stepper Motor Controller
Tic T500 USB Multi-Interface Stepper Motor Controller (Connectors Soldered)
Tic T500 USB Multi-Interface Stepper Motor Controller
Tic T249 USB Multi-Interface Stepper Motor Controller (Connectors Soldered)
Tic T249 USB Multi-Interface Stepper Motor Controller
Tic 36v4 USB Multi-Interface High-Power Stepper Motor Controller (Connectors Soldered)
Tic 36v4 USB Multi-Interface High-Power Stepper Motor Controller

Related Categories

Tic Stepper Motor Controllers
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors