From f315a8c1f95b094d991dc2dd394a84f52b0d0d8b Mon Sep 17 00:00:00 2001 From: Gernot Hehn Date: Mon, 16 May 2022 19:03:20 +0200 Subject: [PATCH] Added Led Fet switch to be switched on with Led Changed temp calibration --- .gitignore | 5 +++++ bobbycar-protocol | 2 +- config.h | 12 ++++++------ defines.h | 3 +++ main.cpp | 7 +++++++ 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 724f042..e7bdba0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,8 @@ CMakeCache.txt CMakeFiles Makefile cmake_install.cmake +*.bin +*.hex +*.elf +*.a +*.map diff --git a/bobbycar-protocol b/bobbycar-protocol index cb5939e..496e255 160000 --- a/bobbycar-protocol +++ b/bobbycar-protocol @@ -1 +1 @@ -Subproject commit cb5939eefbf990c4e493746d816d09d1dfa5422c +Subproject commit 496e2556f4858e37df6ae59a84788a34eca862bf diff --git a/config.h b/config.h index 8fd65f8..de22920 100644 --- a/config.h +++ b/config.h @@ -41,8 +41,8 @@ * Then you can verify voltage on value 6 (to get calibrated voltage multiplied by 100). */ #define BAT_FILT_COEF 655 // battery voltage filter coefficient in fixed-point. coef_fixedPoint = coef_floatingPoint * 2^16. In this case 655 = 0.01 * 2^16 -#define BAT_CALIB_REAL_VOLTAGE 3970 // input voltage measured by multimeter (multiplied by 100). For example 43.00 V * 100 = 4300 -#define BAT_CALIB_ADC 1492 // adc-value measured by mainboard (value nr 5 on UART debug output) +#define BAT_CALIB_REAL_VOLTAGE 4800 // input voltage measured by multimeter (multiplied by 100). For example 43.00 V * 100 = 4300 +#define BAT_CALIB_ADC 1845 // adc-value measured by mainboard (value nr 5 on UART debug output) #define BAT_CELLS 12 // battery number of cells. Normal Hoverboard battery: 10s @@ -54,10 +54,10 @@ * Enable warning and/or poweroff and make and flash firmware. */ #define TEMP_FILT_COEF 655 // temperature filter coefficient in fixed-point. coef_fixedPoint = coef_floatingPoint * 2^16. In this case 655 = 0.01 * 2^16 -#define TEMP_CAL_LOW_ADC 1655 // temperature 1: ADC value -#define TEMP_CAL_LOW_DEG_C 358 // temperature 1: measured temperature [°C * 10]. Here 35.8 °C -#define TEMP_CAL_HIGH_ADC 1588 // temperature 2: ADC value -#define TEMP_CAL_HIGH_DEG_C 489 // temperature 2: measured temperature [°C * 10]. Here 48.9 °C +#define TEMP_CAL_LOW_ADC 1593 // temperature 1: ADC value +#define TEMP_CAL_LOW_DEG_C 400 // temperature 1: measured temperature [°C * 10]. Here 40.0 °C +#define TEMP_CAL_HIGH_ADC 1463 // temperature 2: ADC value +#define TEMP_CAL_HIGH_DEG_C 623 // temperature 2: measured temperature [°C * 10]. Here 62.3 °C // ############################### INPUT ############################### diff --git a/defines.h b/defines.h index 55d2592..b703ada 100644 --- a/defines.h +++ b/defines.h @@ -185,6 +185,9 @@ #define LED_PIN GPIO_PIN_2 #define LED_PORT GPIOB +#define LIGHT_PIN GPIO_PIN_3 +#define LIGHT_PORT GPIOB + #define BUZZER_PIN GPIO_PIN_4 #define BUZZER_PORT GPIOA diff --git a/main.cpp b/main.cpp index daaef2d..f263e2a 100644 --- a/main.cpp +++ b/main.cpp @@ -1050,6 +1050,10 @@ void MX_GPIO_Init() GPIO_InitStruct.Pin = LED_PIN; HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = LIGHT_PIN; + HAL_GPIO_Init(LIGHT_PORT, &GPIO_InitStruct); + __HAL_AFIO_REMAP_SWJ_NOJTAG(); GPIO_InitStruct.Pin = BUZZER_PIN; HAL_GPIO_Init(BUZZER_PORT, &GPIO_InitStruct); @@ -1392,6 +1396,7 @@ void communicationTimeout() buzzer.pattern = 1; HAL_GPIO_WritePin(LED_PORT, LED_PIN, GPIO_PIN_RESET); + HAL_GPIO_WritePin(LIGHT_PORT, LIGHT_PIN, GPIO_PIN_RESET); } #ifdef MOTOR_TEST @@ -1497,6 +1502,7 @@ void parseCommand() #endif HAL_GPIO_WritePin(LED_PORT, LED_PIN, command.led ? GPIO_PIN_RESET : GPIO_PIN_SET); + HAL_GPIO_WritePin(LIGHT_PORT, LIGHT_PIN, command.led ? GPIO_PIN_SET : GPIO_PIN_RESET); command.start = Command::INVALID_HEADER; // Change the Start Frame for timeout detection in the next cycle timeoutCntSerial = 0; // Reset the timeout counter @@ -1645,6 +1651,7 @@ void applyIncomingCanMessage() case MotorController::Command::Led: case MotorController ::Command::Led: HAL_GPIO_WritePin(LED_PORT, LED_PIN, *((bool*)buf) ? GPIO_PIN_SET : GPIO_PIN_RESET); + HAL_GPIO_WritePin(LIGHT_PORT, LIGHT_PIN, *((bool*)buf) ? GPIO_PIN_SET : GPIO_PIN_RESET); break; case MotorController::Command::Poweroff: case MotorController::Command::Poweroff: