aa8mc

  • **
  • 50
Weird Magnetometer readings
« on: February 08, 2016, 07:29:18 pm »
This is my first multirotor build so I'm sure this is probably a noob oversight.  I am working on a Flamewheel F450 clone with a Revo and a generic UBLOX 7M based GPS.  I am running LibrePilot 15.09 on everything.  I got the quad running pretty well without the GPS save a little PID tuning.  I added the GPS, which I am reasonably sure doesnt have an aux magnetometer in it.  I plugged in the GPS and after a while i can get a pretty good fix with about 12 satellites just in my back yard.  Now I want to switch the attitude estimation algorithm so that I can use the GPS for Position Hold and the like.  When I switch over and reboot the board, I get critical alarms on ATTI, STAB and MAG.  I understand that in INS13 mode that ATTI and STAB are dependent on good GPS fix and magnetometer readings.  The GPS is green but MAG is red.  I set the home location.  I ran through the calibration procedures multiple times.  When I calibrate the magnetometer, the MAG light goes green and all is well...until I move the quad at all.  Then it goes red again. 

EDIT: Fixed the attachment
« Last Edit: February 08, 2016, 08:40:36 pm by caseyjmorton »
F450 Quad Clone
Outrunner1000KV Motors
HobbyWing FlyFun 30A ESCs
1045 Props
Telemetry via OP Link
FlySky FS-i6 transmitter w/ 10 channel mod
Sparky2 Flight controller
HobbyAce UBLOX 6M GPS
Running LibrePilot next branch
MinimOSD
FlySight Spexman FPV Goggles
Floureon 5500mAh LiPos

suzali

  • *
  • 41
Re: Weird Magnetometer readings
« Reply #1 on: February 08, 2016, 09:55:36 pm »
I have exactly the same issue  :-[

But I found out the following:
If vehicle is not moving the GPS position jumps slightly. This causes a gps-course and gps-speed value. The gps-course changes every few seconds. The magnetometer reports the right value. You can see the gps-course and gps-speed on the gps window. As soon as real mag-heading and gps-heading differ more than 5 degrees the alarm cahnges to orange, if the difference is greater than 15 degrees the warning gets red.(according to the pre defined values in gps setting)

Can anyone help ???

aa8mc

  • **
  • 50
Re: Weird Magnetometer readings
« Reply #2 on: February 08, 2016, 10:15:09 pm »
I'm wondering if it's just a matter of us having had the misfortune of buying cheap GPS modules.  I'm very seriously considering sending this one back and getting the more expensive one with an external antenna.
F450 Quad Clone
Outrunner1000KV Motors
HobbyWing FlyFun 30A ESCs
1045 Props
Telemetry via OP Link
FlySky FS-i6 transmitter w/ 10 channel mod
Sparky2 Flight controller
HobbyAce UBLOX 6M GPS
Running LibrePilot next branch
MinimOSD
FlySight Spexman FPV Goggles
Floureon 5500mAh LiPos

ogre55

  • *
  • 10
Re: Weird Magnetometer readings
« Reply #3 on: February 08, 2016, 11:19:51 pm »
I believe I might be having the same problems as you. whenever the GPS is enabled in the attitude algorithm the mag and ATTI sensors go crazy. I have tried calibrating and re-calibrating in different areas to see if there was interference, but had the same result. I uploaded a video of what was happening to YouTube.



any Ideas?
« Last Edit: February 08, 2016, 11:34:16 pm by ogre55 »

f5soh

  • *****
  • 4572
    • LibrePilot
Re: Weird Magnetometer readings
« Reply #4 on: February 08, 2016, 11:43:45 pm »
When you are using the Basic algorithm only Gyros and Accelerometers are taken in account.

Using INS13, all sensors are taken in account and your MAG is Red.
https://librepilot.atlassian.net/wiki/display/LPDOC/INS13+-+GPS+Navigation#INS13-GPSNavigation-Complementaryfilter

How did you set the HomeLocation ? I think i see a 0 altitude in Attitude page.

You need a MAG without alarms first at all.
Even if your MAG is ok you can't receive a reliable GPS data indoors: Position and Velocity stable.

You can validate the first 5 steps, move your quad around all axis and finally save the last step.





f5soh

  • *****
  • 4572
    • LibrePilot
Re: Weird Magnetometer readings
« Reply #5 on: February 08, 2016, 11:54:05 pm »
As soon as real mag-heading and gps-heading differ more than 5 degrees the alarm cahnges to orange, if the difference is greater than 15 degrees the warning gets red.(according to the pre defined values in gps setting)

GPS heading refers to path direction when the quad move, you can move backwards and facing at opposite. So in fact using a multirotor the GPS.heading and Mag.heading differs.
When steady the heading is not really defined but can do big jumps if you are indoors.

A small example where the data from both sensors do not match: https://youtu.be/EBAEDeS3200?t=23s

Using the World Mag Model the board know how is the vector that represent the mag vector expected from the home location. If differs from 5% (Orange), 15% (Red).


Re: Weird Magnetometer readings
« Reply #6 on: February 09, 2016, 02:45:28 am »
1) Twist all your high power wire pairs and triplets:  Battery to PDB, PDB to ESC, ESC to motor.  This will greatly reduce mag interference that only happens when large currents flow through these wires.  This does nothing to help the red mag when you are just sitting there.
2) Realise that it may not be possible to get good flight time mag health in a high power multicopter (lots of amps means lots of mag field from the wires) or in a mini or smaller quad (mag sensor is closer to the bad wiring) without using an external mag (typically part of a new GPS).
3) Calibrate your mags carefully; away from ground and metal.  Mag readings happen the whole time during mag calibration, not just when you press the button, so don't let the quad get close to ground or metal at any time during calibration.

