BIN1, BIN2, PWMB are the pins to control another motor.įirst of all, we need to use the STM32 timer module to output two PWM waves. By inputting different duty cycles, the speed of the motor speed can be changed. The drive logic table is as follows:ĭifferent combinations of AIN1 and AIN2 can realize the forward and reverse rotation and stop of the motor. The motor drive chip used here is TB6612, which can easily drive the operation of two DC motors. , So that the speed of the motor runs at a given speed. The real-time speed of the motor is obtained through the encoder, and the deviation is taken as the input of the PID controller through the difference with the given speed, and the PWM duty cycle is changed through PID control. For a given speed, the idea of closed-loop control is needed here. Because our control goal is to achieve the motor running at any speed. ![]() ![]() By changing the PWM duty cycle, the motor speed can be changed. ![]() The speed control block diagram is as follows:Īs can be seen from the above block diagram, STM32 controls the rotation of the two DC motors by outputting PWM waves through the timer module. The motor used in the trolley is a 12v power supply DC motor with encoder feedback, so that closed-loop speed control can be used.
0 Comments
Leave a Reply. |