cancel
Showing results for 
Search instead for 
Did you mean: 

Six-Step BLDC Control Complimentary Switching Issue

Karthik DM
Associate III

Hello,

Currently, I'm working with BLDC motor controller development. I used complementary switching logic to control my MOSFET. Here, the motor is not starting at less duty cycle, the motor is starting only at 70percent duty cycle. and more noise also coming

anybody, please help me how to solve this issue.

Thank You.

Commutation code is:

case 1:

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_1);

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2);

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2);

HAL_TIM_PWM_Stop(&htim1, TIM_CHANNEL_3);

HAL_TIMEx_PWMN_Stop(&htim1, TIM_CHANNEL_3);

//__HAL_TIM_SetCompare(&htim1, TIM_CHANNEL_1, duty_cycle);

//__HAL_TIM_SetCompare(&htim1, TIM_CHANNEL_2, 0);

TIM1->CCR1 = duty_cycle;

TIM1->CCR2 = 0;

break;

case 2:

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_1);

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3);

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_3);

HAL_TIM_PWM_Stop(&htim1, TIM_CHANNEL_2);

HAL_TIMEx_PWMN_Stop(&htim1, TIM_CHANNEL_2);

//__HAL_TIM_SetCompare(&htim1, TIM_CHANNEL_1, duty_cycle);

//__HAL_TIM_SetCompare(&htim1, TIM_CHANNEL_3, 0);

TIM1->CCR1 = duty_cycle;

TIM1->CCR3 = 0;

break;

case 3:

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2);

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2);

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3);

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_3);

HAL_TIM_PWM_Stop(&htim1, TIM_CHANNEL_1);

HAL_TIMEx_PWMN_Stop(&htim1, TIM_CHANNEL_1);

//__HAL_TIM_SetCompare(&htim1, TIM_CHANNEL_2, duty_cycle);

//__HAL_TIM_SetCompare(&htim1, TIM_CHANNEL_3, 0);

TIM1->CCR2 = duty_cycle;

TIM1->CCR3 = 0;

break;

case 4:

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2);

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2);

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_1);

HAL_TIM_PWM_Stop(&htim1, TIM_CHANNEL_3);

HAL_TIMEx_PWMN_Stop(&htim1, TIM_CHANNEL_3);

//__HAL_TIM_SetCompare(&htim1, TIM_CHANNEL_2, duty_cycle);

//__HAL_TIM_SetCompare(&htim1, TIM_CHANNEL_1, 0);

TIM1->CCR2 = duty_cycle;

TIM1->CCR1 = 0;

break;

case 5:

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3);

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_3);

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_1);

HAL_TIM_PWM_Stop(&htim1, TIM_CHANNEL_2);

HAL_TIMEx_PWMN_Stop(&htim1, TIM_CHANNEL_2);

//__HAL_TIM_SetCompare(&htim1, TIM_CHANNEL_3, duty_cycle);

//__HAL_TIM_SetCompare(&htim1, TIM_CHANNEL_1, 0);

TIM1->CCR3 = duty_cycle;

TIM1->CCR1 = 0;

break;

case 6:

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3);

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_3);

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2);

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2);

HAL_TIM_PWM_Stop(&htim1, TIM_CHANNEL_1);

HAL_TIMEx_PWMN_Stop(&htim1, TIM_CHANNEL_1);

//__HAL_TIM_SetCompare(&htim1, TIM_CHANNEL_3, duty_cycle);

//__HAL_TIM_SetCompare(&htim1, TIM_CHANNEL_2, 0);

TIM1->CCR3 = duty_cycle;

TIM1->CCR2 = 0;

break;

2 REPLIES 2
Javier1
Principal

take a look at https://community.st.com/s/question/0D53W00000iC3sUSAS/how-to-setting-tim-chxchxn-for-six-step-bldc-motor-control

You dont want to Stop the pwm you want to disable specific pwm channels.

we dont need to firmware by ourselves, lets talk
Karthik DM
Associate III

Hello Javier

Thanks for your kind reply,

Can you please suggest to me how to disable a specific PWM channel?

Thank You.