SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By UberSteve
#6702
Hi,

Would anybody here be able to point me in the direction of some resources regarding the above subject.

I'm using an Accelerometer to measure braking forces, and as you would expect, I am getting false readings when the vehicle is braking while going down a hill.

I’m just interested in what other people are doing to compensate this problem.

Cheers,
Steve
By tvelliott
#6776
Here is my thought...

You could add a gyro to your system. integrate the gyro output such that it gives you the tilt angle. You will have to make your integration accurate to reduce cumulative error due to gyro drift etc... This will only work if the time you are traveling on a slope is less than the acceptable drift on the integration. When you are level, you can use the accelerometer to correct the gyro integration... kind of recursive :)
By Caffeine
#6796
A 2 axis accelerometer is all you need.

One axis in the direction you're trying to measure, and one vertical.

When acceleration happens, the vertical axis will not change. When tilt happens, the vertical axis will decrease. When the vertical axis decreases, it's simple trigonometry to figure out the tilt and remove it's effects from your acceleration.

That's the way one high profile in car accelerometer works.
By cdnsnowboarder
#10498
what about for snowboarding when the accelerometer will tilt and twist?
By npk
#10607
You need a 3axis accelerometer then. You need to calibrate so that total of your accelerations should be = g. You then subtract of your bias accelerations from each axis. Now you can integrate up your accelerations.

remember, you must add in quadrature to get total acceleration.

a_total = sqrt(a_x^2 + a_y^2 + a_z^2)
n
By cdnsnowboarder
#10612
That was the equation I planned on useing. While programming today I realized I need cubic root not square root. Main thing i'm wondering about is for special cases like cornering. When moving in a circle at a constant speed, and object is always accelerating. The accelerometer would read this accel and change the speed (which should not be changed) accordingly.

I'm using the equation, Anet = cbrt(Ax*Ax+Ay*Ay+Az*Az)
Accel = 1g - Anet
this way while not moving, Anet will be 1g(from gravity) so accel =0g, or when in free-fall, Anet=0g so accel = 1g.
say I pull 2g's while cornering, that means accel would = -1g. I don't think I would actually slow down by 1g while cornering. I'm not really sure though so i'm going to make it and try it in a car, hopefully it works. If it doesn't work I will use a thermometer of some sort to measure windspeed. any ideas of a good cheap linear quickly adjusting one?
By npk
#10628
Hey there,

I'm sorry, but I don't fully understand what you are trying to do. Before I continue, I must say that the equation to use the cube-root is not correct (it is the square-root.)

That being said, making inertial navigation systems (which measure distance traveled by integrating acceleration twice) are hard! This is not a trivial thing to do. You need very precise & accurate accelerometers.

I just got myself a 2axis accelerometer for doing something similar (in a car.) I'm going to spend some quality lab time understanding the devices before I even begin to deal with taking measurements. Calibration is going to play a huge role in this game.

Take care!
n
By cdnsnowboarder
#10645
haha yeah you're right on the square root, I thought myself into circles after too many hours of programming yesterday.

I don't care about distance, just speed.

I am using the MMA7260Q 3-axis, 200mv/g max+/-6g samplin freq11khz (90us). I set the A/D in the PIC to run every 8us so each channel gets sampled every 8us*3(chan) = 24us which is less than half of 90us. I run a timer to count real time (var=var+timerperiod) Timerperiod right now is 8us, but it seems to be not letting anything else interupt while its running, so i think i may slow it down a little. When integrating, I divide accel by the var which is reset each time i integrate.
Ax = average of 10 or maybe 100 values taken at 24us/value
Anet = sqrt(Ax^2+Ay^2+Az^2)
accel = 1g-anet
change in speed = accel/(time to get 10 or maybe 100 values for average)
new speed = old speed + change in speed

My physics teacher also stressed the fact that I should calibrate, but I was hopeing that I wouldn't have to. I don't really have a clue how I would calibrate. I plan on testing it by sitting in a car with a hopefully accurate speedo and twisting and tilting it. All I can figure out is too put the output into a linear equation for example as x in y=mx+b, m and b would be calibrators, and y would be the calibrated output. I have never done programming calibration before. I just realized I could use adjustable resistors inbetween the accelerometer and the PIC, but I'm worried those would move while I bash the crap out of it. I guess I could always glue it but that sounds kinda bojang'd.

