0
\$\begingroup\$

Context: I am programming a flight controller for an autonomous drone. I want it to be able to hover in place so I am working on a PID controller for the throttle to keep vertical velocity at 0. (Assume the drone is level with respect to gravity as I have a separate PID controller for that).

Since I am dealing with velocity rather than acceleration but my only sensor is an IMU, I am trying to integrate the acceleration data to get velocity. However, when I do this it introduces a lot of drift, and I have tried several ways of correcting for the drift but none of them have produced useable results.

My question is this: Can I use a lowpass filter on the acceleration data instead of an integrator and would it eliminate drift? I don't care about the accuracy of the result because I am finding the gains of the PID controller experimentally. As long as it is precise and does not drift it should work.

\$\endgroup\$
  • \$\begingroup\$ Put a resistor across your integrator's capacitor to handle drift. \$\endgroup\$ – Hearth Mar 22 at 1:05
  • \$\begingroup\$ @Hearth I'm doing this in software, sorry if it was unclear \$\endgroup\$ – Plasmabot Mar 22 at 1:06
  • \$\begingroup\$ Please see this: dsp.stackexchange.com/a/54088/41790. Basically, a ‘leaky integrator’, correctly analyzed. \$\endgroup\$ – Ed V Mar 22 at 2:13
  • \$\begingroup\$ "I'm doing this in software, sorry if it was unclear " That would make it a software question not electronics :-) \$\endgroup\$ – Oldfart Mar 22 at 7:48
0
\$\begingroup\$

Can I use a lowpass filter on the acceleration data instead of an integrator and would it eliminate drift?

You probably do want to low pass filter it, but only to eliminate high frequency noise and vibration - not drift.

Your ultimate goal is to hold a fixed vertical position, but the accelerometer only gives the rate of change in velocity. So to get absolute position you calibrate it for zero acceleration when stationary, then integrate the output to get velocity, and integrate that to get distance (height).

If the sensor was perfectly accurate and didn't drift at all then the integrated height output wouldn't drift. However in practice there will be some drift, and a small vertical acceleration will still occur. The only practical way to eliminate this is to have an absolute height input, eg. from a ground distance sensor, altimeter (air pressure sensor), or GPS. If you have that then you can high pass filter the integration to eliminate drift from it (but lose long-term height information), then add in low pass filtered absolute position information for total height control.

Note that while double integration makes the height drift very sensitive to accelerometer errors, the acceleration output is rapid so short-term stability can be very good, whereas an absolute height sensor may be too slow and/or inaccurate for this purpose. So for best stability you need both sensor types.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.