Compare commits
3 Commits
peters_pla
...
no-pwm-mar
Author | SHA1 | Date | |
---|---|---|---|
209cbca8ba | |||
1125ab934c | |||
0c3b449a2c |
2
.github/workflows/workflow.yml
vendored
2
.github/workflows/workflow.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config: [motortest, motortest_peter, feedcode-front, feedcode-back, greyhash]
|
||||
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:
|
||||
|
@ -174,6 +174,61 @@ add_custom_command(OUTPUT feedcode-back.bin COMMAND arm-none-eabi-objcopy -O bin
|
||||
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
|
||||
#
|
||||
|
18
main.cpp
18
main.cpp
@ -530,7 +530,11 @@ void updateMotors()
|
||||
OverrunFlag = true;
|
||||
|
||||
constexpr int32_t pwm_res = 64000000 / 2 / PWM_FREQ; // = 2000
|
||||
constexpr int32_t pwm_margin = 100; /* This margin allows to always have a window in the PWM signal for proper Phase currents measurement */
|
||||
constexpr int32_t foc_pwm_margin = 100; /* This margin allows to always have a window in the PWM signal for proper Phase currents measurement */
|
||||
|
||||
using bobbycar::protocol::ControlType;
|
||||
const int32_t pwm_margin_l = (left.rtP.z_ctrlTypSel == uint8_t(ControlType::FieldOrientedControl)) ? foc_pwm_margin : 0;
|
||||
const int32_t pwm_margin_r = (right.rtP.z_ctrlTypSel == uint8_t(ControlType::FieldOrientedControl)) ? foc_pwm_margin : 0;
|
||||
|
||||
/* Make sure to stop BOTH motors in case of an error */
|
||||
|
||||
@ -575,9 +579,9 @@ void updateMotors()
|
||||
int wl = left.rtY.DC_phaC;
|
||||
|
||||
/* Apply commands */
|
||||
LEFT_TIM->LEFT_TIM_U = (uint16_t)std::clamp(ul + pwm_res / 2, pwm_margin, pwm_res-pwm_margin);
|
||||
LEFT_TIM->LEFT_TIM_V = (uint16_t)std::clamp(vl + pwm_res / 2, pwm_margin, pwm_res-pwm_margin);
|
||||
LEFT_TIM->LEFT_TIM_W = (uint16_t)std::clamp(wl + pwm_res / 2, pwm_margin, pwm_res-pwm_margin);
|
||||
LEFT_TIM->LEFT_TIM_U = (uint16_t)std::clamp(ul + pwm_res / 2, pwm_margin_l, pwm_res-pwm_margin_l);
|
||||
LEFT_TIM->LEFT_TIM_V = (uint16_t)std::clamp(vl + pwm_res / 2, pwm_margin_l, pwm_res-pwm_margin_l);
|
||||
LEFT_TIM->LEFT_TIM_W = (uint16_t)std::clamp(wl + pwm_res / 2, pwm_margin_l, pwm_res-pwm_margin_l);
|
||||
// =================================================================
|
||||
|
||||
|
||||
@ -612,9 +616,9 @@ void updateMotors()
|
||||
int wr = right.rtY.DC_phaC;
|
||||
|
||||
/* Apply commands */
|
||||
RIGHT_TIM->RIGHT_TIM_U = (uint16_t)std::clamp(ur + pwm_res / 2, pwm_margin, pwm_res-pwm_margin);
|
||||
RIGHT_TIM->RIGHT_TIM_V = (uint16_t)std::clamp(vr + pwm_res / 2, pwm_margin, pwm_res-pwm_margin);
|
||||
RIGHT_TIM->RIGHT_TIM_W = (uint16_t)std::clamp(wr + pwm_res / 2, pwm_margin, pwm_res-pwm_margin);
|
||||
RIGHT_TIM->RIGHT_TIM_U = (uint16_t)std::clamp(ur + pwm_res / 2, pwm_margin_r, pwm_res-pwm_margin_r);
|
||||
RIGHT_TIM->RIGHT_TIM_V = (uint16_t)std::clamp(vr + pwm_res / 2, pwm_margin_r, pwm_res-pwm_margin_r);
|
||||
RIGHT_TIM->RIGHT_TIM_W = (uint16_t)std::clamp(wr + pwm_res / 2, pwm_margin_r, pwm_res-pwm_margin_r);
|
||||
// =================================================================
|
||||
|
||||
/* Indicate task complete */
|
||||
|
Reference in New Issue
Block a user