need help with hmc5883
need help with hmc5883
I'm trying to get this HMC5883L as pictured below working. Can anyone comment on what is the expected behavior of the mag value when you rotate around the yaw axis? I am thinking it should read the compass direction in degrees? It is not working like this for me. Has anyone go the HMC5883L working? In the attached screenshot is the arrow under the "PITCH" supposed to be the compass?
thanks,
Brendin
thanks,
Brendin
- Attachments
-
- mag.JPG
- (24.01 KiB) Not downloaded yet
Re: need help with hmc5883
I have the HMC5883L working (sortoff) on my FF IMU 1.22L. I think there is an issue with some calibration for these units for them to be perfect. I am sure its beeing worked and will be public soon. On my unit the the numbers are definately not degrees but the arrow pretty much follows the rotation on the Z-axis!
HMC5843 seems to be working for HH on FF IMU 1.1. But I seem to get better results at certain orientations....
HMC5843 seems to be working for HH on FF IMU 1.1. But I seem to get better results at certain orientations....
Re: need help with hmc5883
I have now installed the HMC5883 too on my Jussi shield.
I am using now:
original WM+
BMA020
BMP085 + HMC5883 + LLC
it looks like this now:
completely sealed with Plasti Dip, liquid plastic, so its 100% waterproof, except the baro hole.
Mag indicator does follow the rotate too very good, but when i roll or pitch the board, the value does change too.
Is that, because the z-axis is only for a few degrees in x and y axis compensated?
I am using now:
original WM+
BMA020
BMP085 + HMC5883 + LLC
it looks like this now:
completely sealed with Plasti Dip, liquid plastic, so its 100% waterproof, except the baro hole.

