How does a stepper motor bridge work? What is an H-bridge and why is it needed?

Why do we need motor drivers and H-bridges in particular?

Having learned to “jump” pins and light up LEDs, Arduino fans and enthusiasts want something more, something more powerful, for example, learning to control motors. It is impossible to directly connect the motor to the microcontroller, since typical controller pin currents are several milliamps, and for motors, even toy ones, the count is tens and hundreds of milliamps, up to several amperes. The same thing with voltage: the microcontroller operates with voltages up to 5 V, and motors come in different voltages.

This review is only about powering brushed DC motors; for stepper motors it is better to use specialized stepper motor drivers, and brushless motors have their own drivers; they are incompatible with brushed motors. Note that in the Russian-language literature there is some terminological confusion - engine drivers are called both “hardware” modules and code fragments, functions responsible for working with these “hardware” drivers. By “driver” we mean a module that is connected on the one hand to a microcontroller (for example, to an Arduino board), and on the other hand to the motor. This “converter” of the controller’s logical signals into output voltage to power the motor is the “driver” of the motor, and, in particular, our L9110S driver.

Operating principle of doubleH-bridge basedL9110 S

H - bridge (read "ash-bridge") - an electronic module, analogous to a switch, usually used to power DC motors and stepper motors, although more specialized modules are usually used for stepper motors. It is designated “H” because the circuit diagram of an H-bridge resembles the letter H.

The “stick” H has a DC motor. If you close contacts S1 and S4, the motor will rotate in one direction, on the left there will be zero (S1), on the right + voltage (S4). If you close contacts S2 and S3, then the right motor contact will have zero (S3), and the left + power (S1), the motor will rotate in the other direction. The bridge is an L9110 chip with protection against through currents: when switching, the contacts first open, and only after a while other contacts close. There are two L9110 chips on the board, so one board can control two DC consumers: motors, solenoids, LEDs, whatever, or one two-winding stepper motor (such stepper motors are called two-phase bipolar).

Board elements

The board is small, there are few elements:

  1. Motor connection A
  2. Motor connection connector B
  3. Motor A H-bridge chip
  4. Motor B H-bridge chip
  5. Power and control connection pins

Connection

Motor A and Motor B - two outputs for connecting a load, current no more than 0.8 A; V-1A - signal “Motor B forward”; IN 1B- signal “Motor B reverse”; Ground (GND)- must be connected to the ground of the microcontroller and the motor power supply.; Nutrition (VCC) - motor power supply (no more than 12 V); A-1A - signal "Motor A forward"; A-1B-"Motor A reverse" signal. The signals on the pins control the voltage at the outputs for connecting motors:

To smoothly control the output voltage, we apply not just HIGH, but a pulse-width modulated (PWM) signal. All Arduino pins marked with ~ can give PWM output with the command analogWrite(n,P), where n is the pin number (in Arduino Nano and Uno these are 3.5-6 and 9-11, respectively). When using these pins for a PWM signal, you must use Timers 0 (pins 5 and 6), Timer 1 (pins 9 and 10) and Timer 2 (pins 3 and 11). The fact is that some library functions can use the same timers - then there will be a conflict. By and large, it is enough to know that pin 3 is connected to input A-1B, and pin 5 to input A1-A, the digitalWrite(3,127) command will supply 50% of the voltage to the motor in the forward direction.

Usage example

Robot control: trolley with headlight (white LED) and reversing light (red LED). The program is listed below and describes the cyclic movement of the cart: forward-stop-backward-stop. All important steps in the program are commented.

