need help with hmc5883

Post Reply
xnaron
Posts: 1
Joined: Mon Feb 21, 2011 3:36 am

need help with hmc5883

Post by xnaron »

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
Attachments
compass.jpg
mag.JPG
(24.01 KiB) Not downloaded yet

JussiH
Posts: 39
Joined: Thu Jan 20, 2011 1:16 am

Re: need help with hmc5883

Post by JussiH »

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....

User avatar
BlueAngel
Posts: 30
Joined: Sun Feb 27, 2011 11:35 am

Re: need help with hmc5883

Post by BlueAngel »

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:
IMGP4172.JPG

IMGP4169.JPG

IMGP4163.JPG


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?

arnaldo
Posts: 49
Joined: Sun Mar 06, 2011 4:53 pm

Re: need help with hmc5883

Post by arnaldo »

i have the same problem...

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: need help with hmc5883

Post by Alexinparis »

arnaldo wrote:i have the same problem...

please try the dev version with its mag calibration feature.
it should correct this problem.

arnaldo
Posts: 49
Joined: Sun Mar 06, 2011 4:53 pm

Re: need help with hmc5883

Post by arnaldo »

where is dev version?


ops...just read on rcgroups

arnaldo
Posts: 49
Joined: Sun Mar 06, 2011 4:53 pm

Re: need help with hmc5883

Post by arnaldo »

after calibration the problem is the same...

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: need help with hmc5883

Post by ziss_dm »

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

arnaldo
Posts: 49
Joined: Sun Mar 06, 2011 4:53 pm

Re: need help with hmc5883

Post by arnaldo »

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...

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: need help with hmc5883

Post by ziss_dm »

Hi,
It is not normal.. :(
Check the Z axes of magnetometer. It should be positive.

regards,
ziss_dm

arnaldo
Posts: 49
Joined: Sun Mar 06, 2011 4:53 pm

Re: need help with hmc5883

Post by arnaldo »

where i can check that?

ziss_dm
Posts: 529
Joined: Tue Mar 08, 2011 5:26 am

Re: need help with hmc5883

Post by ziss_dm »

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

pequod
Posts: 6
Joined: Fri May 06, 2011 9:14 am

Re: need help with hmc5883

Post by pequod »

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.

arnaldo
Posts: 49
Joined: Sun Mar 06, 2011 4:53 pm

Re: need help with hmc5883

Post by arnaldo »

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...

pequod
Posts: 6
Joined: Fri May 06, 2011 9:14 am

Re: need help with hmc5883

Post by pequod »

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.

arnaldo
Posts: 49
Joined: Sun Mar 06, 2011 4:53 pm

Re: need help with hmc5883

Post by arnaldo »

can you make me the file to test mag? i'm not so expert to make it...

noobee
Posts: 66
Joined: Fri Feb 25, 2011 2:57 pm

Re: need help with hmc5883

Post by noobee »

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 417 times

pequod
Posts: 6
Joined: Fri May 06, 2011 9:14 am

Re: need help with hmc5883

Post by pequod »

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?

arnaldo
Posts: 49
Joined: Sun Mar 06, 2011 4:53 pm

Re: need help with hmc5883

Post by arnaldo »

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!

arnaldo
Posts: 49
Joined: Sun Mar 06, 2011 4:53 pm

Re: need help with hmc5883

Post by arnaldo »

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

doduveloce
Posts: 5
Joined: Fri May 13, 2011 9:43 pm

Re: need help with hmc5883

Post by doduveloce »

Hi all,

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

arnaldo
Posts: 49
Joined: Sun Mar 06, 2011 4:53 pm

Re: need help with hmc5883

Post by arnaldo »


noobee
Posts: 66
Joined: Fri Feb 25, 2011 2:57 pm

Re: need help with hmc5883

Post by noobee »

arnaldo wrote:now mine works perfectly

http://www.youtube.com/watch?v=ImO-jMp-rZ4


so, what was the problem and how did you fix it?

thanks.

MadEmY
Posts: 4
Joined: Wed May 25, 2011 10:05 pm

Re: need help with hmc5883

Post by MadEmY »

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!!!
Attachments
Paris 3.0 Layout
Paris 3.0 Layout

capt
Posts: 54
Joined: Wed Jan 19, 2011 10:54 pm

Re: need help with hmc5883

Post by capt »

That looks right.

MadEmY
Posts: 4
Joined: Wed May 25, 2011 10:05 pm

Re: need help with hmc5883

Post by MadEmY »

TNX a lot Capt,

Bye!

arnaldo
Posts: 49
Joined: Sun Mar 06, 2011 4:53 pm

Re: need help with hmc5883

Post by arnaldo »

with last dev 529 mag doesn't work well like with 526

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: need help with hmc5883

Post by Alexinparis »

even after a fine mag recalibration ?

arnaldo
Posts: 49
Joined: Sun Mar 06, 2011 4:53 pm

Re: need help with hmc5883

Post by arnaldo »

yeah...the same problem before swap channel....when i pitch the arrow rotates

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: need help with hmc5883

Post by Alexinparis »

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.

arnaldo
Posts: 49
Joined: Sun Mar 06, 2011 4:53 pm

Re: need help with hmc5883

Post by arnaldo »

i'm using allinone with same conf of other dev...:(

User avatar
BlueAngel
Posts: 30
Joined: Sun Feb 27, 2011 11:35 am

Re: need help with hmc5883

Post by BlueAngel »

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;}

ch_porchet
Posts: 3
Joined: Sun Jun 12, 2011 10:24 am

Re: need help with hmc5883

Post by ch_porchet »

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

doduveloce
Posts: 5
Joined: Fri May 13, 2011 9:43 pm

Re: need help with hmc5883

Post by doduveloce »

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:

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

ch_porchet
Posts: 3
Joined: Sun Jun 12, 2011 10:24 am

Re: need help with hmc5883

Post by ch_porchet »

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+

ch_porchet
Posts: 3
Joined: Sun Jun 12, 2011 10:24 am

Re: need help with hmc5883

Post by ch_porchet »

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

KeesvR
Posts: 194
Joined: Fri May 27, 2011 6:51 pm
Location: The Netherlands

Re: need help with hmc5883

Post by KeesvR »

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.

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: need help with hmc5883

Post by jevermeister »

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 :

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

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: need help with hmc5883

Post by Alexinparis »

Hi,
Does it follow the sensor direction like this ?
http://www.multiwii.com/faq#How_should_ ... directions

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: need help with hmc5883

Post by jevermeister »

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

User avatar
jevermeister
Posts: 708
Joined: Wed Jul 20, 2011 8:56 am
Contact:

Re: need help with hmc5883

Post by jevermeister »

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

Post Reply