LibrePilot Forum

Users => Vehicles - MultiRotors => Topic started by: Jacarebs on March 18, 2017, 08:28:12 am

Title: AuxMag won't get a decent orientation
Post by: Jacarebs on March 18, 2017, 08:28:12 am
Hey! I've been struggling to fly my drone, since the mag won't get calibrated, I think. I used this video as a guideline on how to calibrate the AuxMag on my Ublox 6m GPS:

https://www.youtube.com/watch?v=o4V_ZGG0Hk0 (https://www.youtube.com/watch?v=o4V_ZGG0Hk0)

I can pretty much nail it down, but as soon as I move the drone in the yaw axis, the mag reading start to get wrose and worse, until I rotate it by roughly 180 degrees, then it starts lowering the error percentage again. I've also tried to correct the AuxMag orientation and I could manage to get the bargraphs down to 0, but as soon as I move the drone, they start to go off by way more than 10 units.

I just want to fly my drone and I've spent way more than 100hrs trying to build this drone. The only thing that keeps me from flying it is this damn mag. I could fly it before when I was at the beach, somehow I could get the calibrations right, but as soon as I got back to the city, I tried taking off with it and I saw, by the LibrePilot app, that themag readings were red. I tried taking off anyway and it just flew erratically and I ended up crashing-landing it. It wasn't too bad, it is still in one piece, but I got pretty frustrated when I tried recalibrating it and could not get it working.

What am I missing? I'm calibrating it in my bedroom, attached to my laptop by a 1.5m USB cable. The AuxMag is sitting with the GPS up in a pole, tightly fixed.

Please help!
Title: Re: AuxMag won't get a decent orientation
Post by: Mateusz on March 18, 2017, 04:14:07 pm
To adjust orientation of AuxMag to match internal Mag you need first good calibration of both magnetometers.


Best is if you take it outdoors, use OP-link modem and attach battery. Keep it in the air and rotate it slowly without putting on the ground. You don't need to follow instructions in wizard, you can just click to last step (6th step) and rotate it slowly in all possible directions, then finish last step to save calibration.

If that is done correctly, then you can adjust AuxMag rotations, to have bars at zero. If you still don't have bars at zero, then there are high power currents messing up one Mag readouts. Basically Mag must be green all time, to be able to adjust AuxMag rotation. (On the movie both mags <0.5% error in green boxes).
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 18, 2017, 06:11:19 pm
To adjust orientation of AuxMag to match internal Mag you need first good calibration of both magnetometers.

  • You can't have good mag calibration if you put your copter on floor while it's calibrating or too close to metal items/wires
  • Calibration collects samples all time from start, not just when it asks you to rotate copter, so any disturbance will cause error

Best is if you take it outdoors, use OP-link modem and attach battery. Keep it in the air and rotate it slowly without putting on the ground. You don't need to follow instructions in wizard, you can just click to last step (6th step) and rotate it slowly in all possible directions, then finish last step to save calibration.

If that is done correctly, then you can adjust AuxMag rotations, to have bars at zero. If you still don't have bars at zero, then there are high power currents messing up one Mag readouts. Basically Mag must be green all time, to be able to adjust AuxMag rotation. (On the movie both mags <0.5% error in green boxes).

Yeah, I get that the mag is capturing data all the time and I can skip to the 6th step and rotate it, I've been using this method lately. The problem is that I don't think my OP-link is working anymore... is there a way that I could do it without it? With, like, a really long USB cable? I will try to do it outdoors today and see what comes out of it.

Yeah he's got less than 0.5% of error, but he has his board outside his drone. Should I do it as well or should I keep my board in my drone?

Thanks!
Title: Re: AuxMag won't get a decent orientation
Post by: Mateusz on March 18, 2017, 06:48:57 pm
Yeah he's got less than 0.5% of error, but he has his board outside his drone. Should I do it as well or should I keep my board in my drone?

The whole purpose of calibration is to account for quad-copter itself. So taking FC out from quad for calibration would defeat the purpose. I think the movie is just for demonstration how to do alignment of two magnetometers. For that it is required to have good calibration. But it's not how calibration should be done for flight purpose.

