cyoung / stratux

Aviation weather and traffic receiver based on RTL-SDR.
BSD 3-Clause "New" or "Revised" License
1.06k stars 362 forks source link

Hardware measurements on an HMC5883L Digital Compass in a LEADIY-D3 #309

Closed Ergonomicmike closed 8 years ago

Ergonomicmike commented 8 years ago
  1. Stratux version: 0.vb7+alpha to 18de.sh build
  2. Stratux config:

    SDR [ ] single [X] dual

    GPS [X ] yes [ ] no type: BU-353

    AHRS [X] yes [ ] no

    power source: Anker E5 usb cable: Anker cable

  3. EFB app and version: (e.g., WingX Pro7 8.6.2) N/A EFB platform: (e.g., iOS 9.2) N/A EFB hardware: (e.g., iPad Mini 2) N/A
  4. Description of your issue:

First, after seeing a Stratus V2 play, I don't think that getting the digital compass to work on the Stratux is an issue. (No warning from Stratus to place the unit away from metal or to swing the compass before using.) Still, it bugs me because the digital compass is suppose to work, whether Stratux uses it or not.

So, I bought a LEADIY-D3, per https://www.reddit.com/r/stratux/comments/479wy0/ry835ai_ahrs_alternative_for_sale_2499/

(Note now that the website leadiy.com (all in Chinese) shows a -D3A now.)

It says it has the same chipset as the RY835ai.

It has (ostensibly) a Honeywell HMC5883L on the board. (Ostensibly because it says L883 on the IC.)

Although I get a "Heading" indication in the Stratux UI AHRS page that tracks, that appears to be a (drifting) gyro output, that starts at 360 degrees when the Stratux first powers up, regardless of the orientation of the Stratux.

I got out my old 'scope. Now, my eyes are old, my hands are shaky, and these parts have gotten a lot smaller. (And my 'scope pin probe a lot bigger.) So someone should confirm my findings.

Data sheet from http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/HMC5883L_3-Axis_Digital_Compass_IC.pdf (Updated for Data Sheet for the "L" version.)

Pin 1, SCL is not toggling. It stays high all the time. (The header pin on the board for SCL does pulse low.) Pin 16, SDA is also high all the time.

Pin 2 and Pin 4 are connected by the PCB. The data sheet shows that Pin 4 is supposed to be No Connection.

~~Pin 14 is supposed to tie to Pin 2 in a single supply configuration. If it does, I can't see a pad. Looking at an enlargement of the same board without the L883 confirms that there is no connection on pin 14. http://www.amazon.co.uk/LEADIY-D3C-MPU6050-Angular-Sensor-Acceleration/dp/B00WG9HUTM?tag=duc08-21~~

Some folks in the arduino forum have been fighting inconsistencies with data sheets and code. http://forum.arduino.cc/index.php?topic=55159.0

They also say that the chip is susceptible to failure from reflow soldering.

If there are actual misconnections at the hardware level (on the PCB) , then it might be that no amount of code is going to make the chip with this board.

(Updated to remove reference to pin 15, DRDY. Not needed unless max throughput it desired.)

I'll leave it to Chris to close this "issue" out.

Ergonomicmike commented 8 years ago

So now I'm wondering aloud if the Stratux waits for the Compass to self test and then if it switches the Compass from the default single to continuous mode? From the datasheet:


OPERATIONAL EXAMPLES The HMC5883L has a fairly quick stabilization time from no voltage to stable and ready for data retrieval. The nominal 56 milli-seconds with the factory default single measurement mode means that the six bytes of magnetic data registers (DXRA, DXRB, DZRA, DZRB, DYRA, and DYRB) are filled with a valid first measurement. To change the measurement mode to continuous measurement mode, after the power-up time send the three bytes: 0x3C 0x02 0x00 This writes the 00 into the second register or mode register to switch from single to continuous measurement mode setting. With the data rate at the factory default of 15Hz updates, a 67 milli-second typical delay should be allowed by the I 2 C master before querying the HMC5883L data registers for new measurements. To clock out the new data, send: 0x3D, and clock out DXRA, DXRB, DZRA, DZRB, DYRA, and DYRB located in registers 3 through 8. The HMC5883L will automatically re-point back to register 3 for the next 0x3D query. All six data registers must be read properly before new data can be placed in any of these data registers.

Below is an example of a (power-on) initialization process for “continuous-measurement mode”:

  1. Write CRA (00) – send 0x3C 0x00 0x70 (8-average, 15 Hz default, normal measurement)
  2. Write CRB (01) – send 0x3C 0x01 0xA0 (Gain=5, or any other desired gain)
  3. Write Mode (02) – send 0x3C 0x02 0x00 (Continuous-measurement mode)
  4. Wait 6 ms or monitor status register or DRDY hardware interrupt pin
  5. Loop Send 0x3D 0x06 (Read all 6 bytes. If gain is changed then this data set is using previous gain) Convert three 16-bit 2’s compliment hex values to decimal values and assign to X, Z, Y, respectively. Send 0x3C 0x03 (point to first data register 03) Wait about 67 ms (if 15 Hz rate) or monitor status register or DRDY hardware interrupt pin End_loop
