LibrePilot Forum

Users => Applications - Autonomous Flight => Topic started by: proctoidpaul on November 29, 2016, 10:55:04 pm

Title: Add a mag chip?
Post by: proctoidpaul on November 29, 2016, 10:55:04 pm
Ok, this may be a bit far out there, and I'm assuming the answer is "no", but just wanted to make sure. 

Is there any reasonable way to ADD a mag chip to an existing GPS?  I've got photo of my unit from Banggood attached.

This one was supposed to have a mag per their posting, but did not.  (FYI, they have compensated me for that error.)  Just trying to see if I can salvage use of this.

Paul
Title: Re: Add a mag chip?
Post by: hwh on November 30, 2016, 12:37:28 am
It's certainly possible to solder a mag chip onto the board.  Because the chip doesn't have pins it would be hard to do with a soldering iron but it might be possible to do it.   With a hot air rework station it would be reasonably easy.

The chip is a HMC5883L and the easiest, cheapest way to get one would be to order one of the hmc5883L boards on eBay or on banggood http://www.banggood.com/Electronic-Compass-Module-Three-Axis-Magneto-Resistive-Sensor-p-926151.html?p=SO28133399239201512V

I think I remember a post by someone in the forum that took a board like that and just put the whole board inside the GPS case with hot melt glue without trying to unsolder the chip and move it to the GPS board.  That would make all the soldering much easier since it would just be soldering wires.
Title: Re: Add a mag chip?
Post by: TheOtherCliff on November 30, 2016, 04:58:00 am
It looks like there is a place for a mag chip below and left ANT.

I have a hot air rework station and I would just solder one on the board.  It looks like it also already has the SDA and SCL lines for the mag at the connector.
Title: Re: Add a mag chip?
Post by: proctoidpaul on November 30, 2016, 02:20:57 pm
Thanks guys!  I have an EE friend...  Will see if possibly he could help. 


Sent from my iPad using Tapatalk
Title: Re: Add a mag chip?
Post by: Mateusz on November 30, 2016, 02:58:53 pm
Also easy to order chip alone http://www.ebay.com/itm/HMC5883-HMC5883L-Honeywell-COMPASS-Triple-Axis-I2C-LCC-16-NEW/222161143987 plenty of them unsoldered on the ebay.
You may want to watch to the end this youtube movie how to solder QFN package that has no side pins exposed using just hot-air gun https://www.youtube.com/watch?v=c_Qt5CtUlqY
Title: Re: Add a mag chip?
Post by: proctoidpaul on November 30, 2016, 11:52:46 pm
Thanks for all the responses!  Extremely helpful.

So, after viewing the video I'm going to opt for just using the full board.  My EE buddy doesn't have the equipment nor do I feel I can likely get the job done to work with just the chip.  But can someone guide me on how to connect the board:

All the sources appear to be from China or Hong Kong, so it will take a few days to get this in.  But adding a $5 board seems much more reasonable that plopping down 8-10 times that for a whole new unit.
Title: Re: Add a mag chip?
Post by: hwh on December 01, 2016, 12:43:51 am
It depends on the exact board but essentially SDA and SCL need to be run down to the revo's matching pins on the FLEXI port.   And connect the appropriate power/ground from somewhere to the board.  The main gps cable brings 5v from the revo to the gps if it runs on 5v, if not the 5 pin component on the gps is probably a 3.3v regulator you could steal 3.3v from.
Title: Re: Add a mag chip?
Post by: Mateusz on December 01, 2016, 12:15:51 pm
I haven't tried this, but source code indicates that HMC5x83 chips should be supported

Code: [Select]
librepilot/flight/pios/inc/pios_hmc5x83.h:    bool    TempCompensation; // enable temperature sensor on HMC5983 for temperature gain compensation

I think this $2 board is pretty nice as it has two screw holes, which allow you to mount magnetometer firmly, such that it is not rotating after calibration.
http://www.ebay.com/itm/HMC5883L-Triaxial-Compass-High-Accuracy-HMC5983-Replace-Temperature-Compensation-/282092719710

You could also solder it (wthout pins) just small wires and hot glue next to ublox module, if you have space in GPS case (not sure), just be careful to insulate it from remaining electronics.
Title: Re: Add a mag chip?
Post by: hwh on December 01, 2016, 08:08:01 pm
...You could also solder it (wthout pins) just small wires and hot glue next to ublox module, if you have space in GPS case (not sure), just be careful to insulate it from remaining electronics.
I'm sure I saw a post about someone who did that but couldn't find it when I searched.  I think he even posted a picture of the gps with the mag board in it.
Title: Re: Add a mag chip?: Some progress.. but need help
Post by: proctoidpaul on January 04, 2017, 12:42:19 am
Ok, over the long silence I did [finally] get the external mag received and installed.  Good news is I've run it through configuration and can consistently get "green" lights.  Taken a test flight and checked the flight log, and the mag stayed "green" throughout.