Magnetometer is sensitive to metals, conductors or whole quad-copter frame. Also both mags must have fixed position. All bodies nearby magnetometer are taken into account when doing calibration, so magnetometer gets cleaner picture. What cannot be accounted for is changing magnetic field. Changing magnetic field comes from wires conducting electricity for example motors pulling more or less current when motors spin faster/slower. That cannot be removed by calibration and is the reason why you need magnetometer far from these sources.

But once your have good mag calibration, you can find rotations. Rotations are needed to tell software how external magnetometer is mounted as every manufacture can place it differently. Internal magnetometer is convenient tool for that, as it's orientation is known. When both mags are aligned, both show the same curves in scopes and both bars are at zeros.


I forgot one more thing. The only way to isolate from magnetic field is couple of meters of concrete wall. You can't do that on quad-copter, but you can redirect magnetic field, by making it weaker in one direction and stronger in another. Direction of magnetic field is like on (see attached Fig1). If you twist wires then you make magnetic field weaker in the direction perpendicular to the horizontally twisted wires (see attached Fig2). In Fig1 magnetic field is stronger in the direction perpendicular to wires.
That's why people often twist higher current wires if they run below magnetometer. It may help. I don't recommend surfaces that redirect static field (nu-metal) as that would isolate  your magnetometer. You would probably get less interference from motors but magnetometer would sense only noise.
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 18, 2017, 07:45:47 pm
Yeah he's got less than 0.5% of error, but he has his board outside his drone. Should I do it as well or should I keep my board in my drone?

The whole purpose of calibration is to account for quad-copter itself. So taking FC out from quad for calibration would defeat the purpose. I think the movie is just for demonstration how to do alignment of two magnetometers. For that it is required to have good calibration. But it's not how calibration should be done for flight purpose.

Magnetometer is sensitive to metals, conductors or whole quad-copter frame. Also both mags must have fixed position. All bodies nearby magnetometer are taken into account when doing calibration, so magnetometer gets cleaner picture. What cannot be accounted for is changing magnetic field. Changing magnetic field comes from wires conducting electricity for example motors pulling more or less current when motors spin faster/slower. That cannot be removed by calibration and is the reason why you need magnetometer far from these sources.

But once your have good mag calibration, you can find rotations. Rotations are needed to tell software how external magnetometer is mounted as every manufacture can place it differently. Internal magnetometer is convenient tool for that, as it's orientation is known. When both mags are aligned, both show the same curves in scopes and both bars are at zeros.


I forgot one more thing. The only way to isolate from magnetic field is couple of meters of concrete wall. You can't do that on quad-copter, but you can redirect magnetic field, by making it weaker in one direction and stronger in another. Direction of magnetic field is like on (see attached Fig1). If you twist wires then you make magnetic field weaker in the direction perpendicular to the horizontally twisted wires (see attached Fig2). In Fig1 magnetic field is stronger in the direction perpendicular to wires.
That's why people often twist higher current wires if they run below magnetometer. It may help. I don't recommend surfaces that redirect static field (nu-metal) as that would isolate  your magnetometer. You would probably get less interference from motors but magnetometer would sense only noise.

Yeah, I've seen people twisting their wires and I get the physics around it, but since I can't event calibrate it when the motors are not spinning, I don't really think that the magnetic field generated by powering the escs are actually being the real problem; I think that I'm not calibrating it properly. I just calibrated it outside and I asked a friend to hold the drone while I skipped to the 6th phase of the calibration. Then I took the drone and gently rotated it in all directions possible 2 times and then I asked my friend to hold it again and I saved the last position. After that, I just put it on the ground and tried to get the orientation of the AuxMag correctly. As you can see in figure 1, the mag of my GPS is in the bottom of the GPS board, so it has 180 degrees of roll rotation. In figure  2 and 3, you can see that the GPS is rotated in the yaw axle by -145 degrees, roughly, considering that the white wings are the positive region and that the red wings are the negative region; note that the FC is pointed to the white wings, so it has a 90 degree rotation in the yaw axle. The problem is that when I input this information, the bargraphs do not align. Also, even though I got an error margin of 2% at max after the calibration, as soon as I rotate the drone, the readings go off the chart, reaching as high as 50~60% of error. To be honest, this part of the process has always been a problem and I could never get this right. Do you think my auxmag could be broken? I don't think it is, since it reads the values, but I'm nearly giving up and buying another GPS. Could you describe me how you calibrate your mags or what could I do?

