Accelerometer to trace path?
moihussain
Posts: 2
Hi. I, along with a few friends am working on a project in which we aim to trace the path of a model aircraft. I am new to accelerometers. What I understand about them is that we could obtain resolved values of acceleration along the x,y and z directions(please correct me if I'm wrong). How feasible is tracing the path of this model aircraft based on the accelerometer output values?
Any suggestions or advice are highly appreciated.
Hussain
Any suggestions or advice are highly appreciated.
Hussain
Comments
It's very like (make that certain) you'll have accululated error over time so you path wont be precise. This is one reason guidance systems use multiple sensors including GPS.
I do think it would be a fun project to see how accurately the path was described by the sensors.
BTW, welcome to the forums.
That seems to be a good idea to me. We'll try out with it. If it isn't working then we'll probably go for 6-axis sensing by adding a gyroscope as you suggested.
Thank you.
Hussain
http://obex.parallax.com/objects/download/aux/47/
I wonder if it would be possible to start with a simple experiment in just one dimension. Set up an accelerometer on something that moves in a straight line - say a toy car, then move it from a to b and see if you can work out where b is?
You should get an acceleration, probably a bit of fairly constant speed, then a deceleration.
Some of this can move quickly into some fairly heavy calculus, but essentially, if you sample more often then the errors are lower. Use two formulas one after the other:
Velocity = Initial Velocity plus Acceleration x Time.
then
Position = Initial Position plus Velocity x Time
The errors will clearly be less if you sample 1000x a second compared with once a second (once a second might even miss the entire initial acceleration).
Do some experiments and post the results here. It would be interesting to see what numbers you get and how bad the error is.
"Velocity = Initial Velocity plus Acceleration x Time. "
"Position = Initial Position plus Velocity x Time"
Yes, but it's a circular reference... in order to determine velocity you need distance, otherwise the numbers you see have no significant weight.
It would be like asking someone how long it will take to get to the store, when you don't know the distance to the store to begin with.
Even though you have an acceleration value, you don't know the distance (or displacement) that caused that amount of frame to frame acceleration.
Fortunately the accelerometer provides an output in G's ... you need to integrate Gravity with Acceleration so your left with displacement ... then integrate displacement with time to solve for Velocity.
Think about driving a car... Where the wheel meets the road, your measuring the displacement from frame to frame through a speedometer cable ir directly from the engine transmission. ( Either way a direct link to the ground). Taking the number of pulses or revolutions over time gives you your velocity (or speed reading) because you know (or the speedometer knows) how many pulses there are for a given amount of distance ... unfortunately with an accelerometer, the only way to measure from frame to frame is to take Gravity (a constant) and solve for displacement from the acceleration value it's giving you. Integrating the displacement with time provides you with your velocity.
The you can determine position ...
That's if your on a flat surface.... If you are at an angle, the displacement vector needs to be integrated with the angle using simple trigonometry.
Integration can get a bit heavy with calculus but maybe it can be simplified. I was thinking of the linear air bed experiments we did at school and how cool it would be to redo those experiments with modern accelerometers and a propeller chip!
Of course you need some simplifications. V = Vo + AT assumes you know Vo at the beginning and for the purposes of an experiment, set it at zero. Not so sure about a model plane, but you might be able to take a reasonable guess from some recent GPS readings plus airspeed to calculate real wind direction, and then you could do further calculations on air speed alone. And if you assume propeller speed = air speed, and then simplify again by assuming constant battery voltage, so propeller speed = air speed, then maybe you could use the input value to the propeller ESC as a proxy for speed. That is something the microcontroller would already know?
Need to work in x,y,z dimensions but you could get x and y from an electronic compass. Z is harder but I think there are some simple circuits that use motion sensor infrared sensors to look at the different reading from the sky vs the ground and work out the true position of the craft.
But then there is rotation. In three dimensions.
So yes... if you know all those things you can work out Vo!
The integral is just lots of readings taken at regular intervals, right?
But I suspect the problem is not the readings, it is the error, and the error accumulates so rapidly that you probably need to do all the math in floating point, and if you go to floating point then it is not as fast as integer math, so less readings, which means more error.
I am not sure how quickly those errors accumulate. Is it inaccurate over seconds, or tens of seconds, or tenths of seconds?
But don't jumbo jets have gyros in them that are good enough to calculate position for hours, even without any GPS input?
Don't get me wrong, your proposal is great, I'd love to see something like this.... I've tried it myself awhile back to calculate displacement in the way that you mention. I stopped pursuing it when my net displacement always seemed to add up to zero, and was driving me nuts... then I realized that I didn't integrate gravity into the equation. What I was actually looking at was accumulated acceleration, which was good that my accumulator returned to Zero. Means that I was capturing the accelerator values as best as I could. It would hover near Zero as long as I didn't move the accelerometer too abruptly, but part of the 'tracking' algorithm was to nudge it toward Zero very slowly in an attempt to self calibrate. The accumulation behavior made perfect sense after thinking about it for awhile... Assuming I start from a still position, as I move I accelerate at a particular rate, likewise when I stop I decelerate at a particular rate... the net acceleration from Start to Stop is zero ... the trick is to apply the rate at regular sample intervals and use the Equation: Acceleration = 9.80665 m/s^2 in a way that s cancels out due to the timing of your regular sampling interval, and since you know the Acceleration value ... solve for m and place m in an accumulator
I would expect all the accelerations to sum to zero if you start off moving then end up stopped. So you get a positive acceleration as you move off. Then the acceleration is zero while you coast, and the velocity stays the same (assume no friction). Then you have a negative acceleration which subracts from velocity until the velocity is zero and you stop moving.
But if there is a tiny error - say the accelerometer read 0.0001 when it was still, over time that would be calculated as acceleration to the speed of light. So I see what you mean about needing to zero somehow. I guess you need an outside frame of reference to calibrate to. These days that could be a GPS reading, and the accelerometers try to fill in the gaps between GPS readings?