Page 1 of 1

module for the HMC5883L compass

Posted: Thu Aug 23, 2018 2:08 pm
by backpacker69
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?

Re: module for the HMC5883L compass

Posted: Thu Aug 23, 2018 5:12 pm
by Jerry Messina
Looks like the HMC5883L is no longer available... you might want to try another IC

Re: module for the HMC5883L compass

Posted: Thu Aug 23, 2018 6:13 pm
by backpacker69
been looking at using the breakout board available from adafruit as well as sparkfun unless there is a better choice?

Re: module for the HMC5883L compass

Posted: Thu Aug 23, 2018 6:18 pm
by Jerry Messina
From what I see both of those are no longer available.

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

Re: module for the HMC5883L compass

Posted: Thu Aug 23, 2018 6:49 pm
by backpacker69
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

Re: module for the HMC5883L compass

Posted: Thu Aug 23, 2018 7:05 pm
by backpacker69
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?

Re: module for the HMC5883L compass

Posted: Thu Aug 23, 2018 10:20 pm
by backpacker69
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("--------");
  }
}

Re: module for the HMC5883L compass

Posted: Sun Aug 26, 2018 10:44 am
by Ralph
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.