Thanks for the help, man.
Title: Re: AuxMag won't get a decent orientation
Post by: Mateusz on March 19, 2017, 06:55:53 am
You can take two small papers and draw on them (USB port, Bottom/Top, FC/GPS and L833 chip orientation) see attachment.
To match both L883, I did +180 roll and -45 yaw of the paper with GPS label on it.

If you do -145 that's very strange rotation. It's 45 deg then another 100deg. But board is square and chip is perpendicular to it's edges, so extra 10 deg makes no sense to me. I am not sure in which direction + or - is, but you could try a couple of combinations.

Maybe just give a try +180 roll and -45 yaw and if that does not work, check other +/- options ?
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 19, 2017, 07:51:17 am
You can take two small papers and draw on them (USB port, Bottom/Top, FC/GPS and L833 chip orientation) see attachment.
To match both L883, I did +180 roll and -45 yaw of the paper with GPS label on it.

If you do -145 that's very strange rotation. It's 45 deg then another 100deg. But board is square and chip is perpendicular to it's edges, so extra 10 deg makes no sense to me. I am not sure in which direction + or - is, but you could try a couple of combinations.

Maybe just give a try +180 roll and -45 yaw and if that does not work, check other +/- options ?

Well, I tried a lot of combinations and neither of them worked. I got my aux mag calibrated though, it seems, because I do not get red alarms in it, even at 1m from my laptop. I think that I just need to calibrate the onboard mag and see if I can match their rotations. Does the onboard mag calibrates at the same time with the aux mag or I need to take off my aux mag to calibrate the onboard one?

I tried flying my drone today with the aux mag only to see what would happen and it actually took off, but it was quite erratic: I was flying a stabilized mode with GPS assist and attitude/attitude/axislock/alitudevario as its configuration and the drone would keep drifting and going towards the wall or something and up or down, so I would need to compensate for it constantly. I tried to switch to PositionHold after taking off and it went on in circles.

Do you think that my problems reside on my mag configuration?
Title: Re: AuxMag won't get a decent orientation
Post by: Mateusz on March 19, 2017, 09:11:01 am
Well, I tried a lot of combinations and neither of them worked.

Roll 180 and yaw -45 also didnt work ? Flight controller and GPS have the same magnetometer chip. If they both point in the same direction, then rotation is 0,0,0. What you set in GCS is the rotation for external (aux) mag.

I got my aux mag calibrated though, it seems, because I do not get red alarms in it, even at 1m from my laptop. I think that I just need to calibrate the onboard mag and see if I can match their rotations. Does the onboard mag calibrates at the same time with the aux mag or I need to take off my aux mag to calibrate the onboard one?

From what I remember you need to select "Use Both" magnetometers to get the calibrated together at the same time. And that's the correct way to do it.

I tried to switch to PositionHold after taking off and it went on in circles.
Do you think that my problems reside on my mag configuration?

Flying in circles so called toilet bowl is typical to bad calibration of magnetometer or bad mag readings. I doubt your rotations are correct, 145 deg makes no sense to me.
If you have all sensors telling EKF that front is front and Mag tells front is back. Then you get oscillations in EKF states and toilet bowl.
If you look inside flight controller you see chip L883 (dot). So if you imagine that reading this from left to right and above that label is forward direction, you have to match that with the same chip on GPS module. If I am not wrong I think it's 180 roll and +45 or -45 yaw.

How is the horizon in PDF behaving ? Are the scopes showing the same pattern when you rotate copter in all directions ? X,Y,Z for MagSensor should follow exactly X,Y,Z lines for AuxMagSensor if you set rotations correctly.
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 19, 2017, 06:33:51 pm
Roll 180 and yaw -45 also didnt work ? Flight controller and GPS have the same magnetometer chip. If they both point in the same direction, then rotation is 0,0,0. What you set in GCS is the rotation for external (aux) mag.

Nah, unfortunately the 180/-45 didn't work... I followed your example yesterday and I was trying to figure out the rotation of the mag, but since I don't think the onboard mag is calibrated, it was worthless to continue until I get it calibrated.

From what I remember you need to select "Use Both" magnetometers to get the calibrated together at the same time. And that's the correct way to do it.

