Accelerometer reading transmission

The RF link is slow, and unreliable, so given that I came up the following scheme for transmitting the readings back:

  • Only transmit readings when they change
  • Transmit each reading 3 times when it changes
  • Add a checksum so the receiver can tell if the reading was transmitted OK

The Manchester library I’m using (originally from here) just transmits 16-bit integers, so I want to pack everything into 16 bits.

The reading you get out the ADC on the ATTiny is 10-bits, and for now I’m transmitting the whole of it.  The next 2 bits identify the axis the reading is for, and the final 4 bits are a simple checksum (XOR of each of the groups of 4 bits together).

The receiver checks the checksum, discards the reading if it’s wrong, and otherwise updates the axis and sends the reading out to serial (for now) so I can see what it’s up to.

Rather than pasting the whole source in here, I’ve put it up on github: Transmitter, Receiver.

Finally, a screenshot of it in action:

Comments are closed.