Over the past few weeks I have been working on a self-balancing robot project. I have a Sparkfun 9DOF sensor stick that contains the sensors I have been implementing. However once receiving data from the ADXL345 accelerometer and ITG-3200 gyro it seems that for any given axis, + values are measured as 0<data<260 while - values return data in the data>65000 range. I find this confusing and wondered if anyone had any insight as to what is happening and how I can better understand this data. There seems to be no mention in either data sheet that would shed any light on my problem.
Many thanks, I have attached a sample of the data.
Hi Andrew,
What codes are you using? I just "build" a balancing robot using the ITG-3205 Gyro and ADXL345 Acc starting with Fabio's FREEIMU code and it seemed to return good data.
Hope it helps,
Alex
The -65000 numbers looks suspiciously like you have some problem with signed or unsigned ints somewhere. Check the type of the number you are actually receiving from the device, and make sure you don't have to modifiy it somehow.
accel[0] = (((int) buff[3]) << 8) | buff[2]; // X axis (internal sensor y axis)
Walk us through what you understand this code to do, please.
My understanding is that it is shifting the high order byte by 8 places and then appending the low order byte to form an int. Now, where I get lost is why you are then storing this int in a float array.
accel[0] = (((int) buff[3]) << 8) | buff[2]; // X axis (internal sensor y axis)
Walk us through what you understand this code to do, please.
My understanding is that it is shifting the high order byte by 8 places and then appending the low order byte to form an int. Now, where I get lost is why you are then storing this int in a float array.
Although I can not take all of the credit of this code (I used various components of the code provided here: GitHub - Razor-AHRS/razor-9dof-ahrs: AHRS Firmware for the SparkFun 9DOF Razor IMU and SparkFun 9DOF Sensor Stick) my understanding of this code is indeed that the bytes are shifted while the float array is implemented to reduce variables and simplify callback (the original code was much larger). I could be wrong and if so I would be glad of any suggestions.
I see, I did remove the arrays in case and as you said, the problem still persists. I'm sorry for all the questions, I'm just starting to figure some of this out and I've had some great help and support so far. Would the implementation of an integer array fix this issue?