Can communication (#9)
* First tries with can * More implementations * More registers * More implementations * Moved canbus registers into protocol submodule * CAN finishing work * Implemented debug utilities * back/front board compile time defines * More compile defines * Fixed disable mosfets stuck * More improvements * More refactorings * Cleanups * Cleanups * Updated merged protocol
This commit is contained in:
@ -36,12 +36,18 @@ include_directories(
|
||||
|
||||
#add_definitions(-DMOTOR_TEST)
|
||||
add_definitions(-DFEATURE_IGNORE_OTHER_MOTOR)
|
||||
add_definitions(-DGSCHISSENES_HALL)
|
||||
#add_definitions(-DGSCHISSENE_PWM_FREQ)
|
||||
#add_definitions(-DFEATURE_BUTTON)
|
||||
add_definitions(-DPETERS_PLATINE)
|
||||
add_definitions(-DHUARN2)
|
||||
#add_definitions(-DHUARN2)
|
||||
#add_definitions(-DHUARN3)
|
||||
add_definitions(-DFEATURE_SERIAL_CONTROL)
|
||||
add_definitions(-DFEATURE_SERIAL_FEEDBACK)
|
||||
#add_definitions(-DFEATURE_SERIAL_CONTROL)
|
||||
#add_definitions(-DFEATURE_SERIAL_FEEDBACK)
|
||||
#add_definitions(-DLOG_TO_SERIAL)
|
||||
add_definitions(-DFEATURE_CAN)
|
||||
#add_definitions(-DCAN_LOG_UNKNOWN_ADDR)
|
||||
add_definitions(-DIS_BACK)
|
||||
|
||||
add_executable(firmware.elf
|
||||
STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c
|
||||
@ -59,13 +65,16 @@ add_executable(firmware.elf
|
||||
STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c
|
||||
STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c
|
||||
STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c
|
||||
STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c
|
||||
|
||||
bobbycar-foc-model/BLDC_controller.h
|
||||
bobbycar-foc-model/BLDC_controller.c
|
||||
bobbycar-foc-model/BLDC_controller_data.c
|
||||
bobbycar-foc-model/rtwtypes.h
|
||||
|
||||
bobbycar-protocol/protocol.h
|
||||
bobbycar-protocol/bobbycar-can.h
|
||||
bobbycar-protocol/bobbycar-common.h
|
||||
bobbycar-protocol/bobbycar-serial.h
|
||||
|
||||
startup_stm32f103xe.s
|
||||
system_stm32f1xx.c
|
||||
|
Submodule bobbycar-protocol updated: 39f76cb62b...b6f0d6a185
23
config.h
23
config.h
@ -1,17 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef PETERS_PLATINE
|
||||
#ifdef GSCHISSENE_PWM_FREQ
|
||||
#define PWM_FREQ 12000 // PWM frequency in Hz
|
||||
#else
|
||||
#define PWM_FREQ 16000 // PWM frequency in Hz
|
||||
#endif
|
||||
#define DEAD_TIME 48 // PWM deadtime
|
||||
#ifdef MOTOR_TEST
|
||||
#define DELAY_IN_MAIN_LOOP 20
|
||||
#else
|
||||
#define DELAY_IN_MAIN_LOOP 5
|
||||
#endif
|
||||
#define TIMEOUT 5 // number of wrong / missing input commands before emergency off
|
||||
#define A2BIT_CONV 50 // A to bit for current conversion on ADC. Example: 1 A = 50, 2 A = 100, etc
|
||||
|
||||
// ADC conversion time definitions
|
||||
@ -50,13 +44,7 @@
|
||||
#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_CELLS 10 // battery number of cells. Normal Hoverboard battery: 10s
|
||||
#define BAT_LOW_LVL1_ENABLE 0 // to beep or not to beep, 1 or 0
|
||||
#define BAT_LOW_LVL2_ENABLE 1 // to beep or not to beep, 1 or 0
|
||||
#define BAT_LOW_LVL1 (360 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE // gently beeps at this voltage level. [V*100/cell]. In this case 3.60 V/cell
|
||||
#define BAT_LOW_LVL2 (350 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE // your battery is almost empty. Charge now! [V*100/cell]. In this case 3.50 V/cell
|
||||
#define BAT_LOW_DEAD (337 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE // undervoltage poweroff. (while not driving) [V*100/cell]. In this case 3.37 V/cell
|
||||
|
||||
#define BAT_CELLS 12 // battery number of cells. Normal Hoverboard battery: 10s
|
||||
|
||||
/* Board overheat detection: the sensor is inside the STM/GD chip.
|
||||
* It is very inaccurate without calibration (up to 45°C). So only enable this funcion after calibration!
|
||||
@ -70,13 +58,6 @@
|
||||
#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_WARNING_ENABLE 0 // to beep or not to beep, 1 or 0, DO NOT ACTIVITE WITHOUT CALIBRATION!
|
||||
#define TEMP_WARNING 600 // annoying fast beeps [°C * 10]. Here 60.0 °C
|
||||
#define TEMP_POWEROFF_ENABLE 0 // to poweroff or not to poweroff, 1 or 0, DO NOT ACTIVITE WITHOUT CALIBRATION!
|
||||
#define TEMP_POWEROFF 650 // overheat poweroff. (while not driving) [°C * 10]. Here 65.0 °C
|
||||
|
||||
#define INACTIVITY_TIMEOUT 8 // minutes of not driving until poweroff. it is not very precise.
|
||||
|
||||
|
||||
|
||||
// ############################### INPUT ###############################
|
||||
|
24
defines.h
24
defines.h
@ -23,33 +23,57 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
#ifdef PETERS_PLATINE
|
||||
#ifdef GSCHISSENES_HALL
|
||||
#define LEFT_HALL_U_PIN GPIO_PIN_10
|
||||
#define LEFT_HALL_V_PIN GPIO_PIN_11
|
||||
#define LEFT_HALL_W_PIN GPIO_PIN_12
|
||||
#else
|
||||
#define LEFT_HALL_U_PIN GPIO_PIN_12
|
||||
#define LEFT_HALL_V_PIN GPIO_PIN_11
|
||||
#define LEFT_HALL_W_PIN GPIO_PIN_10
|
||||
#endif
|
||||
|
||||
#define LEFT_HALL_U_PORT GPIOC
|
||||
#define LEFT_HALL_V_PORT GPIOC
|
||||
#define LEFT_HALL_W_PORT GPIOC
|
||||
|
||||
#ifdef GSCHISSENES_HALL
|
||||
#define RIGHT_HALL_U_PIN GPIO_PIN_7
|
||||
#define RIGHT_HALL_V_PIN GPIO_PIN_6
|
||||
#define RIGHT_HALL_W_PIN GPIO_PIN_5
|
||||
#else
|
||||
#define RIGHT_HALL_U_PIN GPIO_PIN_5
|
||||
#define RIGHT_HALL_V_PIN GPIO_PIN_6
|
||||
#define RIGHT_HALL_W_PIN GPIO_PIN_7
|
||||
#endif
|
||||
|
||||
#define RIGHT_HALL_U_PORT GPIOB
|
||||
#define RIGHT_HALL_V_PORT GPIOB
|
||||
#define RIGHT_HALL_W_PORT GPIOB
|
||||
#else
|
||||
#ifdef GSCHISSENES_HALL
|
||||
#define LEFT_HALL_U_PIN GPIO_PIN_7
|
||||
#define LEFT_HALL_V_PIN GPIO_PIN_6
|
||||
#define LEFT_HALL_W_PIN GPIO_PIN_5
|
||||
#else
|
||||
#define LEFT_HALL_U_PIN GPIO_PIN_5
|
||||
#define LEFT_HALL_V_PIN GPIO_PIN_6
|
||||
#define LEFT_HALL_W_PIN GPIO_PIN_7
|
||||
#endif
|
||||
|
||||
#define LEFT_HALL_U_PORT GPIOB
|
||||
#define LEFT_HALL_V_PORT GPIOB
|
||||
#define LEFT_HALL_W_PORT GPIOB
|
||||
|
||||
#ifdef GSCHISSENES_HALL
|
||||
#define RIGHT_HALL_U_PIN GPIO_PIN_12
|
||||
#define RIGHT_HALL_V_PIN GPIO_PIN_11
|
||||
#define RIGHT_HALL_W_PIN GPIO_PIN_10
|
||||
#else
|
||||
#define RIGHT_HALL_U_PIN GPIO_PIN_10
|
||||
#define RIGHT_HALL_V_PIN GPIO_PIN_11
|
||||
#define RIGHT_HALL_W_PIN GPIO_PIN_12
|
||||
#endif
|
||||
|
||||
#define RIGHT_HALL_U_PORT GPIOC
|
||||
#define RIGHT_HALL_V_PORT GPIOC
|
||||
|
@ -36,7 +36,7 @@ extern "C" {
|
||||
*/
|
||||
#define HAL_MODULE_ENABLED
|
||||
#define HAL_ADC_MODULE_ENABLED
|
||||
/* #define HAL_CAN_MODULE_ENABLED */
|
||||
#define HAL_CAN_MODULE_ENABLED
|
||||
/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
|
||||
/* #define HAL_CEC_MODULE_ENABLED */
|
||||
#define HAL_CORTEX_MODULE_ENABLED
|
||||
@ -129,7 +129,7 @@ extern "C" {
|
||||
#define PREFETCH_ENABLE 1U
|
||||
|
||||
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
|
||||
#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
|
||||
#define USE_HAL_CAN_REGISTER_CALLBACKS 1 /* CAN register callback disabled */
|
||||
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
|
||||
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
|
||||
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
|
||||
|
Reference in New Issue
Block a user