SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By abagde
#171467
I am currently using this accelerometer to measure the angle of incline while riding a bike. Basically I slightly modified the given code to calculate atan(x-measurement/z-measuement), and this is giving out the correct angle when the bike is stationary, at least in the -89 to 89 degree range. However, when I am riding the bike, the measurements are way off, the angle jumps all around the place. Is there a way I can phase out the effects of linear motion in my code?
By Mee_n_Mac
#171487
abagde wrote:I am currently using this accelerometer to measure the angle of incline while riding a bike. Basically I slightly modified the given code to calculate atan(x-measurement/z-measuement), and this is giving out the correct angle when the bike is stationary, at least in the -89 to 89 degree range. However, when I am riding the bike, the measurements are way off, the angle jumps all around the place.
Of course, you've just demonstrated the Equivalence Principle.
http://en.wikipedia.org/wiki/Equivalence_principle
abagde wrote:Is there a way I can phase out the effects of linear motion in my code?
Phase out ... errr ... you can diminish the effects of acceleration via a low pass filter but off course that means your angle readings will be delayed. A magnetometer can measure your angle wrt to the Earth's magnetic field and is immune to acceleration but is sensitive to metal and stray magnetic fields.
By falingtrea
#171527
You might try turning on the pulse LFP filter bit and taking a rolling sample of the data. That may smooth it out enough.
By Valen
#171554
Are side-wheels an option? (joking.... somewhat)

As you are very likely causing the bike to swing left and right as you pedal. When the bike is leaning left and right due to the pedalling oscillation the Z-axis is not a true representation of the downwards gravity vector any more. The Y axis plays along in combination to the X axis. Your intended method only works for non-accelerated motions. And the left right oscillation is a form of acceleration.

[EDIT]Important to know: where is this accelerometer mounted? Mounted on the steering bars you might get even worse accelerations on top of it due to rotations.
By smileyfujioka
#171616
Hi abagde!

I am also using mma8452q. May I know what code/platform are you using? I am using lpc1769 and also facing a lot of troubles. Mind if you share your code? Thanks! :)