Oh. I was actually selecting AuxOnly. Well, I'll calibrate it again today with both and see what comes out of it. Thanks :D. Oh, by the way, do you know somehing about virtual board orientation? Do I need to set something other than 0,0,0 if the FC is actually pointing forward?

Flying in circles so called toilet bowl is typical to bad calibration of magnetometer or bad mag readings. I doubt your rotations are correct, 145 deg makes no sense to me.
If you have all sensors telling EKF that front is front and Mag tells front is back. Then you get oscillations in EKF states and toilet bowl.
If you look inside flight controller you see chip L883 (dot). So if you imagine that reading this from left to right and above that label is forward direction, you have to match that with the same chip on GPS module. If I am not wrong I think it's 180 roll and +45 or -45 yaw.

How is the horizon in PDF behaving ? Are the scopes showing the same pattern when you rotate copter in all directions ? X,Y,Z for MagSensor should follow exactly X,Y,Z lines for AuxMagSensor if you set rotations correctly.

Well, then we seem to have found the culprit to why all these things are happening: it really is the mag, then. The horizon is pretty neat, even though it wiggles a bit even when the drone is stopped. The scopes are shown on figure 1 when it is pointing towards me and on figure 2 when it is pointing to the right. It should not move, right?

Thanks
Title: Re: AuxMag won't get a decent orientation
Post by: Mateusz on March 19, 2017, 07:19:17 pm
Oh. I was actually selecting AuxOnly. Well, I'll calibrate it again today with both and see what comes out of it. Thanks :D. Oh, by the way, do you know somehing about virtual board orientation? Do I need to set something other than 0,0,0 if the FC is actually pointing forward?

No if FC is flat and pointing forward you don't need to touch virtual board rotation. It's only for FC. In future if you would rotate your FC and adjust virtual board rotation, you would need to adjust also AuxMag rotation. In your case you don't touch virtual board rotation, as your FC is pointing forward already (front motors 1 and 2).

Well, then we seem to have found the culprit to why all these things are happening: it really is the mag, then. The horizon is pretty neat, even though it wiggles a bit even when the drone is stopped. The scopes are shown on figure 1 when it is pointing towards me and on figure 2 when it is pointing to the right. It should not move, right?

Magnetomer is like a digital compass it's measure a vector [x,y,z] in 3D space pointing where strongest magnetic field is (preferably north). So when you rotate it then these x,y,z curves should also change. What I see on your scopes is that MagSensor.x goes up and at the same time AuxSensorMag.x goes down in opposite direction. This means one has different orientation. When they are both aligned and have matched orientation curves from aux/internal behave the same (x follows other x, y follows other y etc..). Both magnetometers must give the same information, not conflicting. So when you turned it, both MagSensor.x and AuxSensorMag.x should go either up or down but together and not opposite directions.
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 19, 2017, 07:33:13 pm
No if FC is flat and pointing forward you don't need to touch virtual board rotation. It's only for FC. In future if you would rotate your FC and adjust virtual board rotation, you would need to adjust also AuxMag rotation. In your case you don't touch virtual board rotation, as your FC is pointing forward already (front motors 1 and 2).

Well, then I won't mess with it :). Thanks.

Magnetomer is like a digital compass it's measure a vector [x,y,z] in 3D space pointing where strongest magnetic field is (preferably north). So when you rotate it then these x,y,z curves should also change. What I see on your scopes is that MagSensor.x goes up and at the same time AuxSensorMag.x goes down in opposite direction. This means one has different orientation. When they are both aligned and have matched orientation curves from aux/internal behave the same (x follows other x, y follows other y etc..). Both magnetometers must give the same information, not conflicting. So when you turned it, both MagSensor.x and AuxSensorMag.x should go either up or down but together and not opposite directions.

Oh, I get it now. Well, I will try to calibrate it today with both mags active at the same time - by selecting Both in mag usage, on the Magnetometer tab - and I will post the results.

Thanks a lot :)
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 19, 2017, 08:36:49 pm
Ok, I just tried calibrating it again and this time both mags wouldn't give me a red warning at any time. They would give me orange warnings sometimes, but not a red. However, the orange warnings would go as high as 11%. Well, I tried getting the orientation right and it would not work again, with any combination. I tried flying it again and it would fly worse than before, I couldn't even take off properly, it would either flip to the side or take off and fly away in a direction.