The motor is connected to the terminals of MOTOR A, the LEDs are connected to the output of MOTOR B. The robot moves TIME forward by turning on the white LED. Next is the TIME time with half-lit white LEDs. Then it drives back, turning on the red LEDs. Next is TIME again, turning on the red and then white LEDs at half brightness. // L9110S motor driver // by Dr.S // website // define which ports we will use to control the motor and LEDs #define FORWARD 3 #define BACK 5 #define WHITE_LIGHT 6 #define RED_LIGHT 9 #define LEDOUT 13 #define TIME 5000 unsigned char Forward_Speed ​​= 200; unsigned char Back_Speed ​​= 160; unsigned char White_Light = 210; unsigned char Red_Light = 220; void setup() ( // declare bridge control pins as outputs: pinMode(FORWARD, OUTPUT); pinMode(BACK, OUTPUT); pinMode(WHITE_LIGHT, OUTPUT); pinMode(RED_LIGHT, OUTPUT); pinMode(LEDOUT, OUTPUT); ) // the loop routine runs over and over again forever: void loop() ( // The robot moves forward for time TIME analogWrite(WHITE_LIGHT, White_Light); // Turn on the white LED "headlights" analogWrite(RED_LIGHT, 0); analogWrite (FORWARD, Forward_Speed); // The robot went forward analogWrite(BACK, 0); delay(TIME); // and wait a little // The robot turns on the “headlights” to half the normal brightness and stands analogWrite(WHITE_LIGHT, White_Light / 2); // Turn on the white LED "headlights" as parking lights analogWrite(RED_LIGHT, 0); analogWrite(FORWARD, 0); // The robot is standing analogWrite(BACK, 0); delay(TIME); // and wait a little // Robot turns on the red "reverse" LEDs and goes backwards analogWrite(WHITE_LIGHT, 0); // Turn on the white LED "headlights" as parking lights analogWrite(RED_LIGHT, Red_Light); analogWrite(FORWARD, 0); analogWrite(BACK, Back_Speed); // Robot goes back delay(TIME); // and wait a bit // The robot turns on alternately red and white LEDs and stands analogWrite(WHITE_LIGHT, 0); analogWrite(RED_LIGHT, Red_Light / 2); // Turn on the red LED as parking lights analogWrite(FORWARD, 0); analogWrite(BACK, 0); // The robot costs delay(TIME / 2); // and wait a bit analogWrite(WHITE_LIGHT, White_Light / 2); // Turn on the white LED "headlights" as parking lights analogWrite(RED_LIGHT, 0); delay(TIME / 2); // and wait a bit)

Schematic diagram

Module Specifications

  • Two independent outputs, up to 800 mA each
  • Maximum overload capacity 1.2 A
  • Supply voltage from 2.5 to 12 V
  • Logic levels compatible with 3.3 and 5 V logic
  • Operating range 0 °C to 80 °C

Distinctive features:

  • Overheat shutdown
  • Overcurrent shutdown
  • Starting current limited by soft start function
  • ESD protection
  • Status feedback
  • Sleep mode for direct battery connection
  • Work with and without braking
  • A brief description of:
  • On-channel resistance Rds(on) 12 mOhm
  • Operating supply voltage V cc.op. 5.5…35V
  • Continuous load current I cont. (Ta = 85°C) 7.0A
  • Current protection threshold Ishutdown 30A
  • Operating frequency 20 kHz

Typical connection diagram:

Block diagram:

Pin locations:

Description of pins:

Description:

IR3220 is a high-level dual switch integrated circuit. Together with two lower-level switches, for example, IRF741), IR3220 organizes a controlled H-bridge. It provides per-arm loss of control protection, H-bridge control logic, soft start, and overcurrent and overvoltage protection. Signals IN1 and IN2 set the operating modes and activate a sequence of PWM cycles for a smooth start to limit the inrush current. When using the specified type of transistor and proper cooling, the internal system of the chip that controls the high-level switches protects the operation of the entire -H-bridge. The soft start duration is set by the external RC circuit time constant and resets automatically.

Documentation:

Today we will look at a circuit that allows you to change the polarity of the DC voltage applied to the load.

The need to change voltage polarity often arises when controlling motors or in bridge voltage converter circuits. For example, for DC motors this is necessary to change the direction of rotation, and stepper motors or pulsed bridge DC-DC converters will not work at all without solving this problem.

So, below you can see a diagram that, due to its external similarity with the letter H, is usually called an H-bridge.

K1, K2, K3, K4 - controlled keys

A, B, C, D - key control signals

The idea behind this circuit is very simple:

If the keys K1 and K4 are closed, and the keys K2 and K3 are open, then the supply voltage is applied to point h1, and point h2 is shorted to the common wire. The current through the load in this case flows from point h1 to point h2.

