LibrePilot Forum

Users => Applications - Autonomous Flight => Topic started by: malakym on February 29, 2016, 10:01:03 pm

Title: [SOLVED] Can't get data from Aux Mag
Post by: malakym on February 29, 2016, 10:01:03 pm
SOLVED: possible faulty gps/mag (even though mag works in an Rasberry Pi)


After having problems using the internal MAG in a Revo I bought myself a GPS+Mag unit - a NEO-7M.

I am using the 'next' branch and can see Aux Mag settings.

Once wired up the GPS works fine, so the unit is powered up.

It's wired up as per the left item here https://librepilot.atlassian.net/wiki/download/attachments/12058679/gps_wiring.png I have opened the casing and confirmed the SCL/SDA connections, I've also tried swapping them just incase with no luck.

I have the mag setting set to Aux Only, when I change to internal only I can see data from that sensor but nothing at all once I am set to Aux.

I have powered the unit with the flight battery before plugging USB in - I also use an OPLink groundstation and have tried this on both.


MAG is black, I2C is black, SENSOR is green.

MagState.Source is showing Invalid

I've changed AuxMagSensor.MetaData / Flight Telemetry update to 1000ms and sent it, confirmed its applied by reading the entry back.

I have tested GPS in the Flexi port to confirm the port is working and all seems okay.

I have no way to confirm the magnetometer is working separately, how could I do that? I have many USB>RS232 adaptors and such.

I have read through https://librepilot.atlassian.net/wiki/display/LPDOC/Aux+Mag+Setup+and+Calibration I am confused with the "- Pick a port to use: FlexiPort or I2CPort" line, since the Revo has an I2C port (as far as I know) and there is an option for such. With this I also tried setting AuxMagSettings.Type = Flexi instead of I2C, I have also tried going through the wizard and letting that set it based on selection with no luck either.
Title: Re: Can't get data from Aux Mag
Post by: hwh on February 29, 2016, 10:18:00 pm
There was another thread about something similar, https://forum.librepilot.org/index.php?topic=679.msg4931#msg4931  maybe your problem is the same setting.
Title: Re: Can't get data from Aux Mag
Post by: Mateusz on February 29, 2016, 10:24:49 pm
I have read through https://librepilot.atlassian.net/wiki/display/LPDOC/Aux+Mag+Setup+and+Calibration I am confused with the "- Pick a port to use: FlexiPort or I2CPort" line, since the Revo has an I2C port (as far as I know) and there is an option for such. With this I also tried setting AuxMagSettings.Type = Flexi instead of I2C, I have also tried going through the wizard and letting that set it based on selection with no luck either.

Revo has no I2C port, it has to be Flexi and you have to connect I2C to flexi port. Also you should use INS31 attitude estimation algorithm not Complementary. Complementary does not use Mag or GPS, hence in that mode it would be black.
Title: Re: Can't get data from Aux Mag
Post by: f5soh on February 29, 2016, 10:41:35 pm
Wizard should configure all you need for GPS+i2c
Flexiport as I2C
Auxmag type as Flexi
You should at least get a I2C orange or green, but not grey.
Title: Re: Can't get data from Aux Mag
Post by: malakym on February 29, 2016, 11:09:05 pm
Okay, I got confused with some people saying this does not have I2C but I can select it under the flexiport. I noticed the wizard selected Flexi under AuxMag Type and tried that first, then went with I2C.


So now I have.
Set Flexiport to I2C (I already had this)
Set AuxMag type to Flexi (I had mainly been trying I2C)
Set AuxMag Usage to AuxOnly (I already had this)
Set INS13 (This was off, forgot to change it after starting from scratch)
Set my home location including altitude as it wasn't set.

I2C is now Orange
MAG is now Black

I'm still getting no data under AuxMagSensor, all 0, Status None.


My ATTI and STAB are Red currently as im still waiting for a GPS fix - I realise GPS+MAG is needed for this - but the above data should still be arriving yes?
Title: Re: Can't get data from Aux Mag
Post by: f5soh on February 29, 2016, 11:14:49 pm
I2C is now Orange

Seems your mag is not powered, wizard wiring assumes the mag side is powered from GPS side.

You can select the Fusion Algorithm to Comp+Mag or EKFIndoor, more easy for testing indoor.
Title: Re: Can't get data from Aux Mag
Post by: malakym on February 29, 2016, 11:24:03 pm
How would it be powered then? The wiring in the unit has no other power than the GPS side.

Or can this tell that no power is connected on the Flexiport?


I have changed
RevoSettings.FusionAlgorithm to Complementary+Mag

ATTI+STAB are Green.

GPS is Red (I can get a decent fix in a window but it takes a while initially)
MAG is Black (still not seeing data under AuxMagSensor)
Title: Re: Can't get data from Aux Mag
Post by: f5soh on February 29, 2016, 11:43:47 pm
Before looking at Mag, you need a green I2c alarm.

