If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.
Special Thanks To:
Aaron Holmes
Aaron Wheeler
Adam Horden
Alan Scrimgeour
Andre
Andrew Haynes
Anonymous000
asabase
Austin Weil
barney
Barry
Bert Hickman
Bill Kukowski
Blitzorn
Brandon Paradelas
Bruce Bowling
BubeeMike
Byong Park
Cesiumsponge
Chris F.
Chris Hooper
Corey Worthington
Derek Woodroffe
Dalus
Dan Strother
Daniel Davis
Daniel Uhrenholt
datasheetarchive
Dave Billington
Dave Marshall
David F.
Dennis Rogers
drelectrix
Dr. John Gudenas
Dr. Spark
E.TexasTesla
eastvoltresearch
Eirik Taylor
Erik Dyakov
Erlend^SE
Finn Hammer
Firebug24k
GalliumMan
Gary Peterson
George Slade
GhostNull
Gordon Mcknight
Graham Armitage
Grant
GreySoul
Henry H
IamSmooth
In memory of Leo Powning
Jacob Cash
James Howells
James Pawson
Jeff Greenfield
Jeff Thomas
Jesse Frost
Jim Mitchell
jlr134
Joe Mastroianni
John Forcina
John Oberg
John Willcutt
Jon Newcomb
klugesmith
Leslie Wright
Lutz Hoffman
Mads Barnkob
Martin King
Mats Karlsson
Matt Gibson
Matthew Guidry
mbd
Michael D'Angelo
Mikkel
mileswaldron
mister_rf
Neil Foster
Nick de Smith
Nick Soroka
nicklenorp
Nik
Norman Stanley
Patrick Coleman
Paul Brodie
Paul Jordan
Paul Montgomery
Ped
Peter Krogen
Peter Terren
PhilGood
Richard Feldman
Robert Bush
Royce Bailey
Scott Fusare
Scott Newman
smiffy
Stella
Steven Busic
Steve Conner
Steve Jones
Steve Ward
Sulaiman
Thomas Coyle
Thomas A. Wallace
Thomas W
Timo
Torch
Ulf Jonsson
vasil
Vaxian
vladi mazzilli
wastehl
Weston
William Kim
William N.
William Stehl
Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Registered Member #2431
Joined: Tue Oct 13 2009, 09:47PM
Location: Chico, CA. USA
Posts: 5639
Ok ill look at the math for a kalman fiter too, but it looks ugly.
I need: 1) Code for a PID prototype function in C. 2) Kalman filter math model, and the C code function. 3) High Pass filter Math model, and the C code fro a funtcion call.
Im thinking this will take 6 to 9 months to get something realy working well.
If you find the kalman filter too complex or dont need that level of accuracy, you could try a complementary filter. It simply uses say 99% of the angle derived from the gyroscope, and 1% of the accelerometers: ANGLE=(PREVIOUS_ANGLE+GYRO_RATE*dt)*0.99 + ACCEL_ANGLE*0.01, where accel_angle is the angle derived from the accelerometers using the 3d atan function. From experience this can almost rival a kalman filter, and is a much easier to compute at a high update frequency.
I have code for both this and a 2nd order complementary filter on my site , although I didn't design the latter so cannot explain it off the top of my head. You'll also find some quadrocopter PID code on the git (see the 5th most recent post)
/edit
I must add, I've currently only implemented this on a 6DoF board, although I imagine adding the magnemometer should be relatively simple.
Registered Member #30
Joined: Fri Feb 03 2006, 10:52AM
Location: Glasgow, Scotland
Posts: 6706
Nice , sorry about the OT digression but can you recommend a good place to get quadcopter parts in the UK? I want to build one and I have a friend who does too.
Patrick, as far as I know the output of the gyro module doesn't saturate. It just has an unpredictable offset, so it's not quite zero (or Vcc/2 or whatever) when the angular rate is zero.
What saturates is the integrator in your code, whose job it is to turn rate into angular position.
I bought all my parts from hobbyking (china). You generally get a lot for your money, with the only real downsides being the lengthy shipping times and the awkwardness of returning anything. IIRC the total cost of my quad came to around £120 including the transmitter and quite a few spares.
Registered Member #2431
Joined: Tue Oct 13 2009, 09:47PM
Location: Chico, CA. USA
Posts: 5639
big5824 wrote ...
...From experience this can almost rival a kalman filter, and is a much easier to compute at a high update frequency.
/edit
I must add, I've currently only implemented this on a 6DoF board, although I imagine adding the magnemometer should be relatively simple.
Yep im glad someone made this point, i am using an STM32F4 board, so fast code is important. It looks like a wholelot of math for the Kalman filter to be calling repetitively.
I will also add a feature to turn off the magnetometer at the compitition, should it turn to crap... Accleration and gyro are far more important.
Steve Conner wrote ... Patrick, as far as I know the output of the gyro module doesn't saturate. It just has an unpredictable offset, so it's not quite zero (or Vcc/2 or whatever) when the angular rate is zero.
What saturates is the integrator in your code, whose job it is to turn rate into angular position.
Ok, ill look at the code for that, i know the PID has a similar problem with the I term in poorly implenented PIDs.
HobbyKing is an ok source youll get cheap stuff thats ok but not great. i Always use A Main Hobbies here in the states, but i dont know about shipping for you international folks... with A Main i get the good stuff, Castle ESCs, Savox servos, E-Flite, HiTec... and so on.
Registered Member #2431
Joined: Tue Oct 13 2009, 09:47PM
Location: Chico, CA. USA
Posts: 5639
big5824 wrote ...
If you find the kalman filter too complex or dont need that level of accuracy, you could try a complementary filter. It simply uses say 99% of the angle derived from the gyroscope, and 1% of the accelerometers: ANGLE=(PREVIOUS_ANGLE+GYRO_RATE*dt)*0.99 + ACCEL_ANGLE*0.01, where accel_angle is the angle derived from the accelerometers using the 3d atan function. From experience this can almost rival a kalman filter, and is a much easier to compute at a high update frequency.
I have code for both this and a 2nd order complementary filter on my site , although I didn't design the latter so cannot explain it off the top of my head. You'll also find some quadrocopter PID code on the git (see the 5th most recent post)
/edit
I must add, I've currently only implemented this on a 6DoF board, although I imagine adding the magnemometer should be relatively simple.
ive reviewed the available options and decided to move away from the kalman filter for the moment, and use the complementary filter, since i want to keep the embedded system (STM32F4) cycle time reasonable. Ive got a lot of real time points that need to be hit, and a limited number of timers...
Registered Member #2529
Joined: Thu Dec 10 2009, 02:43AM
Location:
Posts: 600
Just noticed this thread.
Yes, the trick to nulling the drift on the gyros is to have two vectors, the magnetic vector and the gravity vector.
There is a very subtle gotcha though; you can't measure the gravity vector (directly) using accelerometers; accelerometers always read zero to gravity!!!
What they actually measure is the aerodynamic lift; and the assumption is that the average lift is equal and opposite to the gravity vector. So the accelerometers will give you an "upwards" vector from the aerofoils.
That doesn't USUALLY matter, unless your aircraft is very unstable; it needs to be somewhat aerodynamically stable so that it generally points upwards.
It's not usually a problem with aircraft, but it's a huge issue for rocketry.
Registered Member #65
Joined: Thu Feb 09 2006, 06:43AM
Location:
Posts: 1155
BigBad wrote ...
There is a very subtle gotcha though; you can't measure the gravity vector (directly) using accelerometers; accelerometers always read zero to gravity!!!
I'm not sure what you meant, but these usually read -9.80665 m/s^2 assuming the z axis is perpendicular and position is fixed.
The 0 g only occurs if one was accelerating downwards at 1 g , placed in Geostationary orbit, or broke the sensor by exceeding its tolerance.
Registered Member #2431
Joined: Tue Oct 13 2009, 09:47PM
Location: Chico, CA. USA
Posts: 5639
yes carbon rods point is the condition my accelerometer says to expect for calibration purposes on initialization, 0g on X, 0g on Y, and 1g on z... i realize two vectors (x,y) can be used to see the upward direction to gravity on a leaning static object, but my flying machine wont just be in a hover, it will have translational accelerations, which cant be seperated without a gyro.
Registered Member #2529
Joined: Thu Dec 10 2009, 02:43AM
Location:
Posts: 600
Carbon_Rod wrote ...
BigBad wrote ...
There is a very subtle gotcha though; you can't measure the gravity vector (directly) using accelerometers; accelerometers always read zero to gravity!!!
I'm not sure what you meant, but these usually read -9.80665 m/s^2 assuming the z axis is perpendicular and position is fixed.
The 0 g only occurs if one was accelerating downwards at 1 g , placed in Geostationary orbit, or broke the sensor by exceeding its tolerance.
Yeah if you measure it carefully, you'll find it gives you an upwards acceleration when you're sitting on the ground, even when it's not moving.
When it's in the air, you're basically measuring the lift vector, and that will wander around a lot. If the lift vector is on average vertical, then you can use the average lift vector to work out which way is up. The rate gyros will help you stabilise it and then any aerodynamic stability will kick in over several seconds.
It's sometimes historically been a problem with aircraft, if they do a lot of aerobatics, the lift vector points in all different directions and the artificial horizon will start not being horizontal. The system has averaged the lift vector, but the lift has been going crazy, and the aircraft may have been losing altitude and accelerating sideways. But in level flight it will sort itself back out again quite quickly.
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.