Detailed explanation of H-bridge motor drive circuit of STM32+IR2104S


  Motor: commonly known as "motor", an electromagnetic device that realizes the conversion or transmission of electric energy according to the law of electromagnetic induction. Including: electric motors and generators.
  The electric motor is represented by the letter M in the circuit, and its main function is to generate driving torque; as the power source for electrical appliances or various machinery, the generator is represented by the letter G in the circuit, and its main function is to convert mechanical energy into Electrical energy.
  Motor control: the control of starting, accelerating, running, decelerating and stopping the motor.

1. DC brush motor

  Brushed DC (Brushed DC, referred to as BDC), because of its simple structure, convenient operation, low cost, good flat motion and speed control performance and other advantages, is widely used in various power devices, as small as toys, buttons Adjustable car seats can be seen in production machinery such as printing machinery.
  The electrical energy of the DC power supply enters the armature winding through the brushes and the commutator to generate an armature current. The magnetic field generated by the armature current interacts with the main magnetic field to generate electromagnetic torque, which causes the motor to rotate and drive the load.

Advantages: low price and convenient control.
Disadvantages: due to the existence of brushes and commutators, brushed motors have complex structure, poor reliability, many failures, large maintenance workload, short life, and commutation sparks are prone to electromagnetic interference.

2. Stepper motor

  A stepper motor is an actuator that converts electrical pulses into angular displacement; more generally speaking: when the stepper driver receives a pulse signal, it drives the stepper motor to rotate a fixed angle in the set direction. We can control the angular displacement of the motor by controlling the number of pulses, so as to achieve the purpose of precise positioning; at the same time, we can also control the speed and acceleration of the motor rotation by controlling the pulse frequency, so as to achieve the purpose of speed regulation.

Advantages: simple control, large low-speed torque, low cost;
disadvantages: stepper motors have no-load starting frequency, so stepper motors can run normally at low speeds, but they cannot start when they are higher than a certain speed, accompanied by sharp howling At the same time, the stepping motor is open-loop control, and the control accuracy and speed are not as high as the servo motor.

3. Servo motor

  Servo motors are widely used in various control systems. They can convert the input voltage signal (or pulse number) into the mechanical output on the motor shaft and drag the controlled components to achieve the control purpose. The servo motor system is shown below. Fig. Generally, the required torque can be controlled by the current output by the controller; the motor should be fast, small in size, and small in control power. Servo motors are mainly used in various motion control systems, especially follow-up System.
  Servo motors are divided into DC and AC. The earliest servo motors are general DC brushed motors. When the control accuracy is not high, the general DC motors are used as servo motors. Currently with permanent magnet synchronous motor technology With the rapid development of the world, most of the servo motors refer to AC permanent magnet synchronous servo motors or DC brushless motors.

Advantages: It can control the speed, the position accuracy is very accurate, the efficiency is high, and the life is long.
Disadvantages: The control is complicated and expensive, requiring professionals to control it.

4. Brushless DC motor

  Brushless DC motor [BLDCM] is developed on the basis of brushed DC motor, but its drive current is out-of-the-box AC. Generally, there are two types of brushless motor drive currents, one is trapezoidal wave (square wave), and the other is sine wave. The square wave drive is called the brushless DC motor (BLDC); the sine wave drive It is called Permanent Magnet Synchronous Machine (PMSM), which is actually a servo motor.
  Brushless DC motors and servo motors have similar advantages and disadvantages. The BLDC motor is cheaper than the PMSM motor, and the drive control method is simpler.

5. DC geared motor