Currently, the only external mag we support is on the OP V9 GPS.  We will be supporting more kinds of external mags in the next release.

aa8mc

  • **
  • 50
Re: Weird Magnetometer readings
« Reply #7 on: February 09, 2016, 02:55:23 am »
Thanks for the info.  I will try again tonight.  Out of curiosity when is the next release scheduled?
F450 Quad Clone
Outrunner1000KV Motors
HobbyWing FlyFun 30A ESCs
1045 Props
Telemetry via OP Link
FlySky FS-i6 transmitter w/ 10 channel mod
Sparky2 Flight controller
HobbyAce UBLOX 6M GPS
Running LibrePilot next branch
MinimOSD
FlySight Spexman FPV Goggles
Floureon 5500mAh LiPos

aa8mc

  • **
  • 50
Re: Weird Magnetometer readings
« Reply #8 on: February 09, 2016, 02:56:01 am »
And also where can I get my hands on an op v9?
F450 Quad Clone
Outrunner1000KV Motors
HobbyWing FlyFun 30A ESCs
1045 Props
Telemetry via OP Link
FlySky FS-i6 transmitter w/ 10 channel mod
Sparky2 Flight controller
HobbyAce UBLOX 6M GPS
Running LibrePilot next branch
MinimOSD
FlySight Spexman FPV Goggles
Floureon 5500mAh LiPos

aa8mc

  • **
  • 50
Re: Weird Magnetometer readings
« Reply #9 on: February 09, 2016, 04:42:48 am »
Ok so I am pretty sure I figured it out (at least in my case).  The last step of the mag calibration finishes with the board in a weird attitude (on one side). I guess this may be obvious to some but you need to bring it back to level before saving the calibration.
F450 Quad Clone
Outrunner1000KV Motors
HobbyWing FlyFun 30A ESCs
1045 Props
Telemetry via OP Link
FlySky FS-i6 transmitter w/ 10 channel mod
Sparky2 Flight controller
HobbyAce UBLOX 6M GPS
Running LibrePilot next branch
MinimOSD
FlySight Spexman FPV Goggles
Floureon 5500mAh LiPos

cato

  • *
  • 341
Re: Weird Magnetometer readings
« Reply #10 on: February 09, 2016, 11:32:25 am »
the v9 are not available anywhere at the moment, and to me it looks like the guys who built it have no intention to sell it anymore. Only way seems to be to get hold of a used one.

As the next version of Librepilot will support I2C Mag connection, it may not be necessary to try to get a V9. I am about to try a setup of that type. The only problem I see is that there seems quite a quality difference with M8N GPS. I have one which is super quick and very reliable, while the other continues to be slow and not very precise. There is a revo clone thread here where you can find ebay links which seem to sell good quality revo with good gps (my good one is from ebay).
Nighthawk 250, MT1806, 12A ESC OneShot125, Revo, M8n GPS, FPV
Cinetank MKII, Elite 2216, 30A Afro OneShot125, Revo Clone, M8N GPS

