
TMCM-1311 TMCL Firmware V1.11 Manual (Rev. 1.17 / 2015-NOV-05)
16
www.trinamic.com
4.1.1
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<8; i++)
C=Command[i];
Command[8]=Checksum; //insert checksum as last byte of the command
//Now, send it to the module
in Delphi:
var
i, Checksum: byte;
Command: array[0..8] of byte;
//Set the “Command” array to the desired command
//Calculate the Checksum:
Checksum:=Command[0];
for i:=1 to 7 do Checksum:=CCommand[i];
Command[8]:=Checksum;
//Now, send the “Command” array (9 bytes) to the module
4.2
Reply Format
Every time a command has been sent to a module, the module sends a reply.
The reply format for RS485/ /USB is as follows:
Bytes Meaning
1
Reply address
1
Module address
1
Status (e.g. 100 means
no error
)
1
Command number
4
Value (MSB first!)
1
Checksum
The checksum is also calculated by adding up all the other bytes using an 8-bit addition.
When using CAN bus, just leave out the first byte (module address) and the last byte (checksum).
Do not send the next command before you have received the reply!