On a side note: I noticed that sometimes a motor will spin really slowly before taking off, so I always need to apply a roll command to make it spin normally, and it has always occurred, even from day 1 of this drone.

Do you think any of my sensors are broken or something? If I could log a flight on LP, would it help? If so, do you know how I could do it?
Title: Re: AuxMag won't get a decent orientation
Post by: Mateusz on March 19, 2017, 08:45:10 pm
Orange is 11% is not good. Must be green all time. Did you calibrate it indoors perhaps ? Are you trying to fly indoors ? For flying you should set it to AuxOnly, cause internal one will read bad stuff when motors are running. Just use both for calibration and setting rotations when motors are not running, then switch to AuxOnly.
What we know is that AuxMag is flipped 180 deg, cause it's bottom of GPS board, and Mag on FC is top. So you just need to roll it 180 deg and then adjust yaw. Then you should see curves in scopes behaving the same, do they ?

Be careful with USB cable, not to break micro-usb port on Revo, it can rip off if you pull cable accidentally.

One more thing that comes into my mind. You use I2C for aux-mag right ? Can you check scopes by adding I2CStatus UAVObject and checking if there are no event_errors or timeouts ? Is I2C box always green ?
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 19, 2017, 09:02:50 pm
Orange is 11% is not good. Must be green all time. Did you calibrate it indoors perhaps ? Are you trying to fly indoors ? For flying you should set it to AuxOnly, cause internal one will read bad stuff when motors are running. Just use both for calibration and setting rotations when motors are not running, then switch to AuxOnly.
What we know is that AuxMag is flipped 180 deg, cause it's bottom of GPS board, and Mag on FC is top. So you just need to roll it 180 deg and then adjust yaw. Then you should see curves in scopes behaving the same, do they ?

Be careful with USB cable, not to break micro-usb port on Revo, it can rip off if you pull cable accidentally.

I did it outdoors, on the penthouse of my apartment building, with clear skies. I calibrated and tried the rotations with it set to Both and motors stopped. Then, I tried to fly it with it set to AuxOnly.

In figure 1, it was facing me and then I rotated it to face right. Notice that the onboard mag seems constant. I tried zooming in and the values were really not changing.
Title: Re: AuxMag won't get a decent orientation
Post by: Mateusz on March 19, 2017, 09:06:52 pm
I did it outdoors, on the penthouse of my apartment building, with clear skies. I calibrated and tried the rotations with it set to Both and motors stopped. Then, I tried to fly it with it set to AuxOnly.

In figure 1, it was facing me and then I rotated it to face right. Notice that the onboard mag seems constant. I tried zooming in and the values were really not changing.

Indeed this looks interesting. Can you change colors, so they're not the same as AuxMag for Mag ? To me it looks like AuxMag is constant on this plot.
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 19, 2017, 09:16:51 pm

Indeed this looks interesting. Can you change colors, so they're not the same as AuxMag for Mag ? To me it looks like AuxMag is constant on this plot.

Sure. Figure 1 shows the graph with different colors, see if that's better. The drone was facing right and I rotated it to face me. Note that the X and Y on the onboard mag are almost overlapping
Title: Re: AuxMag won't get a decent orientation
Post by: Mateusz on March 19, 2017, 09:30:23 pm
Sure. Figure 1 shows the graph with different colors, see if that's better. The drone was facing right and I rotated it to face me. Note that the X and Y on the onboard mag are almost overlapping

Stupid question :) Is this with Use Both, or just AuxMag ? ;)
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 19, 2017, 09:33:28 pm
Stupid question :) Is this with Use Both, or just AuxMag ? ;)

I just tried with both and they have the same behaviour. It doesn't seem to make a difference :/
Title: Re: AuxMag won't get a decent orientation
Post by: Mateusz on March 19, 2017, 09:39:58 pm
I just tried with both and they have the same behaviour. It doesn't seem to make a difference :/