Ergonomicmike commented 8 years ago

BTW, in addition to the fact that the compass doesn't detect North on start up, it does not deviate when it's running when I hold a strong magnet near the chip either.

Ergonomicmike commented 8 years ago

So, since the SCL input is always high to the Compass, I have to assume that it's wired to the MPU-6050's Auxiliary i2c bus.

I also assume that the Compass has to be switched to the Continuous Measurement Mode thru the MPU-6050's Aux Bus. (A one time event after 56 milliseconds after start up.)

On page 26 of the MPU-6050 datasheet they discuss using their Aux i2c bus for Magnetometers. They say this is good for sensor fusion in their on-chip DMP. (But since metal in the aircraft could be a problem, the Stratux might not want that fusion. OTOH, perhaps knowing mag field components would mitigate the pitching up in a bank? Might be worth a try.)


7.11 Auxiliary I 2 C Serial Interface The MPU-60X0 has an auxiliary I 2 C bus for communicating to an off-chip 3-Axis digital output magnetometer or other sensors. This bus has two operating modes:

Auxiliary I 2 C Bus Modes of Operation:

Pass Through mode sounds more like what Chris wants. But I can't tell if you HAVE to use analog switches (on the PCB) for AUX-DA and AUX-CL. Update: Apparently the "Serial Interface Bypas Mux" contains the analog switches.

Even if you don't need analog switches, it appears from the traces on the LEADIY-D3 that it is wired for the Auxiliary Mode of the MPU-6050. (That is, the SCL pin from the Compass comes from the AUX-CL pin on the 6050.) So it seems that it would take a different PCB layout for Pass-Through Mode.

So if Stratux had to have Compass, and if there are no production boards wired for Pass-Through, then someone might have to come up with a break out board specifically for the Stratux.

Ergonomicmike commented 8 years ago

Boy, they don't make this easy.

Here's the separate Register Map document for the MPU-650 that tells how to send initialization data to the Compass via the Auxillary SCL & SDA. http://43zrtwysvxb2gf29r5o0athu.wpengine.netdna-cdn.com/wp-content/uploads/2015/02/MPU-6500-Register-Map2.pdf

Ergonomicmike commented 8 years ago

It seems to me that someone must have done all this already. Here's one with compass integration. https://github.com/wesleymilan/Dual-MPU9150-DMP-Intel-Galileo-and-Edison-CPP

Update: I notice that they have code to do the Aux SCL thing. (But I didn't see code to switch their Compass to Continuous.)

Ergonomicmike commented 8 years ago

Also, FWIW, some code here:

http://elinux.org/Sparkfun:_HMC5883L_Magnetometer

skypuppy commented 8 years ago

Wow, another serendipitous coincidence. My first embedded system was a BeagleBone Black! I got 4 of them for different projects while learning this stuff.

This is relevant to the Pi because of one fantastic resource I found that is applicable to both worlds, a book called "Exploring Beaglebone," by Prof. Derek Molloy. It's available from Amazon and elsewhere. I've used it many, many times over the past year+ and it is extremely helpful. It's about 550 pages of pure gold. I have needed/read thousands of tech books over my years and this one tops them all and by a huge margin. The first 200 pages or so are about the basics of Linux. There is also a section, with examples, of basic electronics.
Then the fun starts. He give the theory, then the practical, a whole lot of practical, about using these little beasts. While it focuses on the BeagleBone Black, with just a few address and pin changes, it applies almost 100% to the RPi2/3! I can't say enough good about the information in this work of Dr. Molloy's. I have used my first one so many times that the pages are falling out!!! (Amazon, amazingly, replaced it at no charge, when it should have been the publishers responsibility, Wiley.) It talks about interfacing with I2C, SPI, serial, using Eclipse and Qt, making the RPi a web server, interfacing to it via ssh with or without X, and so much more -- ALL with 'C/C++' code examples and a little bit of Java and Python now and then. Further, all code in the book is backed up and kept current and corrected on the accompanying website.
He even answers simple and complex tech questions on that eb site!!!!!
I'm telling you, this guy is tireless. He makes 45 minute web videos about many topics having to do with computers and sensors, and so on. Remember, though, that his code is aimed at teaching an audience, not optimizing the source code.

The companion website is here: www.exploringbeaglebone.com, segregated by chapter with chapter topic very evident.

Skypuppy

On 03/13/2016 08:33 PM, Ergonomicmike wrote:

Also, FWIW, some code here:

http://elinux.org/Sparkfun:_HMC5883L_Magnetometer

— Reply to this email directly or view it on GitHub https://github.com/cyoung/stratux/issues/309#issuecomment-196098486.

Ergonomicmike commented 8 years ago

I noticed that LithuanianAmerican no longer sells the LEADIY-D3. Last he emailed me, he was trying to talk to the Compass, without success. I noticed in the reddit that ppl are moving on to another chipset. So am closing this.