Implemented PETERS_PLATINE

This commit is contained in:
2020-10-19 18:20:52 +02:00
parent c7c0b768ac
commit 4cf506652f
4 changed files with 45 additions and 13 deletions

View File

@ -229,17 +229,17 @@ int main()
timeout = 0;
#ifdef MOTOR_TEST
left.state.enable = false;
left.state.ctrlMod = ControlMode::Voltage;
left.state.ctrlTyp = ControlType::Sinusoidal;
left.state.enable = true;
left.state.ctrlMod = ControlMode::Torque;
left.state.ctrlTyp = ControlType::FieldOrientedControl;
left.state.pwm = pwm;
left.state.iMotMax = 1;
left.state.iMotMax = 10;
right.state.enable = true;
right.state.ctrlMod = ControlMode::Voltage;
right.state.ctrlTyp = ControlType::Sinusoidal;
right.state.ctrlMod = ControlMode::Torque;
right.state.ctrlTyp = ControlType::FieldOrientedControl;
right.state.pwm = pwm;
right.state.iMotMax = 1;
right.state.iMotMax = 10;
constexpr auto pwmMax = 500;
@ -302,13 +302,23 @@ void updateMotors()
}
// Get Left motor currents
#ifdef PETERS_PLATINE
int16_t curL_phaB = (int16_t)(offsetrl1 - adc_buffer.rl1)*2;
int16_t curL_phaA = (int16_t)(offsetrl2 - adc_buffer.rl2)*2;
#else
int16_t curL_phaA = (int16_t)(offsetrl1 - adc_buffer.rl1);
int16_t curL_phaB = (int16_t)(offsetrl2 - adc_buffer.rl2);
#endif
int16_t curL_DC = (int16_t)(offsetdcl - adc_buffer.dcl);
// Get Right motor currents
#ifdef PETERS_PLATINE
int16_t curR_phaB = (int16_t)(offsetrr1 - adc_buffer.rr1)*2;
int16_t curR_phaC = (int16_t)(offsetrr2 - adc_buffer.rr2)*2;
#else
int16_t curR_phaB = (int16_t)(offsetrr1 - adc_buffer.rr1);
int16_t curR_phaC = (int16_t)(offsetrr2 - adc_buffer.rr2);
#endif
int16_t curR_DC = (int16_t)(offsetdcr - adc_buffer.dcr);
const int8_t chopL = std::abs(curL_DC) > (left.state.iDcMax * A2BIT_CONV);
@ -813,7 +823,11 @@ void MX_TIM_Init() {
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
#ifdef PETERS_PLATINE
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
#else
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_LOW;
#endif
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_SET;
@ -854,7 +868,11 @@ void MX_TIM_Init() {
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
#ifdef PETERS_PLATINE
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
#else
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_LOW;
#endif
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_SET;