If you do the opposite, open the keys K1 and K4, and close the keys K2 and K3, then the polarity of the voltage on the load will change to the opposite, point h1 will be closed to the common wire, and point h2 to the power bus. The current through the load will now flow from point h2 to point h1.

In addition to changing the polarity, the h-bridge, in the case of controlling an electric motor, adds another bonus to us - the ability to short-circuit the ends of the windings, which leads to sharp braking of our engine. This effect can be achieved by simultaneously closing either keys K1 and K3, or keys K2 and K4. Let's call this case “braking mode”. To be fair, it is worth noting that this H-bridge bonus is used much less often than simply changing the polarity (later it will be clear why).

Anything can act as keys: relays, field-effect transistors, bipolar transistors. The industry makes H-bridges built into microcircuits (for example, the LB1838 chip, a stepper motor driver, contains two built-in H-bridges) and produces special drivers for controlling H-bridges (for example, the IR2110 driver for controlling field workers). In this case, chip developers, of course, try to squeeze out as many bonuses as possible and eliminate as many unwanted effects as possible. It is clear that such industrial solutions cope with the task best, but radio junkers are poor people, and good microcircuits cost money, so we, of course, will consider purely home-made versions of bridges and their control circuits.

In self-propelled art (that is, in amateur radio practice), H-bridges are most often used either on powerful MOSFETs (for high currents) or on bipolar transistors (for low currents).

Quite often, key control signals are combined in pairs. They are combined in such a way that one external control signal generates two control signals in our circuit at once (that is, for two switches at once). This allows us to reduce the number of external control signals from four to two (and save 2 controller legs if we have controller control).

Signals are most often combined in two ways: either A is combined with B, and C is combined with D, or A is combined with D, and B is combined with C. To identify and record the differences, let’s call the method when pairs AB and CD are formed “common control” antiphase switches" (to change the polarity of the voltage applied to the load, these switches must operate in antiphase, i.e. if one opens, the other must close), and the method when pairs AD and BC are formed will be called "general control of common-mode switches" (these switches to change the polarity they work in phase, i.e. either both must open, or both must close).

To make it clearer what we are talking about, look at the figure on the right. Let us further agree to consider a high voltage level as one, and a low voltage level as zero. On the left side of the figure, the transistors are controlled independently of each other. To open the upper transistor, you need to apply the control signal A=0, and to close it, you need to apply A=1. To open and close the lower transistor you need to apply B=1 or B=0. If you use an additional transistor to combine signals A and B (see the right side of the figure), then you can control the upper and lower transistors with one common signal AB. When AB = 1, both transistors open, and when AB = 0, both close.


The figure on the left shows an H-bridge with common control of anti-phase switches, and the figure on the right shows common control of common-mode switches. U1 and U2 are nodes that allow one external common signal to generate a separate signal for each of the keys operating in a pair.

Now let's think about what each of these two control methods gives us.

With general control of antiphase switches, we can easily make sure that both upper or both lower keys are open (if the circuit is like ours on the left, then this will happen when AB = CD), that is, the braking mode is available to us. However, the downside is that with this control method we will almost certainly get through currents through the transistors; the only question will be their magnitude. In modern microchips, to combat this problem, a special delay circuit is introduced for one of the transistors.

With general control of common-mode switches, we can easily overcome through currents (we just need to first send a signal to turn off the pair of transistors that is currently in use, and only then a signal to turn on the pair that we plan to use). However, with such control, you can forget about the braking mode (even moreover, if we accidentally simultaneously apply one to both external control signals, we will create a short circuit in the circuit).

Since getting through currents is a much more acidic option (it’s not easy to fight them), they usually prefer to forget about the braking mode.

In addition to all of the above, it is necessary to understand that with frequent constant switching (in converters or when controlling steppers), it will be fundamentally important for us not only to avoid the occurrence of through currents, but also to achieve maximum switching speed of the keys, since their heating depends on this. If we use the h-bridge simply to reverse a DC motor, then the switching speed is not so critical, since the switching is not systematic and the switches, even if they heat up, will most likely have time to cool down before the next switching.

That’s basically the whole theory, if I remember anything else important, I’ll definitely write it down.

