FIX included, Center the negative mag vector values in HMC58X3::getValues(float *x,float *y,float *z)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
HMC58X3 Arduino Library |
New
|
Undecided
|
Unassigned |
Bug Description
HMC58X3:
Returns values from 2^16 when negative magnitudes are detected.
see design guide page 7 at:
corvusm3.
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://
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:
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;
}
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!