set current controller gains based on NVM configration

If the motor phase resistance and phase inductance was loaded from NVM (pre_calibrated = true) (as opposed to calibration) the current control P and I gains would not be loaded correctly. This commit fixes this.
This commit is contained in:
Samuel Sadok
2018-03-23 19:54:45 -07:00
parent 7695828d31
commit 0e37ff01e4
2 changed files with 14 additions and 5 deletions
+12 -5
View File
@@ -58,6 +58,17 @@ void Motor::disarm() {
axis_->missed_control_deadline_ = true;
}
// @brief Tune the current controller based on phase resistance and inductance
// This should be invoked whenever one of these values changes.
// TODO: allow update on user-request or update automatically via hooks
void Motor::update_current_controller_gains() {
// Calculate current control gains
float current_control_bandwidth = 1000.0f; // [rad/s]
current_control_.p_gain = current_control_bandwidth * config_.phase_inductance;
float plant_pole = config_.phase_resistance / config_.phase_inductance;
current_control_.i_gain = plant_pole * current_control_.p_gain;
}
// @brief Set up the gate drivers
void Motor::DRV8301_setup() {
DRV_SPI_8301_Vars_t* local_regs = &gate_driver_regs_;
@@ -234,11 +245,7 @@ bool Motor::run_calibration() {
return false;
}
// Calculate current control gains
float current_control_bandwidth = 1000.0f; // [rad/s]
current_control_.p_gain = current_control_bandwidth * config_.phase_inductance;
float plant_pole = config_.phase_resistance / config_.phase_inductance;
current_control_.i_gain = plant_pole * current_control_.p_gain;
update_current_controller_gains();
is_calibrated_ = true;
return true;
+2
View File
@@ -82,8 +82,10 @@ public:
bool arm();
void disarm();
void setup() {
update_current_controller_gains();
DRV8301_setup();
}
void update_current_controller_gains();
void DRV8301_setup();
bool check_DRV_fault();
bool do_checks();