Stabilise altitude using z axis accelerometer

Firmware/software/electronics/mechanics
Post Reply
*matt*
Beginner
Posts: 1
Joined: Sun May 19, 2013 10:05 am

Stabilise altitude using z axis accelerometer

Post by *matt* »

I was wondering if anyone has tried using the z axis of the MPU-6050 accelerometer to help maintain altitude. I know it will only help with sudden changes in altitude, but combined with the MS5611 pressure sensor it may work better.

I will try to implement something myself although I’m not an experienced programmer.

Matt
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Stabilise altitude using z axis accelerometer

Post by tobias »

It might work but our experience is that the accelerometer readings are very noisy from the vibrations which might make it difficult. Filtering the values might be a solution. Looking forward to your results!
TheFrog4u
Expert
Posts: 113
Joined: Fri Feb 08, 2013 6:59 pm
Location: Bremen, Germany

Re: Stabilise altitude using z axis accelerometer

Post by TheFrog4u »

hmm interesting.. one idea would be to replace thrust ctrl with z-axis acceleration ctrl.
mjc506
Beginner
Posts: 13
Joined: Wed Feb 20, 2013 1:41 pm

Re: Stabilise altitude using z axis accelerometer

Post by mjc506 »

dawwwww thanks! You've just given me the prod I needed to get my hover mode working completely!

(I have it working fairly nicely just using the barometer, but was looking for a decent derivative term - I'll now use an integrated reading from the accelerometer (to get velocity)
Fucitol
Beginner
Posts: 19
Joined: Wed May 08, 2013 7:49 am

Re: Stabilise altitude using z axis accelerometer

Post by Fucitol »

That sounds very good! Please keep us updated on how you are doing, many people are interested in an altitude hold function.
mjc506
Beginner
Posts: 13
Joined: Wed Feb 20, 2013 1:41 pm

Re: Stabilise altitude using z axis accelerometer

Post by mjc506 »

sure, code is here: https://bitbucket.org/mjc506/crazyflie-firmware and it compiles and runs fine. You will also need a patched cf-client - I used Phiamo's code: https://bitbucket.org/phiamo/crazyflie-pc-client (but couldn't get his firmware working for me)

Altitude hold works ok, but I still need to tweak the PID tuning - these show up in the 'Parameters' tab, so they are adjustable in flight. Currently, if the CF gets too far away from its set point (or if you adjust the set point too quickly with the throttle) it goes into oscillation, but dropping the integral and/or proportional terms should help. I think most of the oscillation is from the integral term, but I've been fighting with my crappy Derivative function for the last few days :roll:
Post Reply