From 8b76c1b1940d5c27199bfd7b2803e8a4ac721762 Mon Sep 17 00:00:00 2001 From: Euan Date: Mon, 4 Mar 2024 21:59:40 +0000 Subject: [PATCH 1/2] Wizard improvements Add fault descriptions Add kv and kt to make it easier to spot wrong flux linkage --- commands.cpp | 1 + datatypes.h | 4 +++- utility.cpp | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/commands.cpp b/commands.cpp index f24d0acc3..30d1eb5f3 100755 --- a/commands.cpp +++ b/commands.cpp @@ -2680,6 +2680,7 @@ QString Commands::faultToStr(mc_fault_code fault) case FAULT_CODE_ENCODER_MAGNET_TOO_STRONG: return "FAULT_CODE_ENCODER_MAGNET_TOO_STRONG"; case FAULT_CODE_PHASE_FILTER: return "FAULT_CODE_PHASE_FILTER"; case FAULT_CODE_ENCODER_FAULT: return "FAULT_CODE_ENCODER_FAULT"; + case FAULT_CODE_PHASE_OUTPUT_ERROR: return "FAULT_CODE_PHASE_OUTPUT_ERROR"; } return "Unknown fault"; diff --git a/datatypes.h b/datatypes.h index b0aa5a0a9..153034325 100644 --- a/datatypes.h +++ b/datatypes.h @@ -118,7 +118,9 @@ typedef enum { FAULT_CODE_ENCODER_NO_MAGNET, FAULT_CODE_ENCODER_MAGNET_TOO_STRONG, FAULT_CODE_PHASE_FILTER, - FAULT_CODE_ENCODER_FAULT + FAULT_CODE_ENCODER_FAULT, + FAULT_CODE_LV_OUTPUT_FAULT, + FAULT_CODE_PHASE_OUTPUT_ERROR, } mc_fault_code; typedef enum { diff --git a/utility.cpp b/utility.cpp index ca7e45feb..c0613b6dd 100755 --- a/utility.cpp +++ b/utility.cpp @@ -476,6 +476,8 @@ QString Utility::detectAllFoc(VescInterface *vesc, vesc->commands()->getAppConf(); waitSignal(ap, SIGNAL(updated()), 4000); + + auto genRes = [&p, &ap]() { QString sensors; switch (p->getParamEnum("foc_sensor_mode")) { @@ -483,20 +485,28 @@ QString Utility::detectAllFoc(VescInterface *vesc, case 1: sensors = "Encoder"; break; case 2: sensors = "Hall Sensors"; break; default: break; } + + float kv = (20.0*sqrt(3.0)) / (M_PI * p->getParamDouble("foc_motor_flux_linkage") * (double)p->getParamInt("si_motor_poles")); + float kt = 30.0 / (M_PI * kv); + return QString("VESC ID : %1\n" "Motor current : %2 A\n" "Motor R : %3 mΩ\n" "Motor L : %4 µH\n" "Motor Lq-Ld : %5 µH\n" "Motor Flux Linkage : %6 mWb\n" - "Temp Comp : %7\n" - "Sensors : %8"). + "Motor Kv : %7 RPM/V\n" + "Motor Kt : %8 Nm/A\n" + "Temp Comp : %9\n" + "Sensors : %10"). arg(ap->getParamInt("controller_id")). arg(p->getParamDouble("l_current_max"), 0, 'f', 2). arg(p->getParamDouble("foc_motor_r") * 1e3, 0, 'f', 2). arg(p->getParamDouble("foc_motor_l") * 1e6, 0, 'f', 2). arg(p->getParamDouble("foc_motor_ld_lq_diff") * 1e6, 0, 'f', 2). arg(p->getParamDouble("foc_motor_flux_linkage") * 1e3, 0, 'f', 2). + arg(kv, 0, 'f', 2). + arg(kt, 0, 'f', 2). arg(p->getParamBool("foc_temp_comp") ? "True" : "False"). arg(sensors); }; @@ -578,7 +588,7 @@ QString Utility::detectAllFoc(VescInterface *vesc, case -100 + FAULT_CODE_ENCODER_MAGNET_TOO_STRONG: reason = "Magnet too strong, magnet is too strong or too close to the encoder"; break; case -100 + FAULT_CODE_PHASE_FILTER: reason = "Phase filter fault, invalid phase filter readings"; break; case -100 + FAULT_CODE_ENCODER_FAULT: reason = "Encoder fault, check encoder connections and alignment"; break; - + case -100 + FAULT_CODE_PHASE_OUTPUT_ERROR: reason = "Phase outputs shorted or disconnected, Check for damage to cables or connectors"; break; default: reason = QString::number(resDetect); break; } From 4a4aa87325f2854baf00d99ea54c23306cd12770 Mon Sep 17 00:00:00 2001 From: Euan Date: Mon, 4 Mar 2024 22:01:06 +0000 Subject: [PATCH 2/2] Remove some blank lines --- utility.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/utility.cpp b/utility.cpp index c0613b6dd..15550760f 100755 --- a/utility.cpp +++ b/utility.cpp @@ -476,8 +476,6 @@ QString Utility::detectAllFoc(VescInterface *vesc, vesc->commands()->getAppConf(); waitSignal(ap, SIGNAL(updated()), 4000); - - auto genRes = [&p, &ap]() { QString sensors; switch (p->getParamEnum("foc_sensor_mode")) {