As you understand, you can come up with quite a lot of practical H-bridge circuits, as well as options for controlling them, since, as we have already figured out, it is important to take into account the maximum current, the switching speed of the keys, and options for combining key control (as well as the general possibility of such associations), so each practical scheme needs a separate article (indicating where this particular scheme is appropriate to use). Here I will give, as an example, only a simple circuit based on bipolar transistors, suitable, say, for controlling not very powerful DC motors (but I will show how to calculate it).

So, an example:

The H-bridge itself is made on transistors T1, T2, T3, T4, and with the help of additional transistors T5, T6, the control of common-mode switches is combined (signal A controls transistors T1 and T4, signal B controls transistors T2 and T3).

This scheme works as follows:

When the level of signal A becomes high, current begins to flow through resistor R2 and the p-n junctions of the BE transistors T5 and T4, these transistors open, resulting in a current flowing through the BE junction of transistor T1, resistor R1 and open transistor T5, as a result of which transistor T1 opens .

When the level of signal A becomes low, the p-n junctions of the BE transistors T5 and T4 are closed, these transistors close, the current stops flowing through the junction of the BE transistor T1 and it also closes.

How to calculate such a scheme? Very simple. Let us have a supply voltage of 12V, a maximum motor current of 1A and a control signal also of 12 volts (state “1” corresponds to a voltage level of about 12V, state “0” corresponds to a level of about zero volts).

First, select transistors T1, T2, T3, T4. Any transistors that can withstand a voltage of 12V and a current of 1A are suitable, for example, KT815 (npn) and its complementary pair - KT814 (pnp). These transistors are designed for current up to 1.5 Amperes, voltage up to 25 Volts and have a gain of 40.

We calculate the minimum control current of transistors T1, T4: 1A/40=25 mA.

We calculate resistor R1, assuming that at the p-n junctions of the BE transistors T1, T4 and at the open transistor T5 each drops 0.5V: (12-3*0.5)/25=420 Ohm. This is the maximum resistance at which we will obtain the desired control current, so we will select the nearest lower value from the standard range: 390 Ohms. In this case, our control current will be (12-3*0.5)/390=27 mA, and the power dissipated by the resistor: U 2 /R=283 mW. That is, the resistor should be set to 0.5 W (or put several 0.125 W resistors in parallel, but so that their total resistance is 390 Ohms)

Transistor T5 must withstand the same 12V and 27 mA current. Suitable, for example, KT315A (25 Volts, 100 mA, minimum gain 30).

We calculate its control current: 27 mA / 30 = 0.9 mA.

We calculate resistor R2, assuming that at the BE transitions of transistors T5 and T4 each drops 0.5 V: (12-2*0.5)/0.9 = 12 kOhm. Again, select the nearest smaller value from the standard series: 10 kOhm. In this case, the control current T5 will be 1.1 mA and 12.1 mW of heat will be dissipated on it (that is, a regular 0.125 W resistor will do).

That's the whole calculation.

Next I would like to talk about this. In the theoretical diagrams of H-bridges presented in the article, we only have keys drawn, but in the example under consideration, in addition to the keys, there are other elements - diodes. Each of our keys is shunted with a diode. Why was this done and can it be done differently?

In our example, we control an electric motor. The load on which we switch the polarity using the H-bridge is the winding of this motor, that is, our load is inductive. And inductance has one interesting feature - the current through it cannot change abruptly.

Inductance works like a flywheel - when we spin it, it stores energy (and interferes with spinning), and when we release it, it continues to spin (consuming
stored energy). Likewise, when an external voltage is applied to a coil, current begins to flow through it, but it does not increase sharply, as through a resistor, but gradually, since part of the energy transmitted by the power source is not spent on accelerating electrons, but is stored by the coil in the magnetic field. When we remove this external voltage, the current through the coil also does not drop instantly, but continues to flow, decreasing gradually, only now the energy previously stored in the magnetic field is spent to maintain this current.

