mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-24 01:23:52 +08:00
Add dc_bus_over_power error
This commit is contained in:
@@ -140,6 +140,20 @@ bool Axis::do_checks() {
|
||||
if (!(vbus_voltage <= board_config.dc_bus_overvoltage_trip_level))
|
||||
error_ |= ERROR_DC_BUS_OVER_VOLTAGE;
|
||||
|
||||
// This is the same math that's used in update_brake_current(). Should we calculate IBus globally?
|
||||
float Ibus_sum = 0.0f;
|
||||
for (size_t i = 0; i < AXIS_COUNT; ++i) {
|
||||
if (axes[i]->motor_.armed_state_ == Motor::ARMED_STATE_ARMED) {
|
||||
Ibus_sum += axes[i]->motor_.current_control_.Ibus;
|
||||
}
|
||||
}
|
||||
|
||||
if(board_config.power_supply_wattage >= 0.0f &&
|
||||
Ibus_sum * vbus_voltage > board_config.power_supply_wattage)
|
||||
{
|
||||
error_ |= ERROR_DC_BUS_OVER_POWER;
|
||||
}
|
||||
|
||||
// Sub-components should use set_error which will propegate to this error_
|
||||
motor_.do_checks();
|
||||
encoder_.do_checks();
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
ERROR_CONTROLLER_FAILED = 0x200,
|
||||
ERROR_POS_CTRL_DURING_SENSORLESS = 0x400,
|
||||
ERROR_WATCHDOG_TIMER_EXPIRED = 0x800,
|
||||
ERROR_DC_BUS_OVER_POWER = 0x1000,
|
||||
};
|
||||
|
||||
enum State_t {
|
||||
|
||||
@@ -81,6 +81,7 @@ struct BoardConfig_t {
|
||||
//<! 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.
|
||||
float power_supply_wattage = 0.0f;
|
||||
PWMMapping_t pwm_mappings[GPIO_COUNT];
|
||||
PWMMapping_t analog_mappings[GPIO_COUNT];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user