diff --git a/CHANGELOG.md b/CHANGELOG.md index ac23bac9..bd9beae1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Please add a note of your changes below this heading if you make a Pull Request. * Automatic d axis current for Maximum Torque Per Amp (MTPA) ### Changed +* Changed ratiometric `motor.config.current_lim_tolerance` to absolute `motor.config.current_lim_margin` * Moved `controller.vel_ramp_enable` into `controller.config`. # Releases diff --git a/Firmware/MotorControl/motor.cpp b/Firmware/MotorControl/motor.cpp index 78dd9d03..6b9922c7 100644 --- a/Firmware/MotorControl/motor.cpp +++ b/Firmware/MotorControl/motor.cpp @@ -360,7 +360,7 @@ bool Motor::FOC_current(float Id_des, float Iq_des, float I_phase, float pwm_pha ictrl.Id_measured += ictrl.I_measured_report_filter_k * (Id - ictrl.Id_measured); // Check for violation of current limit - float I_trip = config_.current_lim_tolerance * effective_current_lim(); + float I_trip = effective_current_lim() * config_.current_lim_margin; if (SQ(Id) + SQ(Iq) > SQ(I_trip)) { set_error(ERROR_CURRENT_LIMIT_VIOLATION); return false; diff --git a/Firmware/MotorControl/motor.hpp b/Firmware/MotorControl/motor.hpp index cf2c7c63..155e952f 100644 --- a/Firmware/MotorControl/motor.hpp +++ b/Firmware/MotorControl/motor.hpp @@ -74,7 +74,7 @@ public: // Read out max_allowed_current to see max supported value for current_lim. // float current_lim = 70.0f; //[A] float current_lim = 10.0f; //[A] - float current_lim_tolerance = 1.25f; // multiple of current_lim + float current_lim_margin = 8.0f; // Maximum violation of current_lim // Value used to compute shunt amplifier gains float requested_current_range = 60.0f; // [A] float current_control_bandwidth = 1000.0f; // [rad/s] @@ -248,7 +248,7 @@ public: make_protocol_property("direction", &config_.direction), make_protocol_property("motor_type", &config_.motor_type), make_protocol_property("current_lim", &config_.current_lim), - make_protocol_property("current_lim_tolerance", &config_.current_lim_tolerance), + make_protocol_property("current_lim_margin", &config_.current_lim_margin), make_protocol_property("inverter_temp_limit_lower", &config_.inverter_temp_limit_lower), make_protocol_property("inverter_temp_limit_upper", &config_.inverter_temp_limit_upper), make_protocol_property("requested_current_range", &config_.requested_current_range),