Saludos
Revisando encontré que el heading en mi programa (justo despues del atan2) nunca llega a valores superiores a 2*pi, es posible que tengas razon en lo del tipo de dato que espera ese bloque de atan2
esos 0.92/1000 estaban mal. basandome en un programa de arduino, solo se multiplica los valores raw por la escala elegida, en mi caso seria 0.92 unicamente.
la configuracion es la siguiente:
1.Configuration Register A = 0x10 (configuración por defecto) (¿porque tienes este registro en 0x70?)
con la configuracion de este registro en 0x10, segun el datasheet tendria:
-Typical Data Output Rate (Hz) = 15 (Default)
-Measurement Mode = Normal measurement configuration (Default). In normal measurement configuration the device follows normal measurement flow. The positive and negative pins of the resistive load are left floating and high impedance.
Configuracion Register B = 0x20 (configuracion por defecto)
Recommended Sensor Field Range = 1.3 gauss
Gain(LSb/Gauss) = 1092 (default)
Digital Resolution (mG/LSb) = 0.92 (esta es la escala por la que multiplico los valores raw)
Mode Register = 0x0 (Medicion continua)
Continuous-Measurement Mode. In continuous-measurement mode, the device continuously performs measurements and places the result in the data register. RDY goes high when new data is placed in all three registers. After a power-on or a write to the mode or configuration register, the first measurement set is available from all three data output registers after a period of 2/fDO and subsequent measurements are available at a frequency of fDO, where fDO is the frequency of data output.
Estoy seguro de que el problema que tengo está en el atan o en la medicion de los valores raw, pues en la salida de ese atan nunca llega a valores superiores a 6.28 (2*pi)
probe este programa en arduino y funciona perfectamente, da el giro de 0 a 360, por este descubri que mi heading nunca llega a valores superiores a 2*pi...creo que nisiquiera tiene calibración, solo agrega un angulo de inclinacion que corresponde a nuestra ubicacion geografica, en mi caso seria -0.105 rad
// Calculate heading when the magnetometer is level, then correct for signs of axis.
float heading = atan2(scaled.YAxis, scaled.XAxis);
// Once you have your heading, you must then add your 'Declination Angle', which is the 'Error' of the magnetic field in your location.
// Find yours here:
http://www.magnetic-declination.com/ // Mine is: 2� 37' W, which is 2.617 Degrees, or (which we need) 0.0456752665 radians, I will use 0.0457
// If you cannot find your Declination, comment out these two lines, your compass will be slightly off.
float declinationAngle = 0.009 ;
heading += declinationAngle;
http://arduikyo.blogspot.nl/2013/08/hmc5883l-compass-arduino-processing.htmlGracias por la ayuda, comentare si logro solucionar esto hoy