From a4278d388d7236e204fe0172ae20aa8928091020 Mon Sep 17 00:00:00 2001 From: Euan Date: Wed, 31 May 2023 21:09:45 +0100 Subject: [PATCH 1/3] Perform full offset calibration when running FOC detection Undriven offsets are not measured on startup as the motor might be spinning (reboot from crash, etc) So the only time undriven was measured was manually in VESC Tool. This runs the full offset calibration before detecting the motor to improve detection and make sure the undriven offsets are measured. --- conf_general.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/conf_general.c b/conf_general.c index d6d56b41..e474be5e 100644 --- a/conf_general.c +++ b/conf_general.c @@ -1652,6 +1652,12 @@ int conf_general_detect_apply_all_foc(float max_power_loss, int faultM1 = FAULT_CODE_NONE; int faultM2 = FAULT_CODE_NONE; + // Measure DC offsets including undriven (ignore returned status) + // Needs to be done before getting the motor configuration + if(mcpwm_foc_dc_cal(true) == -1) { + return mc_interface_get_fault() - 100; // Offset fault by -100 + } + int motor_last = mc_interface_get_motor_thread(); mc_interface_select_motor_thread(1); From 06d834d02009ae04fa714d89516e0aa6d3e9a3ec Mon Sep 17 00:00:00 2001 From: Euan Date: Wed, 31 May 2023 21:11:45 +0100 Subject: [PATCH 2/3] correct comment --- conf_general.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf_general.c b/conf_general.c index e474be5e..8bfa1100 100644 --- a/conf_general.c +++ b/conf_general.c @@ -1652,7 +1652,7 @@ int conf_general_detect_apply_all_foc(float max_power_loss, int faultM1 = FAULT_CODE_NONE; int faultM2 = FAULT_CODE_NONE; - // Measure DC offsets including undriven (ignore returned status) + // Measure DC offsets including undriven // Needs to be done before getting the motor configuration if(mcpwm_foc_dc_cal(true) == -1) { return mc_interface_get_fault() - 100; // Offset fault by -100 From 6ae5b63f616f043b2b4cf5da3f60bf63e3e21735 Mon Sep 17 00:00:00 2001 From: Euan Mutch Date: Tue, 26 Sep 2023 09:41:07 +0100 Subject: [PATCH 3/3] Don't calibrate undriven --- conf_general.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf_general.c b/conf_general.c index 8bfa1100..f5c6855a 100644 --- a/conf_general.c +++ b/conf_general.c @@ -1652,9 +1652,9 @@ int conf_general_detect_apply_all_foc(float max_power_loss, int faultM1 = FAULT_CODE_NONE; int faultM2 = FAULT_CODE_NONE; - // Measure DC offsets including undriven + // Measure DC offsets // Needs to be done before getting the motor configuration - if(mcpwm_foc_dc_cal(true) == -1) { + if(mcpwm_foc_dc_cal(false) == -1) { return mc_interface_get_fault() - 100; // Offset fault by -100 }