SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By andrewkinnear
I have a question regarding the IDG300, and drift compensation. The break out board does not have a temperature output, the values it return seem to drift quite a lot. In a couple minutes it will drift 7 mV. I can see why the 6DOF board uses the ADXRS, it’s much a much better sensor, when integrating the readings you basically see very little drift.

I am building a RC Quad-copter type project, I’m planning to use simple PID type algorithms to stabilize the thing (track achieved rates compared to input rates from the transmitter). Kalman filters are way too complex for my un-educated brain. I’m using a propeller chip, 12bit ADC to interface with the IDG300 and ADXRS (3 axis). I will be controlling the thing with a RC transmitter, so I could possibly compensate myself for drift, but I would like to minimize the drift as much as possible.

Would it be safe to say that the drift is uniform over time? I could maybe track the drift along an approximate curve and compensate accordingly. It’s an idea. Build a graph, find where the readings currently are compared to the graph (during start-up / calibration phase), and start from there. Has anyone tried this? Will this work?
By edmoore
Not a safe assumption - (d^2)Drift/d(Time^2) != 0 - the rate of drift is not constant.

You have two options - compensate with your brain. RC Heli pilots often put gyros on their machines to control the tail swing. That just damps out any movement - but it will drift, so they naturally correct that with stick inputs. However, that system is marginally stable - your system in unstable.

The accelerometer + gyro route is the common solution. You're already beginning to sweat because I'm about to use the 'K'-word - Kalman. However, let's not give up hope just yet.

The accelerometer measures tilt when its in equilibrium, i.e. the only force vector acting upon its proof-mass is gravity. This is often not the case for, say, a quadcopter (which can be accelerating in all sorts of direction) but it's not far off in the limit - your average non-gravitational acceleration over time might be roughly 0.

A Gyro, as you know, gives you good response in the short term, but is not a stable reference long term.

So you could suppose you make a little simple algorithm that trusts the accelerometer more when you're not being very dynamic, and the gyro more when you're making dynamic movements - a weighted average with dynamically assigned co-efficients:

Angle = a1*accelerometer + a2*gyro

a1 + a2 = 1
accelerometer = what the accelerometer reckons the tilt is
gyro = the integrated output of the gyro

You would make a1 larger when you're nearer equilibrium, and a2 larger when you're further away from equilibrium.

The algorithm you come up with for picking the values of a1 and a2 is the tricky bit in all this, and the kalman filter essentially is the optimal implementation of that algorithm.

However, you may be able to think of ways that, whilst not delivering such good performance, might still be adequate. However, there is a strong argument for digging deep and getting out a pen and paper, brushing up on some linear algebra and having a go at crocking the kalman filter. He's not that scary once you realise what he's doing.

By andrewkinnear
As far as I can figure, logically, the accelerometer readings are pretty useless in the air, because the acceleration experienced is only the acceleration caused as a result of the 4 propellers, in free fall the accelerometers read zero g, unless you are connected to the ground by something you can not really use accelerometer readings for tilt, although at high enough speeds the air resistance will give you some form of reading.

I have managed to get the noise of the gyro’s down to about 2 LSB on the ADC, by averaging multiple samples with software, I do the same for the Input pulses from the receiver. I also have the thing making adjustments at 200 times a second (PID -> Mixer -> Servo Pulse generator). It looks stable apart from the drift. If only I could reduce the drift.

Maybe two or three sonic range finders strapped to the bottom at angles will help keep it in a stable hover. Or maybe something that examines the horizon... not too sure...
By JasonDorie
I think maybe you misunderstand how they work. The accelerometer will read a constant 1G of acceleration due to gravity. If the accelerometer is perfectly level, that 1G will look like (0.0x, 0.0y, 1.0z). If you're tilted 45 degrees to one side, the accelerometer will read (0.707x, 0.0y, 0.707z).

The biggest problem with accelerometers for this is that they also measure vibration, so your instantaneous readings could be severely off. Integrated over a relatively short time period they'll tell you where 'down' is, and can therefore be used to compensate for gyro drift.