Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

Motor Control ICs Forum Discussions

sohail
Level 2
10 questions asked 10 replies posted 25 sign-ins
Level 2

Hi,

           Someone Pl clarify how to calculate Checksum For user Uart Communication. AS per Imotion Software user Manual.

 

2.3.5 Checksum
Checksum is 16-bits and calculated as mentioned below:
[Command: Node address] + Data Word 0 + Data Word 1 + Checksum = 0x0000
Example Checksum calculation:
Input: Node address =1, command =2, Data Word 0 = 0x1122 and Data Word 1 = 0x3344
Checksum = -1*(0x0201+0x1122+0x3344) = 0xB999 

As per example transfer data  = { 0x01, 0x05, 0x01, 0x7D, 0x00, 0x00, 0xFE, 0x7D};

 

my understanding of formula 

1st step = (ox0501+ox017D+ox0000) =067E

2nd step (FFFF- 067E)+1  = F982 is check sum

but  in Example checksum is   0xFE, 0x7D.

Can someone Guide what  I am Doing Wrong?

 

Thanks

 

0 Likes
1 Solution
Krupashankar
Moderator
Moderator 250 replies posted 100 solutions authored 5 likes given
Moderator

Hi @sohail,

Please find the below steps:


As per example transfer data  = { 0x01, 0x05, 0x01, 0x7D, 0x00, 0x00, 0xFE, 0x7D};

1st step = (ox0501+ox017D+ox0000) =067E


Data is stored in little endian format as per example data the word will be 0x0501, 0x7D01 and 0x0000.

In the above calculation given by you the second word was taken wrongly.

First Step : 0x0501 + 0x7D01 + 0x0000 = 0x8202 

2nd step (FFFF- 067E)+1  = F982 is check sum


Second Step: 2's Complement ( 0x8202) = 0x7DFE 

storing in little endian format checksum will be 0xFE and 0x7D

Please let us know if any further details is required

 

Thanks,

Krupashankar

View solution in original post

0 Likes
1 Reply
Krupashankar
Moderator
Moderator 250 replies posted 100 solutions authored 5 likes given
Moderator

Hi @sohail,

Please find the below steps:


As per example transfer data  = { 0x01, 0x05, 0x01, 0x7D, 0x00, 0x00, 0xFE, 0x7D};

1st step = (ox0501+ox017D+ox0000) =067E


Data is stored in little endian format as per example data the word will be 0x0501, 0x7D01 and 0x0000.

In the above calculation given by you the second word was taken wrongly.

First Step : 0x0501 + 0x7D01 + 0x0000 = 0x8202 

2nd step (FFFF- 067E)+1  = F982 is check sum


Second Step: 2's Complement ( 0x8202) = 0x7DFE 

storing in little endian format checksum will be 0xFE and 0x7D

Please let us know if any further details is required

 

Thanks,

Krupashankar

0 Likes