Important parameters of geared motors

  The motor generally has a minimum starting voltage, which is the voltage value that can make the motor (without load) start to rotate. In order to ensure the normal operation of the motor, it is generally necessary to connect the voltage value range between the two ends of the motor: the minimum operating voltage to the rated voltage. And within this voltage range, the speed is considered proportional to the voltage.
  The motor coil is made of copper wires, so the motor armature winding resistance is generally very small, so the current in the loop is generally relatively large. This has a great influence on our motor drive design.
  In addition, the motor has a more important parameter: torque .
  Simplified understanding Torque is the force that the motor can drive the external components to rotate. Physically it is described by torque, the unit is: Nm (commonly used unit: Kg.cm). Large torque can drive heavier things.
  It is generally believed that the torque of a DC motor is proportional to the current.

6. DC geared motor drive design

  DC motor rotation: the motor can be rotated by supplying power to the two wires of the motor, the positive voltage motor is rotated forward, and the opposite voltage motor is reversed; the higher the voltage, the faster the motor rotates, the lower the voltage, and the lower the speed.
  We hope that S1M32 can easily adjust the motor speed, but the voltage and current of the IO interface of STM32 are generally very limited. The voltage is 3.3V and the current is 8mA. Therefore, in order to facilitate the control, it is necessary to directly add a drive circuit to the microcontroller and the motor. The motor drive board has two input lines: power input line and control signal input line. The power input line is generally required to provide a large current power supply that can provide the rated power of the motor. Generally speaking, what is the voltage and rated current required by the motor, then how much voltage and current must be provided to the motor drive board, which is to provide power to the motor origin of. The control signal line is connected with the signal line of the microcontroller, which is a method of realizing speed regulation, which is generally an adjustable square wave signal of PWM. The motor drive board also has an output line with two interfaces, which are directly connected to the pins of the DC motor. Note that the output line of the motor driver board here should be output after a series of circuits, that is, the output line modulated by the input signal.
  Motor control must have a driver.
  If you don't need forward and reverse rotation control (one-way rotation), you can use the following drive circuit to achieve one-way speed control of the motor.



◆When the switches A and D are closed, and B and C are open, the DC motor rotates normally, and the rotation direction is recorded as the positive direction.
◆ When the switches B and C are closed, and A and D are open, the DC motor rotates normally, and the rotation direction is recorded as the opposite direction.
◆ When switches A and C are closed, B and D are open, or when switches B and D are closed, and A and C are open, the DC motor does not rotate. At this time, it can be considered that the motor is in the "brake" state, and the electric potential generated by the motor's inertial rotation will be short-circuited, forming a back EMF that hinders the movement, forming a "brake" effect.
◆When switches A and B are closed or when switches C and D are closed, the power supply will be directly short-circuited, which will burn the power supply. This situation is strictly prohibited.
◆When the four switches A, B, C, and D are all off, it is considered that the motor is in the "idling" state, and the electric potential generated by the inertia of the motor will not be able to form a circuit, so there will be no back EMF that hinders the movement. Rotate inertia for a longer time.

  Such a simple control of the switch state can control the direction of selection of the motor.
  As you can see from the above picture, its shape is similar to the letter "H", and it is used as a load; the loaded DC motor is built on it like a "bridge"; so it is called "H-bridge drive". The position of the 4 switches is called the "bridge arm".
  There are triodes and MOS tubes that can be used as electronic switches in the circuit. You can use these two devices instead of switches to achieve

