From 1a810d1d93f52d130bc66bef8762c851421af05b Mon Sep 17 00:00:00 2001 From: Peter Poetzi Date: Sun, 2 Oct 2022 18:17:09 +0200 Subject: [PATCH 1/3] added 4 milliohm config --- CMakeLists.txt | 10 ++++++++++ main.cpp | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7326fc..89028a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,7 @@ target_compile_options(motortest.elf PRIVATE # -DPWM_FREQ_12KHZ # -DFEATURE_BUTTON # -DPETERS_PLATINE +# -DSHUNT_4_MILLIOHM # -DHUART2 # -DHUART3 # -DFEATURE_SERIAL_CONTROL @@ -106,6 +107,7 @@ target_compile_options(motortest_peter.elf PRIVATE # -DPWM_FREQ_12KHZ # -DFEATURE_BUTTON -DPETERS_PLATINE +# -DSHUNT_4_MILLIOHM # -DFEATURE_INVERT_HALL # -DHUART2 # -DHUART3 @@ -134,6 +136,7 @@ target_compile_options(feedcode-front.elf PRIVATE # -DPWM_FREQ_12KHZ # -DFEATURE_BUTTON -DPETERS_PLATINE +# -DSHUNT_4_MILLIOHM # -DHUART2 # -DHUART3 # -DFEATURE_SERIAL_CONTROL @@ -160,6 +163,7 @@ target_compile_options(feedcode-back.elf PRIVATE # -DPWM_FREQ_12KHZ # -DFEATURE_BUTTON -DPETERS_PLATINE +# -DSHUNT_4_MILLIOHM # -DHUART2 # -DHUART3 # -DFEATURE_SERIAL_CONTROL @@ -186,6 +190,7 @@ target_compile_options(greyhash.elf PRIVATE -DPWM_FREQ_12KHZ # -DFEATURE_BUTTON -DPETERS_PLATINE +# -DSHUNT_4_MILLIOHM # -DHUART2 -DHUART3 -DFEATURE_SERIAL_CONTROL @@ -212,6 +217,7 @@ target_compile_options(pcbv2_front.elf PRIVATE # -DPWM_FREQ_12KHZ # -DFEATURE_BUTTON -DPETERS_PLATINE + # -DSHUNT_4_MILLIOHM # -DHUART2 # -DHUART3 # -DFEATURE_SERIAL_CONTROL @@ -239,6 +245,7 @@ target_compile_options(pcbv2_back.elf PRIVATE # -DPWM_FREQ_12KHZ # -DFEATURE_BUTTON -DPETERS_PLATINE + # -DSHUNT_4_MILLIOHM # -DHUART2 # -DHUART3 # -DFEATURE_SERIAL_CONTROL @@ -266,6 +273,7 @@ target_compile_options(pcbv2_test.elf PRIVATE # -DPWM_FREQ_12KHZ # -DFEATURE_BUTTON -DPETERS_PLATINE + # -DSHUNT_4_MILLIOHM # -DHUART2 # -DHUART3 # -DFEATURE_SERIAL_CONTROL @@ -316,6 +324,7 @@ target_compile_options(commander_v2_front.elf PRIVATE # -DPWM_FREQ_12KHZ # -DFEATURE_BUTTON -DPETERS_PLATINE + -DSHUNT_4_MILLIOHM # -DHUART2 # -DHUART3 # -DFEATURE_SERIAL_CONTROL @@ -366,6 +375,7 @@ target_compile_options(commander_v2_back.elf PRIVATE # -DPWM_FREQ_12KHZ # -DFEATURE_BUTTON -DPETERS_PLATINE + -DSHUNT_4_MILLIOHM # -DHUART2 # -DHUART3 # -DFEATURE_SERIAL_CONTROL diff --git a/main.cpp b/main.cpp index c229ac9..7a848b9 100644 --- a/main.cpp +++ b/main.cpp @@ -496,6 +496,12 @@ void updateMotors() #endif int16_t curR_DC = (int16_t)(offsetdcr - adc_buffer.dcr); + +#ifdef SHUNT_4_MILLIOHM + curL_DC *= 2; + curR_DC *= 2; +#endif + const bool chopL = std::abs(curL_DC) > (left.iDcMax.load() * AMPERE2BIT_CONV); if (chopL) left.chops++; -- 2.50.1 From 3e0ac63d6447bbfda61c2b428b243c6f895946c7 Mon Sep 17 00:00:00 2001 From: Peter Poetzi Date: Sun, 2 Oct 2022 18:22:50 +0200 Subject: [PATCH 2/3] refine parameter (based on measurements) --- main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 7a848b9..01c6c9b 100644 --- a/main.cpp +++ b/main.cpp @@ -498,8 +498,8 @@ void updateMotors() #ifdef SHUNT_4_MILLIOHM - curL_DC *= 2; - curR_DC *= 2; + curL_DC *= 2.162; + curR_DC *= 2.162; #endif const bool chopL = std::abs(curL_DC) > (left.iDcMax.load() * AMPERE2BIT_CONV); -- 2.50.1 From 85f66fe186c8e3ba98d06606db583129ab557c39 Mon Sep 17 00:00:00 2001 From: Peter Poetzi Date: Sun, 2 Oct 2022 18:29:22 +0200 Subject: [PATCH 3/3] refine parameter (based on measurements) --- main.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/main.cpp b/main.cpp index 01c6c9b..a706bc4 100644 --- a/main.cpp +++ b/main.cpp @@ -464,15 +464,15 @@ void updateMotors() static int16_t offsetdcl{2000}; static int16_t offsetdcr{2000}; - if (offsetcount < 2000) // calibrate ADC offsets + if (offsetcount < 20000) // calibrate ADC offsets { offsetcount++; - offsetrl1 = (adc_buffer.rl1 + offsetrl1) / 2; - offsetrl2 = (adc_buffer.rl2 + offsetrl2) / 2; - offsetrr1 = (adc_buffer.rr1 + offsetrr1) / 2; - offsetrr2 = (adc_buffer.rr2 + offsetrr2) / 2; - offsetdcl = (adc_buffer.dcl + offsetdcl) / 2; - offsetdcr = (adc_buffer.dcr + offsetdcr) / 2; + offsetrl1 = (adc_buffer.rl1 + offsetrl1 * 9) / 10; + offsetrl2 = (adc_buffer.rl2 + offsetrl2 * 9) / 10; + offsetrr1 = (adc_buffer.rr1 + offsetrr1 * 9) / 10; + offsetrr2 = (adc_buffer.rr2 + offsetrr2 * 9) / 10; + offsetdcl = (adc_buffer.dcl + offsetdcl * 9) / 10; + offsetdcr = (adc_buffer.dcr + offsetdcr * 9) / 10; return; } @@ -498,8 +498,8 @@ void updateMotors() #ifdef SHUNT_4_MILLIOHM - curL_DC *= 2.162; - curR_DC *= 2.162; + curL_DC *= 2.276; + curR_DC *= 2.276; #endif const bool chopL = std::abs(curL_DC) > (left.iDcMax.load() * AMPERE2BIT_CONV); -- 2.50.1