If you disconnect external mag, and reboot board just to be sure. Does internal mag show any  behaviour ? If on-board Mag is broken then you can't use it to determin rotations, and you would need to use AuxOnly mag, and guess rotations somehow by looking at the chip... That would explain why you couldn't get bars to zero, as internal mag wasn't giving any read-outs and wasn't valid reference...
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 19, 2017, 09:45:39 pm
If you disconnect external mag, and reboot board just to be sure. Does internal mag show any  behaviour ? If on-board Mag is broken then you can't use it to determin rotations, and you would need to use AuxOnly mag, and guess rotations somehow by looking at the chip... That would explain why you couldn't get bars to zero, as internal mag wasn't giving any read-outs and wasn't valid reference...

Oh, I think that my onboard mag is dead, hahahaha. Just look at the attached image. Well, that really explains a lot on why I couldn't get the right rotations and everything. Hmm, does it means that I should ditch my FC and buy a new one?
Title: Re: AuxMag won't get a decent orientation
Post by: f5soh on March 19, 2017, 09:50:14 pm
Please post your config file
File > Export UAV data

Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 19, 2017, 09:54:40 pm
Please post your config file
File > Export UAV data

Right away.

Title: Re: AuxMag won't get a decent orientation
Post by: f5soh on March 19, 2017, 10:08:33 pm
The onboard mag calibration number are really strange.
Be sure there is not magnetic device around in your frame, like buzzer.

Your Auxmag calibration looks fine, you can easily adjust the AuxMag orientation settings the fusion algorithm to INSIndoor and look at heading in PFD if matches the North for example. (with frame pointing North)

Roll=180 is fine, you just need to adjust the Yaw value for a matching heading.
Title: Re: AuxMag won't get a decent orientation
Post by: Mateusz on March 19, 2017, 10:28:05 pm
External Mag
Code: [Select]
<field name="mag_bias" values="-319.968201,181.037781,-30.0836201"/>

Internal Mag
Code: [Select]
<field name="mag_bias" values="-44.587059,5.03997326,6849.60059"/>

f5soh has a point, maybe something with very strong magnetic field nearby... and before you showed mag2.JPG that both mags showed some response, so it's unlikely internal one broke just now.
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 19, 2017, 10:34:25 pm
The onboard mag calibration number are really strange.
Be sure there is not magnetic device around in your frame, like buzzer.

Your Auxmag calibration looks fine, you can easily adjust the AuxMag orientation settings the fusion algorithm to INSIndoor and look at heading in PFD if matches the North for example.

Roll=180 is fine, you just need to adjust the Yaw value for a matching heading.

Well, I have a voltage reader on the leg of my drone that beeps when the voltage is too low; is this considered a buzzer? I had to set Roll=180 and Yaw=-90 to get the right heading. It points North just fine with that, is this ok?

External Mag
Code: [Select]
<field name="mag_bias" values="-319.968201,181.037781,-30.0836201"/>

Internal Mag
Code: [Select]
<field name="mag_bias" values="-44.587059,5.03997326,6849.60059"/>

f5soh has a point, maybe something with very strong magnetic field nearby... and before you showed mag2.JPG that both mags showed some response, so it's unlikely internal one broke just now.

Let's just hope that it is not broken! Hmm, the battery is, like, RIGHT UNDER the FC. Would that be a problem?
Title: Re: AuxMag won't get a decent orientation
Post by: f5soh on March 19, 2017, 10:45:10 pm
yes, a Lipo saver has a buzzer and magnetic fields.

Your onboard Mag is saturated.

You can reset the onboard Mag calibratio, go to the UAVOBrowser:
Set all the RevoCalibration > mag_bias values to 0 and
RevoCalibration mag_transform to 1,0,0,0,1,0,0,0,1

(https://forum.librepilot.org/index.php?action=dlattach;topic=3239.0;attach=5588)

Look the value on scope for MagSensor, if you see value above 500 you can assume there is some magnetic disturbance around.


Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 19, 2017, 10:58:41 pm
yes, a Lipo saver has a buzzer and magnetic fields.

Your onboard Mag is saturated.

You can reset the onboard Mag calibratio, go to the UAVOBrowser:
Set all the RevoCalibration > mag_bias values to 0 and
RevoCalibration mag_transform to 1,0,0,0,1,0,0,0,1

Look the value on scope for MagSensor, if you see value above 500 you can assume there is some magnetic disturbance around.

Wow, nice. I did what you said and I just got these values when pointing it nearly to west.  The highest line is the y variable of the onboard mag. What could be the magnetic disturbance? I took off the buzzer and it is still the same. Keep in mind that the onboard mag is not calibrated, tho.
Title: Re: AuxMag won't get a decent orientation
Post by: f5soh on March 19, 2017, 11:06:01 pm
Redo calibration

No need to quote a post that's just above
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 19, 2017, 11:10:37 pm
It's kinda late in here, so I don't know if I will be able to calibrate it today, but I will get it done asap and post the results when I calibrate it.

Thanks a lot :).