But as soon as I switched to INS13 navigation, my flight data screen (artificial horizon) goes haywire.  When I switched back to basic (complementary) mode the quad won't fly right now either.

here's a youtube of my screen while the quad is setting idle, with good satellite lock and all "green".

https://www.youtube.com/watch?v=iA8BamEgQU0

Any idea what's going on?  I rerun all the calibrations (except the thermal one) and the thing still thinks its upside down and moving around bunches.

I've also tried playing around with the mag installation settings (Pitch/Roll) but those don't seem to have any affect either!

I was a little suspicious of my antenna layout, but moving those around don't seem to affect anything at all... so I don't think those are the issue.

I do have a "non ferous" barier (foil tape) lining the bottom shell of the GPS unit, between the GPS board and the mag.

Paul
Title: Re: Add a mag chip?
Post by: f5soh on January 04, 2017, 12:53:52 am
You should adjust the AuxMag Orientation, looking at the 3 blue bars in Magnetometer tab:
https://www.youtube.com/watch?v=qLsd4O75N9o

The MAG alarm can be green with orientation completely wrong.

Title: Re: Add a mag chip?
Post by: proctoidpaul on January 04, 2017, 03:49:33 am
Ok, that helped a lot, so thanks!  Went through several recalibration efforts and adjustment of the aux mag x,y,z values.

Getting close but I can't get it to totally zero'd out.  And AH is now just a few degrees off rather than being totally upside down, but I can't get it truly level just yet.

Since the onboard mag is poor to begin with, (yellow a lot) what does success look like and what is the relationship between x, y, z and roll, pitch and yaw.  Is there a guide on this?  Clearly these are not directly related.  Ie: How do I know which values to change and in what direction?

Right now I'm getting close with two of the values set to 180... But playing around with the other one doesn't seem to drive it home...


Sent from my iPad using Tapatalk
Title: Re: Add a mag chip?
Post by: TheOtherCliff on January 05, 2017, 06:53:41 am
Long stories short:
- For I2C aux mag you need "aux mag orientation" (board rotation) 0,180,0 or 180,0,180 (they are the same)
- a little bit of leaning and wobble in the PFD is normal

PFD leaning can be corrected using:
https://librepilot.atlassian.net/wiki/display/LPDOC/Aux+Mag+Setup+and+Calibration
See the section titled "Fine Tuning Your Hover To Stop Drift (Not Required)"
Title: Re: Add a mag chip?
Post by: proctoidpaul on January 05, 2017, 08:20:48 pm
Long stories short:
- For I2C aux mag you need "aux mag orientation" (board rotation) 0,180,0 or 180,0,180 (they are the same)
- a little bit of leaning and wobble in the PFD is normal

PFD leaning can be corrected using:
https://librepilot.atlassian.net/wiki/display/LPDOC/Aux+Mag+Setup+and+Calibration
See the section titled "Fine Tuning Your Hover To Stop Drift (Not Required)"


Thanks, found that doc last night late after another failed attempt.

Given all that I've learned so far, here are the plans for my next attempt:

-Get everything flying (with minimal/zero drift) in basic navigation/attitude mode by adjusting the board orientation settings (after basic calibration) with GPS and AuxMag disconnected. 
-Make note of a  physical location and orientation where the unit can be positioned to get a good position reflected on the Artificial Horizon.  This needs to be outdoors and away from any metallic interferences.
-Change to INS13 with Aux Mag only
-Perform AuxMag calibration with typical battery fully installed and powered up
-Return the model to the previous position used at the conclusion of the basic tests.
-Adjust roll,pitch,yaw settings of the AuxMag only until the Artificial Horizon is 'close' to previous basic results (referencing reply and documentation above).  Start with pitch (not upside down) then yaw (make sure North is North), then tweak from there.
-Confirm stable Mag and GPS status, even with light power applied to motors
-test fly in a non GPS mode, (attitude) and make any final adjustments to AuxMag orientation to minimize drift
-finally test something like GPS Hold mode

