k3ng_rotator_controller
k3ng_rotator_controller copied to clipboard
LSM303 on POLOLU library
I am JA7FKF Satoh. Thank you for providing a great sketch.
Now I am trying to make an AZ / EL rotator. LSM303 is used to detect AZ / EL. The library was specified by FEATURE_AZ_POSITION_POLOLU_LSM303.
I read the source because the AZ displayed on the LED is a little strange.
The original source is as follows.
void read_azimuth(byte force_read){ .............. #ifdef FEATURE_AZ_POSITION_POLOLU_LSM303 .............. float heading = compass.heading();
//float heading = atan2(lsm.magData.y, lsm.magData.x);
// heading += declinationAngle;
// Correct for when signs are reversed.
/*
if (heading < 0) heading += 2 * PI;
if (heading > 2 * PI) heading -= 2 * PI;
raw_azimuth = (heading * RAD_TO_DEG) * HEADING_MULTIPLIER; // radians to degree
The unit of the return value of POLOLU's heading function is a degree, so I thought it was necessary to modify the source.
My modifications are as follows.
float heading = compass.heading();
//float heading = atan2(lsm.magData.y, lsm.magData.x);
// heading += declinationAngle();
// Correct for when signs are reversed.
#ifdef POLOLU_LSM_303_DECLINATION_ANGLE // JA7FKF
heading += (POLOLU_LSM_303_DECLINATION_ANGLE); // JA7FKF
#endif // POLOLU_LSM_303_DECLINATION_ANGLE // JA7FKF
#ifdef POLOLU_LSM_303_CHANGE_AXIS // JA7FKF
heading += (POLOLU_LSM_303_CHANGE_AXIS); // JA7FKF
#endif // POLOLU_LSM_303_CHANGE_AXIS // JA7FKF
// if (heading < 0) heading += 2 * PI; // JA7FKF
// if (heading > 2 * PI) heading -= 2 * PI; // JA7FKF
while (heading < 0) heading += 360; // JA7FKF
while (heading > 359.99) heading -= 360; // JA7FKF
raw_azimuth = (heading * RAD_TO_DEG) * HEADING_MULTIPLIER; // radians to degree
Incidentally, we also included the conversion of declination and AXIS. The declination and AXIS values were set in Settings.h.
At a minimum, it is suggested that the source correct the difference between radians and degree.
Thank you!!