PS: Oh. I was just quoting to make sure it was clear, hehe.
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 21, 2017, 02:11:49 am
Ok, I just did the calibration and almost everything seems fine, besides the fact that the X coordinate on the onboard mag seems tilted, but it working and that the Y coordinate on the onboard mag doesn't move. the Z coordinate seems fine and behaves like the one on the aux mag.

Well, I will try it again and post the results as I go.

@EDIT: on the second time, things went better, but still wrong.

@EDIT#2: Well, I spent nearly 3 hours trying to calibrate it. I have even used the LP app, alpha version, to try calibrating it and see if something comes up. In the end, the app just seems to introduce many more errors, so I just stuck with my laptop. I concluded that no matter how I calibrate it, and I tried many different forms, the onboard mag may get really good readings and a really low (like 2% or something) error percentage when it is facing one side, but as soon as I rotate it, it WILL begin to give absurdly wrong readings on the onboard mag. The AuxMag seems to suffer from it too, but to a no comparable lower extent.

Is there something I can do?
Title: Re: AuxMag won't get a decent orientation
Post by: Mateusz on March 21, 2017, 08:36:44 am
What rotations do you put in ? Scopes will only agree when all  rotations are correct and neither of Mags is saturated by some stronger magnetic field nearby.
You need both conditions simultaneously, good rotations and no magnetic interference.

You have quite a few options, but I guess you thought about them already

You don't need internal Mag for flight, the only time you need it is to determine correct rotations for the AuxMag. If AuxMag rotations are wrong, then measurement might be pointing in completely another direction then it should be. One way or the other, you just need to get these rotations right, whole thing does not need to be even mounted in frame but must only be oriented the same way. Once you have values correct, you can put that back in and calibrate AuxMag, set it to "Use Aux Only" and keep fingers crossed that external one is not affected by strong magnetic field source.

Companies such as DJI have magnetometer in Phantom installed in landing gear http://wiki.dji.com/en/index.php/Phantom-Mount_the_Landing_Gear_with_the_Compass_Module
This is also to avoid magnetic interference from power distribution board and motors. Anything that performs switching of current, generates magnetic field, same with power lines and of course magnets often used in buzzers.

You need to experiment a bit. Maybe someone else can help more...
Title: Re: AuxMag won't get a decent orientation
Post by: TheOtherCliff on March 21, 2017, 09:05:49 am
All the Pixhawk I2C Aux mags should use either 180,0,180 for board rotation or 0,180,0 (they are the same 3D rotation) if the GPS/mag is mounted normally.  At least all the ones I have tested use this.

Board rotation does not affect the health of the mag, but if rotation is wrong, the PFD / HUD will go crazy in INS13 (Outdoor) mode.

By the way you should be using INS13 (Outdoor) mode.  I assume from the posts I read that you have a Revo class FC.

https://librepilot.atlassian.net/wiki/display/LPDOC/Aux+Mag+Setup+and+Calibration
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 22, 2017, 05:29:41 am
What rotations do you put in ? Scopes will only agree when all  rotations are correct and neither of Mags is saturated by some stronger magnetic field nearby.
You need both conditions simultaneously, good rotations and no magnetic interference.

You have quite a few options, but I guess you thought about them already
  • Do calibration outside of frame just to determine correct rotations
  • Do calibration outside of frame with small HM5883L chip (L883 symbol) if you have one at hand and can place it same way as is on GPS just to determine correct AuxMag rotations
  • Use FC or mobile phone app to determine source of magnetic interference
  • Mount FC in different place

