A DC motor PWM speed controller based on STM32 microprocessor, IR2110 driver chip and photoelectric encoder is introduced. The principle of DC motor speed regulation and the working principle of photoelectric encoder are introduced in detail.
According to the overall scheme design, the hardware and software designs of logic signal processing circuit, IR2110 driver circuit, main program and PWM output subroutine are designed. This design can be mainly used in small electric boats or vehicles, and has high application value.
With the development of power electronics technology, DC motors are widely used in many fields, such as industrial control, navigation, automotive engineering and precision household appliances, depending on their excellent control performance and linear characteristics. [1] After years of research and development, the DC motor speed control technology has reached a new height, and has been greatly improved in accuracy, controllability and anti-jamming performance. Nowadays, the digital DC speed regulation system has gradually become the mainstream. In this paper, a DC motor controller is designed with STM32 as the main chip and IR2110 as the driving chip. It can control the speed and direction of the DC motor by adjusting the rotation direction and angle of the photoelectric encoder. The controller can be applied to small electric boats or vehicles, and has high application value. Pulse width modulation (PWM) voltage regulation is widely used in many DC motor speed regulation methods nowadays. The main principle is that a fixed frequency is used to control the on-off of the power supply, and the average voltage is adjusted by adjusting the duty ratio of the armature voltage on the DC motor to achieve the purpose of controlling the motor speed.
D=V1/t. In general, the average speed VD and duty cycle can be approximated as a linear relationship, that is, the average speed of the motor is VD=Vmax/t. According to this formula, the average voltage can be changed only by changing duty cycle, so as to control the motor speed.
When the duty cycle is more than 50%, less than 50% or equal to 50%, the DC motor can be turned forward, reversed and stopped respectively. This design uses absolute photoelectric encoder to control the speed and steering of the DC motor by adjusting the rotation direction and angle of the photoelectric encoder. When the rotation angle and direction change, the output signal will also change. CPU will judge the signal and adjust the duty ratio, so as to control the speed and steering of the DC motor. The output signal of the encoder is shown in Figure 2. The photoelectric encoder output two phase orthogonal square wave pulse signal, the phase difference between them is 90 degrees. Each pulse represents the angle increment of the measured object, thermostatic element and the motor speed can be calculated by counting the pulse signals of phase A and B. When phase A leads phase B 90 degrees, the DC motor is in positive rotation; when phase A lags phase B 90 degrees, the DC motor is in reverse. This design uses STM32 as the main control chip, MOSFET power field effect transistor and IR2110 as the driving chip to build the driving circuit, and has a host computer (for a given motor speed).
The output signal of the encoder is first connected to the STM32 data bus through the interface circuit. At the same time, the PWM output by STM32 generates the timing signal which meets the needs of the driving circuit through the logic signal processing circuit. After interlocking the output signal, it is loaded into the driving circuit to realize the control of the DC motor.
Working principle: in a sampling period, the feedback signal of the motor speed measured by the encoder is fed back to CPU through the interface circuit. The CPU obtains the given speed of the motor from the upper computer, or the system can set the speed by itself. According to the deviation between the given speed and the feedback signal, the control quantity is obtained by PI control algorithm. The CPU outputs PWM according to the control quantity, and drives the motor through IR2110 driving circuit. IR2110 is a half-bridge driver chip developed by American IR Company, which combines the advantages of photoelectric isolation and electromagnetic isolation. It integrates most of the circuits of independent driving high-voltage side and low-voltage side power MOSFET, and can output logic voltage ranging from 3.3V to 20V. IR2110 uses bootstrapping technology to generate a floating power supply, which can drive the upper and lower two MOSFETs of the same phase bridge arm within 500V. In the figure, HIN and LIN are the logic level input signal of IR2110, SD is the protection signal input, when SD is low level, the input signal is consistent with the level signal of output signal; when SD is high level, HO and LO signals are turned off, the output channel is locked, and the driven MOSFET is disconnected. The implementation principle of bootstrap technology is that there is no working frequency requirement for the low end of IR2110, and for high-end, the power supply is mainly supplied by bootstrap capacitor C1. The driving power supply VCC charges C1 through bootstrap diodes D1, C1, load and Q2. When the input of PWMHIN is high level, the VB terminal of IR2110 is connected with the H0 terminal, Q1 is driven by VB and HO, the voltage of C1 is VCC, and the gate of Q1 tube is driven by energy storage on C1, thus realizing bootstrapping drive; when PWMHIN is low level, VB terminal is disconnected from H0 terminal, and VCC charges C1 rapidly through D1, thus realizing bootstrapping. C1 must be charged periodically. If a MOSFET tube is in a long-term on-state, C1 and the high-side driver will form a relief circuit, which makes the gate-level undervoltage of the high-end power transistor, leading to the failure of the MOSFET to be driven. The logic signal processing circuit is shown in Fig. 5. Its function is to generate timing signals that satisfy the requirements of the driving circuit and to protect the output signals from interlocking. STM32 outputs a PWM processing circuit, which generates HIN and LIN control signals for the high and low input terminals of IR2110. Through logical operation with non-gate 4001, the interlock protection between groups of high and low is realized, so that IFUP1 and IFDN1, IFUP2 and IFDN2 can not be high level at the same time. As shown in Figure 6, the circuit uses two IR2110 chips to drive high and low-end MOSFET transistors. In the figure, the voltage comparator LM2903 (U105) is used for level conversion to convert the voltage to the 15V voltage required by IR2110. C103 and C105 are bootstrap capacitors, C104 and C106 are bypass filter capacitors (Tantalum capacitors are commonly used), D102 and D103 are bootstrap diodes. Their functions are to charge bootstrap capacitors. Fast recovery diodes should be selected to protect them from high-voltage backbreaking into VCC and burning IR2110. When IFUP1 and IFDN2 are high, IFDN1 and IFUP2 are low, U102_H and U103_L are turned on to realize forward drive; when IFUP1 and IFDN2 are low, IFDN1 and IFUP2 are high, U102_L and U103_H are turned on to realize reverse drive. In addition to hardware design, it also includes communication circuit, power supply circuit, isolation circuit, protection circuit, high and low speed limit circuit, etc. The software design adopts modular design method, as shown in Figure 7. After initialization, the handshake communication is completed with the host computer, and the speed and steering of the motor are given by the host computer or the system itself. Then the photoelectric encoder module is adjusted to obtain the current speed and steering of the motor.
Then, PI control algorithm is used to adjust the control deviation. Finally, the timing is determined, if it is reached, the PWM output driver module is called; if not, the current state information of the system is displayed. The CPU detects and judges the PI regulated control quantity every 20 ms, and outputs PWM to drive the circuit. When the motor is in positive rotation (duty cycle is more than 50%), if the motor needs to accelerate, the duty cycle increases by 5% every 20 ms; if the motor stops operation, the duty cycle immediately adjusts to 50%; if the motor is in positive and reverse switching, the duty cycle first adjusts to 50%, then decreases by 5% every 20 ms. In order to prevent the excessive current flowing through the motor, the motor is damaged. In software design, the motor must be accelerated by stages. This design chooses STM32 as CPU, IR2110 as driver chip, and designs a DC motor speed controller, which realizes speed regulation and drive of DC motor, and has strong reliability and adjustability. Overall, the design has a certain practical value.