From 1b67dc2666be7fb07f044ecad005f37ee5a507f5 Mon Sep 17 00:00:00 2001 From: "Jeffrey M. Friesen" Date: Sun, 5 Apr 2020 12:28:08 -0700 Subject: [PATCH] Refactored name of is_test_build, also added dual stuff to foc_detect_apply_all_can --- commands.c | 2 +- conf_general.h | 3 ++- terminal.c | 36 +++++++++++++++++++++++++++++++----- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/commands.c b/commands.c index bf7c60ab..efa8d7a6 100644 --- a/commands.c +++ b/commands.c @@ -182,7 +182,7 @@ void commands_process_packet(unsigned char *data, unsigned int len, ind += 12; send_buffer[ind++] = app_get_configuration()->pairing_done; - send_buffer[ind++] = FW_IS_TEST_BUILD; + send_buffer[ind++] = FW_TEST_VERSION_NUMBER; reply_func(send_buffer, ind); } break; diff --git a/conf_general.h b/conf_general.h index b49b2123..43957b14 100644 --- a/conf_general.h +++ b/conf_general.h @@ -23,7 +23,8 @@ // Firmware version #define FW_VERSION_MAJOR 5 #define FW_VERSION_MINOR 00 -#define FW_IS_TEST_BUILD 1 +// Set to 0 for building a release and iterate during beta test builds +#define FW_TEST_VERSION_NUMBER 1 #include "datatypes.h" diff --git a/terminal.c b/terminal.c index b1a064e4..846fcbb7 100644 --- a/terminal.c +++ b/terminal.c @@ -661,6 +661,7 @@ void terminal_process_string(char *str) { } #ifdef HW_HAS_DUAL_MOTORS mc_interface_select_motor_thread(2); + mcconf = mc_interface_get_configuration(); 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)); @@ -681,7 +682,7 @@ void terminal_process_string(char *str) { if (res == -10) { commands_printf("Could not measure flux linkage."); } else if (res == -11) { - commands_printf("Fault code occured during detection."); + commands_printf("Fault code occurred during detection."); } commands_printf("Detection failed.\n"); @@ -719,6 +720,9 @@ void terminal_process_string(char *str) { if (res >= 0) { commands_printf("Detection finished and applied. Results:"); +#ifdef HW_HAS_DUAL_MOTORS + commands_printf("\nMOTOR 1\n"); +#endif const volatile mc_configuration *mcconf = mc_interface_get_configuration(); commands_printf("Motor Current : %.1f A", (double)(mcconf->l_current_max)); commands_printf("Motor R : %.2f mOhm", (double)(mcconf->foc_motor_r * 1e3)); @@ -729,20 +733,42 @@ 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); + mcconf = mc_interface_get_configuration(); + 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); + } + commands_printf("\nNote that this is only printing values of motors 1"); + commands_printf("and 2 of the currently connected unit, other motors"); + commands_printf("may have been detected, but won't be printed here"); +#endif } else { if (res == -10) { commands_printf("Could not measure flux linkage."); } else if (res == -11) { - commands_printf("Fault code occured during detection."); + commands_printf("Fault code occurred during detection."); } commands_printf("Detection failed.\n");