So here it is. Let's look again at our very first drawing (here it is, on the right). Let's say we had keys K1 and K4 closed. When we open these switches, current continues to flow through the winding, that is, charges continue to move from point h1 to point h2 (due to the energy accumulated by the winding in the magnetic field). As a result of this movement of charges, the potential of point h1 decreases, and the potential of point h2 increases. The occurrence of a potential difference between points h1 and h2 when the coil is disconnected from an external power source is also known as self-induction emf. During the time we open keys K3 and K2, the potential of point h1 can drop significantly below zero, just as the potential of point h2 can rise significantly above the potential of the power bus. That is, our keys may be at risk of breakdown by high voltage.

How to deal with this? There are two ways.

The first way. You can bypass the keys with diodes, as in our example. Then, when the potential of point h1 drops below the level of the common wire, diode D3 will open, through which current will flow from the common wire to point h1, and the further drop in the potential of this point will stop. Similarly, when the potential of point h2 increases above the potential of the power bus, diode D2 will open, through which current will flow from point h2 to the power bus, which again will prevent further growth of the potential of point h2.

The second way is based on the fact that when charges are pumped from one point in the circuit to another, the change in potentials between these two points will depend on the capacitance of the circuit between these points. The larger the capacitance, the more charge must be moved from one point to another to obtain the same potential difference (read more in the article “How capacitors work”). Based on this, it is possible to limit the growth of the potential difference between the ends of the motor winding (and, accordingly, the growth of the potential difference between points h1, h2 and the power and ground buses) by shunting this winding with a capacitor. This, in fact, is the second way.

That's all for today, good luck!

Video review

Operating principle of the H-bridge

The term "H-bridge" comes from the graphical representation of this circuit, which resembles the letter "H". The H-bridge consists of 4 keys. Depending on the current state of the switches, a different state of the motor is possible.

S1S2S3S4Result
1 0 0 1 Motor turns to the right
0 1 1 0 Motor turns left
0 0 0 0 Free rotation of the motor
0 1 0 1 Motor slows down
1 0 1 0 Motor slows down
1 1 0 0
0 0 1 1 Power supply short circuit

Connection and setup

The H-bridge (Troyka-module) communicates with the control electronics via 2 signal wires D and E - the speed and direction of rotation of the engine.

The motor is connected to terminals M+ and M-. And the power source for the motor is connected with its contacts to the blocks under the screw P. The positive terminal of the power supply is connected to the P+ terminal, and the negative terminal is connected to the P- terminal.

When connected to or it is convenient to use.
You can do without unnecessary wires.

Examples of work

Let's start demonstrating the capabilities. The connection diagram is in the picture above. The control board is powered via USB or an external power connector.

Examples for Arduino

First, turn the motor for three seconds in one direction and then the other.

dc_motor_test.ino #define SPEED 11 // pins to exit mode // rotate the motor in one direction for 3 seconds digitalWrite(DIR, LOW) ; digitalWrite(SPEED, HIGH) ; delay(3000 ) ; digitalWrite(SPEED, LOW) ; delay(1000); // then turn the motor in the other direction for 3 seconds digitalWrite(DIR, HIGH) ; digitalWrite(SPEED, HIGH) ; delay(3000 ) ; // then stop the engine digitalWrite(SPEED, LOW) ; delay(1000); )

Let's improve the experiment: let's make the motor smoothly accelerate to maximum and stop in one direction, and then in the other.

dc_motor_test2.ino // motor speed control pin (with PWM support)#define SPEED 11 // pin for selecting the direction of motor movement#define DIR A3 void setup() ( // pins to exit mode pinMode(DIR, OUTPUT) ; pinMode(SPEED, OUTPUT) ; ) void loop() ( // change direction digitalWrite(DIR, LOW) ; for (int i = 0 ; i<= 255 ; i++ ) { analogWrite(SPEED, i) ; delay(10 ) ; } // make the motor stop slowly for (int i = 255 ; i > 0 ; i-- ) ( analogWrite(SPEED, i) ; delay(10 ) ; ) // change direction digitalWrite(DIR, HIGH) ; // now let's make the motor slowly accelerate to maximum for (int i = 0 ; i<= 255 ; i++ ) { analogWrite(SPEED, i) ; delay(10 ) ; } for (int i = 255 ; i >0 ; i-- ) ( analogWrite(SPEED, i) ; delay(10 ) ; ) )

Example for Iskra JS

