Testing a DIYDrones magnetometer in HK's GCS from Pete Hollands on Vimeo.
I test the DIY Drones magnetometer ( HMC5843 magnetometer breakout board ) using Happy Killmore's Ground Control Station connected using SERIAL_UDB_EXTRA telemetry format, to a UAV DevBoard V3 running
MatrixPilot (revision 729 of trunk).
photos:
picasaweb.google.com/peter.hollands/Twinstar2Build#5547623052830239122
UAVDevBoard / MatrixPilot:
code.google.com/p/gentlenav/wiki/Home?tm=6
HK GCS:
code.google.com/p/happykillmore-gcs/
DIY Drones Store:
store.diydrones.com/HMC5843_Triple_Axis_Magnetometer_p/br-hmc5843-01.htm
Self Calibrating Mathematics, and software to integrate via I2c written by William Premerlani:-
diydrones.com/profile/WilliamPremerlani
Source Code:
code.google.com/p/gentlenav/source/browse/trunk/libUDB/magneto_udb.c
Comments
http://www.magnetic-declination.com/
Looks like Mavlink would be the way to go so I could see the live mag. output and there wouldn't have to be any postprocessing and trying to sinc "position with error" later. That's also a great idea to log a flight and see in FLAN if the plane's attitude from the magnetometer changes with a known throttle change.
Thanks,
Bryan
A an excerpt follows:-
"Why would we want to do the oversampling manually? The reason is that this IMU will be
mounted on a MAV containing electromotors. The strong electromagnetic field generated by
the motors is superimposed on the earth's magnetic field and the magnetic field measurement
is dominated by the field of the motors. The magnetic field of the motors has a maximum
frequency of 300Hz. Based on the sampling theorem the rotary field of the motors can be
completely reconstructed from the digital measurements if the magnetosensor is sampled at
a rate 600Hz. By appropriately low-pass filtering the signal the rotating field components
can be removed from the measurements yielding the direction of the earth's magnetic field.
If we can do this manually on the MCU, we can be sure that the low-pass filter is designed
correctly. If the oversampling is done inside the magnetosensor, we can only hope that high
frequencies are filtered correctly."
Good question. I personally have only just started testing out the magnetometer.
I think it would be good to run some tests. Only a few people have so far been using the magnetometer.
I think we can categorize the deviation into two types:-
1) "Steady State Deviation" relative to the magnetometer
2) "Variable Deviation" relative to the magnetometer position.
I believe, but I'm not quite sure, that Bill has type 1), Steady State Deviation, covered off in his mathematics and code. Bill wrote a good overview of Maths behind Magnetometer calibration in this document. So if you read that, you will see that the plane was meant to continuously re-calibrate the magnetometer's "offsets", every time the plane turns in any direction, by using the accurate yet transient information provided by the gyros. Bill uses the terminology of "offsets" rather than deviation, and so I have not quite worked out whether they are effectively the same thing. I have not personally verified that the code fully implements the ideas in Bill's mathematics.
The electric engine magnetism is going to be harder to deal with. It's constantly changing over time.
There are two aspects to the changing magnetism in an electic motor:-
a) Changes during every revolution
b) Changes as a result of throttling up and down.
I thought that I had read that the PixHawk team over sampled their magnetometer (they are also using the HMC 5843 )at at least twice the rate of their electric motor, to overcome some of the issues. I just looked for that information again, and could not find it. So I may have got that wrong.
When you fly with the magnetometer, SERIAL_UDB_EXTRA transmits the calculated magnetic vector in the earth frame of reference ( ma:, mb:, mc:) . This is then translated into the Google Earth (GE) representation (by flan.pyw), and you will find that you can switch on a GE later to show the horizontal (compass style) magnetic vector. So it is then fairly easy to see if it is moving around during flight when the engines go on and off. e.g. Look for a swing in the magnetic vector and / or the plane's reported orientation between paths of full throttle, and gliding (throttle off).
If you are doing tests, then you should know that the MAVLink branch of matrix pilot with telemetry set to SERIAL_MAVLINK will graph the raw magnetometer data for you in real time in QGroundCotnrol (i.e. in the reference of the plane / UDB board) at 4 times / second. You could easily move that up to 8 times / second or possibly faster. The vector will be correct, although the actual milligaus figure is about by 1.3. (I don't think it's worth doing the floating point arithmetic in the dspic). See my video demo of Mavlink for instructions. (The magnetic values were static in that demo, but they now work in the latest release).
Well I hope that helps you a little further down this journey. Best wishes, Pete
Have you experienced any error (deviation) based on where you place the magnetometer or when the motor is running?
I was thinking of running a test where everything is hooked up outside of the plane and there is a serial connection with a terminal program running. Bill's Mag Demo is running and spitting out the post processed data from the Mag in "serial-debug". Then I would move the plane around the set up and turn the motor on and off and see from the terminal info if there was any magnetic deviation.
Do you think all of this is necessary from your experience?
Thanks and thanks for the great video tutorials. I've watched them all!
Bryan
@HK Personally, I don't think we need a North Calibration offset in the GCS. The MatrixPIlot magnetometer options allows the user to dial in an offset (Declination also known as Variation) to allow for the fact that magnetic North is not aligned with true North.
Thanks for the Mavlink message list. I'll take a look at that later.
Please download my new version 1.0.18 which might handle the output speed a bit better. Not sure what the Hz is on the UDB but I was seeing some serious lag with the 50Hz output of the APM. This latest version handles the high speed much metter.
Also, do you think I should have a "set as north" type button to calibrate the 3D model for the direction you're flying? Sort of a heading offset that I could handle internally?