diff --git a/CHANGELOG.md b/CHANGELOG.md index 58fde384..8edcf215 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Unreleased Features Please add a note of your changes below this heading if you make a Pull Request. +# Releases +## [0.5.0] - 2020-08-03 ### Added * AC Induction Motor support. * Tracking of rotor flux through rotor time constant @@ -48,7 +50,6 @@ Please add a note of your changes below this heading if you make a Pull Request. * Fixed a numerical issue in the trajectory planner that could cause sudden jumps of the position setpoint * `input_pos`, `input_vel`, `pos_estimate_linear`, `pos_estimate_circular`, are now in units of [turns] or [turns/s] instead of [counts] or [counts/s] -# Releases ## [0.4.12] - 2020-05-06 ### Fixed * Fixed a numerical issue in the trajectory planner that could cause sudden jumps of the position setpoint diff --git a/Firmware/MotorControl/axis.cpp b/Firmware/MotorControl/axis.cpp index f8fd2d15..04a802c6 100644 --- a/Firmware/MotorControl/axis.cpp +++ b/Firmware/MotorControl/axis.cpp @@ -336,6 +336,7 @@ bool Axis::run_closed_loop_control_loop() { controller_.input_pos_ = *controller_.pos_estimate_linear_src_; } } + controller_.input_pos_updated(); // Avoid integrator windup issues controller_.vel_integrator_torque_ = 0.0f; diff --git a/Firmware/MotorControl/encoder.cpp b/Firmware/MotorControl/encoder.cpp index 352d26ba..2c465988 100644 --- a/Firmware/MotorControl/encoder.cpp +++ b/Firmware/MotorControl/encoder.cpp @@ -181,8 +181,8 @@ bool Encoder::run_direction_find() { // and the encoder state 0. // TODO: Do the scan with current, not voltage! bool Encoder::run_offset_calibration() { - static const float start_lock_duration = 1.0f; - static const int num_steps = (int)(config_.calib_scan_distance / config_.calib_scan_omega * (float)current_meas_hz); + const float start_lock_duration = 1.0f; + const int num_steps = (int)(config_.calib_scan_distance / config_.calib_scan_omega * (float)current_meas_hz); // Require index found if enabled if (config_.use_index && !index_found_) { @@ -311,6 +311,7 @@ void Encoder::sample_now() { case MODE_SPI_ABS_AMS: case MODE_SPI_ABS_CUI: case MODE_SPI_ABS_AEAT: + case MODE_SPI_ABS_RLS: { axis_->motor_.log_timing(TIMING_LOG_SAMPLE_NOW); // Do nothing @@ -400,6 +401,11 @@ void Encoder::abs_spi_cb(){ pos = rawVal & 0x3fff; } break; + case MODE_SPI_ABS_RLS: { + uint16_t rawVal = abs_spi_dma_rx_[0]; + pos = (rawVal >> 2) & 0x3fff; + } break; + default: { set_error(ERROR_UNSUPPORTED_ENCODER_MODE); return; @@ -470,6 +476,7 @@ bool Encoder::update() { delta_enc -= 6283; } break; + case MODE_SPI_ABS_RLS: case MODE_SPI_ABS_AMS: case MODE_SPI_ABS_CUI: case MODE_SPI_ABS_AEAT: { diff --git a/Firmware/MotorControl/low_level.cpp b/Firmware/MotorControl/low_level.cpp index b6cd64be..d447539d 100644 --- a/Firmware/MotorControl/low_level.cpp +++ b/Firmware/MotorControl/low_level.cpp @@ -28,8 +28,8 @@ /* Private macros ------------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/ /* Global constant data ------------------------------------------------------*/ -const float adc_full_scale = (float)(1 << 12); -const float adc_ref_voltage = 3.3f; +constexpr float adc_full_scale = static_cast(1UL << 12UL); +constexpr float adc_ref_voltage = 3.3f; /* Global variables ----------------------------------------------------------*/ // This value is updated by the DC-bus reading ADC. @@ -454,7 +454,7 @@ float get_adc_voltage_channel(uint16_t channel) //-------------------------------- void vbus_sense_adc_cb(ADC_HandleTypeDef* hadc, bool injected) { - static const float voltage_scale = adc_ref_voltage * VBUS_S_DIVIDER_RATIO / adc_full_scale; + constexpr float voltage_scale = adc_ref_voltage * VBUS_S_DIVIDER_RATIO / adc_full_scale; // Only one conversion in sequence, so only rank1 uint32_t ADCValue = HAL_ADCEx_InjectedGetValue(hadc, ADC_INJECTED_RANK_1); vbus_voltage = ADCValue * voltage_scale; @@ -493,7 +493,7 @@ static void decode_hall_samples(Encoder& enc, uint16_t GPIO_samples[num_GPIO]) { // TODO: Document how the phasing is done, link to timing diagram void pwm_trig_adc_cb(ADC_HandleTypeDef* hadc, bool injected) { #define calib_tau 0.2f //@TOTO make more easily configurable - static const float calib_filter_k = CURRENT_MEAS_PERIOD / calib_tau; + constexpr float calib_filter_k = CURRENT_MEAS_PERIOD / calib_tau; // Ensure ADCs are expected ones to simplify the logic below if (!(hadc == &hadc2 || hadc == &hadc3)) { diff --git a/Firmware/MotorControl/motor.cpp b/Firmware/MotorControl/motor.cpp index b5d7b94f..c7e50128 100644 --- a/Firmware/MotorControl/motor.cpp +++ b/Firmware/MotorControl/motor.cpp @@ -73,9 +73,9 @@ void Motor::DRV8301_setup() { // Solve for exact gain, then snap down to have equal or larger range as requested // or largest possible range otherwise - static const float kMargin = 0.90f; - static const float kTripMargin = 1.0f; // Trip level is at edge of linear range of amplifer - static const float max_output_swing = 1.35f; // [V] out of amplifier + constexpr float kMargin = 0.90f; + constexpr float kTripMargin = 1.0f; // Trip level is at edge of linear range of amplifer + constexpr float max_output_swing = 1.35f; // [V] out of amplifier float max_unity_gain_current = kMargin * max_output_swing * hw_config_.shunt_conductance; // [A] float requested_gain = max_unity_gain_current / config_.requested_current_range; // [V/V] diff --git a/Firmware/communication/can_simple.cpp b/Firmware/communication/can_simple.cpp index 77e8f416..f21f4b90 100644 --- a/Firmware/communication/can_simple.cpp +++ b/Firmware/communication/can_simple.cpp @@ -4,7 +4,7 @@ #include -static const uint8_t NUM_NODE_ID_BITS = 6; +static constexpr uint8_t NUM_NODE_ID_BITS = 6; static constexpr uint8_t NUM_CMD_ID_BITS = 11 - NUM_NODE_ID_BITS; void CANSimple::handle_can_message(can_Message_t& msg) { diff --git a/Firmware/odrive-interface.yaml b/Firmware/odrive-interface.yaml index fd36a11c..2c9060eb 100644 --- a/Firmware/odrive-interface.yaml +++ b/Firmware/odrive-interface.yaml @@ -924,6 +924,9 @@ valuetypes: SpiAbsAeat: value: 0x102 doc: not yet implemented + SpiAbsRls: + value: 0x103 + doc: RLS Encoders ODrive.Controller.ControlMode: values: