Hello all,
I have a question for anyone who has worked with the ADXL345 - 10 bit resolution - and therefore may know.
How do we have a 10-bit resolution (ADXL345) with an I2C communication +ardunio uno when a priori the data is transmitted by "packet" of 8 bit?
I still don't understand why?
Sincere thanks!
According to the data sheet, each axis has two eight bit registers that contain its data. It recommends that you do a multibyte read on each axis to get the corresponding pair.
Then you can do some bit twiddling to combine the data as 10 bits.
Or just use a library to abstract that away for you - Adafruit has one.
10 bits and transmitting 8 bits at a time. Let's say the transmission is from MSB to LSB.
10 bits will need to be split into 2 8 bit packets.
first 8 bits, from packet a
b7 b6 b5 b4 b3 b2 b1 b0. This would be the MSB bits. Bit positions b7, b6, b5, b4, b3, and b2 are irrelevant. The only bits that matter are bits 1 and 0.
A 16 bit number b15b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1,b0
If the first 2 bits were put into a 16 bit variable. Put bit1 from packetA into position b9 and bit0 from packetA into b8. Put the bits from packetB into bits b7 to b0. That's how a 10 bit data packet can be sent with a protocol that sends 8 bits at a time.
Hope that makes sense.
wildbill:
According to the data sheet, each axis has two eight bit registers that contain its data. It recommends that you do a multibyte read on each axis to get the corresponding pair.Then you can do some bit twiddling to combine the data as 10 bits.
Or just use a library to abstract that away for you - Adafruit has one.
Idahowalker:
10 bits and transmitting 8 bits at a time. Let's say the transmission is from MSB to LSB.10 bits will need to be split into 2 8 bit packets.
first 8 bits, from packet a
b7 b6 b5 b4 b3 b2 b1 b0. This would be the MSB bits. Bit positions b7, b6, b5, b4, b3, and b2 are irrelevant. The only bits that matter are bits 1 and 0.
A 16 bit number b15b14,b13,b12,b11,b10,b9,b8,b7,b6,b5,b4,b3,b2,b1,b0
If the first 2 bits were put into a 16 bit variable. Put bit1 from packetA into position b9 and bit0 from packetA into b8. Put the bits from packetB into bits b7 to b0. That's how a 10 bit data packet can be sent with a protocol that sends 8 bits at a time.
Hope that makes sense.
Thanks for explaining me to understand this problem.
