|
|
@@ -6,6 +6,7 @@
|
|
|
|
|
|
static foc_observer_t foc_obser = {
|
|
|
.enc_err_cnt = 0,
|
|
|
+ .b_force_sensorless = false,
|
|
|
};
|
|
|
void foc_observer_init(void) {
|
|
|
foc_obser.is_sensorless_enable = false;
|
|
|
@@ -19,6 +20,7 @@ void foc_observer_init(void) {
|
|
|
foc_obser.is_sensorless_stable = false;
|
|
|
foc_obser.sensorless_stable_cnt = 0;
|
|
|
foc_obser.sensorless_unstable_cnt = 0;
|
|
|
+ foc_obser.b_force_sensorless = false;
|
|
|
#ifdef CONFIG_SMO_OBSERVER
|
|
|
smo_observer_init(CONFIG_SMO_PLL_BANDWITH, CONFIG_SMO_LFP_WC, CONFIG_SMO_GAIN_K, CONFIG_SMO_SIGMOID_MAX);
|
|
|
foc_obser.is_sensorless_enable = true;
|
|
|
@@ -44,6 +46,9 @@ float foc_observer_update(float uAlp, float uBeta, float iAlp, float iBeta){
|
|
|
}
|
|
|
|
|
|
bool foc_observer_diagnostic(float enc_angle, float enc_vel) {
|
|
|
+ if (foc_obser.b_force_sensorless) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
if (enc_vel <= (foc_observer_sensorless_working_speed() - 100.0f)) {
|
|
|
if (!foc_obser.is_sensorless_running) {
|
|
|
if (motor_encoder_may_error()) {
|
|
|
@@ -91,14 +96,17 @@ float foc_observer_speed(void) {
|
|
|
}
|
|
|
|
|
|
bool foc_observer_is_encoder(void) {
|
|
|
+ if (foc_obser.b_force_sensorless) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
return !foc_obser.is_sensorless_running;
|
|
|
}
|
|
|
|
|
|
void foc_observer_use_sensorless(bool use_smo) {
|
|
|
- if (foc_obser.is_sensorless_enable) {
|
|
|
- foc_obser.is_sensorless_running = use_smo;
|
|
|
+ if (foc_obser.is_sensorless_enable && use_smo) {
|
|
|
+ foc_obser.b_force_sensorless = true;
|
|
|
}else {
|
|
|
- foc_obser.is_sensorless_running = false;
|
|
|
+ foc_obser.b_force_sensorless = false;
|
|
|
}
|
|
|
}
|
|
|
void foc_observer_enable_sensorless(bool enable) {
|