7. H-bridge circuit analysis

  The following begins with the H bridge circuit built by the MS tube to explain the motor forward and reverse control. To make the motor run, a pair of MOS transistors on the diagonal must be turned on. As shown in the figure, when the Q1 tube and Q4 tube are turned on (at this time, Q2 and Q3 must be turned off), the current flows from the positive pole of the power supply through Q1 from left to right through the motor, and then returns to the negative pole of the power supply through Q4. As shown by the current arrow in the figure, the current flowing in this direction will drive the motor to rotate clockwise.
  When the other pair of MOS transistors 2-phase Q3 is turned on (at this time, Q1 and Q4 must be turned off), current flows through the motor from right to left, thereby driving the motor to rotate in a counterclockwise direction. When driving the motor, it is very important to ensure that the two MOS transistors on the same side of the H bridge are not turned on at the same time. If the MOS transistors Q1 and Q2 are turned on at the same time, the current will pass from the positive pole of the power supply through the two MOS transistors and return to the negative pole directly. At this time, there is no other load in the circuit except the MOS tube, so the current on the circuit reaches the maximum value, and the MOS tube and power supply are burned out. Q3 and Q4 are turned on at the same time for the same reason.
  When driving the motor, it is very important to ensure that the two MOS transistors on the same side of the bridge will not be turned on at the same time. If the MOS transistors Q1 and Q2 are turned on at the same time, the current will pass from the positive pole of the power supply through the two MOS transistors and return to the negative pole directly. At this time, there is no other load in the circuit except the MOS tube, so the current on the circuit reaches the maximum value, and the MS tube and power supply are burned out. Q3 and Q4 are turned on at the same time for the same reason.

  A simple switch can only control the forward and reverse rotation of the motor, and the introduction of PWM control can realize the direction and speed adjustment.
  Adjust the duty cycle to achieve speed control. The larger the duty cycle, the greater the average voltage (current) and the faster the speed. The PWM frequency is generally between 10KHz and 20KHz. Too low frequency will result in too low motor speed and high noise. If the frequency is too high, the efficiency of the system will be reduced due to the switching loss of the MOS tube.
  According to the different PWM control modes of different bridge arms, it can be roughly divided into three control modes:
  limited unipolar mode "unipolar mode" bipolar mode.

1. Restricted unipolar mode

● Restricted unipolar mode: the motor armature drive voltage polarity is single

  • Advantages: The control circuit is simple.
  • Disadvantages: no braking, no dynamic braking, and no torque when the load exceeds the set speed. The static difference of speed control is large, the speed control performance is very poor, and the stability is not good.

2. Unipolar mode

Unipolar mode: The polarity of the motor armature drive voltage is single.

  • Advantages: fast start, acceleration, braking, energy consumption braking, energy feedback, speed regulation performance is not as good as bipolar mode, but the phase is similar, the motor characteristics are also better. It can also provide reverse torque when the load is overspeed.
  • Disadvantages: When braking, you cannot decelerate to 0, and there is no braking force when the speed is close to 0. It cannot be reversed suddenly. The dynamic performance is not good, and the static difference of speed regulation is slightly larger.


PWM and PWMN are complementary PWM signals, which are generally controlled by the channel and complementary channel of the advanced control timer.

When PWM is high level: MQS tubes 1 and 4 are both turned on, MOS tubes 2 and 3 are both turned off, the current flows from the positive pole of the power supply, through MOS tube 1, from left to right through the motor, and then flows into the negative pole of the power supply through MOS tube 4 .
When PWM is at low level: MOS transistors 2 and 4 are both turned on, and MOS transistors 1 and 3 are both turned off. According to Lenz's law, there is self-induced electromotive force, and the current still flows through the motor from left to right through MOS transistor 4 and MOS. Tube 2 forms a current loop.

3. Bipolar mode

Bipolar mode: The polarity of the armature voltage is alternating between positive and negative.

  • Advantages: It can run in forward and reverse rotation, fast start, high speed control accuracy, good dynamic performance, small speed control static difference, large speed control range, can accelerate, decelerate, brake, reverse, and can when the load exceeds the set speed, Provides the reverse moment, which can overcome the static friction of the motor bearing and produce a very low speed.
  • Disadvantages: The control circuit is complicated. During the working period, the 4 MOS tubes are all in working condition, the power loss is large, and the motor is easy to get hot.

PWM1 and PWM1N, PWM2 and PWM2N are complementary PWM channels. In the bipolar mode using advanced control timer channel and complementary channel control, PwM1 and PWM2 have the same period, the same duty cycle, and the opposite polarity, so that the two MpS tubes on the diagonal line are turned on and turned off at the same time.

