mirror of https://github.com/rusefi/bldc.git
Allow passive flux linkage measurement
This commit is contained in:
parent
e06a179943
commit
f32ee99852
|
@ -41,6 +41,7 @@
|
||||||
* Fix possible runaway after faults during openloop measurements (flux linkage, encoder).
|
* Fix possible runaway after faults during openloop measurements (flux linkage, encoder).
|
||||||
* Added more current sampling modes.
|
* Added more current sampling modes.
|
||||||
* Added FOC interpolation mode.
|
* Added FOC interpolation mode.
|
||||||
|
* Allow passive flux linkage measurement.
|
||||||
|
|
||||||
### 6.02
|
### 6.02
|
||||||
#### 2023-03-12
|
#### 2023-03-12
|
||||||
|
|
|
@ -972,6 +972,16 @@ int conf_general_measure_flux_linkage_openloop(float current, float duty,
|
||||||
*result = false;
|
*result = false;
|
||||||
int fault = FAULT_CODE_NONE;
|
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.
|
// Don't let impossible values through.
|
||||||
if (res <= 0.0 || ind <= 0.0) {
|
if (res <= 0.0 || ind <= 0.0) {
|
||||||
return fault;
|
return fault;
|
||||||
|
@ -1031,6 +1041,7 @@ int conf_general_measure_flux_linkage_openloop(float current, float duty,
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
float rpm_now = 0;
|
float rpm_now = 0;
|
||||||
|
|
||||||
|
if (fabsf(current) > mcconf->cc_min_current) {
|
||||||
// Start by locking the motor
|
// Start by locking the motor
|
||||||
for (int i = 0;i < 200;i++) {
|
for (int i = 0;i < 200;i++) {
|
||||||
mc_interface_lock_override_once();
|
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
|
// Let the H-bridges settle
|
||||||
chThdSleepMilliseconds(5);
|
chThdSleepMilliseconds(5);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*linkage = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
float linkage_sum = 0.0;
|
float linkage_sum = 0.0;
|
||||||
float linkage_samples = 0.0;
|
float linkage_samples = 0.0;
|
||||||
|
@ -1185,12 +1200,12 @@ int conf_general_measure_flux_linkage_openloop(float current, float duty,
|
||||||
linkage_sum += mcpwm_foc_get_vq() / rad_s_now;
|
linkage_sum += mcpwm_foc_get_vq() / rad_s_now;
|
||||||
|
|
||||||
// Optionally use magnitude
|
// Optionally use magnitude
|
||||||
// linkage_sum += sqrtf(SQ(mcpwm_foc_get_vq()) + SQ(mcpwm_foc_get_vd())) / rad_s_now;
|
// linkage_sum += sqrtf(SQ(mcpwm_foc_get_vq()) + SQ(mcpwm_foc_get_vd())) / rad_s_now;
|
||||||
|
|
||||||
// Optionally use magnitude of observer state
|
// Optionally use magnitude of observer state
|
||||||
// float x1, x2;
|
// float x1, x2;
|
||||||
// mcpwm_foc_get_observer_state(&x1, &x2);
|
// mcpwm_foc_get_observer_state(&x1, &x2);
|
||||||
// linkage_sum += sqrtf(SQ(x1) + SQ(x2));
|
// linkage_sum += sqrtf(SQ(x1) + SQ(x2));
|
||||||
|
|
||||||
linkage_samples += 1.0;
|
linkage_samples += 1.0;
|
||||||
chThdSleep(1);
|
chThdSleep(1);
|
||||||
|
@ -1205,14 +1220,15 @@ int conf_general_measure_flux_linkage_openloop(float current, float duty,
|
||||||
|
|
||||||
if (linkage_samples > 0) {
|
if (linkage_samples > 0) {
|
||||||
*linkage_undriven = linkage_sum / linkage_samples;
|
*linkage_undriven = linkage_sum / linkage_samples;
|
||||||
|
*result = true;
|
||||||
} else {
|
} else {
|
||||||
*linkage_undriven = 0.0;
|
*linkage_undriven = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*linkage > 0.0) {
|
if (*linkage > 0.0) {
|
||||||
*result = true;
|
*result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Some functions use 0 to detect a failure
|
// Some functions use 0 to detect a failure
|
||||||
if (fault != FAULT_CODE_NONE) {
|
if (fault != FAULT_CODE_NONE) {
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#define FW_VERSION_MAJOR 6
|
#define FW_VERSION_MAJOR 6
|
||||||
#define FW_VERSION_MINOR 05
|
#define FW_VERSION_MINOR 05
|
||||||
// Set to 0 for building a release and iterate during beta test builds
|
// 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"
|
#include "datatypes.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue