From ff0cacba6a7dd5165cac720e1b6a2f850a47b7ce Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Tue, 10 Apr 2018 18:53:58 -0700 Subject: [PATCH 1/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 192a3c6b..16613f9a 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ All non-power I/O is 3.3V output and 5V tolerant on input, except: You need one or two [brushless motors](https://hackaday.io/project/11583-odrive-high-performance-motor-control/log/37666-hobby-motors-in-your-robots), [quadrature incremental encoder(s)](https://discourse.odriverobotics.com/t/which-encoders-to-choose/63/2), and a power resistor. -*The power resistor values you need depends on your motor setup, and peak/average decelleration power. A good starting point would be a [0.47 ohm, 50W resistor](https://www.digikey.com/product-detail/en/te-connectivity-passive-product/HSA50R47J/A102181-ND/2056131).* +The power resistor values you need depends on your motor setup, and peak/average decelleration power. A good starting point would be a [0.47 ohm, 50W resistor](https://www.digikey.com/product-detail/en/te-connectivity-passive-product/HSA50R47J/A102181-ND/2056131). **Warning! Failure to use a break resistor may result in damage to your ODrive and/or power supply!** Wire up the motor phases into the 3-phase screw terminals, and the power resistor to the AUX terminal. Wire up the power source (12-24V) to the DC terminal, make sure to pay attention to the polarity. Do not apply power just yet. From 6e60ec4631bcb72d96124c52eaa0aa9a9a53262c Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Sun, 15 Apr 2018 17:38:37 -0700 Subject: [PATCH 2/2] Check for dc bus overvoltage --- Firmware/Board/v3/Inc/main.h | 2 ++ Firmware/MotorControl/low_level.c | 26 ++++++++++++++++++++------ Firmware/MotorControl/low_level.h | 6 ++++-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Firmware/Board/v3/Inc/main.h b/Firmware/Board/v3/Inc/main.h index ac9bd857..4292821d 100644 --- a/Firmware/Board/v3/Inc/main.h +++ b/Firmware/Board/v3/Inc/main.h @@ -170,8 +170,10 @@ #if HW_VERSION_VOLTAGE == 48 #define VBUS_S_DIVIDER_RATIO 19.0f +#define VBUS_OVERVOLTAGE_LEVEL 52.0f #elif HW_VERSION_VOLTAGE == 24 #define VBUS_S_DIVIDER_RATIO 11.0f +#define VBUS_OVERVOLTAGE_LEVEL 26.0f #else #error "unknown board voltage" #endif diff --git a/Firmware/MotorControl/low_level.c b/Firmware/MotorControl/low_level.c index c1e99742..45c7529c 100644 --- a/Firmware/MotorControl/low_level.c +++ b/Firmware/MotorControl/low_level.c @@ -68,7 +68,8 @@ Motor_t motors[] = { .current_setpoint = 0.0f, // [A] .calibration_current = 10.0f, // [A] .resistance_calib_max_voltage = 1.0f, // [V] - You may need to increase this if this voltage isn't sufficient to drive calibration_current through the motor. - .dc_bus_brownout_trip_level = 8.0f, // [V] + .dc_bus_undervoltage_trip_level = 8.0f, // [V] + .dc_bus_overvoltage_trip_level = VBUS_OVERVOLTAGE_LEVEL, // [V] .phase_inductance = 0.0f, // to be set by measure_phase_inductance .phase_resistance = 0.0f, // to be set by measure_phase_resistance .motor_thread = 0, @@ -176,7 +177,8 @@ Motor_t motors[] = { .current_setpoint = 0.0f, // [A] .calibration_current = 10.0f, // [A] .resistance_calib_max_voltage = 1.0f, // [V] - You may need to increase this if this voltage isn't sufficient to drive calibration_current through the motor. - .dc_bus_brownout_trip_level = 8.0f, // [V] + .dc_bus_undervoltage_trip_level = 8.0f, // [V] + .dc_bus_overvoltage_trip_level = VBUS_OVERVOLTAGE_LEVEL, // [V] .phase_inductance = 0.0f, // to be set by measure_phase_inductance .phase_resistance = 0.0f, // to be set by measure_phase_resistance .motor_thread = 0, @@ -1320,8 +1322,16 @@ bool check_DRV_fault(Motor_t* motor) { } //Returns true if everything is OK (no fault) -bool check_PSU_brownout(Motor_t* motor) { - if(vbus_voltage < motor->dc_bus_brownout_trip_level) +bool check_vbus_undervoltage(Motor_t* motor) { + if(vbus_voltage < motor->dc_bus_undervoltage_trip_level) + return false; + return true; +} + +//Returns true if everything is OK (no fault) +// TODO This will be less repetitive with the refactoring +bool check_vbus_overvoltage(Motor_t* motor) { + if(vbus_voltage > motor->dc_bus_overvoltage_trip_level) return false; return true; } @@ -1338,8 +1348,12 @@ bool do_checks(Motor_t* motor) { DRV8301_readData(&motor->gate_driver, local_regs); return false; } - if (!check_PSU_brownout(motor)) { - motor->error = ERROR_DC_BUS_BROWNOUT; + if (!check_vbus_undervoltage(motor)) { + motor->error = ERROR_DC_BUS_UNDERVOLTAGE; + return false; + } + if (!check_vbus_overvoltage(motor)) { + motor->error = ERROR_DC_BUS_OVERVOLTAGE; return false; } return true; diff --git a/Firmware/MotorControl/low_level.h b/Firmware/MotorControl/low_level.h index e92774e4..1ed956db 100644 --- a/Firmware/MotorControl/low_level.h +++ b/Firmware/MotorControl/low_level.h @@ -51,7 +51,8 @@ typedef enum { ERROR_DRV_FAULT, ERROR_NOT_IMPLEMENTED_MOTOR_TYPE, ERROR_ENCODER_CPR_OUT_OF_RANGE, - ERROR_DC_BUS_BROWNOUT, + ERROR_DC_BUS_UNDERVOLTAGE, + ERROR_DC_BUS_OVERVOLTAGE, } Error_t; // Note: these should be sorted from lowest level of control to @@ -151,7 +152,8 @@ typedef struct { float current_setpoint; float calibration_current; float resistance_calib_max_voltage; - float dc_bus_brownout_trip_level; + float dc_bus_undervoltage_trip_level; + float dc_bus_overvoltage_trip_level; float phase_inductance; float phase_resistance; osThreadId motor_thread;