Picture Name

Blog

An In-Depth Yet Simple Introduction to H-Bridge Drive Circuits


Release time:

2021-01-12

 

What is an H-bridge?

An H-bridge is a relatively simple circuit, usually consisting of four independently controlled switching components (for exampleMOS-FET) that are typically used to drive loads with larger currents, such as motors. The reason it is called an H-bridge is that its shape resembles the letterH, as shown in the figure below;

 

Here are four switching componentsQ1,Q2,Q3,Q4and there is also a DC motor M,D1,D2,D3,D4which is the freewheeling diode of the MOS-FET;

 

Switching states

Below, taking the control of a DC motor as an example, we will briefly introduce several switching states of the H-bridge, where forward and reverse rotation are artificially defined directions, and in actual engineering, they can be classified according to the actual situation;

Forward rotation

Typically, the H-bridge is used to drive inductive loads, here we will drive a DC motor;

  • OpenQ1andQ4;
  • CloseQ2andQ3;

At this time, assuming the motor is rotating forward, the current passes throughQ1,M,Q4, marked with yellow lines in the figure, as shown below;

 

Reverse rotation

Another state is the motor reversing; at this time, the states of the four switching components are as follows;

  • CloseQ1andQ4;
  • OpenQ2andQ3;

At this time, the motor is reversing (opposite to the previously introduced situation), the current passes throughQ2,M,Q3, marked with yellow lines in the figure, as shown below;

Speed regulation

If you want to regulate the speed of the DC motor, one of the solutions is to input

  • CloseQ2,Q3;
  • OpenQ1,Q4a PWM waveform with a duty cycle, which achieves the effect of reducing the speed. If you need to increase the speed, set the duty cycle of the input PWM to 100%;50%As shown below:

Stop state

Here, taking the motor switching from forward rotation to stop state as an example;

In the case of forward rotation;

  • it is in the open state;Q1andQ4At this time, if you close
  • , the internal structure of the DC motor can beQ1andQ4equivalent to an inductor, which is an inductive load, and the current will not change abruptly, then the current will continue to flow in the original direction. At this time, we hope that the current in the motor can decay quickly;There are two methods here:

The first method: close

, at this time the current will still flow through the reverse freewheeling diode, and briefly openQ1andQ4to achieve the purpose of quickly decaying the current;Q1andQ3The second method: when preparing to stop, close

 

, openQ1, at this time the current will not decay quickly, the current circulates between Q2, M, and Q4, consuming electrical energy through the internal resistance of the MOS-FET;Q2Application

 

 

In actual use, making an H-bridge with discrete components is quite troublesome. There are many commonly used IC solutions on the market, such as the commonly used L293D, L298N, TA7257P, SN754410, etc. Just connect the power supply and motor, and you can drive the motor through input control signals;

Below is the L298N module from a certain treasure, which is quite common and very friendly for beginners, and the wiring is also very simple;

This module has an onboard 5V voltage regulator, which can be enabled using jumpers.

 

If the motor power supply voltage reaches 12V, we can enable the 5V voltage regulator, and the 5V pin can be used as an output, for example, to power an Arduino board.

 

However, if the motor voltage exceeds 12V, the jumper must be disconnected, as these voltages can damage the onboard 5V voltage regulator.

In this case, the 5V pin will be used as an input, as we need to connect it to a 5V power supply for the IC to work properly.

Here we can note that the voltage drop of this IC is about 2V. Therefore, if a 12V power supply is used, the voltage at the motor terminals will be about 10V, which means we will not be able to achieve maximum speed from a 12V DC motor.

Here using

Arduino, for example, this is a demo framework found online, as shown in the figure below;为例,这是网上找的一个Demo整体的框架如下图所示;

 

#define enA 9

    #define in1 6

    #define in2 7

    #define button 4


    int rotDirection = 0;

    int pressed = false;


    void setup() {

      pinMode(enA, OUTPUT);

      pinMode(in1, OUTPUT);

      pinMode(in2, OUTPUT);

      pinMode(button, INPUT);

      // Set initial rotation direction

      digitalWrite(in1, LOW);

      digitalWrite(in2, HIGH);

    }


    void loop() {

    // Read potentiometer value

      int potValue = analogRead(A0); 

      // Map the potentiometer value from 0 to 255

      int pwmOutput = map(potValue, 0, 1023, 0 , 255); 

      // Send PWM signal to L298N Enable pin

      analogWrite(enA, pwmOutput); 


      // Read button - Debounce

      if (digitalRead(button) == true) {

        pressed = !pressed;

      }

      while (digitalRead(button) == true);
      delay(20);


      // If button is pressed - change rotation direction

      if (pressed == true  & rotDirection == 0) {

        digitalWrite(in1, HIGH);

        digitalWrite(in2, LOW);

        rotDirection = 1;

        delay(20);

      }

      // If button is pressed - change rotation direction

      if (pressed == false & rotDirection == 1) {

        digitalWrite(in1, LOW);

        digitalWrite(in2, HIGH);

        rotDirection = 0;

        delay(20);

      }

    }

 

A brief description: First, we need to define the pins and variables required by the program.

Insetup(), we need to set the pin modes and the initial rotation direction of the motor.

InInloop(), we first read the potentiometer value, then map the value obtained from 0 to 1023 linearly to the PWM signal values from 0 to 255, which corresponds to a duty cycle from 0 to 100%.

Then useanalogWrite()function to send the PWM signal to the Enable pin of the L298N board, which actually drives the motor.

Next, we check if the button is pressed, and if so, we invert the states of input 1 and input 2, thereby changing the rotation direction of the motor. The button will act as a toggle switch, changing the motor's rotation direction each time it is pressed.

There are many such small cars on a certain treasure website, as shown in the picture below; the main control can be replaced with a 51 microcontroller or STM32, and of course, Arduino is also fine. Using L298N, a small car can be quickly built.

 

 

 

Disclaimer: The content of the above article is organized from the internet. If there are any copyright issues, please contact us immediately.