34 Commits

Author SHA1 Message Date
cd69f0b894 Merge pull request #21 from bobbycar-graz/wno-volatile
Ignore -Wvolatile warnings from STM32 HAL
2023-04-14 16:58:08 +02:00
323db30bc1 Ignore -Wvolatile warnings from STM32 HAL 2023-04-13 04:18:49 +02:00
1125ab934c Add feedc0de 2 2023-04-09 17:16:38 +02:00
0c3b449a2c All motor configs 2022-10-03 10:20:05 +02:00
cae4a46d18 Merge pull request #19 from bobbycar-graz/fix-can-phaadvmax
Fix data type of a_phaAdvMax in CAN protocol
2022-10-02 16:49:36 +02:00
fea59a5004 Fix data type of a_phaAdvMax in CAN protocol 2022-10-02 02:19:17 +02:00
bf1b2f34bd Updated to latest 2022-09-18 11:00:27 +02:00
8d755d42e7 Updated gitignore 2022-09-10 17:54:11 +02:00
e361066e0b Updated CMakeLists.txt 2022-09-10 17:54:03 +02:00
c8f29ccb9f Reverted to old 2022-09-10 17:50:33 +02:00
f01a34c109 Made some updates 2022-08-27 16:53:03 +02:00
b307e1bc79 Update workflow.yml 2022-08-27 14:04:34 +02:00
3a872bcd58 Update to bobbycar-graz/bobbycar-protocol@496e2556f4 (#18) 2022-05-05 18:21:59 +02:00
fa0c149352 Add build folder, some VS Code folders to .gitignore (#17) 2022-05-05 18:21:33 +02:00
1161ed6c42 Add Id Iq currents 2022-04-26 23:14:40 +02:00
e60c2fa6d2 Added error logging for ci 2022-03-16 18:13:47 +01:00
5ebd6e6779 Added CI
Added a build ci to see if new commits still work
2022-03-16 18:01:47 +01:00
70ef49418b add more hall configs 2022-02-03 21:17:51 +01:00
96a6424baa add new configs for hall 2022-02-03 21:10:31 +01:00
6436fecd85 add new hall sensor configs 2022-02-03 21:08:08 +01:00
3b4e67d740 fixed iMotMax and fieldWeakMax overflow (with ~40A) 2021-09-17 17:35:10 +02:00
c21ad44f9c Fixed compiler warnings 2021-06-28 10:47:14 +02:00
abe066df79 New protocol with more sorts of currents 2021-06-28 10:35:05 +02:00
da24c84835 Update README.md 2021-06-03 21:38:55 +02:00
7ed695dace Updated README with new flash build targets 2021-05-30 02:55:53 +02:00
c194308080 Added greyhash build config 2021-05-30 02:54:29 +02:00
3e768dbdef Multiple build configs in CMake 2021-05-30 02:45:37 +02:00
e2b823c901 Added feedc0de front/back configurations in CMakeLists.txt 2021-05-29 00:01:03 +02:00
0b661709da 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
2021-05-23 17:54:44 +02:00
a88af55928 More cleanups 2021-05-14 21:56:47 +02:00
274466e017 More cleanups and improvements 2021-05-14 21:31:12 +02:00
94ded84e82 Formatting fixes 2021-05-14 21:16:34 +02:00
57e57a07bb Buzzer freq fix 2021-05-14 20:51:01 +02:00
6ec3740aaf HUART2 and HUART3 usable now 2021-05-14 20:46:59 +02:00
10 changed files with 1701 additions and 464 deletions

33
.github/workflows/workflow.yml vendored Normal file
View File

@ -0,0 +1,33 @@
name: CI
on:
push:
release:
types:
- created
# pull_request:
# types: [opened, synchronize, reopened]
# checkout, install make and try to build
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
config: [motortest, motortest_peter, feedcode-front, feedcode-back, greyhash, pcbv2_front, pcbv2_back, pcbv2_test, commander_v2_front, commander_v2_back]
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- name: Install make
run: |
sudo apt update -y
sudo apt install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi cmake make
- name: Build
id: build
run: |
cmake -DCMAKE_BUILD_TYPE=Release .
make -j$(nproc) ${{ matrix.config }}

17
.gitignore vendored
View File

@ -3,3 +3,20 @@ CMakeCache.txt
CMakeFiles
Makefile
cmake_install.cmake
build/
# VS Code
.vscode/
.cache/
# Jetbrains
.idea/
cmake-build-*/
# other
hover.map
libemanuel_foc_model.a
libstm32_hal.a
/*.bin
/*elf

View File

@ -10,10 +10,11 @@ SET(CMAKE_SYSTEM_NAME Generic)
set(COMMON_FLAGS "-mcpu=cortex-m3 -mthumb -Wall -fdata-sections -ffunction-sections")
set(CMAKE_ASM_FLAGS "${COMMON_FLAGS} -x assembler-with-cpp")
set(CMAKE_C_FLAGS "${COMMON_FLAGS} -std=gnu11")
set(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -std=c++17")
set(CMAKE_C_FLAGS "${COMMON_FLAGS}")
set(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -Wno-volatile")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
set(COMMON_LINKER_FLAGS "-specs=nosys.specs -T${CMAKE_SOURCE_DIR}/STM32F103RCTx_FLASH.ld -lc -lm -lnosys -lstdc++ -Wl,--gc-sections -Wl,-Map=${CMAKE_BINARY_DIR}/hover.map,--cref")
set(CMAKE_EXE_LINKER_FLAGS "${COMMON_LINKER_FLAGS}")
@ -33,12 +34,7 @@ include_directories(
bobbycar-protocol
)
#add_definitions(-DMOTOR_TEST)
#add_definitions(-DFEATURE_IGNORE_OTHER_MOTOR)
add_definitions(-DFEATURE_BUTTON)
#add_definitions(-DPETERS_PLATINE)
add_executable(firmware.elf
add_library(stm32_hal STATIC
STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c
STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c
STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c
@ -54,40 +50,418 @@ 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
startup_stm32f103xe.s
system_stm32f1xx.c
)
add_library(emanuel_foc_model STATIC
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
startup_stm32f103xe.s
system_stm32f1xx.c
config.h
defines.h
main.cpp
)
add_custom_command(OUTPUT firmware.hex
COMMAND arm-none-eabi-objcopy -O ihex firmware.elf firmware.hex
DEPENDS firmware.elf)
add_library(bobbycar-protocol INTERFACE
)
add_custom_command(OUTPUT firmware.bin
COMMAND arm-none-eabi-objcopy -O binary -S firmware.elf firmware.bin
DEPENDS firmware.elf)
add_custom_target(firmware ALL
SOURCES firmware.hex firmware.bin)
add_custom_target(flash
COMMAND st-flash --reset write firmware.bin 0x8000000
SOURCES firmware.bin)
#
# motor test
#
add_executable(motortest.elf config.h defines.h main.cpp)
target_link_libraries(motortest.elf stm32_hal emanuel_foc_model bobbycar-protocol)
target_compile_options(motortest.elf PRIVATE
-DMOTOR_TEST
-DFEATURE_IGNORE_OTHER_MOTOR
# -DHALL_BCA
# -DPWM_FREQ_12KHZ
# -DFEATURE_BUTTON
# -DPETERS_PLATINE
# -DHUART2
# -DHUART3
# -DFEATURE_SERIAL_CONTROL
# -DFEATURE_SERIAL_FEEDBACK
# -DLOG_TO_SERIAL
# -DFEATURE_CAN
# -DCAN_LOG_UNKNOWN_ADDR
# -DIS_BACK
)
add_custom_command(OUTPUT motortest.hex COMMAND arm-none-eabi-objcopy -O ihex motortest.elf motortest.hex DEPENDS motortest.elf)
add_custom_command(OUTPUT motortest.bin COMMAND arm-none-eabi-objcopy -O binary -S motortest.elf motortest.bin DEPENDS motortest.elf)
add_custom_target(motortest ALL SOURCES motortest.hex motortest.bin)
add_custom_target(flash-motortest COMMAND st-flash --reset write motortest.bin 0x8000000 SOURCES motortest.bin DEPENDS motortest.bin)
#
# motor test peter
#
add_executable(motortest_peter.elf config.h defines.h main.cpp)
target_link_libraries(motortest_peter.elf stm32_hal emanuel_foc_model bobbycar-protocol)
target_compile_options(motortest_peter.elf PRIVATE
#-DMOTOR_TEST
-DFEATURE_IGNORE_OTHER_MOTOR
-DHALL_ABC
# -DPWM_FREQ_12KHZ
# -DFEATURE_BUTTON
-DPETERS_PLATINE
# -DFEATURE_INVERT_HALL
# -DHUART2
# -DHUART3
# -DFEATURE_SERIAL_CONTROL
# -DFEATURE_SERIAL_FEEDBACK
# -DLOG_TO_SERIAL
-DFEATURE_CAN
# -DCAN_LOG_UNKNOWN_ADDR
-DIS_BACK
)
add_custom_command(OUTPUT motortest_peter.hex COMMAND arm-none-eabi-objcopy -O ihex motortest_peter.elf motortest_peter.hex DEPENDS motortest_peter.elf)
add_custom_command(OUTPUT motortest_peter.bin COMMAND arm-none-eabi-objcopy -O binary -S motortest_peter.elf motortest_peter.bin DEPENDS motortest_peter.elf)
add_custom_target(motortest_peter ALL SOURCES motortest_peter.hex motortest_peter.bin)
add_custom_target(flash-motortest_peter COMMAND st-flash --reset write motortest_peter.bin 0x8000000 SOURCES motortest_peter.bin DEPENDS motortest_peter.bin)
#
# feedc0de front
#
add_executable(feedcode-front.elf config.h defines.h main.cpp)
target_link_libraries(feedcode-front.elf stm32_hal emanuel_foc_model bobbycar-protocol)
target_compile_options(feedcode-front.elf PRIVATE
# -DMOTOR_TEST
-DFEATURE_IGNORE_OTHER_MOTOR
-DHALL_BCA
# -DPWM_FREQ_12KHZ
# -DFEATURE_BUTTON
-DPETERS_PLATINE
# -DHUART2
# -DHUART3
# -DFEATURE_SERIAL_CONTROL
# -DFEATURE_SERIAL_FEEDBACK
# -DLOG_TO_SERIAL
-DFEATURE_CAN
# -DCAN_LOG_UNKNOWN_ADDR
# -DIS_BACK
)
add_custom_command(OUTPUT feedcode-front.hex COMMAND arm-none-eabi-objcopy -O ihex feedcode-front.elf feedcode-front.hex DEPENDS feedcode-front.elf)
add_custom_command(OUTPUT feedcode-front.bin COMMAND arm-none-eabi-objcopy -O binary -S feedcode-front.elf feedcode-front.bin DEPENDS feedcode-front.elf)
add_custom_target(feedcode-front ALL SOURCES feedcode-front.hex feedcode-front.bin)
add_custom_target(flash-feedcode-front COMMAND st-flash --reset write feedcode-front.bin 0x8000000 SOURCES feedcode-front.bin DEPENDS feedcode-front.bin)
#
# feedc0de back
#
add_executable(feedcode-back.elf config.h defines.h main.cpp)
target_link_libraries(feedcode-back.elf stm32_hal emanuel_foc_model bobbycar-protocol)
target_compile_options(feedcode-back.elf PRIVATE
# -DMOTOR_TEST
-DFEATURE_IGNORE_OTHER_MOTOR
# -DHALL_BCA
# -DPWM_FREQ_12KHZ
# -DFEATURE_BUTTON
-DPETERS_PLATINE
# -DHUART2
# -DHUART3
# -DFEATURE_SERIAL_CONTROL
# -DFEATURE_SERIAL_FEEDBACK
# -DLOG_TO_SERIAL
-DFEATURE_CAN
# -DCAN_LOG_UNKNOWN_ADDR
-DIS_BACK
)
add_custom_command(OUTPUT feedcode-back.hex COMMAND arm-none-eabi-objcopy -O ihex feedcode-back.elf feedcode-back.hex DEPENDS feedcode-back.elf)
add_custom_command(OUTPUT feedcode-back.bin COMMAND arm-none-eabi-objcopy -O binary -S feedcode-back.elf feedcode-back.bin DEPENDS feedcode-back.elf)
add_custom_target(feedcode-back ALL SOURCES feedcode-back.hex feedcode-back.bin)
add_custom_target(flash-feedcode-back COMMAND st-flash --reset write feedcode-back.bin 0x8000000 SOURCES feedcode-back.bin DEPENDS feedcode-back.bin)
#
# feedc0de 2 front
#
add_executable(feedcode2-front.elf config.h defines.h main.cpp)
target_link_libraries(feedcode2-front.elf stm32_hal emanuel_foc_model bobbycar-protocol)
target_compile_options(feedcode2-front.elf PRIVATE
# -DMOTOR_TEST
-DFEATURE_IGNORE_OTHER_MOTOR
-DLEFT_HALL_ABC
-DRIGHT_HALL_ABC
# -DPWM_FREQ_12KHZ
# -DFEATURE_BUTTON
-DPETERS_PLATINE
# -DHUART2
# -DHUART3
# -DFEATURE_SERIAL_CONTROL
# -DFEATURE_SERIAL_FEEDBACK
# -DLOG_TO_SERIAL
-DFEATURE_CAN
# -DCAN_LOG_UNKNOWN_ADDR
# -DIS_BACK
)
add_custom_command(OUTPUT feedcode2-front.hex COMMAND arm-none-eabi-objcopy -O ihex feedcode2-front.elf feedcode2-front.hex DEPENDS feedcode2-front.elf)
add_custom_command(OUTPUT feedcode2-front.bin COMMAND arm-none-eabi-objcopy -O binary -S feedcode2-front.elf feedcode2-front.bin DEPENDS feedcode2-front.elf)
add_custom_target(feedcode2-front ALL SOURCES feedcode2-front.hex feedcode2-front.bin)
add_custom_target(flash-feedcode2-front COMMAND st-flash --reset write feedcode2-front.bin 0x8000000 SOURCES feedcode2-front.bin DEPENDS feedcode2-front.bin)
#
# feedc0de 2 back
#
add_executable(feedcode2-back.elf config.h defines.h main.cpp)
target_link_libraries(feedcode2-back.elf stm32_hal emanuel_foc_model bobbycar-protocol)
target_compile_options(feedcode2-back.elf PRIVATE
# -DMOTOR_TEST
-DFEATURE_IGNORE_OTHER_MOTOR
-DLEFT_HALL_ACB
-DRIGHT_HALL_ACB
# -DPWM_FREQ_12KHZ
# -DFEATURE_BUTTON
-DPETERS_PLATINE
# -DHUART2
# -DHUART3
# -DFEATURE_SERIAL_CONTROL
# -DFEATURE_SERIAL_FEEDBACK
# -DLOG_TO_SERIAL
-DFEATURE_CAN
# -DCAN_LOG_UNKNOWN_ADDR
-DIS_BACK
)
add_custom_command(OUTPUT feedcode2-back.hex COMMAND arm-none-eabi-objcopy -O ihex feedcode2-back.elf feedcode2-back.hex DEPENDS feedcode2-back.elf)
add_custom_command(OUTPUT feedcode2-back.bin COMMAND arm-none-eabi-objcopy -O binary -S feedcode2-back.elf feedcode2-back.bin DEPENDS feedcode2-back.elf)
add_custom_target(feedcode2-back ALL SOURCES feedcode2-back.hex feedcode2-back.bin)
add_custom_target(flash-feedcode2-back COMMAND st-flash --reset write feedcode2-back.bin 0x8000000 SOURCES feedcode2-back.bin DEPENDS feedcode2-back.bin)
#
# greyhash
#
add_executable(greyhash.elf config.h defines.h main.cpp)
target_link_libraries(greyhash.elf stm32_hal emanuel_foc_model bobbycar-protocol)
target_compile_options(greyhash.elf PRIVATE
# -DMOTOR_TEST
-DFEATURE_IGNORE_OTHER_MOTOR
# -DHALL_BCA
-DPWM_FREQ_12KHZ
# -DFEATURE_BUTTON
-DPETERS_PLATINE
# -DHUART2
-DHUART3
-DFEATURE_SERIAL_CONTROL
-DFEATURE_SERIAL_FEEDBACK
# -DLOG_TO_SERIAL
# -DFEATURE_CAN
# -DCAN_LOG_UNKNOWN_ADDR
# -DIS_BACK
)
add_custom_command(OUTPUT greyhash.hex COMMAND arm-none-eabi-objcopy -O ihex greyhash.elf greyhash.hex DEPENDS greyhash.elf)
add_custom_command(OUTPUT greyhash.bin COMMAND arm-none-eabi-objcopy -O binary -S greyhash.elf greyhash.bin DEPENDS greyhash.elf)
add_custom_target(greyhash ALL SOURCES greyhash.hex greyhash.bin)
add_custom_target(flash-greyhash COMMAND st-flash --reset write greyhash.bin 0x8000000 SOURCES greyhash.bin DEPENDS greyhash.bin)
#
# peters platine v2 front
#
add_executable(pcbv2_front.elf config.h defines.h main.cpp)
target_link_libraries(pcbv2_front.elf stm32_hal emanuel_foc_model bobbycar-protocol)
target_compile_options(pcbv2_front.elf PRIVATE
# -DMOTOR_TEST
-DFEATURE_IGNORE_OTHER_MOTOR
# -DHALL_BCA
# -DPWM_FREQ_12KHZ
# -DFEATURE_BUTTON
-DPETERS_PLATINE
# -DHUART2
# -DHUART3
# -DFEATURE_SERIAL_CONTROL
# -DFEATURE_SERIAL_FEEDBACK
# -DLOG_TO_SERIAL
-DFEATURE_CAN
# -DCAN_LOG_UNKNOWN_ADDR
# -DIS_BACK
-DAMPERE2BIT_CONV=28
)
add_custom_command(OUTPUT pcbv2_front.hex COMMAND arm-none-eabi-objcopy -O ihex pcbv2_front.elf pcbv2_front.hex DEPENDS pcbv2_front.elf)
add_custom_command(OUTPUT pcbv2_front.bin COMMAND arm-none-eabi-objcopy -O binary -S pcbv2_front.elf pcbv2_front.bin DEPENDS pcbv2_front.elf)
add_custom_target(pcbv2_front ALL SOURCES pcbv2_front.hex pcbv2_front.bin)
add_custom_target(flash-pcbv2_front COMMAND st-flash --reset write pcbv2_front.bin 0x8000000 SOURCES pcbv2_front.bin DEPENDS pcbv2_front.bin)
#
# peters platine v2 back
#
add_executable(pcbv2_back.elf config.h defines.h main.cpp)
target_link_libraries(pcbv2_back.elf stm32_hal emanuel_foc_model bobbycar-protocol)
target_compile_options(pcbv2_back.elf PRIVATE
# -DMOTOR_TEST
-DFEATURE_IGNORE_OTHER_MOTOR
# -DHALL_BCA
# -DPWM_FREQ_12KHZ
# -DFEATURE_BUTTON
-DPETERS_PLATINE
# -DHUART2
# -DHUART3
# -DFEATURE_SERIAL_CONTROL
# -DFEATURE_SERIAL_FEEDBACK
# -DLOG_TO_SERIAL
-DFEATURE_CAN
# -DCAN_LOG_UNKNOWN_ADDR
-DIS_BACK
-DAMPERE2BIT_CONV=28
)
add_custom_command(OUTPUT pcbv2_back.hex COMMAND arm-none-eabi-objcopy -O ihex pcbv2_back.elf pcbv2_back.hex DEPENDS pcbv2_back.elf)
add_custom_command(OUTPUT pcbv2_back.bin COMMAND arm-none-eabi-objcopy -O binary -S pcbv2_back.elf pcbv2_back.bin DEPENDS pcbv2_back.elf)
add_custom_target(pcbv2_back ALL SOURCES pcbv2_back.hex pcbv2_back.bin)
add_custom_target(flash-pcbv2_back COMMAND st-flash --reset write pcbv2_back.bin 0x8000000 SOURCES pcbv2_back.bin DEPENDS pcbv2_back.bin)
#
# peters platine v2 motortest
#
add_executable(pcbv2_test.elf config.h defines.h main.cpp)
target_link_libraries(pcbv2_test.elf stm32_hal emanuel_foc_model bobbycar-protocol)
target_compile_options(pcbv2_test.elf PRIVATE
-DMOTOR_TEST
-DFEATURE_IGNORE_OTHER_MOTOR
# -DHALL_BCA
# -DPWM_FREQ_12KHZ
# -DFEATURE_BUTTON
-DPETERS_PLATINE
# -DHUART2
# -DHUART3
# -DFEATURE_SERIAL_CONTROL
# -DFEATURE_SERIAL_FEEDBACK
# -DLOG_TO_SERIAL
# -DFEATURE_CAN
# -DCAN_LOG_UNKNOWN_ADDR
# -DIS_BACK
-DAMPERE2BIT_CONV=28
-DLEFT_HALL_ABC
#-DLEFT_HALL_ACB
#-DLEFT_HALL_BAC
#-DLEFT_HALL_BCA
#-DLEFT_HALL_CAB
#-DLEFT_HALL_CBA
-DRIGHT_HALL_ABC
#-DRIGHT_HALL_ACB
#-DRIGHT_HALL_BAC
#-DRIGHT_HALL_BCA
#-DRIGHT_HALL_CAB
#-DRIGHT_HALL_CBA
#-DFEATURE_BETTER_FOC_CONFIG
#-DLEFT_PHASE_MEAS_AB
#-DLEFT_PHASE_MEAS_AC
#-DLEFT_PHASE_MEAS_BC
#-DRIGHT_PHASE_MEAS_AB
#-DRIGHT_PHASE_MEAS_AC
#-DRIGHT_PHASE_MEAS_BC
)
add_custom_command(OUTPUT pcbv2_test.hex COMMAND arm-none-eabi-objcopy -O ihex pcbv2_test.elf pcbv2_test.hex DEPENDS pcbv2_test.elf)
add_custom_command(OUTPUT pcbv2_test.bin COMMAND arm-none-eabi-objcopy -O binary -S pcbv2_test.elf pcbv2_test.bin DEPENDS pcbv2_test.elf)
add_custom_target(pcbv2_test ALL SOURCES pcbv2_test.hex pcbv2_test.bin)
add_custom_target(flash-pcbv2_test COMMAND st-flash --reset write pcbv2_test.bin 0x8000000 SOURCES pcbv2_test.bin DEPENDS pcbv2_test.bin)
#
# commander v2 front
#
add_executable(commander_v2_front.elf config.h defines.h main.cpp)
target_link_libraries(commander_v2_front.elf stm32_hal emanuel_foc_model bobbycar-protocol)
target_compile_options(commander_v2_front.elf PRIVATE
#-DMOTOR_TEST
-DFEATURE_IGNORE_OTHER_MOTOR
# -DHALL_BCA
# -DPWM_FREQ_12KHZ
# -DFEATURE_BUTTON
-DPETERS_PLATINE
# -DHUART2
# -DHUART3
# -DFEATURE_SERIAL_CONTROL
# -DFEATURE_SERIAL_FEEDBACK
# -DLOG_TO_SERIAL
-DFEATURE_CAN
# -DCAN_LOG_UNKNOWN_ADDR
# -DIS_BACK
#-DAMPERE2BIT_CONV=28
-DLEFT_HALL_ABC
#-DLEFT_HALL_ACB
#-DLEFT_HALL_BAC
#-DLEFT_HALL_BCA
#-DLEFT_HALL_CAB
#-DLEFT_HALL_CBA
-DRIGHT_HALL_ABC
#-DRIGHT_HALL_ACB
#-DRIGHT_HALL_BAC
#-DRIGHT_HALL_BCA
#-DRIGHT_HALL_CAB
#-DRIGHT_HALL_CBA
#-DFEATURE_BETTER_FOC_CONFIG
#-DLEFT_PHASE_MEAS_AB
#-DLEFT_PHASE_MEAS_AC
#-DLEFT_PHASE_MEAS_BC
#-DRIGHT_PHASE_MEAS_AB
#-DRIGHT_PHASE_MEAS_AC
#-DRIGHT_PHASE_MEAS_BC
)
add_custom_command(OUTPUT commander_v2_front.hex COMMAND arm-none-eabi-objcopy -O ihex commander_v2_front.elf commander_v2_front.hex DEPENDS commander_v2_front.elf)
add_custom_command(OUTPUT commander_v2_front.bin COMMAND arm-none-eabi-objcopy -O binary -S commander_v2_front.elf commander_v2_front.bin DEPENDS commander_v2_front.elf)
add_custom_target(commander_v2_front ALL SOURCES commander_v2_front.hex commander_v2_front.bin)
add_custom_target(flash-commander_v2_front COMMAND st-flash --reset write commander_v2_front.bin 0x8000000 SOURCES commander_v2_front.bin DEPENDS commander_v2_front.bin)
#
# commander v2 back
#
add_executable(commander_v2_back.elf config.h defines.h main.cpp)
target_link_libraries(commander_v2_back.elf stm32_hal emanuel_foc_model bobbycar-protocol)
target_compile_options(commander_v2_back.elf PRIVATE
#-DMOTOR_TEST
-DFEATURE_IGNORE_OTHER_MOTOR
# -DHALL_BCA
# -DPWM_FREQ_12KHZ
# -DFEATURE_BUTTON
-DPETERS_PLATINE
# -DHUART2
# -DHUART3
# -DFEATURE_SERIAL_CONTROL
# -DFEATURE_SERIAL_FEEDBACK
# -DLOG_TO_SERIAL
-DFEATURE_CAN
# -DCAN_LOG_UNKNOWN_ADDR
-DIS_BACK
#-DAMPERE2BIT_CONV=28
-DLEFT_HALL_ABC
#-DLEFT_HALL_ACB
#-DLEFT_HALL_BAC
#-DLEFT_HALL_BCA
#-DLEFT_HALL_CAB
#-DLEFT_HALL_CBA
-DRIGHT_HALL_ABC
#-DRIGHT_HALL_ACB
#-DRIGHT_HALL_BAC
#-DRIGHT_HALL_BCA
#-DRIGHT_HALL_CAB
#-DRIGHT_HALL_CBA
#-DFEATURE_BETTER_FOC_CONFIG
#-DLEFT_PHASE_MEAS_AB
#-DLEFT_PHASE_MEAS_AC
#-DLEFT_PHASE_MEAS_BC
#-DRIGHT_PHASE_MEAS_AB
#-DRIGHT_PHASE_MEAS_AC
#-DRIGHT_PHASE_MEAS_BC
)
add_custom_command(OUTPUT commander_v2_back.hex COMMAND arm-none-eabi-objcopy -O ihex commander_v2_back.elf commander_v2_back.hex DEPENDS commander_v2_back.elf)
add_custom_command(OUTPUT commander_v2_back.bin COMMAND arm-none-eabi-objcopy -O binary -S commander_v2_back.elf commander_v2_back.bin DEPENDS commander_v2_back.elf)
add_custom_target(commander_v2_back ALL SOURCES commander_v2_back.hex commander_v2_back.bin)
add_custom_target(flash-commander_v2_back COMMAND st-flash --reset write commander_v2_back.bin 0x8000000 SOURCES commander_v2_back.bin DEPENDS commander_v2_back.bin)
# util targets
add_custom_target(debug
COMMAND openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg)
add_custom_target(unlock0
COMMAND openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg -c init -c "reset halt" -c "stm32f1x unlock 0")
add_custom_target(unlock1

View File

@ -8,6 +8,7 @@ sudo pacman -Sy --noconfirm \
arm-none-eabi-gdb \
arm-none-eabi-newlib \
cmake \
make \
openocd \
stlink
@ -15,7 +16,10 @@ git clone --recursive git@github.com:bobbycar-graz/bobbycar-controller-firmware.
cd bobbycar-controller-firmware/
cmake -DCMAKE_BUILD_TYPE=Release .
make unlock0 # needed only once per board
make flash
make flash-motortest
make flash-feedc0de-front
make flash-feedc0de-back
make flash-greyhash
```
## Hardware

View File

@ -1,18 +1,15 @@
#pragma once
#ifdef PETERS_PLATINE
#ifdef PWM_FREQ_12KHZ
#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 10
//#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
#ifndef AMPERE2BIT_CONV
#define AMPERE2BIT_CONV 50 // Ampere to bit for current conversion on ADC. Example: 1 A = 50, 2 A = 100, etc
#endif
// ADC conversion time definitions
#define ADC_CONV_TIME_1C5 (14) //Total ADC clock cycles / conversion = ( 1.5+12.5)
@ -50,13 +47,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 +61,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 ###############################

View File

@ -23,33 +23,96 @@
#include "stm32f1xx_hal.h"
#ifdef PETERS_PLATINE
#ifdef LEFT_HALL_CAB
#define LEFT_HALL_U_PIN GPIO_PIN_11
#define LEFT_HALL_V_PIN GPIO_PIN_12
#define LEFT_HALL_W_PIN GPIO_PIN_10
#elif LEFT_HALL_CBA
#define LEFT_HALL_U_PIN GPIO_PIN_11
#define LEFT_HALL_V_PIN GPIO_PIN_10
#define LEFT_HALL_W_PIN GPIO_PIN_12
#elif LEFT_HALL_BAC
#define LEFT_HALL_U_PIN GPIO_PIN_10
#define LEFT_HALL_V_PIN GPIO_PIN_12
#define LEFT_HALL_W_PIN GPIO_PIN_11
#elif LEFT_HALL_BCA
#define LEFT_HALL_U_PIN GPIO_PIN_10
#define LEFT_HALL_V_PIN GPIO_PIN_11
#define LEFT_HALL_W_PIN GPIO_PIN_12
#elif LEFT_HALL_ABC
#define LEFT_HALL_U_PIN GPIO_PIN_12
#define LEFT_HALL_V_PIN GPIO_PIN_10
#define LEFT_HALL_W_PIN GPIO_PIN_11
#else //LEFT_HALL_ACB
#ifndef LEFT_HALL_ACB
#warning "No left Hall configuration defined, using default ACB"
#endif
#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
#define LEFT_HALL_U_PORT GPIOC
#define LEFT_HALL_V_PORT GPIOC
#define LEFT_HALL_W_PORT GPIOC
#ifdef RIGHT_HALL_CAB
#define RIGHT_HALL_U_PIN GPIO_PIN_6
#define RIGHT_HALL_V_PIN GPIO_PIN_5
#define RIGHT_HALL_W_PIN GPIO_PIN_7
#elif RIGHT_HALL_CBA
#define RIGHT_HALL_U_PIN GPIO_PIN_6
#define RIGHT_HALL_V_PIN GPIO_PIN_7
#define RIGHT_HALL_W_PIN GPIO_PIN_5
#elif RIGHT_HALL_BAC
#define RIGHT_HALL_U_PIN GPIO_PIN_7
#define RIGHT_HALL_V_PIN GPIO_PIN_5
#define RIGHT_HALL_W_PIN GPIO_PIN_6
#elif RIGHT_HALL_BCA
#define RIGHT_HALL_U_PIN GPIO_PIN_7
#define RIGHT_HALL_V_PIN GPIO_PIN_6
#define RIGHT_HALL_W_PIN GPIO_PIN_5
#elif RIGHT_HALL_ABC
#define RIGHT_HALL_U_PIN GPIO_PIN_5
#define RIGHT_HALL_V_PIN GPIO_PIN_7
#define RIGHT_HALL_W_PIN GPIO_PIN_6
#else //RIGHT_HALL_ACB
#ifndef RIGHT_HALL_ACB
#warning "No right Hall configuration defined, using default ACB"
#endif
#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 // defined(PETERS_PLATINE)
#ifdef HALL_BCA
#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 HALL_BCA
#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

1570
main.cpp

File diff suppressed because it is too large Load Diff

View File

@ -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 */