You don't need internal Mag for flight, the only time you need it is to determine correct rotations for the AuxMag. If AuxMag rotations are wrong, then measurement might be pointing in completely another direction then it should be. One way or the other, you just need to get these rotations right, whole thing does not need to be even mounted in frame but must only be oriented the same way. Once you have values correct, you can put that back in and calibrate AuxMag, set it to "Use Aux Only" and keep fingers crossed that external one is not affected by strong magnetic field source.

Companies such as DJI have magnetometer in Phantom installed in landing gear http://wiki.dji.com/en/index.php/Phantom-Mount_the_Landing_Gear_with_the_Compass_Module
This is also to avoid magnetic interference from power distribution board and motors. Anything that performs switching of current, generates magnetic field, same with power lines and of course magnets often used in buzzers.

You need to experiment a bit. Maybe someone else can help more...

I've been putting 180,0,-90, but does it matter when I rotate the drone and the readings simply go nuts? I mean, are the error percentages on the Magnetometer tab directly linked to the rotations or they are independent of it? because if they are, they may be a really strong cause of the high error percentages I'm getting. I may try to take the FC out of the drone to see if it makes any difference calibrating, but I don't think I will be able to maintain this calibration, since none of the electric circuits will be involved and the tutorials always says that I should do it while the FC is on the drone.

I haven't got an HM5883L chip at hand :/. I could buy it, but it'd run me at least for 50 bucks in here, maybe more.

Well, I will take the FC out of the drone the next time I lay my hand on it and see what comes out of it. As I recall, that's how I managed to get good readings last time. I will try it soon and post the results. Thanks for the idea :).

All the Pixhawk I2C Aux mags should use either 180,0,180 for board rotation or 0,180,0 (they are the same 3D rotation) if the GPS/mag is mounted normally.  At least all the ones I have tested use this.

Board rotation does not affect the health of the mag, but if rotation is wrong, the PFD / HUD will go crazy in INS13 (Outdoor) mode.

By the way you should be using INS13 (Outdoor) mode.  I assume from the posts I read that you have a Revo class FC.

https://librepilot.atlassian.net/wiki/display/LPDOC/Aux+Mag+Setup+and+Calibration

Yeah, I do have a Revo FC and I've been using INS13 (Outdoor) mode. I've been on that page and read it already, but my problem is not the AuxMag, I've always managed to get good readings on that one. The problem is mainly on the onboard mag, which always gets bad readings, but thanks for the help anyways. As I said to Mateusz, I will take the FC out of the drone and try to calibrate the mag to see how it goes.

I will post results as soon as I get the calibration of the mag done outside of the drone.
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 22, 2017, 06:29:46 am
BEHOLD, FOR I HAVE GOT A PERFECT CALIBRATION.

Ok, so it seems that my frame may have some issues. I just took the FC and the AuxMag out of the drone and tried calibrating it. On my first try, I got 6% max error and the rotations just worked flawlessly with 180,0,-45. The board is simply behaving just like it should, as weird as it may seem. Well, my friends, we seem to have found that I have a magnetic issue on my frame, didn't we? Now, do you guys have any tips about how to solve it?

Thanks a lot!!! I'm really excited to know that the board and the AuxMag aren't broken :DD

@EDIT: ok, I just have disassembled every bit of my drone and found the cause of the problems: my gimbal simply has a HUGE magnetic field interference. As soon as I get it near my board, it just moves from 0.5% to 100% error in a heartbeat. Well, this is the cause. Do you guys have any idea on how I can solve it or if I need to ditch this gimbal? I have the Feiyutech's Mini 3D gimbal and a photo is attached for reference. It is a metal chassis with 3 DOF.

@EDIT2: I figured that if I increase the distance between the FC and the gimbal, the interference is non existent. If I put them at, like, 10cm apart, if just works fine. I will figure out a way to move them apart and will calibrate it again. I will get this done ASAP and will report as soon as I calibrate it!!! :D
Title: Re: AuxMag won't get a decent orientation
Post by: Jacarebs on March 25, 2017, 05:34:51 pm
Ok, so I've been waiting a couple days for some parts that I was going to replace on my drone, like its landing gear and such. Turns out that increasing the distance from the FC to the gimbal really did the trick :). I could get a nice calibration and now the mag is not a problem anymore!

Thanks a lot for the help, guys /o/

Do you guys have any ideas on what I could look up to improve from now on?