add overvoltage protection

The motor phases will go into floating state as soon as an overvoltage condition is detected.
This commit is contained in:
Samuel Sadok
2018-04-10 00:25:19 -07:00
parent 69b06dde89
commit 23009d1e93
4 changed files with 11 additions and 9 deletions
+3 -6
View File
@@ -92,18 +92,15 @@ void Axis::set_step_dir_enabled(bool enable) {
}
}
// @brief Returns true if the power supply is within range
bool Axis::check_PSU_brownout() {
return vbus_voltage >= config_.dc_bus_brownout_trip_level;
}
// @brief Returns true if everything is ok.
// Sets error and returns false otherwise.
bool Axis::do_checks() {
if (!motor_.do_checks())
return error_ |= ERROR_MOTOR_FAILED, false;
if (!check_PSU_brownout())
if (!(vbus_voltage >= board_config.dc_bus_undervoltage_trip_level))
return error_ |= ERROR_DC_BUS_UNDER_VOLTAGE, false;
if (!(vbus_voltage <= board_config.dc_bus_overvoltage_trip_level))
return error_ |= ERROR_DC_BUS_OVER_VOLTAGE, false;
return true;
}
-2
View File
@@ -30,7 +30,6 @@ struct AxisConfig_t {
// For M0 this has no effect if enable_uart is true
float counts_per_step = 2.0f;
float dc_bus_brownout_trip_level = 8.0f; //<! [V] voltage at which the motor stops operating
// Spinup settings
float ramp_up_time = 0.4f; // [s]
@@ -180,7 +179,6 @@ public:
make_protocol_property("startup_sensorless_control", &config_.startup_sensorless_control),
make_protocol_property("enable_step_dir", &config_.enable_step_dir),
make_protocol_property("counts_per_step", &config_.counts_per_step),
make_protocol_property("dc_bus_brownout_trip_level", &config_.dc_bus_brownout_trip_level),
make_protocol_property("ramp_up_time", &config_.ramp_up_time),
make_protocol_property("ramp_up_distance", &config_.ramp_up_distance),
make_protocol_property("spin_up_current", &config_.spin_up_current),
+3 -1
View File
@@ -213,7 +213,9 @@ static inline auto make_obj_tree() {
make_protocol_object("config",
make_protocol_property("brake_resistance", &board_config.brake_resistance),
// TODO: changing this currently requires a reboot - fix this
make_protocol_property("enable_uart", &board_config.enable_uart)
make_protocol_property("enable_uart", &board_config.enable_uart),
make_protocol_property("dc_bus_undervoltage_trip_level", &board_config.dc_bus_undervoltage_trip_level),
make_protocol_property("dc_bus_overvoltage_trip_level", &board_config.dc_bus_overvoltage_trip_level)
),
make_protocol_object("axis0", axes[0]->make_protocol_definitions()),
make_protocol_object("axis1", axes[1]->make_protocol_definitions()),
+5
View File
@@ -23,6 +23,11 @@
struct BoardConfig_t {
bool enable_uart = true;
float brake_resistance = 0.47f; // [ohm]
float dc_bus_undervoltage_trip_level = 8.0f; //<! [V] minimum voltage below which the motor stops operating
float dc_bus_overvoltage_trip_level = 1.08f * HW_VERSION_VOLTAGE; //<! [V] maximum voltage above which the motor stops operating.
//<! This protects against cases in which the power supply fails to dissipate
//<! the brake power if the brake resistor is disabled.
//<! The default is 26V for the 24V board version and 52V for the 48V board version.
};
class Axis;