module for the HMC5883L compass

Discuss PIC and electronic related things

Moderators: David Barker, Jerry Messina

Post Reply
backpacker69
Posts: 18
Joined: Sun Feb 03, 2013 2:26 am
Location: Salmon, Idaho

module for the HMC5883L compass

Post by backpacker69 » Thu Aug 23, 2018 2:08 pm

Want to experiment using an electronic compass and all I find are Adriuno library stuff and one using an 18F4550 but in C.
So I guess I need to convert the C source code into Swordfish (familiar territory) but???
I figure I would inquire if anyone has dealt with an electronic compass using Swordfish?
I miss backpacking the Sierras

Jerry Messina
Swordfish Developer
Posts: 1237
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: module for the HMC5883L compass

Post by Jerry Messina » Thu Aug 23, 2018 5:12 pm

Looks like the HMC5883L is no longer available... you might want to try another IC

backpacker69
Posts: 18
Joined: Sun Feb 03, 2013 2:26 am
Location: Salmon, Idaho

Re: module for the HMC5883L compass

Post by backpacker69 » Thu Aug 23, 2018 6:13 pm

been looking at using the breakout board available from adafruit as well as sparkfun unless there is a better choice?
I miss backpacking the Sierras

Jerry Messina
Swordfish Developer
Posts: 1237
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: module for the HMC5883L compass

Post by Jerry Messina » Thu Aug 23, 2018 6:18 pm

From what I see both of those are no longer available.

I don't have any suggestions... never used one.

backpacker69
Posts: 18
Joined: Sun Feb 03, 2013 2:26 am
Location: Salmon, Idaho

Re: module for the HMC5883L compass

Post by backpacker69 » Thu Aug 23, 2018 6:49 pm

found what may be a better solution
https://www.memsic.com/userfiles/files/ ... _FRevH.pdf
has PWM as well as A/D output
Now to figure out how to implement.
Microchip has a paper on it AN996
http://ww1.microchip.com/downloads/en/A ... 00996a.pdf
now the fun begins but looking at the data sheet it looks like it may be easier than it looks using A/D
I am only interested in measuring about 5-10 degree difference but don't really need an LCD display for my project that I want to build for my E-trike
I miss backpacking the Sierras

backpacker69
Posts: 18
Joined: Sun Feb 03, 2013 2:26 am
Location: Salmon, Idaho

Re: module for the HMC5883L compass

Post by backpacker69 » Thu Aug 23, 2018 7:05 pm

the mxd2020el is no longer in production but did find several sources for a breakout board using the HMC5883L
https://www.robotshop.com/en/hmc5883l-b ... mpass.html
the A/D feature nice but?
I miss backpacking the Sierras

backpacker69
Posts: 18
Joined: Sun Feb 03, 2013 2:26 am
Location: Salmon, Idaho

Re: module for the HMC5883L compass

Post by backpacker69 » Thu Aug 23, 2018 10:20 pm

After some searching for a sensor that is available I found a breakout board at sparkfun that has a simple code that dosen't use any adrunio library. now I need to convert to Swordfish to load into a pic. then instead of an lcd (will use opti-coupler) in final project).

Code: Select all

#include <SparkFun_MAG3110.h>

MAG3110 mag = MAG3110(); //Instantiate MAG3110

void setup() {
  Serial.begin(9600);

  mag.initialize(); //Initializes the mag sensor
  mag.start();      //Puts the sensor in active mode
}

void loop() {

  int x, y, z;
  //Only read data when it's ready
  if(mag.dataReady()) {
    //Read the data
    mag.readMag(&x, &y, &z);

    Serial.print("X: ");
    Serial.print(x);
    Serial.print(", Y: ");
    Serial.print(y);
    Serial.print(", Z: ");
    Serial.println(z);

    Serial.println("--------");
  }
}
I miss backpacking the Sierras

Ralph
Posts: 15
Joined: Tue Apr 01, 2008 3:15 am
Location: Melbourne, Australia

Re: module for the HMC5883L compass

Post by Ralph » Sun Aug 26, 2018 10:44 am

I used the CMPS11 module https://www.robot-electronics.co.uk/htm/cmps11doc.htm with great success. This particular module does all the heavy lifting as it takes care of the tilt compensating maths for you. If you decide to go down this path I can post the two or three lines of code that I used - it was very simple to get going.

Post Reply