|
|
|
@ -18,6 +18,9 @@ extern volatile adc_buf_t adc_buffer;
|
|
|
|
|
|
|
|
|
|
|
|
extern volatile uint32_t timeout;
|
|
|
|
extern volatile uint32_t timeout;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float currentR = 0;
|
|
|
|
|
|
|
|
float currentL = 0;
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t buzzerFreq = 0;
|
|
|
|
uint32_t buzzerFreq = 0;
|
|
|
|
uint32_t buzzerPattern = 0;
|
|
|
|
uint32_t buzzerPattern = 0;
|
|
|
|
|
|
|
|
|
|
|
|
@ -166,7 +169,8 @@ void DMA1_Channel1_IRQHandler() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//disable PWM when current limit is reached (current chopping)
|
|
|
|
//disable PWM when current limit is reached (current chopping)
|
|
|
|
if(ABS((adc_buffer.dcl - offsetdcl) * MOTOR_AMP_CONV_DC_AMP) > DC_CUR_LIMIT || timeout > TIMEOUT || enable == 0) {
|
|
|
|
currentL = (adc_buffer.dcl - offsetdcl) * MOTOR_AMP_CONV_DC_AMP;
|
|
|
|
|
|
|
|
if(ABS(currentL) > DC_CUR_LIMIT || timeout > TIMEOUT || enable == 0) {
|
|
|
|
LEFT_TIM->BDTR &= ~TIM_BDTR_MOE;
|
|
|
|
LEFT_TIM->BDTR &= ~TIM_BDTR_MOE;
|
|
|
|
//HAL_GPIO_WritePin(LED_PORT, LED_PIN, 1);
|
|
|
|
//HAL_GPIO_WritePin(LED_PORT, LED_PIN, 1);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -174,7 +178,8 @@ void DMA1_Channel1_IRQHandler() {
|
|
|
|
//HAL_GPIO_WritePin(LED_PORT, LED_PIN, 0);
|
|
|
|
//HAL_GPIO_WritePin(LED_PORT, LED_PIN, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(ABS((adc_buffer.dcr - offsetdcr) * MOTOR_AMP_CONV_DC_AMP) > DC_CUR_LIMIT || timeout > TIMEOUT || enable == 0) {
|
|
|
|
currentR = (adc_buffer.dcr - offsetdcr) * MOTOR_AMP_CONV_DC_AMP;
|
|
|
|
|
|
|
|
if(ABS(currentR) > DC_CUR_LIMIT || timeout > TIMEOUT || enable == 0) {
|
|
|
|
RIGHT_TIM->BDTR &= ~TIM_BDTR_MOE;
|
|
|
|
RIGHT_TIM->BDTR &= ~TIM_BDTR_MOE;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
RIGHT_TIM->BDTR |= TIM_BDTR_MOE;
|
|
|
|
RIGHT_TIM->BDTR |= TIM_BDTR_MOE;
|
|
|
|
|