diff --git a/k3ng_rotator_controller/k3ng_rotator_controller.ino b/k3ng_rotator_controller/k3ng_rotator_controller.ino index 4e63f08..6e8cb4a 100644 --- a/k3ng_rotator_controller/k3ng_rotator_controller.ino +++ b/k3ng_rotator_controller/k3ng_rotator_controller.ino @@ -1083,6 +1083,9 @@ FEATURE_SATELLITE_TRACKING: Updated P13 library to have observer.update_location function. Controller code now uses update_location rather than instantiating new Observer objects Updated hardcoded AO17TEST TLE + 2023.09.29.0800 + Added FEATURE_AZ_POSITION_HH12_AS5045_SSI_RELATIVE; not tested + All library files should be placed in directories likes \sketchbook\libraries\library1\ , \sketchbook\libraries\library2\ , etc. Anything rotator_*.* should be in the ino directory! @@ -1706,12 +1709,12 @@ struct config_t { char report[80]; #endif //FEATURE_AZ_POSITION_POLOLU_LSM303 -#ifdef FEATURE_AZ_POSITION_HH12_AS5045_SSI +#if defined(FEATURE_AZ_POSITION_HH12_AS5045_SSI) || defined(FEATURE_AZ_POSITION_HH12_AS5045_SSI_RELATIVE) #include "hh12.h" hh12 azimuth_hh12; #endif //FEATURE_AZ_POSITION_HH12_AS5045_SSI -#ifdef FEATURE_EL_POSITION_HH12_AS5045_SSI +#if defined(FEATURE_EL_POSITION_HH12_AS5045_SSI) || defined(FEATURE_EL_POSITION_HH12_AS5045_SSI_RELATIVE) #include "hh12.h" hh12 elevation_hh12; #endif //FEATURE_EL_POSITION_HH12_AS5045_SSI @@ -8623,6 +8626,53 @@ void read_azimuth(byte force_read){ convert_raw_azimuth_to_real_azimuth(); #endif // FEATURE_AZ_POSITION_HH12_AS5045_SSI +// zzzzzz + + #ifdef FEATURE_AZ_POSITION_HH12_AS5045_SSI_RELATIVE + + static float hh12_last_reading = 0; + static byte last_reading_initialized = 0; + float reading_difference = 0; + + float hh12_current_reading = azimuth_hh12.heading(); + + if (!last_reading_initialized){ + hh12_last_reading = hh12_current_reading; + last_reading_initialized = 1; + } + + reading_difference = hh12_last_reading - hh12_current_reading; + + if (abs(reading_difference) > 350.0){ // if we moved more than 350 degrees since the last reading, assume we did a 359->0/0->359 transition + if (reading_difference > 0){ // we went CCW 0->359 + reading_difference = (reading_difference + 360.0) * -1.0; + } else { // we went CW 359->0 + reading_difference = (reading_difference - 360.0) * -1.0; + } + } + + #if defined(OPTION_REVERSE_AZ_HH12_AS5045) + reading_difference = reading_difference * -1.0; + #endif + + raw_azimuth += reading_difference; + + #ifdef DEBUG_HH12 + if ((millis() - last_hh12_debug) > 5000) { + debug.print(F("read_azimuth: HH-12 raw: ")); + control_port->println(raw_azimuth); + last_hh12_debug = millis(); + } + #endif // DEBUG_HH12 + #ifdef FEATURE_AZIMUTH_CORRECTION + raw_azimuth = correct_azimuth(raw_azimuth); + #endif // FEATURE_AZIMUTH_CORRECTION + #if !defined(FEATURE_CALIBRATION) + apply_azimuth_offset(); + #endif + convert_raw_azimuth_to_real_azimuth(); + hh12_last_reading = hh12_current_reading; + #endif // FEATURE_AZ_POSITION_HH12_AS5045_SSI_RELATIVE #ifdef FEATURE_AZ_POSITION_INCREMENTAL_ENCODER if (configuration.azimuth_starting_point == 0) { @@ -11848,7 +11898,7 @@ void service_request_queue(){ control_port->flush(); #endif // DEBUG_LOOP - float work_target_raw_azimuth = 0; + int work_target_raw_azimuth = 0; byte direction_to_go = 0; byte within_tolerance_flag = 0; diff --git a/k3ng_rotator_controller/rotator_dependencies.h b/k3ng_rotator_controller/rotator_dependencies.h index af00d34..8efdb6b 100755 --- a/k3ng_rotator_controller/rotator_dependencies.h +++ b/k3ng_rotator_controller/rotator_dependencies.h @@ -58,7 +58,7 @@ #undef FEATURE_EL_PRESET_ENCODER #endif -#if !defined(FEATURE_AZ_POSITION_POTENTIOMETER) && !defined(FEATURE_AZ_POSITION_ROTARY_ENCODER) && !defined(FEATURE_AZ_POSITION_PULSE_INPUT) && !defined(FEATURE_AZ_POSITION_GET_FROM_REMOTE_UNIT) && !defined(FEATURE_AZ_POSITION_HMC5883L) && !defined(FEATURE_AZ_POSITION_ADAFRUIT_LSM303) && !defined(FEATURE_AZ_POSITION_HH12_AS5045_SSI) &&!defined(FEATURE_AZ_POSITION_INCREMENTAL_ENCODER) &&!defined(FEATURE_AZ_POSITION_POLOLU_LSM303) &&!defined(FEATURE_AZ_POSITION_A2_ABSOLUTE_ENCODER) &&!defined(FEATURE_AZ_POSITION_ROTARY_ENCODER_USE_PJRC_LIBRARY) && !defined(FEATURE_AZ_POSITION_HMC5883L_USING_JARZEBSKI_LIBRARY) && !defined(FEATURE_AZ_POSITION_DFROBOT_QMC5883) && !defined(FEATURE_AZ_POSITION_MECHASOLUTION_QMC5883) +#if !defined(FEATURE_AZ_POSITION_POTENTIOMETER) && !defined(FEATURE_AZ_POSITION_ROTARY_ENCODER) && !defined(FEATURE_AZ_POSITION_PULSE_INPUT) && !defined(FEATURE_AZ_POSITION_GET_FROM_REMOTE_UNIT) && !defined(FEATURE_AZ_POSITION_HMC5883L) && !defined(FEATURE_AZ_POSITION_ADAFRUIT_LSM303) && !defined(FEATURE_AZ_POSITION_HH12_AS5045_SSI) &&!defined(FEATURE_AZ_POSITION_INCREMENTAL_ENCODER) &&!defined(FEATURE_AZ_POSITION_POLOLU_LSM303) &&!defined(FEATURE_AZ_POSITION_A2_ABSOLUTE_ENCODER) &&!defined(FEATURE_AZ_POSITION_ROTARY_ENCODER_USE_PJRC_LIBRARY) && !defined(FEATURE_AZ_POSITION_HMC5883L_USING_JARZEBSKI_LIBRARY) && !defined(FEATURE_AZ_POSITION_DFROBOT_QMC5883) && !defined(FEATURE_AZ_POSITION_MECHASOLUTION_QMC5883) && !defined(FEATURE_AZ_POSITION_HH12_AS5045_SSI_RELATIVE) #error "You must specify one AZ position sensor feature" #endif diff --git a/k3ng_rotator_controller/rotator_features.h b/k3ng_rotator_controller/rotator_features.h index 72d2106..471e702 100755 --- a/k3ng_rotator_controller/rotator_features.h +++ b/k3ng_rotator_controller/rotator_features.h @@ -57,6 +57,7 @@ // #define FEATURE_AZ_POSITION_ADAFRUIT_LSM303 // Uncomment for azimuth using LSM303 compass and Adafruit library (https://github.com/adafruit/Adafruit_LSM303) (also uncomment object declaration below) // #define FEATURE_AZ_POSITION_POLOLU_LSM303 // Uncomment for azimuth using LSM303 compass and Polulu library // #define FEATURE_AZ_POSITION_HH12_AS5045_SSI +// #define FEATURE_AZ_POSITION_HH12_AS5045_SSI_RELATIVE // use when more than 360 degrees of rotation // #define FEATURE_AZ_POSITION_INCREMENTAL_ENCODER // #define FEATURE_AZ_POSITION_A2_ABSOLUTE_ENCODER // #define FEATURE_AZ_POSITION_MECHASOLUTION_QMC5883 // QMC5883 digital compass support using Mechasolution library at https://github.com/keepworking/Mecha_QMC5883L diff --git a/k3ng_rotator_controller/rotator_features_test.h b/k3ng_rotator_controller/rotator_features_test.h index ea8e511..64cd656 100755 --- a/k3ng_rotator_controller/rotator_features_test.h +++ b/k3ng_rotator_controller/rotator_features_test.h @@ -19,7 +19,7 @@ // #define FEATURE_MOON_TRACKING // #define FEATURE_SUN_TRACKING -#define FEATURE_CLOCK +// #define FEATURE_CLOCK // #define FEATURE_GPS // #define FEATURE_RTC_DS1307 // #define FEATURE_RTC_PCF8583 @@ -45,10 +45,10 @@ /* master and remote slave unit functionality */ // #define FEATURE_REMOTE_UNIT_SLAVE // uncomment this to make this unit a remote unit controlled by a host unit -#define FEATURE_MASTER_WITH_SERIAL_SLAVE // [master]{remote_port}<-------serial-------->{control_port}[slave] +// #define FEATURE_MASTER_WITH_SERIAL_SLAVE // [master]{remote_port}<-------serial-------->{control_port}[slave] // #define FEATURE_MASTER_WITH_ETHERNET_SLAVE // [master]<-------------------ethernet--------------------->[slave] -#define FEATURE_MASTER_SEND_AZ_ROTATION_COMMANDS_TO_REMOTE -#define FEATURE_MASTER_SEND_EL_ROTATION_COMMANDS_TO_REMOTE +// #define FEATURE_MASTER_SEND_AZ_ROTATION_COMMANDS_TO_REMOTE +// #define FEATURE_MASTER_SEND_EL_ROTATION_COMMANDS_TO_REMOTE // #define FEATURE_ADC_RESOLUTION12 // 12 bit ADC resolution for Teensy 3.x, Arduino Due Zero MKR families @@ -60,22 +60,23 @@ // #define FEATURE_AZ_POSITION_HMC5883L // HMC5883L digital compass support // #define FEATURE_AZ_POSITION_DFROBOT_QMC5883 // QMC5883 digital compass support using DFRobot library at https://github.com/DFRobot/DFRobot_QMC5883 // #define FEATURE_AZ_POSITION_HMC5883L_USING_JARZEBSKI_LIBRARY // HMC5883L digital compass support using Jarzebski library at https://github.com/jarzebski/Arduino-HMC5883L -#define FEATURE_AZ_POSITION_GET_FROM_REMOTE_UNIT // requires FEATURE_MASTER_WITH_SERIAL_SLAVE or FEATURE_MASTER_WITH_ETHERNET_SLAVE +// #define FEATURE_AZ_POSITION_GET_FROM_REMOTE_UNIT // requires FEATURE_MASTER_WITH_SERIAL_SLAVE or FEATURE_MASTER_WITH_ETHERNET_SLAVE // #define FEATURE_AZ_POSITION_ADAFRUIT_LSM303 // Uncomment for azimuth using LSM303 compass and Adafruit library (https://github.com/adafruit/Adafruit_LSM303) (also uncomment object declaration below) // #define FEATURE_AZ_POSITION_POLOLU_LSM303 // Uncomment for azimuth using LSM303 compass and Polulu library // #define FEATURE_AZ_POSITION_HH12_AS5045_SSI +#define FEATURE_AZ_POSITION_HH12_AS5045_SSI_RELATIVE // use when more than 360 degrees of rotation // #define FEATURE_AZ_POSITION_INCREMENTAL_ENCODER // #define FEATURE_AZ_POSITION_A2_ABSOLUTE_ENCODER // #define FEATURE_AZ_POSITION_MECHASOLUTION_QMC5883 // QMC5883 digital compass support using Mechasolution library at https://github.com/keepworking/Mecha_QMC5883L -// #define FEATURE_EL_POSITION_POTENTIOMETER +#define FEATURE_EL_POSITION_POTENTIOMETER // #define FEATURE_EL_POSITION_ROTARY_ENCODER // #define FEATURE_EL_POSITION_ROTARY_ENCODER_USE_PJRC_LIBRARY // library @ http://www.pjrc.com/teensy/td_libs_Encoder.html // #define FEATURE_EL_POSITION_PULSE_INPUT // #define FEATURE_EL_POSITION_ADXL345_USING_LOVE_ELECTRON_LIB // Uncomment for elevation ADXL345 accelerometer support using ADXL345 library // #define FEATURE_EL_POSITION_ADXL345_USING_ADAFRUIT_LIB // Uncomment for elevation ADXL345 accelerometer support using Adafruit library -#define FEATURE_EL_POSITION_GET_FROM_REMOTE_UNIT // requires FEATURE_MASTER_WITH_SERIAL_SLAVE or FEATURE_MASTER_WITH_ETHERNET_SLAVE +// #define FEATURE_EL_POSITION_GET_FROM_REMOTE_UNIT // requires FEATURE_MASTER_WITH_SERIAL_SLAVE or FEATURE_MASTER_WITH_ETHERNET_SLAVE // #define FEATURE_EL_POSITION_ADAFRUIT_LSM303 // Uncomment for elevation using LSM303 accelerometer and Adafruit library (https://github.com/adafruit/Adafruit_LSM303) (also uncomment object declaration below) // #define FEATURE_EL_POSITION_POLOLU_LSM303 // Uncomment for elevation using LSM303 compass and Polulu library // #define FEATURE_EL_POSITION_HH12_AS5045_SSI