Go Down

Topic: Problem with HMC5883L (Read 5 times) previous topic - next topic

ciucianebbia

Hello,
I have a problem with HMC5883L magnetometer:
card: Arduino 2009
Soft: HMC5883L_Example.pde

The sketch is loaded into the card (arduino) but in the serial monitor I have this:

Constructing new HMC5883L
Setting scale to +/- 1.3 Ga
Entered scale was not valid, valid gauss values are: 0.88, 1.3, 1.9, 2.5, 4.0, 4.7, 5.6, 8.1
Setting measurement mode to continous.
Entered scale was not valid, valid gauss values are: 0.88, 1.3, 1.9, 2.5, 4.0, 4.7, 5.6, 8.1
Raw:   875   1795   883      Scaled:   805.00   1651.40   812.36      Heading:   1.16 Radians      66.63 Degrees      
Raw:   875   1795   883      Scaled:   805.00   1651.40   812.36      Heading:   1.16 Radians      66.63 Degrees      
Raw:   875   1795   883      Scaled:   805.00   1651.40   812.36      Heading:   1.16 Radians      66.63 Degrees      
Raw:   875   1795   883      Scaled:   805.00   1651.40   812.36      Heading:   1.16 Radians      66.63 Degrees      
Raw:   -18176   -15872   322      Scaled:   805.00   1651.40   812.36      Heading:   1.16 Radians      66.63 Degrees      
Raw:   875   1795   883      Scaled:   805.00   1651.40   812.36      Heading:   1.16 Radians      66.63 Degrees      
Raw:   875   1795   883      Scaled:   805.00   1651.40   812.36      Heading:   1.16 Radians      66.63 Degrees      

and so on.

What's happened ?

Thanx

warren631

I use the standard "HMC5883L_Example.INO" and it seems to work but I still get the error:
Quote
Entered scale was not valid, valid gauss values are: 0.88, 1.3, 1.9, 2.5, 4.0, 4.7, 5.6, 8.1

I have tried all those values but I always get this error and changing these numbers doesn't seem to make any difference to the readings.
Why do I get this error?

zittermann


Hello,
I have a problem with HMC5883L magnetometer:
card: Arduino 2009
Soft: HMC5883L_Example.pde

The sketch is loaded into the card (arduino) but in the serial monitor I have this:

Constructing new HMC5883L
Setting scale to +/- 1.3 Ga
Entered scale was not valid, valid gauss values are: 0.88, 1.3, 1.9, 2.5, 4.0, 4.7, 5.6, 8.1
Setting measurement mode to continous.
Entered scale was not valid, valid gauss values are: 0.88, 1.3, 1.9, 2.5, 4.0, 4.7, 5.6, 8.1
Raw:   875   1795   883      Scaled:   805.00   1651.40   812.36      Heading:   1.16 Radians      66.63 Degrees      
Raw:   875   1795   883      Scaled:   805.00   1651.40   812.36      Heading:   1.16 Radians      66.63 Degrees      
Raw:   875   1795   883      Scaled:   805.00   1651.40   812.36      Heading:   1.16 Radians      66.63 Degrees      
Raw:   875   1795   883      Scaled:   805.00   1651.40   812.36      Heading:   1.16 Radians      66.63 Degrees      
Raw:   -18176   -15872   322      Scaled:   805.00   1651.40   812.36      Heading:   1.16 Radians      66.63 Degrees      
Raw:   875   1795   883      Scaled:   805.00   1651.40   812.36      Heading:   1.16 Radians      66.63 Degrees      
Raw:   875   1795   883      Scaled:   805.00   1651.40   812.36      Heading:   1.16 Radians      66.63 Degrees      

and so on.

What's happened ?

Thanx



I get the same errors. Any ideas to get this fixed?

pito

#8
Jan 28, 2013, 11:02 pm Last Edit: Jan 28, 2013, 11:17 pm by pito Reason: 1
..in HMC5883L.cpp change to:
Code: [Select]
char* HMC5883L::GetErrorText(int errorCode)
{
if(errorCode == ErrorCode_1_Num)
return ErrorCode_1;

return "Error not defined."; //or "No error" ??
}


Also such stuff like:
Code: [Select]

int HMC5883L::SetScale(float gauss)
{
uint8_t regValue = 0x00;
if(gauss == 0.88)
{
regValue = 0x00;
m_Scale = 0.73;
}
else if(gauss == 1.3)
{
regValue = 0x01;
m_Scale = 0.92;
}
else if(gauss == 1.9)
{
regValue = 0x02;
..

is of course not to recommend, I would rather use int "gauss" values instead of floats there..

This library does not calibrate the sensor, so when you move a magnet around the values changes and stay off (and you may get wrong heading). Google for HMC58X3 v04 - that driver includes calibration..
https://launchpad.net/hmc58x3

michinyon

I found three lots of code on the net for that device,   and they all had obvious mistakes.

One was so bad, it had obviously never been attempted to actually use.

In the end, I wrote my own.

As for the magnet-waving around, these devices are intended to detect the very weak magnetic
field of the earth.  Waving a magnet around near them is going to impose a much larger magnetic field,
possibly overload them,  and cause problems with overflows in the readings.   If you want to detect magnets,
you need to turn the sensitivity of the device down.

You need to calibrate the device  by setting the offset and scaling factor for each axial direction,  so that
the magnitude of the apparent field vector remains approximately constant no matter which way you
orient the device. 



Go Up