Allow passive flux linkage measurement

This commit is contained in:
Benjamin Vedder 2023-10-08 10:07:11 +02:00
parent e06a179943
commit f32ee99852
3 changed files with 164 additions and 147 deletions

View File

@ -41,6 +41,7 @@
* Fix possible runaway after faults during openloop measurements (flux linkage, encoder).
* Added more current sampling modes.
* Added FOC interpolation mode.
* Allow passive flux linkage measurement.
### 6.02
#### 2023-03-12

View File

@ -972,6 +972,16 @@ int conf_general_measure_flux_linkage_openloop(float current, float duty,
*result = false;
int fault = FAULT_CODE_NONE;
// Allow using old values when only measuring the flux linkage undriven
if (fabsf(current) <= mc_interface_get_configuration()->cc_min_current) {
if (res <= 0.0) {
res = mc_interface_get_configuration()->foc_motor_r;
}
if (ind <= 0.0) {
ind = mc_interface_get_configuration()->foc_motor_l;
}
}
// Don't let impossible values through.
if (res <= 0.0 || ind <= 0.0) {
return fault;
@ -1031,6 +1041,7 @@ int conf_general_measure_flux_linkage_openloop(float current, float duty,
int cnt = 0;
float rpm_now = 0;
if (fabsf(current) > mcconf->cc_min_current) {
// Start by locking the motor
for (int i = 0;i < 200;i++) {
mc_interface_lock_override_once();
@ -1172,6 +1183,10 @@ int conf_general_measure_flux_linkage_openloop(float current, float duty,
// Let the H-bridges settle
chThdSleepMilliseconds(5);
}
} else {
*linkage = 0.0;
}
float linkage_sum = 0.0;
float linkage_samples = 0.0;
@ -1205,14 +1220,15 @@ int conf_general_measure_flux_linkage_openloop(float current, float duty,
if (linkage_samples > 0) {
*linkage_undriven = linkage_sum / linkage_samples;
*result = true;
} else {
*linkage_undriven = 0.0;
}
if (*linkage > 0.0) {
*result = true;
}
}
}
// Some functions use 0 to detect a failure
if (fault != FAULT_CODE_NONE) {

View File

@ -24,7 +24,7 @@
#define FW_VERSION_MAJOR 6
#define FW_VERSION_MINOR 05
// Set to 0 for building a release and iterate during beta test builds
#define FW_TEST_VERSION_NUMBER 17
#define FW_TEST_VERSION_NUMBER 18
#include "datatypes.h"