From ec882ef6530271bae4aec04407bd22f36a87f2d6 Mon Sep 17 00:00:00 2001 From: novirium Date: Thu, 19 May 2022 14:40:31 +0800 Subject: [PATCH] Motor drive constant adjustments --- src/motor-esp32/adc_read.cpp | 6 ++++-- src/motor-esp32/motor_control.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/motor-esp32/adc_read.cpp b/src/motor-esp32/adc_read.cpp index 48e2da9..7348e3c 100644 --- a/src/motor-esp32/adc_read.cpp +++ b/src/motor-esp32/adc_read.cpp @@ -9,7 +9,9 @@ #include "esp_adc_cal.h" #define SYS_VOLTS_PER_ADC_MV ((((2.2+10.0)/2.2)/1000.0)*1.042) -#define MOTOR_AMPS_PER_ADC_MV ((2.5/1000.0)*1.042) +#define MOTOR_AMPS_PER_ADC_MV ((8.5/1000.0)*1.042) +//Roller 3 has a motor driver with the BTS7960B (R9 R3 R8 R2 are all 3K), rather than the BTN7971B (all 1K) +#define MOTOR_AMPS_PER_ADC_MV_R3 ((8.5/1000.0)*1.042) #define ADC_TASK_STACK_SIZE 2048 @@ -47,7 +49,7 @@ static void motor_control_task(void *pvParameters) { xQueueOverwrite(motor_current_queue[1], &result); adc_raw = adc1_get_raw(ADC_ROLLER3_IS); - result = esp_adc_cal_raw_to_voltage(adc_raw, &adc1_11db_chars) * MOTOR_AMPS_PER_ADC_MV; + result = esp_adc_cal_raw_to_voltage(adc_raw, &adc1_11db_chars) * MOTOR_AMPS_PER_ADC_MV_R3; xQueueOverwrite(motor_current_queue[2], &result); adc_raw = adc1_get_raw(ADC_SYS_VOLTAGE); diff --git a/src/motor-esp32/motor_control.h b/src/motor-esp32/motor_control.h index f043d4d..78f5033 100644 --- a/src/motor-esp32/motor_control.h +++ b/src/motor-esp32/motor_control.h @@ -10,7 +10,7 @@ #define MAX_DUTY_RAMP 10.0 // max change in duty per second - where 1.0 is full duty #define MIN_DUTY 0.10 // min duty for each motor -#define MAX_DUTY 0.99 // max duty for each motor - Needs to be below 0.33 to avoid overlapping the three motor phases +#define MAX_DUTY 0.55 // max duty for each motor - Needs to be below 0.33 to avoid overlapping the three motor phases #define DEFAULT_KP 0.0 #define DEFAULT_KI 5.0