From 46e4dc26288fcd8cc8dd7ff6e83bc365b38d9536 Mon Sep 17 00:00:00 2001 From: pmantoine Date: Thu, 7 Apr 2022 16:53:50 +0800 Subject: [PATCH] Motor driver senseFactor and 10bit ADC --- DCCTimerSAMD.cpp | 2 +- MotorDrivers.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DCCTimerSAMD.cpp b/DCCTimerSAMD.cpp index a3f9c00..eb4849b 100644 --- a/DCCTimerSAMD.cpp +++ b/DCCTimerSAMD.cpp @@ -56,7 +56,7 @@ void DCCTimer::begin(INTERRUPT_CALLBACK callback) { ADC->CTRLB.reg &= 0b1111100011111111; // mask PRESCALER bits ADC->CTRLB.reg |= ADC_CTRLB_PRESCALER_DIV64 | // divide Clock by 64 - ADC_CTRLB_RESSEL_12BIT; // Result on 12 bits + ADC_CTRLB_RESSEL_10BIT; // Result on 10 bits default, 12 bits possible ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_1 | // take 1 sample at a time ADC_AVGCTRL_ADJRES(0x00ul); // adjusting result by 0 diff --git a/MotorDrivers.h b/MotorDrivers.h index accddf1..74aab48 100644 --- a/MotorDrivers.h +++ b/MotorDrivers.h @@ -50,8 +50,8 @@ // PMA - senseFactor for 3.3v systems is 1.95 as calculated when using 10-bit A/D samples, // and for 12-bit samples it's more like 0.488, but we probably need to tweak both these #define STANDARD_MOTOR_SHIELD F("STANDARD_MOTOR_SHIELD"), \ - new MotorDriver(3, 12, UNUSED_PIN, 9, A0, 0.488, 2000, UNUSED_PIN), \ - new MotorDriver(11, 13, UNUSED_PIN, 8, A1, 0.488, 2000, UNUSED_PIN) + new MotorDriver(3, 12, UNUSED_PIN, 9, A0, 1.95, 2000, UNUSED_PIN), \ + new MotorDriver(11, 13, UNUSED_PIN, 8, A1, 1.95, 2000, UNUSED_PIN) #else #define STANDARD_MOTOR_SHIELD F("STANDARD_MOTOR_SHIELD"), \ new MotorDriver(3, 12, UNUSED_PIN, 9, A0, 2.99, 2000, UNUSED_PIN), \