Connect GPS and i2c mag wires to flexiPort set as I2c.
Disconnect all, add external power first and next connect usb.
Title: Re: Can't get data from Aux Mag
Post by: malakym on March 01, 2016, 12:11:06 am
I have GPS connected to Main, and is working. This uses VCC, GND, TX and RX.

I have MAG (in a combined GPS+MAG unit) connected via only SCL and SDA, there is no power lines on the board for this.

I power the revo up first via the flight battery before connecting to it.
Title: Re: Can't get data from Aux Mag
Post by: f5soh on March 01, 2016, 07:24:25 am
Double check connections SCL to pin3 and SDA to pin4
Be sure the mag chip is powered.
Title: Re: Can't get data from Aux Mag
Post by: malakym on March 01, 2016, 09:38:05 am
They are the pins I have been using (other than swapping them a few times to try). I opened the casing to check on the PCB to confirm which ones are correct. I've also checked with a multimeter from the GPS+MAG board to behind the connector on the Revo and that is connected okay.

I'm not sure how I can check the mag chip, the GPS side light flashes on on power up but im not sure if there is a light for both or such - any suggestions on how to check?
Title: Re: Can't get data from Aux Mag
Post by: malakym on March 02, 2016, 04:51:55 pm
I've wired the MAG sensor up to a Raspberry PI, and with some basic scripting I can get the data from the sensor fine, so everything in the unit seems to be working okay.
Title: Re: Can't get data from Aux Mag
Post by: f5soh on March 02, 2016, 05:14:22 pm
Try to redo config from scratch.
Upgrade&Erase and next, do wizard... just to start with something fresh.
You should at least get a green I2c alarm.
Title: Re: Can't get data from Aux Mag
Post by: TheOtherCliff on March 02, 2016, 10:57:58 pm
I2C being black is worrisome.  Maybe your Flexiport is broken.  For a test you could change to put GPS on Flexi.

...

To get aux mag working it really should be just setting Configuration -> Hardware -> Flexiport to I2C, setting AuxMagSettings.Type=Flexi, setting AuxMagSettings.Usage=AuxOnly, then highlight AuxMagSettings by clicking on it and press the red up arrow (Save) to make it permanent. Reboot the FC.  At that point, you should be able to see mag data in "Data Objects" -> AuxMagSensor.

Once you get I2C health green (mag should be red or orange or green) Then you need to run the mag sensor calibration.
Title: Re: Can't get data from Aux Mag
Post by: malakym on March 02, 2016, 11:05:52 pm
I have I2C as Orange now.
I have tested GPS on Flexi port previously that that works okay.
AuxMagSensor is all 0s and Status = None

I was about to reply to f5soh, this is what that was...

No luck with that, I still get Orange I2C and Black MAG.

This is what I did to be clear...

Upgrade & Erase

Setup Wizard
-Upgrade(/w Erase all settings)
-Board ID - automatic (USB Revolution, OpenPilot Revolution)
-Reboot Controller
-PWM
-Reboot
-Multirotor
-Quadcopter X
-Rapid ESC
-U-Blox Base + Magnetometer (SCL Blue, SDA White)
-Sensor-Calculate
-Connect flight battery
-Disconnect flight battery
-Output calibration
-Initial Tuning - DJI F450
-Save
-Reboot

-Disconnect USB
-Connect flight battery
-Connect USB

Set home location on map (incuding correct altitude)

SENSOR: Green
GPS: Red (waiting for fix)
I2C: Orange
MAG: Black

Set MagSensor.MetaData.Modes.(Update Period) to 1000ms
Set MagState.MetaData.Modes.(Update Period) to 1000ms


MagSensor data is showing results from onboard Mag.

MagStage.Source is Aux
I2CStats.last_error_type is EVENT (other items are 0s)

Settings.AuxMagSettings.Type is Flexi
Settings.AuxMagSettings.Usage is AuxOnly
Flexi port is I2C

Set RevoCalibration.FusionAlgorithm = Complementary+Mag
(I cant change Attitude > Settings > Attitude Estimation Algorithm to INS13 with the above)

Although the PCB is clearly marked SDA and SCL I flipped them just to be sure, although I confirmed them correct earlier today connected to the Pi.




Title: Re: Can't get data from Aux Mag
Post by: f5soh on March 02, 2016, 11:40:05 pm
No need all this steps, you can stop while you got I2c orange / mag sensor connected with external power.

Post goods pictures with your setup
Title: Re: Can't get data from Aux Mag
Post by: malakym on March 03, 2016, 10:56:31 pm
I'm not exactly sure what you want but here are a few so far.

