Skip to content

Commit f0b291d

Browse files
committed
Improved overvoltage protection
1 parent e89e00b commit f0b291d

7 files changed

+24
-7
lines changed

CHANGELOG

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
* Added raw sampled data mode.
4444
* Compensate inductance for motor saliency in observer.
4545
* Added MTPA mode based on measured current.
46+
* Faster overvoltage protection.
4647

4748
=== FW 5.02 ===
4849
* IMU calibration improvement.

conf_general.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#define FW_VERSION_MAJOR 5
2525
#define FW_VERSION_MINOR 03
2626
// Set to 0 for building a release and iterate during beta test builds
27-
#define FW_TEST_VERSION_NUMBER 62
27+
#define FW_TEST_VERSION_NUMBER 63
2828

2929
#include "datatypes.h"
3030

mc_interface.c

+22-6
Original file line numberDiff line numberDiff line change
@@ -1727,17 +1727,33 @@ void mc_interface_mc_timer_isr(bool is_second_motor) {
17271727
UTILS_LP_FAST(motor->m_input_voltage_filtered, input_voltage, 0.02);
17281728

17291729
// Check for faults that should stop the motor
1730-
static int wrong_voltage_iterations = 0;
1731-
if (input_voltage < conf_now->l_min_vin ||
1732-
input_voltage > conf_now->l_max_vin) {
1733-
wrong_voltage_iterations++;
17341730

1735-
if ((wrong_voltage_iterations >= 8)) {
1731+
static float wrong_voltage_integrator = 0.0;
1732+
float voltage_diff_now = 0.0;
1733+
1734+
if (input_voltage < conf_now->l_min_vin) {
1735+
voltage_diff_now = conf_now->l_min_vin - input_voltage;
1736+
} else if (input_voltage > conf_now->l_max_vin) {
1737+
voltage_diff_now = input_voltage - conf_now->l_max_vin;
1738+
}
1739+
1740+
if (voltage_diff_now > 1.0e-3) {
1741+
wrong_voltage_integrator += voltage_diff_now;
1742+
1743+
const float max_voltage = (conf_now->l_max_vin * 0.05);
1744+
if (wrong_voltage_integrator > max_voltage) {
17361745
mc_interface_fault_stop(input_voltage < conf_now->l_min_vin ?
17371746
FAULT_CODE_UNDER_VOLTAGE : FAULT_CODE_OVER_VOLTAGE, is_second_motor, true);
1747+
1748+
// Windup protection
1749+
wrong_voltage_integrator = max_voltage * 2.0;
17381750
}
17391751
} else {
1740-
wrong_voltage_iterations = 0;
1752+
if (wrong_voltage_integrator > 1.0) {
1753+
wrong_voltage_integrator -= 1.0;
1754+
} else {
1755+
wrong_voltage_integrator = 0.0;
1756+
}
17411757
}
17421758

17431759
// Fetch these values in a config-specific way to avoid some overhead of the general
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)