Skip to main content
Keyshav Mor
Associate II
March 27, 2017
Question

Bi-Directional Motor Control using PWM in STM32F1

  • March 27, 2017
  • 0 replies
  • 543 views
Posted on March 27, 2017 at 07:46

Hello everyone,

I am trying to reverse the motor direction using PWM from the STM32F1 Series controller and using the L293D Motor driver. I have referred to the bi-directional motor control circuit given in l293d datasheet and done connections accordingly. The following is a snippet of the code which I have used to try the direction control.

Please feel free to point out my mistake.

Thanks.

HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_2);

HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_3);

__HAL_TIM_SetCompare(&htim2,TIM_CHANNEL_2,1000);

__HAL_TIM_SetCompare(&htim2,TIM_CHANNEL_3,0);

HAL_Delay(10000);

__HAL_TIM_SetCompare(&htim2,TIM_CHANNEL_2,0);

__HAL_TIM_SetCompare(&htim2,TIM_CHANNEL_3,1000);

HAL_Delay(10000);

#stm32 #nucleo #pwm #motor #control
This topic has been closed for replies.