dc_motor_test.js // connect the library var Motor = require("@amperka/motor" ) ; // connect the motor indicating the speed and direction of rotation pin var myMotor = Motor.connect (( phasePin: A3, pwmPin: P11, freq: 100 ) ) ; // turn the motor back at 75% power myMotor.write(0.75);

Board elements

Motor Driver

The TB6612FNG motor driver is an assembly of two H-half bridges. In our module, we paralleled both channels of the H-bridge chip to compensate for heating.

The motor is connected with its contacts to the M- and M+ screw blocks. Polarity in this case is not important, as it affects the direction of rotation of the shaft and can be changed programmatically.

Load power

The power source for the motor (power supply) is connected with its contacts to the terminal blocks for screw P. The positive terminal of the power supply is connected to the P+ terminal, and the negative terminal is connected to the P- terminal. The motor supply voltage should be between 3-12 VDC.

Contacts for connecting three-wire loops

1-group

    D - directions of engine rotation. Connect to the digital pin of the microcontroller.

    V - power supply to the logical part of the module. Connect to the microcontroller power supply.

    G - earth. Duplicates pin G from the second group of Troyka contacts. Connect to microcontroller ground.

2-group

    E - turning on and controlling the motor rotation speed. Connect to the digital pin of the microcontroller.

    V2 - power supply to the module. Read more about power pooling.

    G - earth. Duplicates pin G from the first group of Troyka contacts. Connect to microcontroller ground.

Power supply jumper

Power supply can also be connected via pins V2 and G from the second group of Troyka contacts. To do this, set the power supply jumper V2=P+. In this case, it is no longer necessary to connect power to the P+ and P- contacts.

Attention! The power supply jumper connects the V2 pins to the P+ terminal block of the external power supply. If you are not sure of your actions or are afraid of applying too high voltage from the H-bridge terminals to the control board, do not install this jumper!

This jumper will be useful when installing an H-bridge on pins supporting V2.

For example, if 12 V is supplied to the board through the external power connector, then by setting the jumper on the Troyka Slot Shield to the V2-VIN position you will receive a voltage of 12 V on the V2 leg of the H-bridge. This 12 V can be sent to power the load - just install jumper V2=P+ on the H-bridge.

Light indication

Dual LED indicating speed and direction of rotation on the board.

When the logic level is high on the rotation direction control pin E, the indicator lights up red. When the level is low - green.

The higher the engine speed, the brighter the green or red LED lights up.

Harness for matching voltage levels

Necessary for pairing devices with different logic level voltages.

In this article, we will take a closer look at how the H-bridge works, which is used to control low-voltage DC motors. As an example, we will use the L298 integrated circuit, which is popular among robotics enthusiasts. But first, from simple to complex.

H-bridge on mechanical switches

The direction of shaft rotation of a DC motor depends on the polarity of the power supply. To change this polarity, without reconnecting the power supply, we can use 4 switches as shown in the following figure.

This type of connection is known as an "H Bridge" - due to the shape of the circuit, which looks like the letter "H". This motor connection diagram has very interesting properties, which we will describe in this article.

If we close the upper left and lower right switches, the motor will be connected on the right to negative and on the left to positive. As a result, it will rotate in one direction (the current path is indicated by red lines and arrows).

If we close the upper right and lower left switches, the motor will be connected on the right to positive, and on the left to negative. In this case, the motor will rotate in the opposite direction.

This control circuit has one significant drawback: if both switches on the left or both switches on the right are closed at the same time, the power supply will be short-circuited, so this situation must be avoided.

The interesting thing about the following circuit is that by using only the two top or bottom switches, we remove power from the motor, causing the motor to stop.

Of course, an H-bridge made entirely of derailleurs is not very versatile. We have given this example only to explain in a simple and visual way the principle of operation of the H-bridge.

But if we replace the mechanical switches with electronic keys, the design will be more interesting, since in this case the electronic keys can be activated by logic circuits, for example, a microcontroller.

Transistorized H-bridge

To create an electronic H-bridge on transistors, you can use both NPN and PNP type transistors. Field effect transistors can also be used. We will look at the NPN transistor version because this is the solution used in the L298 chip, which we will see later.

A transistor is an electronic component whose operation can be complex to describe, but in relation to our H-bridge, its operation is easy to analyze since it operates in only two states (cutoff and saturation).