I know I've skipped several otherwise recommended steps that some have proposed, but I cannot power up my AuxMag without connecting my battery, not installing the battery gives me inaccurate calibration once the battery is installed, and when the system is fully powered up the onboard mag is pretty useless as it spends most of its time yellow/red.

Am I overlooking anything?





Sent from my iPad using Tapatalk
Title: Re: Add a mag chip?
Post by: TheOtherCliff on January 06, 2017, 01:17:50 am
Getting it "level" entails a lot more than you would think, so I skip that and use "hovers without drift" as the best definition of "level".

If even a single motor is not perfectly vertical it won't hover level.
If the gear are bent or stressed it won't
If an arm is bent...
Crash damage...

Some aircraft don't hover level by design.  Helis, Tris...

For me it is just easier to do normal calibrations carefully, but not splitting hairs, then jump to flying in Attitude mode to get the level perfect.
Title: Re: Add a mag chip?
Post by: proctoidpaul on January 06, 2017, 06:41:36 pm
Got it.  I think the key here is that it needs to be close enough to fly...  and reasonable for the aircraft design.  Ie: not off by 30 degrees and/or upside down.

Glad to hear I'm on the right track.

I'm just about ready to retest non-GPS level flight.

I'm going to make a separate post about having to do a full [re] firmware update.

Thanks again!

Paul




Sent from my iPad using Tapatalk
Title: Re: Add a mag chip?: Almost There
Post by: proctoidpaul on January 08, 2017, 11:13:06 pm
After re-flashing the entire board, I redid all initial configuration and got good level flight (with minimal drift) in basic navigation with just a couple small tweaks to the roll and pitch values.

I then did temperature calibration, since winter is happening here in Ohio.  :) and ran an AutoTune cycle "just to be safe".

Hooked up GPS and Mag, ran through those calibrations, Mag set to Aux Only

Took 180 roll and 180 pitch to line up the Artificial Horizon correctly.  By the way, contrary to my early attempt this put the 3 blue bars "pretty close" to 0. And this put the AH pretty level, with just a bit of pitch showing.

It looked like my first mag calibration was good, but after I restarted everything the mag status was consistently yellow.  So I redid the mag calibration and am now getting consistent green (with AuxOnly).  Only thing I can think of is that my PC was too close to the quad, so I move it as far away as I could and still reach the keyboard while doing the calibration routing.

Did a test flight in "attitude" mode again, and once again had very good leveling, no further tweaking required!

After I set up a GPS hold mode and I got ready to test, one of my motors quit working.  Not sure if I got a little snow somewhere it shouldn't be or if something else is going on, but the sun is going down so I'll pick up here [hopefully] tomorrow.
Title: Re: Add a mag chip?: How bad is YELLOW ?
Post by: proctoidpaul on January 09, 2017, 11:02:28 pm
When I followed up today, I've stil got one motor not responding, so I need to diagnose root cause on that.

But I'm seeing Aux MAG Yellow again, most of the time.  Walking it around will get some green, but not "always".

Looking at the numbers, it looks like it's running between 5% and 10% out a lot of the time.

Is this "normal"?  If not, what else should I look at?

re-posting my antennae configuration.  Is this a likely culprit?  Anything else to consider?  Or is this something to not worry about?
Title: Re: Add a mag chip?
Post by: proctoidpaul on January 10, 2017, 03:57:41 am
P.S.  My motor problem is a bad "channel" in a 4-in-1 ESC.  I'm assuming that wouldn't affect my mag calibration, as the problem exists while motors are not powered up at all.
Title: Re: Add a mag chip?
Post by: TheOtherCliff on January 10, 2017, 04:52:38 am
One important thing that should be shouted out from th speakers when you want to do mag calibration is that it is always reading mag data once you start the calibration.  You can't for instance set the quad on your car (metal), start calibration, pick it up, ... set it back down on the car ... finish calibration.  Calibration must be done without any bad stuff at any time from start to finish.
Title: Re: Add a mag chip?
Post by: proctoidpaul on January 10, 2017, 05:52:50 pm
One important thing that should be shouted out from th speakers when you want to do mag calibration is that it is always reading mag data once you start the calibration.  You can't for instance set the quad on your car (metal), start calibration, pick it up, ... set it back down on the car ... finish calibration.  Calibration must be done without any bad stuff at any time from start to finish.

Understood, and I don't think that is the issue.  Is it possible though that the battery lead, coming up and over the battery could be the inconsistent point here?  Ie: I might not be paying enough attention to positioning this consistently.


