I am a pixhawk newbie, so please forgive any errors/confusion in the following.
I was struggling to get an external compass based on a combo GPS/compass to calibrate on a Px4.
The problem compass is based on the HMC5883l. I finally ran it off an Arduino Uno and I am now convinced that the chips is defective (virtually no signal on the Z axis) and the results from Mission Planner and the arduino code tell the same story…dead Z axis.
The GPS part of the module seems to work great so I was looking for a way to get another external compass chip to work. As is well reported, the HMC5883l is long obsolete so I considered using a LMS303D (mounted on a Pololu board); I could not get it to work (using 3.5.3 firmware. I am pretty sure that this makes senses for that firmware in that it does seem to support that chip on the I2C bus. So…
I was informed on this forum (thanks to the developers!) that the new beta firmware 3.5.4 rc 2 has the added feature of supporting the LIS3MDL as an external compass at 01E address on the I2C.
I bought a breakout board from Pololu (about $5) and it works on the I2C bus with the beta firmware (yes!). A few warnings if you try to go this route. The Pololu board defaults via internal pullup to 01D address. All that is needed is to add a jumper to ground and it sets up for 01E (details on how to do this are well documented on the Pololu site). Also, importantly, the Pololu boad is designed to work with an Arduino in that it has level translators set up to support 5 volt signals on the I2C bus. There are two choices on how to make it compatible with the Px4. One is to power the board off of 3.3 and then the i2C works at 3.3. The problem with this approach is that I2C port on the Px4 output 5volts…so one would need to find 3.3 somewhere else. The second approach (the one I took) is to do microsurgery on the board and cut the trace that feeds the i2C pullups from being fed by the input (5v) power and then added a wire flying lead to power the pullups by the onboard 3.3 regulator. So with the cut and the jumper and the grounding jumper to get the correct address, all is good and the module can be plugged directly into the I2C bus.
Thanks again to the developers on supported this chip. I am now waiting eagerly for this Beta firmware to pass testing and being released as stable.
Did you tried with sda-scl lines directly, without the “microsurgery”?, my guess is that it should work because I2C is pull down , so the most important aspect of this signal is that it must go to zero.
Nice to know that this one works, I tried with the cheap Chinese QMC5883, and unfortunately its not working really well with other I2C devices.
I did not try without the microsurgery…I was too scared to have the pullups pull up to 5V though the current is so small that you probably don’t run any real risk of damaging the Px4 circuitry (I am always paranoid about pulling inputs above the supply by more that 0.3V for fear of latch up and frying the inputs though latchup usually requires a pretty high current). I have had good luck with Pololu parts in the past and decided to avoid the “5883” variants. Also, note that this is the only I2C device on the bus…I don’t have an expander or other I2C devices.
Just like you (and for similar reasons) I’m about to add a LIS3MDL on a Pololu board to my Pixhawk 2.1 because my HERE compass is defective in the z-axis! I’m also a newbie to Pixhawk and drones in general.
I looked at the Pixhawk 2.1 specs and found that the I2C VCC is 5V and SCL and SDA lines have 5V level pull up on AP. Presumably then the microsurgery on the Pololu board wouldn’t be necessary. I’m wondering whether I’m missing something here - why did you think that >3.3v was undesirable?
The Polou web page and the data sheet for the LIS3MDL suggest that default I2C address is 0x1E and grounding the SDO pin changes this to 0x1C. This conflicts with your description?
Finally the LIS3MDL can be configured for various sensitivities - did you have to make any changes before you connected it to the Pixhawk or did you simply accept whatever the default is?
I’d be grateful for your response to my comments and any further advice you can offer about using this device with the Pixhawk.
LIS3MDL can be seen on Arducopter, when grounding SDO pin.
5V works fine for me.
configured for various sensitivities
Interesting! I have not changed that option and the drone flies without a problem.
So, if you test that, please report
Let’s see what I recall…it’s been a while. First, I have the Pixhawk,
not the Pixhawk 2.1. I just googled and found the following link for the
Pixhawk (not 2.1 version):
Part way down the page it has the I2C pin and voltage level specs:
1 (red) VCC +5V
2 (blk) SCL +3.3 (pullups)
3 (blk) SDA +3.3 (pullups)
4 (blk) GND GND
I would seem that the new, 2.1 version SCL/SDAs are pulled up to 5.0V as
opposed the older version (pulled up to 3.3V)…note, however I did not
check out the 2.1 specs…I am going on what you report. So, it would seem
that you don’t have to worry about the voltage level translation with the
2.1. Actually, it probably would be fine on with my older Pixhawk as well
but I didn’t want to take the chance.
As regards the address, as I recall, I think I did ground the address bit
however, what I posted on the forum looks in error. If I read the Pololu
site correctly, grounded the bit changes the address from 1E (default, no
grounding) to 1C when grounded. Again, I don’t have it in front of
me…not sure if you need to change the address.
I accepted the default on the sensitivities. It seems to be fine.
Martin, thanks for your quick reply and the clarifications. I feel more confident to proceed now.
@Fi156 thanks to you too for your input. I’ll try to come back here and report the results of my labours in due course.
After further work I too have successfully added the LIS3MDL to my copter. It turns out the Pixhawk 2.1 has two I2C systems, one is the ‘old’ system with 3.3v pullups serving the two Gps ports and the other is a ‘new’ system with 5v pullups. However the old system is 5v tolerant. Plugging the new LIS3MDL into GPS2 port resulted in it not being detected by the Pixhawk. I think that this was because there were already three compasses being detected. I disabled detection of the broken compass of the HERE by changing the COMPASS_TYPEMASK bitmask and for good measure I also changed the address of the new device by cutting the 5v pullup to the SD0 pin and adding a 10k resistor from the pin to ground. The new device was then recognised by the Pixhawk. After recalibration I now seem to have a compass giving accurate headings, tbough only the new one has acceptable offsets. With a little judicious trimming of the inside of the plastic housing I managed to put the new mag inside the HERE casing resulting in a neat and robust finished job. With regard to the sensitivity I left it at the default (most sensitive) which seems to be fine.
Congratulations on getting it to work!
Hey guys, I’m trying to use this same Pololu LIS3MDL breakout PCB. I found a couple of things. First, the compass works on the latest version of copter (3.5.7 as of this writing) with or without grounding the SDO pin.
I’m having a problem though…did anyone else have issues with huge compass offsets? After a calibration, I’m getting offsets around -400 on x and y, and -800 on z! So I’m getting the “compass offsets too high” error. I’m sure that I’m not near anything magnetic…I’m doing this outside, away from buildings or cars. Also the other magnetomers in the pixhawk 2.1 are calibrating with fairly normal offsets.
It has been awhile since I have used my hexacopter with the Pololu LIS3MDL
but I do seem to recall that at least one of the offsets was
in the hundreds. It may even triggered a compass offsets too high error (I
don’t recall), however the bottom line was that the compass was
given solid orientation readings. It did leave me with a little unease
about the offsets but basically, it worked well as a compass…
Yes I had the same issues.
It did leave me with a little unease
about the offsets but basically, it worked well as a compass…
We tested 6 Pololu Modules without a drone on bare Pixhawk by turning the compass in the calibration mode only. One Modul was dead, all others had equally large offsets.
When I remember correctly: One drone still flies with this setup and has logged around 50h air time since then… So from my point of view: Thats not a problem…
@Lukeness17 hi, i’m trying now to connect the Pololu LIS3MD to my pixhawk 1 using arducopter 3.5.7. but i see that it dosent recognize it. do you have any advice perhaps?
Good day, you ca wire it on i2c port, just check the compass type mask and uncheck if its checked LIS3MD.
Just be sure that your gps module don’t have the same module coz with the same add will not work properly.
Better also you update your firmware to the last release 4.0.3.
@Dave84 thank you very much for your help! But if I may ask, why do I need to uncheck it if it is on LIS3MDL? Donsent it need to be on LIS3MDL?
on compass type mask checking the various compasses you will disable the drivers… uncecking it you will enable the driver
I would like to use the LIS3MDL on the Pololu board ( https://www.pololu.com/product/2737 ) with Cube Orange and ArduCopter 4.0.3. After reading this discussion, there are still three questions open for me:
How should the board be mounted (which orientation) on the copter? Components on top or bottom? Which side facing to front? Or does ArduCopter detect the orientation by itself automatically so that it does’t matter how it is mounted?
Is it still necessary to pull the drive the SDO/SA1 pin low (to GND) in order to set it to address 0x1C or does ArduCopter detect it meanwhile also at address 0x1E?
I want to connect it to the I2C lines of GPS1 connector. The documentation still says, the signal lines use 3.3V level: https://ardupilot.org/copter/docs/common-thecube-overview.html but some posts here say, pullups draw it to 5V - so what is correct now? Of course I would prefer to power the Pololu board with 5V which means the SDA/SCL pins are also shifted to 5V.
OK, meanwhile I could answer most of the questions by myself:
Orientation is detected by ArduCopter (tested with 4.0.3) automatically during calibration. It can be seen in the compass configuration screen after reboot.
Nevertheless, it is not completely regardless. In some orientations you get “compass inconsistent” warnings, so the Cube internal magneto behaves a little different to the LIS3MDL and this difference depends on orientation of the LIS3MDL. My recommendation is to let “Y” face towards rear and “X” to the left.
It is also detected by ArduPilot with I²C address 30 (0x1E).
I would recommend to power it with 3.3V as the I²C signal lines of the GPS connectors seem to be pulled up to 3.3V as well.