We can think of a transistor simply as an electronic switch that is closed when the base (b) is 0 V and open when the base is positive.

Okay, we've replaced the mechanical switches with transistor switches. Now we need a control unit that will control our four transistors. For this we will use logical elements of the “AND” type.

H-bridge control logic

An AND gate is made up of integrated electronic components and, without knowing what's inside it, we can think of it as a kind of "black box" that has two inputs and one output. The truth table shows us 4 possible combinations of input signals and their corresponding output signal.

We see that only when both inputs have a positive signal (logical one), a logical one appears at the output. In all other cases, the output will be logical zero (0V).

In addition to this AND gate, our H-bridge will need another type of AND gate, where we can see a small circle at one of its inputs. This is still the same logical element “AND”, but with one inverting (inverted) input. In this case, the truth table will be slightly different.

If we combine these two types of "AND" elements with two electronic switches, as shown in the following figure, then the state of the "X" output can be in three states: open, positive or negative. This will depend on the logic state of the two inputs. This type of output is known as "Three-State Output" and is widely used in digital electronics.

Now let's see how our example will work. When the ENA (enable) input is 0V, regardless of the state of the A input, the X output will be open because the outputs of both the AND gates will be 0V, and hence the two switches will also be open.

When we apply voltage to the ENA input, one of the two switches will be closed depending on the signal at input "A": a high level at input "A" will connect output "X" to positive, a low level at input "A" will connect output "X" "to the minus power supply.

Thus, we built one of the two branches of the “H” bridge. Now let's move on to consider the operation of a full bridge.

Operating a complete H-bridge

By adding an identical circuit for the second branch of the H-bridge, we get a complete bridge to which the motor can already be connected.

Note that the enable input (ENA) is connected to both legs of the bridge, while the other two inputs (In1 and In2) are independent. For clarity of the circuit, we did not indicate the protective resistances at the bases of the transistors.

When ENA is 0V, then all logic gate outputs are also 0V, and therefore the transistors are closed and the motor does not rotate. If a positive signal is applied to the ENA input, and there is 0V at the IN1 and IN2 inputs, then elements “B” and “D” will be activated. In this state, both motor inputs will be grounded and the motor will also not rotate.

If we apply a positive signal to IN1, while IN2 is 0V, then logic element “A” will be activated along with element “D”, and “B” and “C” will be disabled. As a result of this, the engine will receive plus power from the transistor connected to element “A” and minus power from the transistor connected to element “D”. The motor will start rotating in one direction.

If we invert (flip) the signals at the inputs IN1 and IN2, then in this case the logic elements “C” and “B” are activated, and “A” and “D” are disabled. The result of this is that the motor will receive positive power from the transistor connected to “C” and negative power from the transistor connected to “B”. The motor will begin to rotate in the opposite direction.

If there is a positive signal at the inputs IN1 and IN2, then the active elements with the corresponding transistors will be “A” and “C”, while both motor outputs will be connected to the power supply positive.

H-bridge on driver L298

Now let's look at the operation of the L298 chip. The figure shows a block diagram of the L298 driver, which has two identical H-bridges and allows you to control two direct current (DC) motors.

As we can see, the negative part of the bridges is not directly connected to ground, but is available on pin 1 for the bridge on the left and on pin 15 for the bridge on the right. By adding a very small resistance (shunt) between these pins and ground (RSA and RSB), we can measure the current consumption of each bridge using an electronic circuit that can measure the voltage drop at the "SENS A" and "SENS B" points.

This can be useful for regulating motor current (using PWM) or simply activating a protection system in case the motor stalls (in which case its current consumption increases significantly).

Protection diode for inductive loads

Each motor contains a wire winding (coil) and, therefore, in the process of controlling the motor, a surge of self-induction EMF occurs at its terminals, which can damage the bridge transistors.

To solve this problem, you can use fast Shottky type diodes or, if our motors are not particularly powerful, just regular rectifier diodes such as 1N4007. It must be borne in mind that the bridge outputs change their polarity during motor control, so it is necessary to use four diodes instead of one.

If you find an error, please select a piece of text and press Ctrl+Enter.