Mag indicator does follow the rotate too very good, but when i roll or pitch the board, the value does change too.
Is that, because the z-axis is only for a few degrees in x and y axis compensated?
Re: need help with hmc5883
i have the same problem...
-
- Posts: 1630
- Joined: Wed Jan 19, 2011 9:07 pm
Re: need help with hmc5883
arnaldo wrote:i have the same problem...
please try the dev version with its mag calibration feature.
it should correct this problem.
Re: need help with hmc5883
where is dev version?
ops...just read on rcgroups
ops...just read on rcgroups
Re: need help with hmc5883
after calibration the problem is the same...
Re: need help with hmc5883
Hi arnaldo,
I think, in dev version the arrow should point "somethere" (Actually east or west, don't remember exactly). But this "somethere" should remain the same. So it is not really the compass, but it should work for heading lock.
regards,
ziss_dm
I think, in dev version the arrow should point "somethere" (Actually east or west, don't remember exactly). But this "somethere" should remain the same. So it is not really the compass, but it should work for heading lock.
regards,
ziss_dm
Re: need help with hmc5883
mmmm...i don't undesrtand....it's normal if i pitch the model forward about 50° to see the arrow rotates 90°???? it should be locked...however i will try in flight...
in 1,7 versione when...in flight i pitch the model...the tail turned(the same as in the gui) so flight was horrible...
in 1,7 versione when...in flight i pitch the model...the tail turned(the same as in the gui) so flight was horrible...
Re: need help with hmc5883
Hi,
It is not normal..
Check the Z axes of magnetometer. It should be positive.
regards,
ziss_dm
It is not normal..

Check the Z axes of magnetometer. It should be positive.
regards,
ziss_dm
Re: need help with hmc5883
where i can check that?
Re: need help with hmc5883
Hi,
You can put Serial.println(magADC[YAW] ); at the end of the i2c_Mag_getADC () and check values through serial monitor in Arduino IDE.
regards,
ziss_dm
You can put Serial.println(magADC[YAW] ); at the end of the i2c_Mag_getADC () and check values through serial monitor in Arduino IDE.
regards,
ziss_dm
Re: need help with hmc5883
HMC 5883 L issue
The issue with my HMC5883L is the lack of valid z-axis values.
They are normally stored in the registers (0x05 and 0x06; HMC5843
uses register 0x07 and 0x08).
Reading those registers combined always shows the values 0 or -4096. x-, and y- readings are ok. (Datasheet -4096 indicates adc under- or overflow!?)
Z- values measuring is essential for computing heading-values if the
unit is not parallel to earth's surface causing a pitch- or roll-offset.
Details are here:
http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/Magnetic__Literature_Technical_Article-documents/Applications_of_Magnetic_Sensors_for_Low_Cost_Compass_Systems.pdf
You can check this by extracting the hmc related multiwii code snippet in a
seperate sketch displaying the values in the serial monitor or e.g.
using this code (wire lib needed):
http://garden.seeedstudio.com/index....3-axis_Compass
Calibrating the unit or changing the gain settings by manipulating configuration registers did not solve this issue in my case. Though I think that the unit itself is buggy. Your observations would be interesting.
The issue with my HMC5883L is the lack of valid z-axis values.
They are normally stored in the registers (0x05 and 0x06; HMC5843
uses register 0x07 and 0x08).
Reading those registers combined always shows the values 0 or -4096. x-, and y- readings are ok. (Datasheet -4096 indicates adc under- or overflow!?)
Z- values measuring is essential for computing heading-values if the
unit is not parallel to earth's surface causing a pitch- or roll-offset.
Details are here:
http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/Magnetic__Literature_Technical_Article-documents/Applications_of_Magnetic_Sensors_for_Low_Cost_Compass_Systems.pdf
You can check this by extracting the hmc related multiwii code snippet in a
seperate sketch displaying the values in the serial monitor or e.g.
using this code (wire lib needed):
http://garden.seeedstudio.com/index....3-axis_Compass
Calibrating the unit or changing the gain settings by manipulating configuration registers did not solve this issue in my case. Though I think that the unit itself is buggy. Your observations would be interesting.
Re: need help with hmc5883
with the last dev...5008...i can see correct values on z axes...but when i move it on pitch and roll axes...there is correct values on these axes...but also z axes rotate of 180degree...
Re: need help with hmc5883
Could you post some representive (raw) z-values, obtained directly from the hmc5883L registers 5 and 6.
Correct z-values are essential for transforming the mag-values in the horizontal plane and tilt-compensation.
If the z-values are not correct the heading reading is somehow erratic as described above.
Be sure not to confuse the pitch, roll, yaw values presented bei the MultiWii-GUI with the raw measurements of the
earth magnetic field by the hmc senor. The latter are three 12Bit values held in the registers 3-8 of the hmc.
Use special sw as described above to read these registers directly and sending them to arduino serial monitor.
If raw z-values read from the register 5 and 6 are peramanently 0 or -4096 the algo used by the MultiWii Programm will never produce
any reliable compass headings if the unit is tilt. That seems to be the situation you described above.
Correct z-values are essential for transforming the mag-values in the horizontal plane and tilt-compensation.
If the z-values are not correct the heading reading is somehow erratic as described above.
Be sure not to confuse the pitch, roll, yaw values presented bei the MultiWii-GUI with the raw measurements of the
earth magnetic field by the hmc senor. The latter are three 12Bit values held in the registers 3-8 of the hmc.
Use special sw as described above to read these registers directly and sending them to arduino serial monitor.
If raw z-values read from the register 5 and 6 are peramanently 0 or -4096 the algo used by the MultiWii Programm will never produce
any reliable compass headings if the unit is tilt. That seems to be the situation you described above.
Re: need help with hmc5883
can you make me the file to test mag? i'm not so expert to make it...
Re: need help with hmc5883
try running this test pde file. it prints the raw x,y,z values as well as the status byte and ID string.
- Attachments
-
- hmc5883l_test.zip
- (664 Bytes) Downloaded 491 times
Re: need help with hmc5883
I would have offered a similar sketch.
But as I see now the latest dev Version (5008) of the MultiWii Code (used by arnaldo) is displaying distinct x,y and z-mag values too.
It proved my problem: In the (dev)MultiWii GUI the z-mag-value is fixed to "500". Mag-x and mag-y seem to be ok.
I assume a hardware bug in my unit. Which makes it useless (mounted on a all-in-one-board
)
Has anybody made similar observations?
But as I see now the latest dev Version (5008) of the MultiWii Code (used by arnaldo) is displaying distinct x,y and z-mag values too.
It proved my problem: In the (dev)MultiWii GUI the z-mag-value is fixed to "500". Mag-x and mag-y seem to be ok.
I assume a hardware bug in my unit. Which makes it useless (mounted on a all-in-one-board

Has anybody made similar observations?
Re: need help with hmc5883
in mine all axes works fine...i don't understand why when i move on pitch roll axes the z axes rotate about 90 to 180 degree...
so qhen i go forward or backward the tail rotate...same thing on roll!
so qhen i go forward or backward the tail rotate...same thing on roll!
Re: need help with hmc5883
This video shows how my compass works!
i think it works well on yaw movements...but i don't understand the error on pitch and roll!
http://www.youtube.com/watch?v=4SUF5BYkNDs
i think it works well on yaw movements...but i don't understand the error on pitch and roll!
http://www.youtube.com/watch?v=4SUF5BYkNDs
-
- Posts: 5
- Joined: Fri May 13, 2011 9:43 pm
Re: need help with hmc5883
Hi all,
I've got same problem on Y-mag-value. Try to add this:
just after delay(100); in Mag_init()
It works now for me. This solution is not mine, I've found the info in this thread:
http://www.rcgroups.com/forums/showthread.php?t=1413106&page=18
I'm using this multiwii version MultiWii_dev20110508.
For calibrate mag, you have to turn your multiwii in all direction.
I've not done a test in flight, maybe next week.
Olivier
I've got same problem on Y-mag-value. Try to add this:
Code: Select all
i2c_rep_start(0X3C+0); // I2C write direction
i2c_write(0x01); // Write to cfgb register
i2c_write(0x60); // gain 2.5 gauss
just after delay(100); in Mag_init()
It works now for me. This solution is not mine, I've found the info in this thread:
http://www.rcgroups.com/forums/showthread.php?t=1413106&page=18
I'm using this multiwii version MultiWii_dev20110508.
For calibrate mag, you have to turn your multiwii in all direction.
I've not done a test in flight, maybe next week.
Olivier
Re: need help with hmc5883
so, what was the problem and how did you fix it?
thanks.
Re: need help with hmc5883
Hi Guys,
may someone confirm the orientation of my HMC5843 and BMA 180 sensors?
I've seen the youtube video of previous posts, and I think that my board work fine, I need just a confirm...
Thank a lot.
BYE!!!
may someone confirm the orientation of my HMC5843 and BMA 180 sensors?
I've seen the youtube video of previous posts, and I think that my board work fine, I need just a confirm...
Thank a lot.
BYE!!!
Re: need help with hmc5883
TNX a lot Capt,
Bye!
Bye!
Re: need help with hmc5883
with last dev 529 mag doesn't work well like with 526
-
- Posts: 1630
- Joined: Wed Jan 19, 2011 9:07 pm
Re: need help with hmc5883
even after a fine mag recalibration ?
Re: need help with hmc5883
yeah...the same problem before swap channel....when i pitch the arrow rotates
-
- Posts: 1630
- Joined: Wed Jan 19, 2011 9:07 pm
Re: need help with hmc5883
Are you sure there is no mismatch between
#define HMC5843
#define HMC5883
in your conf ?
I redid a check, and it's ok on my FFIMU.
#define HMC5843
#define HMC5883
in your conf ?
I redid a check, and it's ok on my FFIMU.
Re: need help with hmc5883
i'm using allinone with same conf of other dev...

Re: need help with hmc5883
my HC5883 does work now with the newest dev.
I had to change sensor values to:
#define MAG_ORIENTATION(X, Y, Z) {magADC[ROLL] = Y; magADC[PITCH] = -X; magADC[YAW] = Z;}
I had to change sensor values to:
#define MAG_ORIENTATION(X, Y, Z) {magADC[ROLL] = Y; magADC[PITCH] = -X; magADC[YAW] = Z;}
-
- Posts: 3
- Joined: Sun Jun 12, 2011 10:24 am
Re: need help with hmc5883
Hello
I also have a problem with the 5883, I was only a value of 500 on 3 axes
I do not speak English very well so I use google to translate.
So does anyone can tell me how to make this work, but a simple way for me to understand.
thank you very much
Chris
I also have a problem with the 5883, I was only a value of 500 on 3 axes
I do not speak English very well so I use google to translate.
So does anyone can tell me how to make this work, but a simple way for me to understand.
thank you very much
Chris
-
- Posts: 5
- Joined: Fri May 13, 2011 9:43 pm
Re: need help with hmc5883
Hi Chris,
You'll have to decrease 5883l gain, because dafult gain cause an overflow.
This is describe on 5883l datasheet. Start by usig 0x60 then try decrease to 0x50, 0x40, 0x30.
By default gain setting is 0x20.
If you speak french I can explain in french
Olivier
in sensors.pde replace void Mag_init () by this:
You'll have to decrease 5883l gain, because dafult gain cause an overflow.
This is describe on 5883l datasheet. Start by usig 0x60 then try decrease to 0x50, 0x40, 0x30.
By default gain setting is 0x20.
If you speak french I can explain in french

Olivier
in sensors.pde replace void Mag_init () by this:
Code: Select all
void Mag_init() {
delay(100);
i2c_writeReg(0X3C ,0x01 ,0x60 ); //decrease sensor gain to avoid overflow.
i2c_writeReg(0X3C ,0x02 ,0x00 ); //register: Mode register -- value: Continuous-Conversion Mode
}
ch_porchet wrote:Hello
I also have a problem with the 5883, I was only a value of 500 on 3 axes
I do not speak English very well so I use google to translate.
So does anyone can tell me how to make this work, but a simple way for me to understand.
thank you very much
Chris
-
- Posts: 3
- Joined: Sun Jun 12, 2011 10:24 am
Re: need help with hmc5883
hello olivier
oui je parle français, mais je vais essayer de faire se que tu ma dis, enfin si j'ai bien compris
A+
oui je parle français, mais je vais essayer de faire se que tu ma dis, enfin si j'ai bien compris
A+
-
- Posts: 3
- Joined: Sun Jun 12, 2011 10:24 am
Re: need help with hmc5883
hello olivier
alors j'ai essayer de changer les valeur ,mais cela ne change rien
so I try to change the value, but that does not change
Chris
alors j'ai essayer de changer les valeur ,mais cela ne change rien
so I try to change the value, but that does not change
Chris
Re: need help with hmc5883
How should the Mag Z in the Gui react ?
Mine is only moving when i do some Pitch or Roll and not at the Yaw movement.
I can't get a good heading hold.
Mine is only moving when i do some Pitch or Roll and not at the Yaw movement.
I can't get a good heading hold.
- jevermeister
- Posts: 708
- Joined: Wed Jul 20, 2011 8:56 am
- Contact:
Re: need help with hmc5883
Hi,
I have one question too.
I mounted this thingy upside down and did ade a mistake:
My Mistake was not mounting the board facing north .
After running into the trouble: The arrow turned like the copter and then turns backl a little
because of the turned coordinate system I found out htat I have to do the follwing :
It now works great in flight and all movements are correctly presented by the arrow in the GUI
BUT
If I face it west it shwos me north a.s.o. Is there a way to compensate this within these Parameters (did I make a mistake) or do I have to include an offset in the code.
I know it is not neccessare for direction hold but I thin it willbecome a problem if I use GPS.
Nils
I have one question too.
I mounted this thingy upside down and did ade a mistake:
My Mistake was not mounting the board facing north .
After running into the trouble: The arrow turned like the copter and then turns backl a little
because of the turned coordinate system I found out htat I have to do the follwing :
Code: Select all
#define MAG_ORIENTATION(X, Y, Z) {magADC[ROLL] = -Y; magADC[PITCH] = -X; magADC[YAW] = Z;}
It now works great in flight and all movements are correctly presented by the arrow in the GUI
BUT
If I face it west it shwos me north a.s.o. Is there a way to compensate this within these Parameters (did I make a mistake) or do I have to include an offset in the code.
I know it is not neccessare for direction hold but I thin it willbecome a problem if I use GPS.
Nils
-
- Posts: 1630
- Joined: Wed Jan 19, 2011 9:07 pm
Re: need help with hmc5883
Hi,
Does it follow the sensor direction like this ?
http://www.multiwii.com/faq#How_should_ ... directions
Does it follow the sensor direction like this ?
http://www.multiwii.com/faq#How_should_ ... directions
- jevermeister
- Posts: 708
- Joined: Wed Jul 20, 2011 8:56 am
- Contact:
Re: need help with hmc5883
Hi,
Does it follow the sensor direction like this ?
http://www.multiwii.com/faq#How_should_ ... directions
No it didn't - but it does now

Thanks for the RTFM - I needed that alex!
The code is looking like this now:
Code: Select all
#define MAG_ORIENTATION(X, Y, Z) {magADC[ROLL] = -X; magADC[PITCH] = Y; magADC[YAW] = -Z;}
I noticed that the direction changed when I tilted the copter - so there was something really wrong.
I must admit that I do not understand these changes, I think the coordinate printing of the breakout baord is incorrect.
Addition: The reading is not that perfect, a spin by 90° reads 82°. Is the calibration not good enough? Or it is the basement I work in?
Thank you again for helping me out here Alex.
Nils
- jevermeister
- Posts: 708
- Joined: Wed Jul 20, 2011 8:56 am
- Contact:
Re: need help with hmc5883
Hm, dev mag worked well the last days in stationary flight, but if I try some action, the copter randomly changes directions.
I did some ground testing by tilting the copter: There were only minimal fluctuations in directions while tilting it.
^°°
But when I start the motors and trottle up while pressing the copter to the ground: the mag turns about 45° to 70° degrees and starts to flicker.
So my ESCs have a very big influence on it, I mounted it on the backside of my Flydusense board from Flyduino.com, it is about 3cm away from the ESC.
this was the best way to mount it in my opinion.
Is it possible to shield it from the influence( Faraday effect?) or do I have to relocate it? If yes what should I keep in mind?
Nils
I did some ground testing by tilting the copter: There were only minimal fluctuations in directions while tilting it.
^°°
But when I start the motors and trottle up while pressing the copter to the ground: the mag turns about 45° to 70° degrees and starts to flicker.
So my ESCs have a very big influence on it, I mounted it on the backside of my Flydusense board from Flyduino.com, it is about 3cm away from the ESC.
this was the best way to mount it in my opinion.
Is it possible to shield it from the influence( Faraday effect?) or do I have to relocate it? If yes what should I keep in mind?
Nils