From aa589cb565d84c612f98c5d28c0065adb5d093da Mon Sep 17 00:00:00 2001 From: greyhash Date: Mon, 19 Oct 2020 17:42:21 +0200 Subject: [PATCH] Updated Model and did some changes in main.cpp so it works with the new model --- bobbycar-foc-model | 2 +- main.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bobbycar-foc-model b/bobbycar-foc-model index 24e9a0a..e41c8c6 160000 --- a/bobbycar-foc-model +++ b/bobbycar-foc-model @@ -1 +1 @@ -Subproject commit 24e9a0af18c49079c76d6e736dcc1279f7fa3c19 +Subproject commit e41c8c605c0040b2c37f445b791f46bf8ff88748 diff --git a/main.cpp b/main.cpp index 1dce694..102fa39 100644 --- a/main.cpp +++ b/main.cpp @@ -165,7 +165,7 @@ int main() HAL_ADC_Start(&hadc2); left.rtP = rtP_Left; - left.rtP.b_selPhaABCurrMeas = 1; // Left motor measured current phases = {iA, iB} -> do NOT change + left.rtP.z_selPhaCurMeasABC = 1; // Left motor measured current phases = {iA, iB} -> do NOT change left.rtP.z_ctrlTypSel = uint8_t(left.state.ctrlTyp); left.rtP.b_diagEna = DIAG_ENA; left.rtP.i_max = (left.state.iMotMax * A2BIT_CONV) << 4; // fixdt(1,16,4) @@ -181,7 +181,7 @@ int main() left.rtM.outputs = &left.rtY; right.rtP = rtP_Left; - right.rtP.b_selPhaABCurrMeas = 0; // Left motor measured current phases = {iB, iC} -> do NOT change + right.rtP.z_selPhaCurMeasABC = 1; // Left motor measured current phases = {iB, iC} -> do NOT change right.rtP.z_ctrlTypSel = uint8_t(right.state.ctrlTyp); right.rtP.b_diagEna = DIAG_ENA; right.rtP.i_max = (right.state.iMotMax * A2BIT_CONV) << 4; // fixdt(1,16,4) @@ -215,7 +215,7 @@ int main() int pwm = 0; int8_t dir = 1; - const int pwmMax = 400; + const int pwmMax = 1000; for (;;) { HAL_Delay(DELAY_IN_MAIN_LOOP ); //delay in ms @@ -288,8 +288,8 @@ void updateMotors() } // Get Left motor currents - int16_t curL_phaA = (int16_t)(offsetrl1 - adc_buffer.rl1)*2; - int16_t curL_phaB = (int16_t)(offsetrl2 - adc_buffer.rl2)*2; + int16_t curL_phaB = (int16_t)(offsetrl1 - adc_buffer.rl1)*2; + int16_t curL_phaA = (int16_t)(offsetrl2 - adc_buffer.rl2)*2; int16_t curL_DC = (int16_t)(offsetdcl - adc_buffer.dcl); // Get Right motor currents