abdeshpande
New Member
Hi! I'm trying to put together a project where a picaxe 08m2 would log data from an adxl345 accelerometer at 100hz or so. I'm using a proto board from the startup kit. I am using an accelerometer based of the adxl345 (basically a breakout) and have soldered it to the board. It is running off 4.5v (three AA batteries) My program just for logging data is below. it doesn't save it or anything; I'm just using it to test live while it's hooked up to my computer. the code is below. the accelerometer is here: http://www.robotmesh.com/grove-3-axis-digital-accelerometer-16g and I used this tutorial: https://www.sparkfun.com/tutorials/240 and I use this datasheet for the accelerometer: https://www.sparkfun.com/datasheets/Sensors/Accelerometer/ADXL345.pdf
So basically, I can get reading from the accelerometer, but I have NO IDEA what im reading. When I perform the calculations which should apparently get me acceleration in Gs, I get numbers that ARE NOT 0, when the accelerometer is still. Sometimes b3 just goes straight from 0 to 255 and back and forth. Does anyone know what im getting from the accelerometer and what I should be doing differently? BTW the data is stored under 2 different byte variables and are combined into word variables so w0 is x, w1 is y, and w2 is z. When I take any of them, and multiply it by 0.0078 (which the tutorial says to do) I DONT get 0. Does anyone know what I should do?
Help please and thanks in advance!
So basically, I can get reading from the accelerometer, but I have NO IDEA what im reading. When I perform the calculations which should apparently get me acceleration in Gs, I get numbers that ARE NOT 0, when the accelerometer is still. Sometimes b3 just goes straight from 0 to 255 and back and forth. Does anyone know what im getting from the accelerometer and what I should be doing differently? BTW the data is stored under 2 different byte variables and are combined into word variables so w0 is x, w1 is y, and w2 is z. When I take any of them, and multiply it by 0.0078 (which the tutorial says to do) I DONT get 0. Does anyone know what I should do?
Help please and thanks in advance!
Code:
HI2CSETUP I2CMASTER, 0xA6, i2cfast, i2cbyte
HI2COUT 0x31,(0x01) ;puts into +-4g mode
HI2COUT 0x2D,(0x08) ;puts into measurement mode
main:
HI2CIN 0x32,(b0,b1,b2,b3,b4,b5) ;getting data from adxl345. b0 and b1 are x, b2 and b3 are y, and b4 and b5 are z. They *should* be combined in w0, w1, and w2
debug
pause 10
goto main