4. H-bridge hardware circuit design

  In the H bridge, 4 N-type MOS transistors are generally used to build. The reason for not using 2 N-type MOS tubes + 2 P-type MOS tubes is: P-type MOS tubes are difficult to achieve high withstand voltage and large current models, and the on-resistance is large. For MOS with the same performance, N-type is cheaper than P-type.
  For NMOS, when the externally given gate-source Vgs voltage is greater than the chip's Vgs threshold (mostly between 2V-10V), the drain D and the source S are directly connected. If the externally given Vgs voltage is less than the threshold, the drain D and source S are cut off.
  Simply think that it is a switch controlled by the gate G voltage.

  Assume that the Vgs threshold of the N-MOS tube in the figure is 3V, and VCC=24V.
  For, the lower-arm Q2MOS tube can be directly controlled by the STM32 chip pins, because the STM32 PWM high level is 3.3V enough to make the N-MOS tube turn on. The upper arm Q1 MOS transistor cannot directly use the STM32 chip pins to turn it on, because assuming that Q1 is on, the drain D and source S voltages are almost equal (Ros is very small), that is, VA=VCC=24V, which requires Vg >=Va+Vgs=27V. Simply put, if Vg is greater than 27V, Q1 is turned on, and if Vg is less than 27V, Q1 is turned off. So a circuit like this is needed: Boost the 3.3VPWM signal of the STM32 to a voltage of 27V. This circuit can be implemented with a bootstrap circuit .

  Upper arm drive: Bootstrap circuit
  Lower arm drive: Level control In
  actual circuit design, Ves is generally set to 10~20V, because this ensures that the MOS tube is fully turned on.
  There is also a problem when the MOS tube is fully turned on, the internal resistance Rds of the MOS tube is generally relatively small in a few milliohms, which is equivalent to a wire. But when the MOS tube is not fully turned on, that is, when Vgs is less than the turn-on voltage, the MOS is in an incompletely turned on state, and the internal resistance of the MOS tube is relatively large, and the current of the motor drive board is relatively large. Then the heat of the MOS will be very serious and it is likely to burn the chip

5. Half-bridge driver chip IR2104S

  The so-called half-bridge driver chip is a driver chip that can only be used to control the two MOS transistors on one side of the H-bridge. Therefore, when using a half-bridge driver chip, two of these chips are needed to control a complete H-bridge.
  Correspondingly, the full-bridge driver chip can directly control the on and off of 4 MOS transistors, and one chip can complete the control of a complete H-bridge.
  The IR2104 used here is a half-bridge driver chip, so you can see in the schematic diagram that each H-bridge needs two pieces of this chip.

1. Typical circuit design (from the data sheet)

2. Pin function (from the data sheet)

  • VCC is the power input of the chip, and the operating voltage given in the manual is 10~20V. (This is the reason why boost is needed to boost to 12V)
  • IN and SD are used as input control, which can jointly control the rotation state of the motor (direction, speed and whether to rotate).
  • VB and VS are mainly used to form a bootstrap circuit.
  • HO and LO are connected to the gate of the MOS tube and used to control the turn-on and turn-off of the upper and lower MOS, respectively.
  • The COM pin can be directly grounded.

3. Bootstrap circuit

This part is the difficulty of understanding the chip, which needs to be explained. From the above and typical circuit schematic original design can be found in: The chip in a diode indirect Vcc and VB of the foot , in a more indirect VS and VB of the capacitor . This constitutes a bootstrap circuit.

  Function: As the load (motor) has different positions relative to the upper and lower MOS MOS, and the MOS turn-on condition is Vgs>Vth, this will cause the upper MOS to be turned on, and the gate is connected to the ground. The required voltage is larger.
  Because the source of the lower-side MOS is grounded, it is only necessary to make its gate voltage greater than the turn-on voltage Vth to turn on. The source of the high-side MOS is connected to the load. If the high-side MOS is turned on, its source voltage will rise to the H-bridge drive voltage, which is the supply voltage of the MOS. At this time, if the gate-to-ground voltage does not change, then Vgs may be less than Vth, and it turns off. Therefore, if you want to turn on the upper MOS, you must find a way to make its Vgs always greater than or greater than Vth for a period of time (that is, the gate voltage remains greater than the power supply voltage of the MOS tube +Vth).
  The following figure is the internal principle block diagram of IR2104S. The internal principle of this type of chip is basically similar. The two gate control pins (HO and LO) on the right are all controlled by a pair of PMOS and NMOS .


