Skip to content

Commit

Permalink
Improved overvoltage protection
Browse files Browse the repository at this point in the history
  • Loading branch information
vedderb committed Nov 10, 2021
1 parent e89e00b commit f0b291d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* Added raw sampled data mode.
* Compensate inductance for motor saliency in observer.
* Added MTPA mode based on measured current.
* Faster overvoltage protection.

=== FW 5.02 ===
* IMU calibration improvement.
Expand Down
2 changes: 1 addition & 1 deletion conf_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define FW_VERSION_MAJOR 5
#define FW_VERSION_MINOR 03
// Set to 0 for building a release and iterate during beta test builds
#define FW_TEST_VERSION_NUMBER 62
#define FW_TEST_VERSION_NUMBER 63

#include "datatypes.h"

Expand Down
28 changes: 22 additions & 6 deletions mc_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1727,17 +1727,33 @@ void mc_interface_mc_timer_isr(bool is_second_motor) {
UTILS_LP_FAST(motor->m_input_voltage_filtered, input_voltage, 0.02);

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

if ((wrong_voltage_iterations >= 8)) {
static float wrong_voltage_integrator = 0.0;
float voltage_diff_now = 0.0;

if (input_voltage < conf_now->l_min_vin) {
voltage_diff_now = conf_now->l_min_vin - input_voltage;
} else if (input_voltage > conf_now->l_max_vin) {
voltage_diff_now = input_voltage - conf_now->l_max_vin;
}

if (voltage_diff_now > 1.0e-3) {
wrong_voltage_integrator += voltage_diff_now;

const float max_voltage = (conf_now->l_max_vin * 0.05);
if (wrong_voltage_integrator > max_voltage) {
mc_interface_fault_stop(input_voltage < conf_now->l_min_vin ?
FAULT_CODE_UNDER_VOLTAGE : FAULT_CODE_OVER_VOLTAGE, is_second_motor, true);

// Windup protection
wrong_voltage_integrator = max_voltage * 2.0;
}
} else {
wrong_voltage_iterations = 0;
if (wrong_voltage_integrator > 1.0) {
wrong_voltage_integrator -= 1.0;
} else {
wrong_voltage_integrator = 0.0;
}
}

// Fetch these values in a config-specific way to avoid some overhead of the general
Expand Down
Binary file added tests/overvoltage_fault/overvoltage_test_v1.ods
Binary file not shown.
Binary file added tests/overvoltage_fault/overvoltage_test_v1.pdf
Binary file not shown.
Binary file added tests/overvoltage_fault/overvoltage_test_v2.ods
Binary file not shown.
Binary file added tests/overvoltage_fault/overvoltage_test_v2.pdf
Binary file not shown.

0 comments on commit f0b291d

Please sign in to comment.