From 0bb5b2d99c995beab18928bbab04010e9651ac96 Mon Sep 17 00:00:00 2001 From: "Jeffrey M. Friesen" Date: Sun, 5 Apr 2020 12:04:04 -0700 Subject: [PATCH] Cleaned up detect_apply_all terminal command for dual hardware --- conf_general.h | 8 ++++---- terminal.c | 28 +++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/conf_general.h b/conf_general.h index d1251cbf..b9970f2d 100644 --- a/conf_general.h +++ b/conf_general.h @@ -131,12 +131,12 @@ //#define HW_SOURCE "hw_100_250.c" //#define HW_HEADER "hw_100_250.h" -#define HW_SOURCE "hw_unity.c" -#define HW_HEADER "hw_unity.h" +//#define HW_SOURCE "hw_unity.c" +//#define HW_HEADER "hw_unity.h" //#define HW_DUAL_CONFIG_PARALLEL -//#define HW_SOURCE "hw_stormcore_100d.c" -//#define HW_HEADER "hw_stormcore_100d.h" +#define HW_SOURCE "hw_stormcore_100d.c" +#define HW_HEADER "hw_stormcore_100d.h" //#define HW_SOURCE "hw_stormcore_60d.c" //#define HW_HEADER "hw_stormcore_60d.h" diff --git a/terminal.c b/terminal.c index 303c74ef..b1a064e4 100644 --- a/terminal.c +++ b/terminal.c @@ -633,10 +633,14 @@ void terminal_process_string(char *str) { int res = conf_general_detect_apply_all_foc(max_power_loss, true, true); commands_printf("Res: %d", res); + mc_interface_select_motor_thread(1); if (res >= 0) { commands_printf("Detection finished and applied. Results:"); const volatile mc_configuration *mcconf = mc_interface_get_configuration(); +#ifdef HW_HAS_DUAL_MOTORS + commands_printf("\nMOTOR 1\n"); +#endif commands_printf("Motor Current : %.1f A", (double)(mcconf->l_current_max)); commands_printf("Motor R : %.2f mOhm", (double)(mcconf->foc_motor_r * 1e3)); commands_printf("Motor L : %.2f microH", (double)(mcconf->foc_motor_l * 1e6)); @@ -646,15 +650,33 @@ void terminal_process_string(char *str) { commands_printf("Temp Comp Base Temp : %.1f degC", (double)mcconf->foc_temp_comp_base_temp); } - if (res == 0) { + if (mcconf->foc_sensor_mode == FOC_SENSOR_MODE_SENSORLESS) { commands_printf("No sensors found, using sensorless mode.\n"); - } else if (res == 1) { + } else if (mcconf->foc_sensor_mode == FOC_SENSOR_MODE_HALL) { commands_printf("Found hall sensors, using them.\n"); - } else if (res == 2) { + } else if (mcconf->foc_sensor_mode == FOC_SENSOR_MODE_ENCODER) { commands_printf("Found AS5047 encoder, using it.\n"); } else { commands_printf("Detection error: %d\n", res); } +#ifdef HW_HAS_DUAL_MOTORS + mc_interface_select_motor_thread(2); + commands_printf("\nMOTOR 2\n"); + commands_printf("Motor Current : %.1f A", (double)(mcconf->l_current_max)); + commands_printf("Motor R : %.2f mOhm", (double)(mcconf->foc_motor_r * 1e3)); + commands_printf("Motor L : %.2f microH", (double)(mcconf->foc_motor_l * 1e6)); + commands_printf("Motor Flux Linkage : %.3f mWb", (double)(mcconf->foc_motor_flux_linkage * 1e3)); + commands_printf("Temp Comp : %s", mcconf->foc_temp_comp ? "true" : "false"); + if (mcconf->foc_sensor_mode == FOC_SENSOR_MODE_SENSORLESS) { + commands_printf("No sensors found, using sensorless mode.\n"); + } else if (mcconf->foc_sensor_mode == FOC_SENSOR_MODE_HALL) { + commands_printf("Found hall sensors, using them.\n"); + } else if (mcconf->foc_sensor_mode == FOC_SENSOR_MODE_ENCODER) { + commands_printf("Found AS5047 encoder, using it.\n"); + } else { + commands_printf("Detection error: %d\n", res); + } +#endif } else { if (res == -10) { commands_printf("Could not measure flux linkage.");