Bootstrap circuit work flow: The
following circuit diagrams only draw the half bridge, and the other half have the same working principle, so they are omitted.
Assume that Vcc=12V, VM=7.4V, and the turn-on voltage of the MOS tube Vth=6V (the 2.3V of LR7843 is not used, and the reason will be explained later).

(1) The first stage: First input PWM signal to IN, make HO and LO pass through the internal control circuit on the left (make the upper and lower pairs of complementary PMOS and NMOS turn on correspondingly), and output low and high levels respectively. At this time, the upper arm MOS of the external H bridge is cut off, and the small bridge arm MOS is on, and the motor current flows along the line ②. At the same time, VCC charges the bootstrap capacitor through the bootstrap diode (line ①), so that the voltage difference between the two ends of the capacitor is Vcc=12V.

(2) The second stage: This stage is automatically generated inside the chip, that is, the dead zone control stage (introduced in the H bridge, the upper and lower MOS cannot be turned on at the same time, otherwise the VM is directly connected to GND, short-circuited and burned). The HO and LO outputs are both low level, the upper-side MOS is off, and the voltage applied to the lower-side MOS gate is discharged through line ①.

(3) The third stage: output PWM through the IN pin to turn on the internal MOS tube on the left as shown in the figure. Since the voltage on the capacitor cannot change suddenly, the voltage (12V) on the bootstrap capacitor can be added to the gate and source of the high-side MOS at this time, so that the high-side MOS can also be kept on for a certain period of time. At this time, the source-to-ground voltage of the upper-side MOS ≈VM=7.4V, the gate-to-ground voltage ≈VM+Vcc=19.4V, and the voltage across the capacitor=12V, so the upper-side MOS can be turned on normally.

Note: Because the capacitor is continuously discharging at this time, the voltage difference will gradually decrease. Finally, the voltage from the positive pole of the capacitor to ground (that is, the voltage from the gate to ground of the upper-side MOS) will drop to Vcc, then the gate-source voltage of the upper-side MOS ≈Vcc-VM=12V-7.6V=4.4V< Vth=6V , The high-end MOS will still be turned off.

Supplementary summary:
★ Therefore, in order to make the high-end MOS continuously conduct, the bootstrap capacitor must be continuously charged and discharged, that is, the cyclic operation is in the above three phases (the upper and lower bridge arms are in the state of turning on in turn, and the control signal is input to PWM. Yes), in order to ensure that the upper bridge arm MOS is turned on. The bootstrap diode is mainly used to prevent backflow to VCC and damage the circuit when the capacitor is discharged.

★ However, in the actual test of the above driver board, it will be found that it can work normally without turning the upper and lower MOS on in turn. This is because even if the bootstrap capacitor is discharged, it is the gate source of the upper MOS. When the voltage drops to 4.4V, it is still greater than Vth=2.3V of LR7843.
So in the above driver board, the bootstrap circuit has no effect? ​​Of course not. Due to the characteristics of the MOS tube, the bootstrap circuit can increase the gate-source voltage while reducing the on-resistance of the MOS tube, thereby reducing Heat loss, so it is still recommended to adopt a turn-on method, and use the large pressure difference generated by the bootstrap capacitor to make the MOS tube conduction work.

8. Schematic and PCB

Guess you like

Origin blog.csdn.net/qq_39400113/article/details/108909800