Sent from my iPad using Tapatalk
Title: Re: Add a mag chip?
Post by: TheOtherCliff on January 11, 2017, 08:53:37 pm
You should mount the battery with same orientation each time.  That's easy for me since I need the lead coming out on one side...

Make sure all wires are twisted.  That means battery to connector and connector to PDB too.

1609 fixed a bug in the mag calibration, so you should be using 1609.  (I forget when that bug was introduced...)

Recalibrate your mags without setting it down (not even on the ground) during the calibration.
Title: Re: Add a mag chip?
Post by: proctoidpaul on January 11, 2017, 09:33:26 pm
Cool.  I'm running 16.09, so I think my key opportunities are

I have been doing most calibration attempts outside, but setting the quad on my concrete drive.  I'm assuming that a wooden table a couple feet off the ground would be OK, or are you just saying to keep it fully "hand held" during calibration?  Obviously that would be nearly impossible to keep fully still/oriented "just right" if just keeping it hand-held.

Either way, looks like I've got a bad ESC, so it'll be a few days before I resume flight tests.

Best regards,

Paul
Title: Re: Add a mag chip?
Post by: TheOtherCliff on January 12, 2017, 06:32:19 am
A wooden table is probably OK.  I set mine on a wooden railing, but I'm careful to keep it away from known nails.

And it is less a problem if you are using AuxOnly mag, since the aux mag is mounted higher than the OnBoard.  Please use AuxOnly.
Title: Re: Add a mag chip?
Post by: proctoidpaul on February 17, 2017, 12:19:41 am
I'm back in the air now after replacing my speed controller.  I got a good mag calibration, with one battery (a 4S 1800 mah) but then again got slightly yellow status (running 5-8% error rate most of the time) when I switched to a slightly smaller battery (a 4S 1600mah).  There are several inches clearance between the battery and mag, and I made sure to run the battery leads in the same position.  Could the difference in calibration be from just the different battery size?

I went ahead and tried a position hold on both batteries.  Position hold was pretty successful, but it did a bit of a pendulum swing fore and aft that seemed to keep getting larger.   I had previously done an AutoTune and when I switched to "bank 3" (where my AutoTune settings were stored) it seemed to reduce the oscillation significantly, although those settings are too touchy for me when flying LOS.  Both batteries responded pretty much the same, so I feel like the "yellow" status wasn't significant enough to cause me any real issues.

As a side note, the only thing I had to watch out for is that when I switched out of stabilize mode to position hold, the throttle was way out of whack.  I had set the position hold to use "altitude" assist.  When I switched INTO position hold, I had to add a lot of throttle to hold altitude.  Conversely, I had to immediately cut a lot of throttle when I switched back to stabilize mode.  I assume 50% position is what's needed to maintain altitude in that mode, so I think the best solution to assist with transition would be to adjust my throttle position in Stabilize to manage level hover ~ 50%... is that the right thinking?  Or is there something else I should do?  (right now I'm flying in stabilize hover @ about 30% throttle.)
Title: Re: Add a mag chip?
Post by: Mateusz on February 17, 2017, 08:09:31 am
Obviously that would be nearly impossible to keep fully still/oriented "just right" if just keeping it hand-held.

I just but in and comment on previous. It depends what sensor is calibrated in procedure and what that sensor reads.

For Mag it reads magnetic field and that's it. It does it by collecting samples continuously, the movements suggested by wizard are just to cover all directions. It does not say it has to be montionless at each position. What I do is I skip first 5 steps and on last one I do slowly as many rotations in all ways as possible to cover sphere with samples. (alpha version of Android app shows that sphere but Android mag calibration is in testing phase).

When you do gyro calibration it must be montionless. If you do accel it must be perfectly aligned. When you do temp calibration this one is performed on two sensors, baro and gyro. Gyro is sensitive to movement and baro to pressure and lighting. With temp calibration board must be all time motionless and in complete darkness.

That's it, just think what sensor measures and what is calibrated.

I use 12-14cm pol for my gps+mag unit, and mast is mounted firmly using two screws. Masts mounted on one screw are useless as they would rotate after calibration.

