MODULE FOR STEPPER MOTORS
MODULE
Firmware Version V1.11
TMCL™ FIRMWARE MANUAL
+
+
TMCM-1310
1-Axis Stepper
Closed Loop Controller / Driver
3 A RMS / 48 V
ABN and SSI Encoder Input
18 GPIOs
USB, EtherCAT®
+
TRINAMIC Motion Control GmbH & Co. KG
Hamburg, Germany
www.trinamic.com
+
TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
Table of Contents
1
2
3
Features........................................................................................................................................................................... 4
Overview ......................................................................................................................................................................... 6
Communication via EtherCAT ................................................................................................................................... 7
3.1
SyncManager ......................................................................................................................................................... 7
3.1.1 Buffered Mode ................................................................................................................................................ 7
3.1.2 Mailbox Mode, used for TMCL-Applications ........................................................................................... 8
3.2
EtherCAT Slave State Machine ......................................................................................................................... 9
3.3
EtherCAT Firmware Update ............................................................................................................................. 11
3.4
Process Data ....................................................................................................................................................... 11
3.5
TMCL Mailbox ...................................................................................................................................................... 13
3.6
Binary Command Format ................................................................................................................................ 13
3.7
Status Codes ....................................................................................................................................................... 13
4
Operation with USB Interface ................................................................................................................................ 14
4.1
Binary Command Format for USB Interface .............................................................................................. 14
4.2
Reply Format ....................................................................................................................................................... 15
4.2.1 Status Codes ................................................................................................................................................. 15
4.3
Standalone Applications .................................................................................................................................. 15
5
The ASCII Interface ................................................................................................................................................... 16
5.1
Format of the Command Line ....................................................................................................................... 16
5.2
Format of a Reply.............................................................................................................................................. 16
5.3
Commands Used in ASCII Mode ................................................................................................................... 16
5.4
Configuring the ASCII Interface .................................................................................................................... 17
6
TMCL Commands ........................................................................................................................................................ 18
6.1
Motion Commands ............................................................................................................................................ 18
6.2
Parameter Commands ...................................................................................................................................... 18
6.3
Control Commands ........................................................................................................................................... 18
6.4
I/O Port Commands .......................................................................................................................................... 18
6.5
Calculation Commands .................................................................................................................................... 19
6.6
Interrupt Commands ........................................................................................................................................ 19
6.6.1 Interrupt Types ............................................................................................................................................ 19
6.6.2 Interrupt Processing ................................................................................................................................... 19
6.6.3 Interrupt Vectors ......................................................................................................................................... 20
6.6.4 Further Configuration of Interrupts ....................................................................................................... 20
6.6.5 Using Interrupts in TMCL .......................................................................................................................... 20
6.7
ASCII Commands ............................................................................................................................................... 21
6.8
Commands ........................................................................................................................................................... 22
6.8.1 ROR (rotate right) ........................................................................................................................................ 22
6.8.2 ROL (rotate left) ........................................................................................................................................... 23
6.8.3 MST (motor stop)......................................................................................................................................... 24
6.8.4 MVP (move to position) ............................................................................................................................ 25
6.8.5 SAP (set axis parameter) ........................................................................................................................... 27
6.8.6 GAP (get axis parameter) .......................................................................................................................... 28
6.8.7 STAP (store axis parameter) ..................................................................................................................... 29
6.8.8 RSAP (restore axis parameter) ................................................................................................................. 30
6.8.9 SGP (set global parameter) ...................................................................................................................... 31
6.8.10 GGP (get global parameter)...................................................................................................................... 32
6.8.11 STGP (store global parameter) ................................................................................................................ 33
6.8.12 RSGP (restore global parameter) ............................................................................................................ 34
6.8.13 RFS (reference search) ................................................................................................................................ 35
6.8.14 SIO (set input / output) ............................................................................................................................. 36
6.8.15 GIO (get input /output) ............................................................................................................................. 38
6.8.16 CALC (calculate) ............................................................................................................................................ 41
6.8.17 COMP (compare)........................................................................................................................................... 42
6.8.18 JC (jump conditional) ................................................................................................................................. 43
6.8.19 JA (jump always) ......................................................................................................................................... 44
6.8.20 CSUB (call subroutine) ............................................................................................................................... 45
www.trinamic.com
2
TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
6.8.21 RSUB (return from subroutine) ................................................................................................................ 46
6.8.22 WAIT (wait for an event to occur) ......................................................................................................... 47
6.8.23 STOP (stop TMCL program execution) ................................................................................................... 48
6.8.24 SCO (set coordinate) ................................................................................................................................... 49
6.8.25 GCO (get coordinate) .................................................................................................................................. 50
6.8.26 CCO (capture coordinate) .......................................................................................................................... 51
6.8.27 ACO (accu to coordinate) .......................................................................................................................... 52
6.8.28 CALCX (calculate using the X register) .................................................................................................. 53
6.8.29 AAP (accumulator to axis parameter) .................................................................................................... 54
6.8.30 AGP (accumulator to global parameter) ............................................................................................... 55
6.8.31 CLE (clear error flags) ................................................................................................................................. 56
6.8.32 VECT (set interrupt vector) ........................................................................................................................ 57
6.8.33 EI (enable interrupt) ................................................................................................................................... 58
6.8.34 DI (disable interrupt) .................................................................................................................................. 59
6.8.35 RETI (return from interrupt) ..................................................................................................................... 60
6.8.36 Customer Specific TMCL Command Extension (user function) ....................................................... 61
6.8.37 Request Target Position Reached Event ............................................................................................... 62
6.8.38 BIN (return to binary mode) .................................................................................................................... 62
6.8.39 TMCL Control Functions ............................................................................................................................. 63
7
Axis Parameters .......................................................................................................................................................... 64
7.1
Velocity Calculation ........................................................................................................................................... 76
8
stallGuard2 Related Parameters ............................................................................................................................. 77
9
Closed-Loop Operation Related Axis Parameter ................................................................................................ 78
9.1
General Closed Loop Axis Parameters ........................................................................................................ 78
9.2
General Structure of the Closed Loop System ......................................................................................... 79
9.3
Setting Encoder Resolution and Motor Resolution ................................................................................. 80
9.4
Positioning Mode .............................................................................................................................................. 81
9.5
Position Maintenance and Standstill Mode ............................................................................................... 84
9.6
Velocity Mode ..................................................................................................................................................... 86
9.7
Torque Mode ....................................................................................................................................................... 87
9.8
Current Regulation ............................................................................................................................................ 88
9.9
Field Weakening ................................................................................................................................................ 92
9.10 Status and Feedback Information ................................................................................................................ 93
9.11 Example Programs: Closed Loop Operation .............................................................................................. 94
9.11.1 Example Program 1 ..................................................................................................................................... 94
9.11.2 Example Program 2 ..................................................................................................................................... 95
10 Reference Search ........................................................................................................................................................ 96
10.1.1 Reference Search Modes (Axis Parameter 193) ................................................................................... 97
11 Global Parameters ...................................................................................................................................................... 99
11.1 Bank 0 ................................................................................................................................................................... 99
11.2 Bank 1 ................................................................................................................................................................. 100
11.3 Bank 2 ................................................................................................................................................................. 101
11.4 Bank 3 ................................................................................................................................................................. 101
12 TMCL Programming Techniques and Structure ............................................................................................... 102
12.1 Initialization ...................................................................................................................................................... 102
12.2 Main Loop .......................................................................................................................................................... 102
12.3 Using Symbolic Constants ............................................................................................................................ 102
12.4 Using Variables ................................................................................................................................................ 103
12.5 Using Subroutines ........................................................................................................................................... 103
12.6 Mixing Direct Mode and Standalone Mode .............................................................................................. 104
13 Life Support Policy ................................................................................................................................................... 105
14 Revision History ........................................................................................................................................................ 106
14.1 Firmware Revision .......................................................................................................................................... 106
14.2 Document Revision ......................................................................................................................................... 106
15 References .................................................................................................................................................................. 107
www.trinamic.com
3
TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
1
4
Features
The TMCM-1310 is a single axis stepper motor controller/driver standalone board with closed loop support.
For communication an USB interface and EtherCAT®* are provided. The module supports motor currents up
to 3A RMS and supply voltages up to 48V nominal. The module offers inputs for one incremental a/b/n
(TTL, open-collector and differential inputs) or absolute SSI encoders (selectable in software). There are
dedicated stop switch inputs, 8 general purpose inputs, and 8 general purpose outputs.
MAIN CHARACTERISTICS
Bipolar stepper motor driver
Up to 256 microsteps per full step
High-efficient operation, low power dissipation
Dynamic current control
Integrated protection: overtemperature and undervoltage
stallGuard2™ feature for stall detection (for open loop operation)
Encoder
Encoder input for incremental a/b/n (TTL, open-collector and differential inputs) and absolute SSI
encoders (selectable in software)
Interfaces
USB 2.0 full-speed (12Mbit/s) communication interface (mini-USB connector)
EtherCAT LINK IN and LINK OUT (RJ45)
Dedicated STOP_L / STOP_R inputs
Up to 8 multi-purpose inputs (+24V compatible, incl. 2 dedicated analog inputs)
Up to 8 multi-purpose outputs (open-drain, incl. 2 outputs for currents up to 1A)
Software
TMCL™ remote (direct mode) and standalone operation with memory for up to 1024 TMCL commands
Closed-loop support
Fully supported by TMCL-IDE (PC based integrated development environment)
Electrical data
Supply voltage: +12V… +48V DC
Motor current: up to 3A RMS (programmable)
Mechanical data
Board size: 110mm x 110mm, height 26.3mm
Please refer to separate TMCM-1310 Hardware Manual for additional information.
* EtherCAT® is registered trademark and patented technology, licensed by Beckhoff Automation GmbH,
Germany.
www.trinamic.com
TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
5
TRINAMIC FEATURES – CLOSED LOOP MODE
The TMCM-1310 is mainly designed to run 2-phase stepper motors in closed loop mode. It offers an
automatic motor load adaption in positioning mode, velocity mode, and torque mode, which is based on
encoder feedback and closed loop control software for analysis, error detection and error correction.
The closed loop mode operation combines the advantages of a stepper driver system with the benefits of
a servo drive. Thus, the TMCM-1310 is able to satisfy ambitious requirements in reliability and precision
and can be used in several industrial demanding applications.
TMCM-1310
Benefits of Stepper Drive
Benefits of Servo Drive
High torque without gearing
No feedback loop oscillations
High precision
Precise velocity control
Reaction to any impact
No position loss
Torque control
Figure 1.1 TMCM-1310 characteristics in closed loop mode
THE TRINAMIC CLOSED LOOP MODE OPERATION
-
prevents the motor from stall and step loss caused by too high load or high velocity.
adapts the current amplitude to each motor load which is within the ranges predetermined by motor
and controller/driver board characteristics.
achieves a higher torque output than in open loop mode.
guarantees a precise and fast positioning.
enables velocity and positioning error compensation.
Using the TMCM-1310, energy will be saved and the motor will be kept cool.
www.trinamic.com
TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
2
6
Overview
The software running on the microprocessor of the TMCM-1310 consists of two parts, a boot loader and
the firmware itself. Whereas the boot loader is installed during production and testing at TRINAMIC and
remains untouched throughout the whole lifetime, the firmware can be updated by the user. New versions
can be downloaded free of charge from the TRINAMIC website (http://www.trinamic.com).
The TMCM-1310 can be used as an EtherCAT slave device. The whole communication with the EtherCAT
master follows a strict master-slave-relationship. Via the TMCL mailbox motor parameters are written
and/or read using TRINAMICs TMCL protocol.
The firmware of this module is related to the standard TMCL firmware with a special range of values. The
TRINAMIC Motion Control Language [TMCL] provides a set of structured motion control commands. Every
motion control command can be given by a host computer or can be stored in an EEPROM on the module
to form programs that run standalone. For this purpose there are not only motion control commands but
also commands to control the program structure (like conditional jumps, compare and calculating).
Every command has a binary representation and a mnemonic. The binary format is used to send
commands from the host to a module in direct mode, whereas the mnemonic format is used for easy
usage of the commands when developing standalone TMCL applications using the TMCL-IDE (IDE means
Integrated Development Environment).
There is also a set of configuration variables for the axis and for global parameters which allow individual
configuration of nearly every function of the module. This manual gives a detailed description of all TMCL
commands and their usage.
www.trinamic.com
TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
3
7
Communication via EtherCAT
3.1
SyncManager
The SyncManager enables consistent and secure data exchange between the EtherCAT master and the local
application, and it generates interrupts to inform both sides of changes. The SyncManager is configured by
the EtherCAT master. The communication direction is configurable, as well as the communication mode
(buffered mode and mailbox mode). The SyncManager uses a buffer located in the memory area for
exchanging data. Access to this buffer is controlled by the hardware of the SyncManager.
A buffer has to be accessed beginning with the start address, otherwise the access is denied. After
accessing the start address, the whole buffer can be accessed, even the start address again, either as a
whole or in several strokes. A buffer access finishes by accessing the end address, the buffer state changes
afterwards. The end address cannot be accessed twice inside a frame. Two communication modes are
supported by SyncManagers, the buffered mode and the mailbox mode.
3.1.1
Buffered Mode
The buffered mode allows both sides, EtherCAT master and local application, to access the communication
buffer at any time. The consumer gets always the latest consistent buffer which was written by the
producer, and the producer can always update the content of the buffer. The buffered mode is used for
cyclic process data.
Data transfer between EtherCAT master (PC etc.) und slave (TMCM-1310) is done using the dual port
memory of the ET1100 EtherCAT-IC on the slave. The buffered mode allows writing and reading data
simultaneously without interference. If the buffer is written faster than it is read out, old data will be
dropped. The buffered mode is also known as 3-buffermode. One buffer of the three buffers is allocated to
the producer (for writing), one buffer to the consumer (for reading), and the third buffer keeps the last
consistently written data of the producer.
0x1000
0x10FF
Buffer 0
(visible)
0x1100
0x11FF
Buffer 1
(invisible, shall not be used)
0x1200
0x12FF
Buffer 2
(invisible, shall not be used)
0x1300
Next usable RAM space
All buffers are
controlled by the
SyncManager. Only
buffer 0 is configured
by the SyncManager
and addressed by
ECAT and μController.
Figure 3.1 SyncManager buffer allocation
As an example, Figure 3.1 demonstrates a configuration with start address 0x1000 and length 0x100. The
other buffers shall not be read or written. Access to the buffer is always directed to addresses in the range
of buffer 0.
www.trinamic.com
TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
ECAT
Master
NEXT
Write begin
8
PDI
µController
Load next buffer
if new data are
available
Read end
Exchange buffer
(if frame is o.k.)
Write end
Read begin
Write begin
Exchange buffer
Write end
Load next buffer
if new data are
available
Read begin
Read end
Figure 3.2 SyncManager buffered mode interaction
3.1.2
Mailbox Mode, used for TMCL-Applications
The mailbox mode implements a handshake mechanism for data exchange, so that no data will be lost.
Each side, EtherCAT master or local application will get access to the buffer only after the other side has
finished its access. The mailbox mode only allows alternating reading and writing. This assures that all
data from the producer will reach the consumer. The mailbox mode uses just one buffer of the configured
size. At first, after initialization/activation, the buffer (mailbox, MBX) is writeable. Once it is written
completely, write access is blocked, and the buffer can be read out by the other side. After it was
completely read out, it can be written again. The time it takes to read or write the mailbox does not
matter. The mailbox mode is used for the application layer protocol.
Via the mailbox motor-parameters of the TMCM-1310 can be written/read using the TMCL protocol.
Master
Write mailbox
Write
Write w. failure
(mailbox full)
µController
mailbox full
mailbox empty
Read mailbox
mailbox full
Read
Read w. failure
(mailbox empty)
mailbox empty
Figure 3.3 SyncManager mailbox interaction
www.trinamic.com
Read
Read w. failure
(mailbox empty)
Write
Write w. failure
(mailbox full)
TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
3.2
9
EtherCAT Slave State Machine
The EtherCAT slave state machine has four states, which are shown in Figure 3.4. After power ON the slave
state machine is in the Init state. In this situation mailbox and process data communication is impossible.
The EtherCAT master initializes the SyncManager channels 0 and 1 for the communication via mailbox.
While changeover from Init state to Pre-Operational state the EtherCAT slave checks the correct
initialization of the mailbox. Afterwards mailbox communication is possible. Now, in the Pre-Operational
state the master initializes the SyncManager channels for the process data and the FMMU channels.
Furthermore adjustments are sent, which differ from the default values.
While changeover from Pre-Operational state to Safe-Operational state the EtherCAT slave checks the
correct initialization of the SyncManager channels for the process data as well as the adjustments for the
Distributed Clocks. Before accepting the change of state, the EtherCAT slave copies actual input data into
the accordant DP-RAM array of the EtherCAT slave controller. In the Safe-Operational state mailbox and
process data communication are possible, but the slave holds its outputs in a safe situation and actualizes
the input data periodically.
Before the EtherCAT slave changes the state to Operational it has to transfer valid output data. In the
Operational state the EtherCAT slave copies the output data from the EtherCAT master to its outputs.
Process data communication and mailbox communication are possible now.
The Bootstrap state is only used for updating the firmware. This state is reachable form the Init state.
During Bootstrap state mailbox communication is available over File-Access over EtherCAT. Beyond this
mailbox communication or process data communication is not possible.
EtherCAT™ Slave State Machine
Init
Pre-Operational
Bootstrap
Safe-Operational
Operational
Figure 3.4 EtherCAT™ slave state machine
www.trinamic.com
(optional)
TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
State / state change
Init
Init to Pre-Operational
Pre-Operational
Pre-Operational to Safe-Operational
Safe-Operational
Safe-Operational to Operational
Operational
Bootstrap
Services
No communication on application layer
Master has access to the DL-information registers
Master configures registers, at least:
•
DL address register
•
SyncManager channels for mailbox
communication
Master initializes Distributed Clock synchronization
Master requests Pre-Operational state
•
Master sets AL control register
Wait for AL status register confirmation
Mailbox communication on the application layer
No process data communication
Master configures parameters using the mailbox:
•
e.g., process data mapping
Master configures DL Register:
•
SyncManager channels for process data
communication
•
FMMU channels
Master requests Safe-Operational state
Wait for AL Status register confirmation
Mailbox communication on the application layer
Process data communication, but only inputs are
evaluated. Outputs remain in safe state
Master sends valid outputs
Master requests Operational state (AL Control/Status)
Wait for AL Status register confirmation
Inputs and outputs are valid
Recommended if firmware updates are necessary
State changes only from and to Init
No Process Data communication
Mailbox communication on application layer, only
FoE protocol available (possibly limited file range)
THREE LEDS DISPLAY THE ACTUAL ACTIVITY:
Green LED
EtherCAT0
LINK OUT state
EtherCAT
LINK IN state
EtherCAT
RUN state
www.trinamic.com
Description
OFF
blinking
single flash
OFF
blinking
single flash
OFF
blinking
single flash
ON
flickering (fast)
No link.
Link and activity.
Link without activity.
No link.
Link and activity.
Link without activity.
The device is in state
The device is in state
The device is in state
The device is in state
The device is in state
INIT.
PRE-OPERATIONAL.
SAFE-OPERATONAL.
OPERATIONAL.
BOOTSTRAP.
10
TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
3.3
11
EtherCAT Firmware Update
For firmware updates the EtherCAT state machine of the slave has to be switched to Bootstrap state. The
file access over EtherCAT protocol (FoE) is used.
THE TWO MAILBOXES FOR DATA TRANSFERS HAVE THE FOLLOWING PARAMETERS:
-
Data output buffer:
Data input buffer:
3.4
Start-address: 4096, length: 268 byte
Start-address: 4364, length: 40 byte
Process Data
In standard configuration for data transfer the following buffers are used (slave view):
DATA OUTPUT BUFFER / ETHERCAT MASTER -> SLAVE DATA TRANSFER
Data output buffer: Start-address: 4096(0x1000), length: first 8 bytes
Start address End address Data type
Data value / contents
0x1000
0x1003
UNSIGNED32 Controller Mode
Bit
0
1
2
3 3
0x1004
0x1007
www.trinamic.com
SIGNED32
Description
No operation
Position mode
Velocity mode
Torque mode
Value
(position / velocity / current)
TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
12
DATA INPUT BUFFER / ETHERCAT SLAVE -> MASTER DATA TRANSFER
Data input buffer: Start-address: 4216(0x1078), length: first 44 bytes
Start address End address
Data type
Data value / contents
0x1078
0x107B
SIGNED32
Target Position
Command for read out:
0x107C
0x107F
SIGNED32
Actual position
Command for read out:
0x1080
0x1083
SIGNED32
Virtual actual position
Command for read out:
0x1084
0x1087
SIGNED32
Encoder Position
Command for read out:
0x1088
0x108B
SIGNED32
Target velocity
Command for read out:
0x108C
0x108F
SIGNED32
Actual velocity
Command for read out:
0x1090
0x1093
SIGNED32
Measured velocity
Command for read out:
0x1094
0x1097
UNSIGNED32
Status word
Command for read out:
0x1098
0x109B
UNSIGNED32
0x109F
SIGNED32
0x1100
0x1103
SIGNED32
0x1104
0x1107
SIGNED32
GAP 1
GAP 233.
GAP 209
GAP 2
GAP 3
GAP 131
GAP 18)
Error flags
Bit
0
1
2
3 3
4
5
6
7
8
9
10
11
0x109C
GAP 0
Description
Target reached
Velocity reached
Closed loop
Position mode
Velocity mode
Torque mode
Home switch
Left stop switch
Right stop switch
Undervoltage
Overvoltage
Overtemperature
Scaler
Command for read out: GAP123
Delta / torque
Command for read out: GAP 14
Gamma
Command for read out: 230
All numbers are stored in little endian format. (least significant byte is stored at the lowest address)
www.trinamic.com
TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
3.5
13
TMCL Mailbox
The TMCM-1310 slave module supports the TMCL protocol in direct mode. The communication follows a
strict master-slave-relationship. Via the TMCL mailbox motor-parameters can be read and/or written.
3.6
Binary Command Format
Every command has a mnemonic and a binary representation. When commands are sent from a host to a
module, the binary format has to be used. Every command consists of a one-byte command field, a onebyte type field, a one-byte motor/bank field and a four-byte value field. So the binary representation of a
command always has seven bytes.
TRANSMIT AN 8-BYTE COMMAND:
Bytes
1
1
1
1
4
Meaning
Module address
Command number
Type number
Motor or Bank number
Value (MSB first!)
Every time a command has been sent to a module, the module sends a reply.
RECEIVE AN 8-BYTE REPLY:
Bytes
1
1
1
1
4
3.7
Meaning
Reply address
Module address
Status (e.g. 100 means no error)
Command number
Value (MSB first!)
Status Codes
The reply contains a status code.
THE STATUS CODE CAN HAVE ONE OF THE FOLLOWING VALUES:
Code
100
2
3
4
5
6
8
Meaning
Successfully executed, no error
Invalid command
Wrong type
Invalid value
Configuration EEPROM locked
Command not available
Parameter is password protected
www.trinamic.com
TMCM-1310 TMCL Firmware V1.11 Manual (Rev. 1.16 / 2014-MAR-19)
4
14
Operation with USB Interface
In direct mode and most cases the TMCL communication over USB follows a strict master/slave
relationship. That is, a host computer (e.g. PC/PLC) acting as the interface bus master will send a command
to the TMCL-1310. The TMCL interpreter on the module will then interpret this command, do the
initialization of the motion controller, read inputs and write outputs or whatever is necessary according to
the specified command. As soon as this step has been done, the module will send a reply back over USB
to the bus master. Only then should the master transfer the next command.
4.1
Binary Command Format for USB Interface
When commands are sent from a host to a module, the binary format has to be used. Every command
consists of a one-byte command field, a one-byte type field, a one-byte motor/bank field and a four-byte
value field. So the binary representation of a command always has seven bytes. When a command is to be
sent via USB interface, it has to be enclosed by an address byte at the beginning and a checksum byte at
the end. In this case it consists of nine bytes.
THE BINARY COMMAND FORMAT FOR USB IS AS FOLLOWS:
Bytes
1
1
1
1
4
1
Meaning
Module address
Command number
Type number
Motor or Bank number
Value (MSB first!)
Checksum
The checksum is calculated by adding up all the other bytes using an 8-bit addition.
CHECKSUM CALCULATION
As mentioned above, the checksum is calculated by adding up all bytes (including the module address
byte) using 8-bit addition. Here are two examples to show how to do this:
in C:
unsigned char i, Checksum;
unsigned char Command[9];
//Set the “Command” array to the desired command
Checksum = Command[0];
for(i=1; i