06-16-2012 06:21 AM
Hi All:
I was hoping I could find some sample code on how to convert data from an ADXL345 accelerometer. I am reading acceleration data from an accelerometer through a PIC MCU into a LabView program on my laptop. The data from the sensor is formatted in two bytes, say axDataLO and axDataHI, forming a 16-bit twos-complement value. This value represents the result of a 10-bit ADC that is right justified with sign extension. If I am clear, the sign exension means that the last 6 bits are padded with either a 1 or 0 depending on the sign of the data. How do I convert this data into a signed integer? Any help is greatly appreciated! Thanks.
Solved! Go to Solution.
06-16-2012 06:56 AM
06-18-2012 08:07 PM
Hi GerdW,
Thanks for your reply. Yes, that was what I needed, as well as, fixing a bug in the code of my PIC microcontroller. I have included a code snippet here in case someone out there is working with the ADXL345. Thanks again for your help. V/R James C.
06-19-2012 01:49 AM
06-19-2012 09:53 AM
Thank you, again. James C
10-07-2012 10:54 PM
Awesome code! Just what I was looking for. Thanks!
12-06-2013 05:21 AM
Hi all. Could I know why the input of "Join Numbers" are crossed? Thanks for the answer.
Regards.
12-06-2013 05:23 AM
12-06-2013 06:42 AM
Thank You for the rapid answer. I've read online documentation about Little and Big Endian. How do I relate the information on the datasheets of the ADXL345 with this concept? Does "Left-Justified" means Big Endian?
Thanks again. Regards.
12-06-2013 09:56 AM