FIX included, Center the negative mag vector values in HMC58X3::getValues(float *x,float *y,float *z)

Bug #793873 reported by Joachimp-x
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
HMC58X3 Arduino Library
New
Undecided
Unassigned

Bug Description

HMC58X3::getValues(float *x,float *y,float *z)
Returns values from 2^16 when negative magnitudes are detected.

see design guide page 7 at:
corvusm3.googlecode.com/files/DesignGuide5843revB.pdf

NB, I'm using your library with the LeafLabs Maple RET6 which has a native implementation of Wiring for an 72MHz ARM Cortex M3 including native working i2c lib.
http://leaflabs.com/

The fix is simple, shift the values of negative magnitude from centered on 2^16 to zero:
  if(xr > 2048) xr -= 65536;

Implimented in: HMC58X3.cpp

void HMC58X3::getValues(float *x,float *y,float *z) {
  int xr,yr,zr;

  getRaw(&xr, &yr, &zr);

  //if magnitude is negative, i.e. greater than 2048 , adjust to return negative
  if(xr > 2048) xr -= 65536;
  if(yr > 2048) yr -= 65536;
  if(zr > 2048) zr -= 65536;
  // end fix negative

  *x= ((float) xr) / x_scale;
  *y = ((float) yr) / y_scale;
  *z = ((float) zr) / z_scale;
}

Revision history for this message
Fabio Varesano (fabio-varesano) wrote :

Hi there, I'm not sure I follow what problem is the library giving you.. would you please elaborate a bit more and/or provide example code which isn't working as it should? Thanks!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.