Decoding infrared helicopter checksum

Hi i recently started a project for school to controll a infrared helicopter from a pc and i am having a hard time decoding the checksum for it, can someone please help me? iv google it many times but i cant seem to understand the methode of decoding it, if someone could please help me and explain how to do it i would appreciate it :slight_smile: , i have tride XOR but did not succeed, maybe i did it wrong, i dont know :slight_smile:

FT = Full throttle
LR = Left/Righ
FB = Forward/Backward
TR = Trim
?? = Checksum
Throt. - LR - FB - L1 - TR - L2 - ??
100 throttle 1 01111110 1000 1000 0100 0000 0000 1010

75 throttle 1 01100011 1000 1000 0100 0000 0000 1101

50 throttle 1 00111101 1000 1000 0100 0000 0000 0101

25 throttle 1 00000111 1000 1000 0100 0000 0000 1011

FT + full left 1 01111110 0001 1000 0100 0000 0000 0011

FT + full right 1 01111110 1111 1000 0100 0000 0000 0001

FT + full back 1 01111110 0111 0001 0100 0000 0000 0001

FT + full Forw 1 01111110 0111 1111 0100 0000 0000 0000

FT + L1 Button 1 01111110 1000 1000 0101 0000 0000 1011

FT + L2 Button 1 01111110 1000 1000 0100 0000 0001 1011

FT + R2 Button 1 01111110 1000 1000 0100 0000 0100 1110

FT + Trim Right Button 1 01111110 1000 1000 0100 0001 0000 1011

FT + Trim Left Button 1 01111110 1000 1000 0100 0010 0000 1101

Thanks a lot in advance! :smiley:

English is not my native language and electronics/arduino is just a hobby, sorry in advance for my bad spelling and stupidity.

The CS looks like an XOR of all the 4 bit nibbles. When you change a single bit, the CS bit in the same position should toggle as well.

Hi, thx for you answer, can you please make an example? :slight_smile:

JohnSm:
i have tride XOR but did not succeed, maybe i did it wrong, i dont know :slight_smile:

I have tried simply summing up the nibbles, then taking the lower nibble of the sum:

void pr(byte b) // print lower nibble of byte to Serial
{
  for (int i=3;i>=0;i--) Serial.print(bitRead(b,i));
  Serial.println();
}

void setup() {
 Serial.begin(9600);  //                                    sum  calculated difference
 pr(1+0b0111+0b1110+0b1000+0b1000+0b0100+0b0000+0b0000); // 1010   1010        0
 pr(1+0b0110+0b0011+0b1000+0b1000+0b0100+0b0000+0b0000); // 1101   1110        +1
 pr(1+0b0011+0b1101+0b1000+0b1000+0b0100+0b0000+0b0000); // 0101   0101        0
 pr(1+0b0000+0b0111+0b1000+0b1000+0b0100+0b0000+0b0000); // 1011   1100        +1
 pr(1+0b0111+0b1110+0b0001+0b1000+0b0100+0b0000+0b0000); // 0011   0011        0
 pr(1+0b0111+0b1110+0b1111+0b1000+0b0100+0b0000+0b0000); // 0001   0001        0
 pr(1+0b0111+0b1110+0b0111+0b0001+0b0100+0b0000+0b0000); // 0001   0010        +1
 pr(1+0b0111+0b1110+0b0111+0b1111+0b0100+0b0000+0b0000); // 0000   0000        0
}

Some of the checksums are correct and some differ by one.
Meaning: Sometimes the calculated checksum ist actually higher by 1 than you showed in your list.

Maybe your example data are not as good as you thought and half of them carry a wrong checksum?

Or maybe the resulting high nibble of the checksum is somehow involved in the actual calculation?

jurs just beat me to it but I did all 13 examples:

                                                     tsum      csum   tsum-csum
 0 = 0001, 0111, 1110, 1000, 1000, 0100, 0000, 0000, 1010  ->  1010   diff=0
 1 = 0001, 0110, 0011, 1000, 1000, 0100, 0000, 0000, 1101  ->  1110   diff=-1
 2 = 0001, 0011, 1101, 1000, 1000, 0100, 0000, 0000, 0101  ->  0101   diff=0
 3 = 0001, 0000, 0111, 1000, 1000, 0100, 0000, 0000, 1011  ->  1100   diff=-1
 4 = 0001, 0111, 1110, 0001, 1000, 0100, 0000, 0000, 0011  ->  0011   diff=0
 5 = 0001, 0111, 1110, 1111, 1000, 0100, 0000, 0000, 0001  ->  0001   diff=0
 6 = 0001, 0111, 1110, 0111, 0001, 0100, 0000, 0000, 0001  ->  0010   diff=-1
 7 = 0001, 0111, 1110, 0111, 1111, 0100, 0000, 0000, 0000  ->  0000   diff=0
 8 = 0001, 0111, 1110, 1000, 1000, 0101, 0000, 0000, 1011  ->  1011   diff=0
 9 = 0001, 0111, 1110, 1000, 1000, 0100, 0000, 0001, 1011  ->  1011   diff=0
10 = 0001, 0111, 1110, 1000, 1000, 0100, 0000, 0100, 1110  ->  1110   diff=0
11 = 0001, 0111, 1110, 1000, 1000, 0100, 0001, 0000, 1011  ->  1011   diff=0
12 = 0001, 0111, 1110, 1000, 1000, 0100, 0010, 0000, 1101  ->  1100   diff=1

All but four of them agree with the additive checksum (csum). Three of those that differ are one greater than the posted checksum and the fourth one is one less.
I agree with jurs that some of your example data are either incorrect or incomplete.

Pete

  • (add) and ^ (xor) are different operators, yielding different results.

and xor doesn't work at all

Pete