diff --git a/Firmware/MotorControl/encoder.cpp b/Firmware/MotorControl/encoder.cpp index 6267e152..168bc0e0 100644 --- a/Firmware/MotorControl/encoder.cpp +++ b/Firmware/MotorControl/encoder.cpp @@ -148,6 +148,8 @@ bool Encoder::run_offset_calibration() { // scan forward i = 0; axis_->run_control_loop([&](){ + axis_->encoder_.update(nullptr, nullptr, nullptr); + float phase = wrap_pm_pi(scan_distance * (float)i / (float)num_steps - scan_distance / 2.0f); float v_alpha = voltage_magnitude * arm_cos_f32(phase); float v_beta = voltage_magnitude * arm_sin_f32(phase); diff --git a/Firmware/MotorControl/motor.cpp b/Firmware/MotorControl/motor.cpp index cbf62952..dad64bc5 100644 --- a/Firmware/MotorControl/motor.cpp +++ b/Firmware/MotorControl/motor.cpp @@ -167,6 +167,8 @@ bool Motor::measure_phase_resistance(float test_current, float max_voltage) { size_t i = 0; axis_->run_control_loop([&](){ + axis_->encoder_.update(nullptr, nullptr, nullptr); + float Ialpha = -(current_meas_.phB + current_meas_.phC); test_voltage += (kI * current_meas_period) * (test_current - Ialpha); if (test_voltage > max_voltage || test_voltage < -max_voltage) @@ -198,6 +200,8 @@ bool Motor::measure_phase_inductance(float voltage_low, float voltage_high) { size_t t = 0; axis_->run_control_loop([&](){ + axis_->encoder_.update(nullptr, nullptr, nullptr); + int i = t & 1; Ialphas[i] += -current_meas_.phB - current_meas_.phC; diff --git a/Firmware/MotorControl/motor.hpp b/Firmware/MotorControl/motor.hpp index 74679b88..49ca126b 100644 --- a/Firmware/MotorControl/motor.hpp +++ b/Firmware/MotorControl/motor.hpp @@ -48,7 +48,7 @@ typedef struct { // Read out max_allowed_current to see max supported value for current_lim. // You can change DRV8301_ShuntAmpGain to get a different range. // float current_lim = 75.0f; //[A] - float current_lim = 10.0f; //[A] + float current_lim = 6.0f; //[A] } MotorConfig_t; class Motor {