Good luck ;)
Title: Re: Add a mag chip?
Post by: TheOtherCliff on February 17, 2017, 12:02:28 pm
I got a good mag calibration, with one battery (a 4S 1800 mah) but then again got slightly yellow status (running 5-8% error rate most of the time) when I switched to a slightly smaller battery (a 4S 1600mah).  There are several inches clearance between the battery and mag, and I made sure to run the battery leads in the same position.  Could the difference in calibration be from just the different battery size?
Generally, you are running such low current when the motors are off, that it just doesn't even see the battery.  This assumes that battery wires (and others) are twisted properly and battery is several inches from your mag.  I presume you have an aux mag and have your mag settings set to "aux only" (important (you don't have to recal mags just to change this)).  Mags should be generally green.  Movement during mag calibrations should always be slow (say take 3 seconds to get from one position to the next) for best calibration.  By force of habit I always set my auxmagsettings and revocalibration .mag_bias to 0,0,0 and auxmagsettings and revocalibration .mag_transform to 1,0,0,0,1,0,0,0,1 before mag cal, but that shouldn't be necessary in 16.09.

I went ahead and tried a position hold on both batteries.  Position hold was pretty successful, but it did a bit of a pendulum swing fore and aft that seemed to keep getting larger.
Was it toilet bowl or just pendulum?  Anyway, these are a sign of bad mags.  It could be calibration and it could be wires not twisted / routed well enough.  If you are seeing a lot of yellow with motors stopped, I would focus on mag cal until that is better.

I had previously done an AutoTune and when I switched to "bank 3" (where my AutoTune settings were stored) it seemed to reduce the oscillation significantly, although those settings are too touchy for me when flying LOS.
Assuming you are flying ATtitude mode...  Either the AT tune is good or bad.  If good, then it should be very "locked" to exactly what you ask it to do.  That should feel better, not worse in LOS.  Is yaw the main problem there?  If so you can reduce the yaw rate / rate mode response yaw to tame that down.  For pitch / roll you reduce the max bank angle: attitude / attitude mode response

Both batteries responded pretty much the same, so I feel like the "yellow" status wasn't significant enough to cause me any real issues.
Mags are important and should usually be green.

I had set the position hold to use "altitude" assist.
I suggest VelocityRoam over PH.  It's the same when sticks are in the center and it lets you drive it around.  "Altitude assist"?  I am guessing you mean "Assisted Control"?  That is generally for adding "PositionHold" to non GPS flight modes.  I don't know what it does to PH.  I haven't used it.  You might try VR with Assist off.

As a side note, the only thing I had to watch out for is that when I switched out of stabilize mode to position hold, the throttle was way out of whack.  When I switched INTO position hold, I had to add a lot of throttle to hold altitude.  ...  Right now I'm flying in stabilize hover @ about 30% throttle.
Yes.  Any mode that stabilizes aLtitude uses 50% stick to mean "don't change aLtitude".  If you are hovering at 30% throttle your props may be too big unless you know you built a real rocket.  What motors props battery weight are you running at 4s?
Title: Re: Add a mag chip?
Post by: proctoidpaul on February 17, 2017, 07:07:28 pm
Wow... Lots of feedback... I love it!

I'm not at home at the moment, but will try to respond with what I can.

First of all, I am pretty highly powered here.  It is the HobbyKing Qaunum 270 (now) with 2205 motors 4s. I think the props are bullnose 5040s.  Hover on 3s is around 50% stick, but 4s gets up pretty quick.

I guess the sensitivity issue after auto tune was partially because I generally fly Acro+ Mode.  That's just too touchy for me after the auto tune settings unless I'm FPV.

The oscillation I was seeing was purely front to back... Nothing side to side, and it wasn't toilet bowl.

When I was out of the wind, didn't seem to happen at all but in steady but light wind it quickly showed up.

I agree that straight Position Hold isn't very useful ongoing, but was trying to verify that mode before I moved on to others.

I probably have 4 inches clearance between the mag and the battery, but I did fail to twist the battery leads.  I can try that when I recalibrate.

I never heard anyone point out slow transition when doing calibration.  Again, had good results till I switched battery, so don't know if that was part of the issue or not, but I'll certainly give that a try too.

In the photo below, I am being sure to keep the battery leads down around the battery, not looping over as shown.  But everything else is representative.


Sent from my iPad using Tapatalk
Title: Re: Add a mag chip?
Post by: proctoidpaul on February 17, 2017, 07:22:28 pm
P.S.  Yes, I was using Aux Mag only.


Sent from my iPad using Tapatalk
Title: Re: Add a mag chip?
Post by: TheOtherCliff on February 18, 2017, 04:15:28 am
Any time you change power or weight you should run AT again.

Or you can tune with the heaviest / least powerful configuration and your lighter / more powerful configurations will be a little less than they could be but still fly quite nicely.  If you tune light/powerful and drop down to heavy/less power you get oscillations (IIRC).