From 98d11baa8f3f03efdf340849289c840add2d4484 Mon Sep 17 00:00:00 2001 From: stancecoke Date: Fri, 28 Jun 2024 14:36:24 +0200 Subject: [PATCH] Debounce Motor Hall Signal --- Src/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Src/main.c b/Src/main.c index ad3bd569..0bef1ea8 100644 --- a/Src/main.c +++ b/Src/main.c @@ -1057,7 +1057,16 @@ int main(void) #if (DISPLAY_TYPE == DISPLAY_TYPE_DEBUG && !defined(FAST_LOOP_LOG)) //print values for debugging - sprintf_(buffer, "%d, %d, %d, %d, %d, %d, %d, %d, %d\r\n", adcData[1],ui16_throttle_offset, uint32_SPEEDx100_cumulated>>SPEEDFILTER, uint32_PAS, MS.Battery_Current, int32_temp_current_target , MS.i_q, MS.u_abs, SystemState); + sprintf_(buffer, "%d, %d, %d, %d, %d, %d, %d, %d, %d\r\n", + adcData[1], + ui16_throttle_offset, + ui16_timertics, + uint32_PAS, + MS.Battery_Current, + int32_temp_current_target , + MS.i_q, + MS.u_abs, + SystemState); // sprintf_(buffer, "%d, %d, %d, %d, %d, %d, %d\r\n",(uint16_t)adcData[0],(uint16_t)adcData[1],(uint16_t)adcData[2],(uint16_t)adcData[3],(uint16_t)(adcData[4]),(uint16_t)(adcData[5]),(uint16_t)(adcData[6])) ; // sprintf_(buffer, "%d, %d, %d, %d, %d, %d\r\n",tic_array[0],tic_array[1],tic_array[2],tic_array[3],tic_array[4],tic_array[5]) ; i=0; @@ -1832,7 +1841,7 @@ void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef* htim) temp5=TIM3->CNT; - ui16_timertics = TIM2->CCR1; + if(TIM2->CCR1>20)ui16_timertics = TIM2->CCR1; //debounce hall signals //Hall sensor event processing