Do you have any idea how to calibrate?
Thank you for the help.
By Philba
#10647
how linear is the device? I would think you have lots of points of calibration - 0g, -1g, +1g. If its not super linear, then you can curve fit. You can also determine the physical rotation that corresponds to -1 and +1 in each axis - look for the peaks as you rotate the device. I'd create a gimble to take the measurements.

If the errors at higher g are a problem you could build a centrifuge to create any g force you want by knowing the diameter and rot freq. make sure the plane of rotation is perpinducular to the g-normal.

more than one way to skin a cat.
By npk
#10682
Do you have any idea how to calibrate?
There are two kinds of calibration:

1) Knowing what the bias values of your accelerometer are. If the accelerometer is sitting in free space, all X,Y,Z outputs should be vcc/2. However, your vcc might vary, temperature varries, so you may not get exactly vcc/2 on your outputs. You have to measure what these constant values are and subtract them from your readings.

2) Knowing that a X mV difference on an output, corresponds to what kind of acceleration. This is in the spec, and also, you know what g is, so you can check the spec sheet. The device is linear (check the spec sheet.)

Knowing the types of calibration, you also must figure out what bandwidth and sensitivity you need. Your bandwidth should be as low as possible. For a car, 10Hz is probably enough, so sample at whatever rate you can get out the board, and average it down to 10Hz. Sensitivity should be as high as possible. There's a 1.5 maximum g mode, that's probably enough. (Simple check is to use distance traveled = 1/2 * acceleration * time^2) Figure out what acceleration you need.

Make a mount for the board. A nice heavy mount that you can clamp down to something. Measure the biases. If possible, have it so that you can rotate the board 90deg. Rotate the board 90deg, make sure you're getting the same a_total.

good luck
n[/quote]
By cdnsnowboarder
#10683
Ah I see, I thought you were talking about calibrating to fix errors with my integration code. I'm not too worried about the linearity, the data sheet for the MMA7260Q says it's fine within the specified range. I like the idea of a centrefuge.

What is a gimble?
By Philba
#10689
cdnsnowboarder wrote:Ah I see, I thought you were talking about calibrating to fix errors with my integration code. I'm not too worried about the linearity, the data sheet for the MMA7260Q says it's fine within the specified range. I like the idea of a centrefuge.

What is a gimble?

argh! gimbal. sorry.

wikipedia sez: http://en.wikipedia.org/wiki/Gimbal
By cdnsnowboarder
#10719
Oh no, I couldn't care less about spelling, I just didn't know what a gimbal was. I was thinking of trying to find or making what is apparently called a gimbal. I just tried to make a little 1axis one (so tilting in the x-axis would not actually tilt the device). After making it, I shook it around and quickly realized that it bounces around almost as much as i shake it, making it use-less for snowboarding. I dont know if you meant to use it for calibrating or for actual use so that z-axis is always pointing towards center of earth.

I've realized that the snowboarding example is different from most accelerometer applications because there is no force causeing forward accel other than the constant 1g of gravity. Does that mean that any accel in any direction should be subtracted from snowboarders speed?

3 examples:
1, not moving (standing on a flat) accelerometer will say 1g(net), if you stand for 1 second, change in speed will be (1g-1g)*1second = 0m/s

2, free-fall, (90% slope) accel will say 0g(net) if falling for 1 second, change in speed = (1g-0g)*1second = 9.8m/s

3.......... Snowboarder is travelling at 26m/s, snowboarder either turns OR hits the brakes, Accel net = 2g for 1second
change in speed = (1g-2g)*1second = -9.8m/s So supposidly, new speed = 16.2m/s.

Is this a valid assumption? --That any net accel over 1g causes a loss of speed no matter what direction it is in.

I think this assumption may work simply because 1g from gravity is the only thing that will cause an increase of speed

Or in other words,
Would accelerating uphill(braking) at 2g's cause the same deceleration as accelerating sideways(turning) at 2g's?