![Trinamic PD57-1060 Firmware Manual Download Page 13](http://html1.mh-extra.com/html/trinamic/pd57-1060/pd57-1060_firmware-manual_1163104013.webp)
PD57/60-1060 / TMCM-1060 TMCL™ Firmware Manual (V1.04 / 2011-AUG-29)
13
Copyright © 2011, TRINAMIC Motion Control GmbH & Co. KG
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
5.2
Reply format
Every time a command has been sent to a module, the module sends a reply.
The reply format for RS485 or 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, the first byte (reply address) and the last byte (checksum) are left out.
Do not send the next command before you have received the reply!