aa8mc

  • **
  • 50
Re: Weird Magnetometer readings
« Reply #11 on: February 09, 2016, 01:12:40 pm »
Good to know.  As a software developer my self I have been thinking about rolling my own from the Next branch.  I saw a pretty sweet video on YouTube of the terrain view in the PFD. Any idea as to the current stability of the rev branch?
F450 Quad Clone
Outrunner1000KV Motors
HobbyWing FlyFun 30A ESCs
1045 Props
Telemetry via OP Link
FlySky FS-i6 transmitter w/ 10 channel mod
Sparky2 Flight controller
HobbyAce UBLOX 6M GPS
Running LibrePilot next branch
MinimOSD
FlySight Spexman FPV Goggles
Floureon 5500mAh LiPos

aa8mc

  • **
  • 50
Weird Magnetometer readings
« Reply #12 on: February 16, 2016, 02:06:56 am »
Ok so I guess not so much on having solved the issue.  My new GPS came in and I got it and the external I2C mag wired.  I got the next branch built and all my firmwares upgraded and configured.  I confirmed that the mag is returning a solid vector and that the arrow is pointing forward on the GPS.  Ran through the full calibration routine.  I'm hoping that currents shouldn't be affecting the mag since its on a stick about 15cm above the main deck.  The mag is giving a green status and but I'm still getting pretty erratic readings for overall attitude.  The artificial horizon typically shows about 45 or so degrees off level. I also see a moderate oscillation.  When I look at the scopes the attitude shows perfect sine waves, which from reading the EKF documentation I believe means that 2 sensors with the same priority are returning conflicting values.  From the docs I also see that the way to remedy this is to change the priorities on your sensors, but that this is really a bandage on a larger problem which is the fact that the sensors are colliding.  Also, it should be noted that when I put the Revo in Complementary mode, everything is as I would expect.

So I now have 3 questions:

1.  How do I set different priorities on the sensors for the EKF algorithm?

2.  Is there an good/easy way to debug the values from the sensors? 

The GPS values seem ok/reasonable.  I'm assuming the gyros and accelerometers are ok since complementary mode seems fine (maybe this is a bad assumption).  Based on these assumptions I'm guessing that the issue lies within either the Baro or the Mag.  Also I keep seeing references to Chinese Revo boards that have a bad capacitor in them.  Unfortunately all of the references I have seen point back to the old OP forums, which are now defunct.  Can anyone provide some insight into this?  Is it possible that this is being caused by one such board?

Casey
« Last Edit: February 16, 2016, 02:51:46 am by caseyjmorton »
F450 Quad Clone
Outrunner1000KV Motors
HobbyWing FlyFun 30A ESCs
1045 Props
Telemetry via OP Link
FlySky FS-i6 transmitter w/ 10 channel mod
Sparky2 Flight controller
HobbyAce UBLOX 6M GPS
Running LibrePilot next branch
MinimOSD
FlySight Spexman FPV Goggles
Floureon 5500mAh LiPos

Re: Weird Magnetometer readings
« Reply #13 on: February 19, 2016, 08:53:15 pm »
I fly the aux mag code all the time.  The keys to success are:
- build with all high power wire pairs/triplets (battery to PDB, PDB to ESC, ESC to motor) twisted and a good PDB that does not produce mag field.
- set mag orientation correctly !!! this is not 0,0,0 for most aux mags ! It is usually 180 on roll or pitch, I forget which
- good mag calibration (never close to ground/car/etc the whole time calibration is running, not just save points, done via telemetry)
- use aux mag only if you have an aux mag
- allow GPS to run 15 minutes in open area outside before first flight of the day (download almanac), 3 minutes there before each flight after that

GPS / aux mag on a pole helps the mag issue.

Even the cheap GPS / mag units have good mags in them.

There is no user way to tune the strength of GPS and mags.  The way it was done requires you to tune the EKF.  Without a math degree or willingness to research EKF nomenclature and tuning, you shouldn't go there.  :)  But it is in GCS->System->Settings->EKFConfiguration.  Honestly, do all the stuff at the top and it will fly without touching this.

FakeR is the R that is used by "Indoor EKF".  It is used to ignore the GPS.

Re: Weird Magnetometer readings
« Reply #14 on: February 19, 2016, 08:57:08 pm »
Here is the aux mag setup doc I wrote.  It was posted for FTT.  I will add it to wiki.