Made some updates
This commit is contained in:
11
.gitignore
vendored
11
.gitignore
vendored
@ -9,3 +9,14 @@ build/
|
|||||||
# VS Code
|
# VS Code
|
||||||
.vscode/
|
.vscode/
|
||||||
.cache/
|
.cache/
|
||||||
|
|
||||||
|
# Jetbrains
|
||||||
|
.idea/
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# other
|
||||||
|
hover.map
|
||||||
|
libemanuel_foc_model.a
|
||||||
|
libstm32_hal.a
|
||||||
|
pcbv2_test.bin
|
||||||
|
pcbv2_test.elf
|
||||||
|
100
CMakeLists.txt
100
CMakeLists.txt
@ -200,8 +200,108 @@ add_custom_command(OUTPUT greyhash.bin COMMAND arm-none-eabi-objcopy -O binary -
|
|||||||
add_custom_target(greyhash ALL SOURCES greyhash.hex greyhash.bin)
|
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)
|
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)
|
||||||
|
|
||||||
|
|
||||||
# util targets
|
# util targets
|
||||||
|
5
config.h
5
config.h
@ -6,7 +6,10 @@
|
|||||||
#define PWM_FREQ 16000 // PWM frequency in Hz
|
#define PWM_FREQ 16000 // PWM frequency in Hz
|
||||||
#endif
|
#endif
|
||||||
#define DEAD_TIME 48 // PWM deadtime
|
#define DEAD_TIME 48 // PWM deadtime
|
||||||
#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
|
// ADC conversion time definitions
|
||||||
#define ADC_CONV_TIME_1C5 (14) //Total ADC clock cycles / conversion = ( 1.5+12.5)
|
#define ADC_CONV_TIME_1C5 (14) //Total ADC clock cycles / conversion = ( 1.5+12.5)
|
||||||
|
38
defines.h
38
defines.h
@ -24,57 +24,63 @@
|
|||||||
|
|
||||||
#ifdef PETERS_PLATINE
|
#ifdef PETERS_PLATINE
|
||||||
|
|
||||||
#ifdef HALL_CAB
|
#ifdef LEFT_HALL_CAB
|
||||||
#define LEFT_HALL_U_PIN GPIO_PIN_11
|
#define LEFT_HALL_U_PIN GPIO_PIN_11
|
||||||
#define LEFT_HALL_V_PIN GPIO_PIN_12
|
#define LEFT_HALL_V_PIN GPIO_PIN_12
|
||||||
#define LEFT_HALL_W_PIN GPIO_PIN_10
|
#define LEFT_HALL_W_PIN GPIO_PIN_10
|
||||||
#elif HALL_CBA
|
#elif LEFT_HALL_CBA
|
||||||
#define LEFT_HALL_U_PIN GPIO_PIN_11
|
#define LEFT_HALL_U_PIN GPIO_PIN_11
|
||||||
#define LEFT_HALL_V_PIN GPIO_PIN_10
|
#define LEFT_HALL_V_PIN GPIO_PIN_10
|
||||||
#define LEFT_HALL_W_PIN GPIO_PIN_12
|
#define LEFT_HALL_W_PIN GPIO_PIN_12
|
||||||
#elif HALL_BAC
|
#elif LEFT_HALL_BAC
|
||||||
#define LEFT_HALL_U_PIN GPIO_PIN_10
|
#define LEFT_HALL_U_PIN GPIO_PIN_10
|
||||||
#define LEFT_HALL_V_PIN GPIO_PIN_12
|
#define LEFT_HALL_V_PIN GPIO_PIN_12
|
||||||
#define LEFT_HALL_W_PIN GPIO_PIN_11
|
#define LEFT_HALL_W_PIN GPIO_PIN_11
|
||||||
#elif HALL_BCA
|
#elif LEFT_HALL_BCA
|
||||||
#define LEFT_HALL_U_PIN GPIO_PIN_10
|
#define LEFT_HALL_U_PIN GPIO_PIN_10
|
||||||
#define LEFT_HALL_V_PIN GPIO_PIN_11
|
#define LEFT_HALL_V_PIN GPIO_PIN_11
|
||||||
#define LEFT_HALL_W_PIN GPIO_PIN_12
|
#define LEFT_HALL_W_PIN GPIO_PIN_12
|
||||||
#elif HALL_ABC
|
#elif LEFT_HALL_ABC
|
||||||
#define LEFT_HALL_U_PIN GPIO_PIN_12
|
#define LEFT_HALL_U_PIN GPIO_PIN_12
|
||||||
#define LEFT_HALL_V_PIN GPIO_PIN_10
|
#define LEFT_HALL_V_PIN GPIO_PIN_10
|
||||||
#define LEFT_HALL_W_PIN GPIO_PIN_11
|
#define LEFT_HALL_W_PIN GPIO_PIN_11
|
||||||
#else //HALL_ACB
|
#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_U_PIN GPIO_PIN_12
|
||||||
#define LEFT_HALL_V_PIN GPIO_PIN_11
|
#define LEFT_HALL_V_PIN GPIO_PIN_11
|
||||||
#define LEFT_HALL_W_PIN GPIO_PIN_10
|
#define LEFT_HALL_W_PIN GPIO_PIN_10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LEFT_HALL_U_PORT GPIOC
|
#define LEFT_HALL_U_PORT GPIOC
|
||||||
#define LEFT_HALL_V_PORT GPIOC
|
#define LEFT_HALL_V_PORT GPIOC
|
||||||
#define LEFT_HALL_W_PORT GPIOC
|
#define LEFT_HALL_W_PORT GPIOC
|
||||||
|
|
||||||
#ifdef HALL_CAB
|
#ifdef RIGHT_HALL_CAB
|
||||||
#define RIGHT_HALL_U_PIN GPIO_PIN_6
|
#define RIGHT_HALL_U_PIN GPIO_PIN_6
|
||||||
#define RIGHT_HALL_V_PIN GPIO_PIN_5
|
#define RIGHT_HALL_V_PIN GPIO_PIN_5
|
||||||
#define RIGHT_HALL_W_PIN GPIO_PIN_7
|
#define RIGHT_HALL_W_PIN GPIO_PIN_7
|
||||||
#elif HALL_CBA
|
#elif RIGHT_HALL_CBA
|
||||||
#define RIGHT_HALL_U_PIN GPIO_PIN_6
|
#define RIGHT_HALL_U_PIN GPIO_PIN_6
|
||||||
#define RIGHT_HALL_V_PIN GPIO_PIN_7
|
#define RIGHT_HALL_V_PIN GPIO_PIN_7
|
||||||
#define RIGHT_HALL_W_PIN GPIO_PIN_5
|
#define RIGHT_HALL_W_PIN GPIO_PIN_5
|
||||||
#elif HALL_BAC
|
#elif RIGHT_HALL_BAC
|
||||||
#define RIGHT_HALL_U_PIN GPIO_PIN_7
|
#define RIGHT_HALL_U_PIN GPIO_PIN_7
|
||||||
#define RIGHT_HALL_V_PIN GPIO_PIN_5
|
#define RIGHT_HALL_V_PIN GPIO_PIN_5
|
||||||
#define RIGHT_HALL_W_PIN GPIO_PIN_6
|
#define RIGHT_HALL_W_PIN GPIO_PIN_6
|
||||||
#elif HALL_BCA
|
#elif RIGHT_HALL_BCA
|
||||||
#define RIGHT_HALL_U_PIN GPIO_PIN_7
|
#define RIGHT_HALL_U_PIN GPIO_PIN_7
|
||||||
#define RIGHT_HALL_V_PIN GPIO_PIN_6
|
#define RIGHT_HALL_V_PIN GPIO_PIN_6
|
||||||
#define RIGHT_HALL_W_PIN GPIO_PIN_5
|
#define RIGHT_HALL_W_PIN GPIO_PIN_5
|
||||||
#elif HALL_ABC
|
#elif RIGHT_HALL_ABC
|
||||||
#define RIGHT_HALL_U_PIN GPIO_PIN_5
|
#define RIGHT_HALL_U_PIN GPIO_PIN_5
|
||||||
#define RIGHT_HALL_V_PIN GPIO_PIN_7
|
#define RIGHT_HALL_V_PIN GPIO_PIN_7
|
||||||
#define RIGHT_HALL_W_PIN GPIO_PIN_6
|
#define RIGHT_HALL_W_PIN GPIO_PIN_6
|
||||||
#else //HALL_ACB
|
#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_U_PIN GPIO_PIN_5
|
||||||
#define RIGHT_HALL_V_PIN GPIO_PIN_6
|
#define RIGHT_HALL_V_PIN GPIO_PIN_6
|
||||||
#define RIGHT_HALL_W_PIN GPIO_PIN_7
|
#define RIGHT_HALL_W_PIN GPIO_PIN_7
|
||||||
@ -83,7 +89,7 @@
|
|||||||
#define RIGHT_HALL_U_PORT GPIOB
|
#define RIGHT_HALL_U_PORT GPIOB
|
||||||
#define RIGHT_HALL_V_PORT GPIOB
|
#define RIGHT_HALL_V_PORT GPIOB
|
||||||
#define RIGHT_HALL_W_PORT GPIOB
|
#define RIGHT_HALL_W_PORT GPIOB
|
||||||
#else
|
#else // defined(PETERS_PLATINE)
|
||||||
#ifdef HALL_BCA
|
#ifdef HALL_BCA
|
||||||
#define LEFT_HALL_U_PIN GPIO_PIN_7
|
#define LEFT_HALL_U_PIN GPIO_PIN_7
|
||||||
#define LEFT_HALL_V_PIN GPIO_PIN_6
|
#define LEFT_HALL_V_PIN GPIO_PIN_6
|
||||||
|
56
main.cpp
56
main.cpp
@ -317,6 +317,7 @@ int main()
|
|||||||
|
|
||||||
enum { CurrentMeasAB, CurrentMeasBC, CurrentMeasAC };
|
enum { CurrentMeasAB, CurrentMeasBC, CurrentMeasAC };
|
||||||
|
|
||||||
|
#ifndef FEATURE_BETTER_FOC_CONFIG
|
||||||
#ifdef PETERS_PLATINE
|
#ifdef PETERS_PLATINE
|
||||||
left.rtP.z_selPhaCurMeasABC = CurrentMeasBC;
|
left.rtP.z_selPhaCurMeasABC = CurrentMeasBC;
|
||||||
#else
|
#else
|
||||||
@ -324,6 +325,23 @@ int main()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
right.rtP.z_selPhaCurMeasABC = CurrentMeasBC;
|
right.rtP.z_selPhaCurMeasABC = CurrentMeasBC;
|
||||||
|
#else
|
||||||
|
#ifdef LEFT_PHASE_MEAS_AB
|
||||||
|
left.rtP.z_selPhaCurMeasABC = CurrentMeasAB;
|
||||||
|
#elif LEFT_PHASE_MEAS_BC
|
||||||
|
left.rtP.z_selPhaCurMeasABC = CurrentMeasBC;
|
||||||
|
#else
|
||||||
|
left.rtP.z_selPhaCurMeasABC = CurrentMeasAC;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef RIGHT_PHASE_MEAS_AB
|
||||||
|
right.rtP.z_selPhaCurMeasABC = CurrentMeasAB;
|
||||||
|
#elif RIGHT_PHASE_MEAS_BC
|
||||||
|
right.rtP.z_selPhaCurMeasABC = CurrentMeasBC;
|
||||||
|
#else
|
||||||
|
right.rtP.z_selPhaCurMeasABC = CurrentMeasAC;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
applyDefaultSettings();
|
applyDefaultSettings();
|
||||||
@ -477,11 +495,11 @@ void updateMotors()
|
|||||||
#endif
|
#endif
|
||||||
int16_t curR_DC = (int16_t)(offsetdcr - adc_buffer.dcr);
|
int16_t curR_DC = (int16_t)(offsetdcr - adc_buffer.dcr);
|
||||||
|
|
||||||
const bool chopL = std::abs(curL_DC) > (left.iDcMax.load() * A2BIT_CONV);
|
const bool chopL = std::abs(curL_DC) > (left.iDcMax.load() * AMPERE2BIT_CONV);
|
||||||
if (chopL)
|
if (chopL)
|
||||||
left.chops++;
|
left.chops++;
|
||||||
|
|
||||||
const bool chopR = std::abs(curR_DC) > (right.iDcMax.load() * A2BIT_CONV);
|
const bool chopR = std::abs(curR_DC) > (right.iDcMax.load() * AMPERE2BIT_CONV);
|
||||||
if (chopR)
|
if (chopR)
|
||||||
right.chops++;
|
right.chops++;
|
||||||
|
|
||||||
@ -1403,22 +1421,22 @@ void doMotorTest()
|
|||||||
|
|
||||||
left.enable = true;
|
left.enable = true;
|
||||||
left.rtU.r_inpTgt = pwm;
|
left.rtU.r_inpTgt = pwm;
|
||||||
left.rtP.z_ctrlTypSel = uint8_t(ControlType::FieldOrientedControl);
|
left.rtP.z_ctrlTypSel = uint8_t(ControlType::Sinusoidal);
|
||||||
left.rtU.z_ctrlModReq = uint8_t(ControlMode::Torque);
|
left.rtU.z_ctrlModReq = uint8_t(ControlMode::Voltage);
|
||||||
left.rtP.i_max = (2 * A2BIT_CONV) << 4;
|
left.rtP.i_max = (2 * AMPERE2BIT_CONV) << 4;
|
||||||
left.iDcMax = 8;
|
left.iDcMax = 8;
|
||||||
left.rtP.n_max = 1000 << 4;
|
left.rtP.n_max = 1000 << 4;
|
||||||
left.rtP.id_fieldWeakMax = (0 * A2BIT_CONV) << 4;
|
left.rtP.id_fieldWeakMax = (0 * AMPERE2BIT_CONV) << 4;
|
||||||
left.rtP.a_phaAdvMax = 40 << 4;
|
left.rtP.a_phaAdvMax = 40 << 4;
|
||||||
|
|
||||||
right.enable = true;
|
right.enable = true;
|
||||||
right.rtU.r_inpTgt = -pwm;
|
right.rtU.r_inpTgt = -pwm;
|
||||||
right.rtP.z_ctrlTypSel = uint8_t(ControlType::FieldOrientedControl);
|
right.rtP.z_ctrlTypSel = uint8_t(ControlType::FieldOrientedControl);
|
||||||
right.rtU.z_ctrlModReq = uint8_t(ControlMode::Torque);
|
right.rtU.z_ctrlModReq = uint8_t(ControlMode::Voltage);
|
||||||
right.rtP.i_max = (2 * A2BIT_CONV) << 4;
|
right.rtP.i_max = (2 * AMPERE2BIT_CONV) << 4;
|
||||||
right.iDcMax = 8;
|
right.iDcMax = 8;
|
||||||
right.rtP.n_max = 1000 << 4;
|
right.rtP.n_max = 1000 << 4;
|
||||||
right.rtP.id_fieldWeakMax = (0 * A2BIT_CONV) << 4;
|
right.rtP.id_fieldWeakMax = (0 * AMPERE2BIT_CONV) << 4;
|
||||||
right.rtP.a_phaAdvMax = 40 << 4;
|
right.rtP.a_phaAdvMax = 40 << 4;
|
||||||
|
|
||||||
constexpr auto pwmMax = 400;
|
constexpr auto pwmMax = 400;
|
||||||
@ -1471,9 +1489,9 @@ void parseCommand()
|
|||||||
left.iDcMax = command.left.iDcMax;
|
left.iDcMax = command.left.iDcMax;
|
||||||
|
|
||||||
left.rtP.z_ctrlTypSel = uint8_t(command.left.ctrlTyp);
|
left.rtP.z_ctrlTypSel = uint8_t(command.left.ctrlTyp);
|
||||||
left.rtP.i_max = (int16_t(command.left.iMotMax) * A2BIT_CONV) << 4;
|
left.rtP.i_max = (int16_t(command.left.iMotMax) * AMPERE2BIT_CONV) << 4;
|
||||||
left.rtP.n_max = command.left.nMotMax << 4;
|
left.rtP.n_max = command.left.nMotMax << 4;
|
||||||
left.rtP.id_fieldWeakMax = (int16_t(command.left.fieldWeakMax) * A2BIT_CONV) << 4;
|
left.rtP.id_fieldWeakMax = (int16_t(command.left.fieldWeakMax) * AMPERE2BIT_CONV) << 4;
|
||||||
left.rtP.a_phaAdvMax = command.left.phaseAdvMax << 4;
|
left.rtP.a_phaAdvMax = command.left.phaseAdvMax << 4;
|
||||||
left.rtU.z_ctrlModReq = uint8_t(command.left.ctrlMod);
|
left.rtU.z_ctrlModReq = uint8_t(command.left.ctrlMod);
|
||||||
left.rtU.r_inpTgt = command.left.pwm;
|
left.rtU.r_inpTgt = command.left.pwm;
|
||||||
@ -1481,9 +1499,9 @@ void parseCommand()
|
|||||||
right.iDcMax = command.right.iDcMax;
|
right.iDcMax = command.right.iDcMax;
|
||||||
|
|
||||||
right.rtP.z_ctrlTypSel = uint8_t(command.right.ctrlTyp);
|
right.rtP.z_ctrlTypSel = uint8_t(command.right.ctrlTyp);
|
||||||
right.rtP.i_max = (int16_t(command.right.iMotMax) * A2BIT_CONV) << 4; // fixdt(1,16,4)
|
right.rtP.i_max = (int16_t(command.right.iMotMax) * AMPERE2BIT_CONV) << 4; // fixdt(1,16,4)
|
||||||
right.rtP.n_max = command.right.nMotMax << 4; // fixdt(1,16,4)
|
right.rtP.n_max = command.right.nMotMax << 4; // fixdt(1,16,4)
|
||||||
right.rtP.id_fieldWeakMax = (int16_t(command.right.fieldWeakMax) * A2BIT_CONV) << 4; // fixdt(1,16,4)
|
right.rtP.id_fieldWeakMax = (int16_t(command.right.fieldWeakMax) * AMPERE2BIT_CONV) << 4; // fixdt(1,16,4)
|
||||||
right.rtP.a_phaAdvMax = command.right.phaseAdvMax << 4; // fixdt(1,16,4)
|
right.rtP.a_phaAdvMax = command.right.phaseAdvMax << 4; // fixdt(1,16,4)
|
||||||
right.rtU.z_ctrlModReq = uint8_t(command.right.ctrlMod);
|
right.rtU.z_ctrlModReq = uint8_t(command.right.ctrlMod);
|
||||||
right.rtU.r_inpTgt = command.right.pwm;
|
right.rtU.r_inpTgt = command.right.pwm;
|
||||||
@ -1624,14 +1642,14 @@ void applyIncomingCanMessage()
|
|||||||
case MotorController<isBackBoard, true> ::Command::CtrlTyp: right.rtP.z_ctrlTypSel = *((uint8_t*)buf); break;
|
case MotorController<isBackBoard, true> ::Command::CtrlTyp: right.rtP.z_ctrlTypSel = *((uint8_t*)buf); break;
|
||||||
case MotorController<isBackBoard, false>::Command::CtrlMod: left .rtU.z_ctrlModReq = *((uint8_t*)buf); break;
|
case MotorController<isBackBoard, false>::Command::CtrlMod: left .rtU.z_ctrlModReq = *((uint8_t*)buf); break;
|
||||||
case MotorController<isBackBoard, true> ::Command::CtrlMod: right.rtU.z_ctrlModReq = *((uint8_t*)buf); break;
|
case MotorController<isBackBoard, true> ::Command::CtrlMod: right.rtU.z_ctrlModReq = *((uint8_t*)buf); break;
|
||||||
case MotorController<isBackBoard, false>::Command::IMotMax: left .rtP.i_max = (int16_t(*((uint8_t*)buf)) * A2BIT_CONV) << 4; break;
|
case MotorController<isBackBoard, false>::Command::IMotMax: left .rtP.i_max = (int16_t(*((uint8_t*)buf)) * AMPERE2BIT_CONV) << 4; break;
|
||||||
case MotorController<isBackBoard, true> ::Command::IMotMax: right.rtP.i_max = (int16_t(*((uint8_t*)buf)) * A2BIT_CONV) << 4; break;
|
case MotorController<isBackBoard, true> ::Command::IMotMax: right.rtP.i_max = (int16_t(*((uint8_t*)buf)) * AMPERE2BIT_CONV) << 4; break;
|
||||||
case MotorController<isBackBoard, false>::Command::IDcMax: left .iDcMax = *((uint8_t*)buf); break;
|
case MotorController<isBackBoard, false>::Command::IDcMax: left .iDcMax = *((uint8_t*)buf); break;
|
||||||
case MotorController<isBackBoard, true> ::Command::IDcMax: right.iDcMax = *((uint8_t*)buf); break;
|
case MotorController<isBackBoard, true> ::Command::IDcMax: right.iDcMax = *((uint8_t*)buf); break;
|
||||||
case MotorController<isBackBoard, false>::Command::NMotMax: left .rtP.n_max = *((uint16_t*)buf) << 4; break;
|
case MotorController<isBackBoard, false>::Command::NMotMax: left .rtP.n_max = *((uint16_t*)buf) << 4; break;
|
||||||
case MotorController<isBackBoard, true> ::Command::NMotMax: right.rtP.n_max = *((uint16_t*)buf) << 4; break;
|
case MotorController<isBackBoard, true> ::Command::NMotMax: right.rtP.n_max = *((uint16_t*)buf) << 4; break;
|
||||||
case MotorController<isBackBoard, false>::Command::FieldWeakMax: left .rtP.id_fieldWeakMax = (int16_t(*((uint8_t*)buf)) * A2BIT_CONV) << 4; break;
|
case MotorController<isBackBoard, false>::Command::FieldWeakMax: left .rtP.id_fieldWeakMax = (int16_t(*((uint8_t*)buf)) * AMPERE2BIT_CONV) << 4; break;
|
||||||
case MotorController<isBackBoard, true> ::Command::FieldWeakMax: right.rtP.id_fieldWeakMax = (int16_t(*((uint8_t*)buf)) * A2BIT_CONV) << 4; break;
|
case MotorController<isBackBoard, true> ::Command::FieldWeakMax: right.rtP.id_fieldWeakMax = (int16_t(*((uint8_t*)buf)) * AMPERE2BIT_CONV) << 4; break;
|
||||||
case MotorController<isBackBoard, false>::Command::PhaseAdvMax: left .rtP.a_phaAdvMax = *((uint16_t*)buf) << 4; break;
|
case MotorController<isBackBoard, false>::Command::PhaseAdvMax: left .rtP.a_phaAdvMax = *((uint16_t*)buf) << 4; break;
|
||||||
case MotorController<isBackBoard, true> ::Command::PhaseAdvMax: right.rtP.a_phaAdvMax = *((uint16_t*)buf) << 4; break;
|
case MotorController<isBackBoard, true> ::Command::PhaseAdvMax: right.rtP.a_phaAdvMax = *((uint16_t*)buf) << 4; break;
|
||||||
case MotorController<isBackBoard, false>::Command::CruiseCtrlEna: left .rtP.b_cruiseCtrlEna = *((bool*)buf); break;
|
case MotorController<isBackBoard, false>::Command::CruiseCtrlEna: left .rtP.b_cruiseCtrlEna = *((bool*)buf); break;
|
||||||
@ -1815,10 +1833,10 @@ void applyDefaultSettings()
|
|||||||
motor.rtU.r_inpTgt = 0;
|
motor.rtU.r_inpTgt = 0;
|
||||||
motor.rtP.z_ctrlTypSel = uint8_t(ControlType::FieldOrientedControl);
|
motor.rtP.z_ctrlTypSel = uint8_t(ControlType::FieldOrientedControl);
|
||||||
motor.rtU.z_ctrlModReq = uint8_t(ControlMode::OpenMode);
|
motor.rtU.z_ctrlModReq = uint8_t(ControlMode::OpenMode);
|
||||||
motor.rtP.i_max = (5 * A2BIT_CONV) << 4;
|
motor.rtP.i_max = (5 * AMPERE2BIT_CONV) << 4;
|
||||||
motor.iDcMax = 7;
|
motor.iDcMax = 7;
|
||||||
motor.rtP.n_max = 1000 << 4;
|
motor.rtP.n_max = 1000 << 4;
|
||||||
motor.rtP.id_fieldWeakMax = (1 * A2BIT_CONV) << 4;
|
motor.rtP.id_fieldWeakMax = (1 * AMPERE2BIT_CONV) << 4;
|
||||||
motor.rtP.a_phaAdvMax = 40 << 4;
|
motor.rtP.a_phaAdvMax = 40 << 4;
|
||||||
motor.rtP.b_cruiseCtrlEna = false;
|
motor.rtP.b_cruiseCtrlEna = false;
|
||||||
motor.rtP.n_cruiseMotTgt = 0;
|
motor.rtP.n_cruiseMotTgt = 0;
|
||||||
|
Reference in New Issue
Block a user