http://i.imgur.com/hJijfnn.jpg
http://i.imgur.com/FQjxjvq.jpg (ESC normally connected for flight battery power)
http://i.imgur.com/Affci3u.jpg
http://i.imgur.com/Fr1Icts.jpg?1 (SCL Blue, SDA White)

I have JST connectors on the end of the Micro JST (gps+mag) to connect to the Micro JST-SH (Revolution).

Blue SCL is connected to Pin 3 (Orange) on Flexi
White SDA is connected to Pin 4 (Green) on Flexi
Title: Re: Can't get data from Aux Mag
Post by: f5soh on March 03, 2016, 11:12:20 pm
Try shorten wires for all connections or at least Gnd/SCL/SDA for mag
Title: Re: Can't get data from Aux Mag
Post by: malakym on March 03, 2016, 11:37:12 pm
I have recently received JST-SH 20cm leads recently, didn't want to modify the GPS+MAG if it wasn't working, but since I confirmed it working on the Pi I have gone and soldered on new leads. Cable length was 42cm before, its 20cm now.

I've just done SDA/SCL with no luck, Im about to do the rest so the mag ground (from Main/GPS) is shorter too.
Title: Re: Can't get data from Aux Mag
Post by: malakym on March 04, 2016, 12:02:41 am
All done but no luck.

http://i.imgur.com/1AsLutW.jpg

GPS working.
I2C Orange, (Aux)Mag sensors showing 0s.
Title: Re: Can't get data from Aux Mag
Post by: f5soh on March 04, 2016, 12:18:02 am
Be sure apply +5v from esc first.

Maybe some hardware issue somewhere, works perfectly here using I2C with two different hardware.
Your Revo board do not follow original routing, maybe related or not, don't know.
For testing a external mag alone is around 3$
Title: Re: Can't get data from Aux Mag
Post by: malakym on March 04, 2016, 12:24:43 am
I'm always powering from flight battery/ESC first. :)

I ordered a MAG3110 last week from China, so will have another one to test eventually if this doesn't get working.

What is different? It looks similar to most pictures I've seen and the diagram in GCS.
Title: Re: Can't get data from Aux Mag
Post by: f5soh on March 04, 2016, 12:30:35 am
Not really the same board.
(https://forum.librepilot.org/index.php?action=dlattach;topic=960.0;attach=1799)

Here is my desk setup for testing
(https://forum.librepilot.org/index.php?action=dlattach;topic=960.0;attach=1801)
If you finally get i2c you can pull next and use the new tab for mag testing and orientation.
(https://forum.librepilot.org/index.php?action=dlattach;topic=960.0;attach=1803)
Title: Re: Can't get data from Aux Mag
Post by: hwh on March 04, 2016, 12:35:16 am
...I ordered a MAG3110 last week from China, so will have another one to test eventually if this doesn't get working....

That won't do any good, the mag that LP supports is the HMC5883L.   The software doesn't have a driver for a MAG3110 unless it's a clone of the HMC5883L.
Title: Re: Can't get data from Aux Mag
Post by: malakym on March 04, 2016, 12:48:43 am
The one I have atm is a HMC5883L at least, I had to use libraries for that chip on the Pi so I know its what we need. Too bad with the 3110, I've gone an ordered a separate HMC5883L from the UK as I don't want to keep waiting :p

Ah I see now, will check the traces to make sure the Flexi port is wired up correctly - granted GPS works in it but might as well.

I saw the Mag Tab commit on IRC earlier but git pull wasn't working earlier for me, its working now so will have a look.
Title: Re: Can't get data from Aux Mag
Post by: malakym on March 05, 2016, 01:15:13 pm
All working now :)

Received a HMC5883L this morning, wired it up and it works.

Looks like an issue with my GPS+MAG then, even if it does work in my Rasberry Pi.

(http://i.imgur.com/W46EYt4.png)
(http://i.imgur.com/vgu4vW5.png)

Just need to calibrate it now, thanks for the help. :)
Title: Re: [SOLVED] Can't get data from Aux Mag
Post by: TheOtherCliff on March 05, 2016, 06:47:09 pm
Read help here:
https://librepilot.atlassian.net/wiki/display/LPDOC/Aux+Mag+Setup+and+Calibration

It will tell you (among other things) that most aux mags need orientation set to BoardRotation.Pitch=180
Title: Re: [SOLVED] Can't get data from Aux Mag
Post by: f5soh on March 05, 2016, 07:33:19 pm
It will tell you (among other things) that most aux mags need orientation set to BoardRotation.Pitch=180

Using the last mag gui the orientation setting is quite easy.
- Calibrate with "booth" mags

If mag chip is facing down, set Roll to 180°
Adjust Yaw orientation if needed, check sliders.
All sliders still around "0" while rotating frame if orientation is correct.