Allow for regen current before braking

This commit is contained in:
Paul Guenette
2020-01-30 12:36:51 -08:00
committed by Oskar Weigl
parent 50d06576b7
commit c5f06845c2
2 changed files with 5 additions and 4 deletions
+4 -4
View File
@@ -585,10 +585,10 @@ void update_brake_current() {
Ibus_sum += axes[i]->motor_.current_control_.Ibus;
}
}
float brake_current = -Ibus_sum;
// Clip negative values to 0.0f
if (brake_current < 0.0f) brake_current = 0.0f;
float brake_duty = brake_current * board_config.brake_resistance / vbus_voltage;
// Don't start braking until -Ibus > regen_current_allowed
float brake_current = std::max(-Ibus_sum - board_config.max_regen_current, 0.0f);
float brake_duty = std::max(brake_current * std::abs(board_config.brake_resistance) / vbus_voltage, 0.0f);
// Duty limit at 90% to allow bootstrap caps to charge
// If brake_duty is NaN, this expression will also evaluate to false
+1
View File
@@ -71,6 +71,7 @@ struct BoardConfig_t {
bool enable_uart = true;
bool enable_i2c_instead_of_can = false;
bool enable_ascii_protocol_on_usb = true;
float max_regen_current = 0.0f;
#if HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR >= 5 && HW_VERSION_VOLTAGE >= 48
float brake_resistance = 2.0f; // [ohm]
#else