Changing HMC5883L registers to QMC5883L

Hello, everybody. I have been working with the HMC5883L compass for a while now, and through much frustration and struggles, I have figured out that the HMC5883L is not on the market anymore, but its semi-clone, the QMC5883L is. However, I am using a code for GPS Guided Robotic car from online and it is a bit difficult to change the code, so I have decided to directly hack the HMC library and change all the registers in the cpp/ and h/ files in the library. Well, I have been trying for two days now, my Serial baud is 9600, and I am using the code below to calibrate my compass but to no avail. I am using this code

/*
  Calibrate HMC5883L. Output for HMC5883L_calibrate_processing.pde
  Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-magnetometr-hmc5883l.html
  GIT: https://github.com/jarzebski/Arduino-HMC5883L
  Web: http://www.jarzebski.pl
  (c) 2014 by Korneliusz Jarzebski
*/

#include <Wire.h>
#include <HMC5883L.h>

HMC5883L compass;

int minX = 0;
int maxX = 0;
int minY = 0;
int maxY = 0;
int offX = 0;
int offY = 0;

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

  // Initialize Initialize HMC5883L
  while (!compass.begin())
  {
    delay(500);
  }

  // Set measurement range
  compass.setRange(HMC5883L_RANGE_1_3GA);

  // Set measurement mode
  compass.setMeasurementMode(HMC5883L_CONTINOUS);

  // Set data rate
  compass.setDataRate(HMC5883L_DATARATE_30HZ);

  // Set number of samples averaged
  compass.setSamples(HMC5883L_SAMPLES_8);
}

void loop()
{
  Vector mag = compass.readRaw();

  // Determine Min / Max values
  if (mag.XAxis < minX) minX = mag.XAxis;
  if (mag.XAxis > maxX) maxX = mag.XAxis;
  if (mag.YAxis < minY) minY = mag.YAxis;
  if (mag.YAxis > maxY) maxY = mag.YAxis;

  // Calculate offsets
  offX = (maxX + minX)/2;
  offY = (maxY + minY)/2;

  Serial.print(mag.XAxis);
  Serial.print(":");
  Serial.print(mag.YAxis);
  Serial.print(":");
  Serial.print(minX);
  Serial.print(":");
  Serial.print(maxX);
  Serial.print(":");
  Serial.print(minY);
  Serial.print(":");
  Serial.print(maxY);
  Serial.print(":");
  Serial.print(offX);
  Serial.print(":");
  Serial.print(offY);
  Serial.print("\n");
}

Well, no data is coming from the Serial Monitor. I also will attach the registers I changed. The code I am about to attach is the registers in .h file of the HMC5883L library to make the QMC work on the same library.

#define HMC5883L_ADDRESS              (0x0D) 
#define HMC5883L_REG_CONFIG_A         (0x0A) 
#define HMC5883L_REG_CONFIG_B         (0x0B) 
#define HMC5883L_REG_MODE             (0x09) 
#define HMC5883L_REG_OUT_X_M          (0x01) 
#define HMC5883L_REG_OUT_X_L          (0x00) 
#define HMC5883L_REG_OUT_Z_M          (0x05) 
#define HMC5883L_REG_OUT_Z_L          (0x04) 
#define HMC5883L_REG_OUT_Y_M          (0x03) 
#define HMC5883L_REG_OUT_Y_L          (0x02) 
#define HMC5883L_REG_STATUS           (0x0C) 
#define HMC5883L_REG_IDENT_A          (0x06) 
#define HMC5883L_REG_IDENT_B          (0x07) 
#define HMC5883L_REG_IDENT_C          (0x08)

NOTE: THIS CODE ABOVE IS FOR THE .H FILE FOR THE HMC5883L AFTER I CHANGED THE REGISTERS TO QMC REGISTERS

Does anybody know what my problem is?

Best regards, Daniel

Much easier to use one of the QMC5883 libraries instead. Only minor changes to calling programs are required.

I understand, sir. I am currently working on project using code for HMC5883L, and I simply don't have time or knowledge to change code to my liking. May you please guide me, because I have been working on this for a while and am getting lost. Here is a link for tutorial code for the project:

N

I simply don't have time or knowledge to change code to my liking.

Please explain why you wasted so much time trying to modify the HMC5883 library.

You can post a request on the Gigs & Collaborations section, but you might be asked to pay for the help.

I cannot change the code altogether so I was wondering if you had any experience with changing these registers.

I cannot change the code altogether

That is a joke, right?

I don't have time and do not know enough to change code. Please help instead of making fun of me

Hi Daniel,

It depends on which QMC5883L you're using.

After a somewhat torturous investigation, it turns out there's an A and B version of device, labelled DA5883 and DB5883 on the chip respectively.

The DA5883 is identical to the HMC5883L, except (and I kid you not) that the status register doesn't work. In this case it's possible to use a HMC5883L library, but it's necessary to comment out lines that poll the data ready (RDY) bit in the status register. Instead just read the data after a sample time delay of so many milliseconds in your sketch.

The DB5883 on the other hand is a completely different device and functions according the the QMC5883L datasheet. In this case, as jremington suggests just use a QMC5883L library instead.

It's rather frustrating, as these changes are completely undocumented and have caused a good deal of confusion for those of us using this device.

Thank you for your advice.

Daniel