Guide to breadboarding an Arduino controlled H-bridge featuring MOSFET driver ICs with bootstrapped high-side drivers. The lessons in theory and circuit construction techniques will inform your design of full-featured single and three-phase inverters and motor drives.
This article is the fourth in a series. Before continuing, please review the following links which describe the foundational bridge arm circuit and the theory of operation for a full H-bridge. Pay special attention to the bootstrap circuit, as it is a fundamental aspect of many commercial MOSFET gate drivers such as the featured Infineon (Internation Rectifier) IR2110PBF drivers as shown in Figure 1. The last link is also important as it describes the operation of the H-bridge including some surprising results involving unintended current spikes, commutation via flyback diodes, and motor braking mechanisms.
- Guide to Bootstrap Operation in a MOSFET Gate Drive Circuit
- Breadboard a Bootstrapped MOSFET Motor Driver with Arduino PWM Control
- H-Bridge Motor Drive Dynamics: Identification of Current Spikes
Figure 1: Breadboard Arduino controlled H-bridge driving a Pololu DC motor. The Digilent Analog Discovery 3 is used to analyze the Arduino waveforms.
SAFETY: Protect your PC by disconnecting the Computer’s USB port whenever 15 VDC supply is activated. This protects against an inadvertently connection between the 15 VDC supply and any Arduino pin.
Failure to heed this warning could result in the destruction of your PC’s USB port, processor, or motherboard.
Instead, power the Arduino from an independent source such as a low-cost cell phone charger. Additionally, you may also wish to purchase a USB port isolator to protect your PC.
Why build a H-bridge when COTS products are readily available?
Let’s face it, high performance Commercial Off The Shelf (COTS) H-bridges are readily available. An example with similar architecture is the Seeed (Cytron) MD13S. This is a compact board designed for driving motors up to 30 VDC with a continuous 13 A. By comparison, the breadboard assembly featured in this engineering brief is limited to about 1 A.
That’s not the point.
The DIY H-bridge motor driver is like a rite of passage. It’s challenging to breadboard a stable circuit as the high-power and high-frequency nature of the circuit pushes the limits of the prototyping technique. Likewise, you will need to be careful with the Microcontroller/FPGA design to correctly commutate the semiconductor switches as described in this article.
Tech Tip: I fondly remember my first experiments with DIY motor drives. At the time, I did not have a current regulated power supply. However, I did have hundreds of MOSFETs sourced from scrap yard – as many as I wanted provided, I separated the aluminum heat sinks. I think you know where this is going. Mistakes resulted in the explosive destruction of the MOSFET often with an accompanying foot-high fireball. Learn from my mistakes. Start small with a regulated power supply.
Be prepared, this experiment can be a bit on the expensive side, as you will certainly destroy a few MOSFETs and driver ICs as part of the learning process. Remember to protect your PC’s USB port by using an inexpensive cell phone charger for the microcontroller.
On the positive side, you will learn and gain significant assembly plus troubleshooting skills along the way. Expect exponential learning as you take the next steps and iterate the design on a PCB striving for a compact circuit that will gracefully handle overload conditions. For a greater challenge, add a third bridge arm and design a 3-phase driver for a BLDC or synchronous motor. If you are still in the game move on IGBTs and three-phase vectored drives for induction motors with a full Variable Frequency Drive (VFD).
Circuit description
The schematic as shown in Figure 2 is a clone of the previously introduced bridge arm. The difference is that the H-bridge uses two of the IR2110PBF-based bridge arms. In total, the bridge uses two driver ICs coupled to four IRF520PBF MOSFETS with an Arduino Nano Every as the controlling element.
In the previous article, the motor’s positive terminal was connected to the center of the bridge arm while the negative terminal was connected to ground. Recall that the motor’s speed could be controlled but not its direction. The schematic is included as Figure 3 for convenience.
Observe that the motor’s ground terminal is now connected to a second H-bridge as shown in Figure 2. This allows full velocity and directional control of the DC motor.
Figure 2: Schematic of the H-bridge featuring two IR2110 drivers and the Arduino Nano Every. The Arduino is powered via its USB port (not shown).
Figure 3: Schematic of the bridge arm featuring the IR2110 driver and the Arduino Nano Every. Capacitor C2 performs the critical bootstrap operation. The Arduino is powered via its USB port (not shown).
Wiring
Forgive me. I will not provide any additional information other than the schematic and woefully inadequate image of the breadboard as Figure 1. My inner professor will not allow anything more.
Understand that you will make mistakes as you construct the circuit. There is great value in troubleshooting the design. This is an underappreciated skill you need to develop to successfully troubleshooting your future PCB designs. Mistakes happen. For example, while constructing the second bridge arm, I inadvertently missed the low-side driver connection (pin 1 of the IR2110). The circuit sort of – intermittently – worked. Thankfully, the bench power supply’s current limit activated before the MOSFET was destroyed. Hint: Never let the MOSFET gates float.
Wiring tips
Keep things clean and separated. For example, the driver and micro in Figure 1 are on separate breadboards. Each circuit is built and tested independently. This provides a clear separation of the 5 VDC and 15 VDC supplies. This is very important, as crossing the 15 VDC supply with any Arduino I/O pin will immediately destroy the Arduino (loud pop with lingering smoke) and possibly the USB supply (tears if it destroys your PC). Refer to the previous safety tip regarding the port isolator or a cell phone charger to power the Arduino. Protect your expensive equipment!
DO NOT attempt to build the entire circuit in one setting. Instead, build and troubleshoot the Bridge Arms independently. For example, connect the motor between the bridge arm and ground, test by applying a PWM signal to the high-side driver. Likewise, connect the motor between the bridge arm and the positive rail, test by PWM the low-side driver.
Also note that the bridge arm driver is replicated. Each section should look identical.
Code description
The rudimentary Arduino software is shown in this listing. This is a brute force (open loop) solution with zero guards to protect the MOSFETs.
/**** CAUTION **** **** CAUTION **** **** CAUTION **** **** CAUTION **** **** CAUTION ****
*
* This code is written specifically for an Arduino Nano Every. It will NOT work on other Arduino
* microcontrollers as it depends on direct SFR manipulation to operate in a Fast PWM mode.
* For Fast PWM techniques, refer to https://forum.digikey.com/t/fast-pwm-for-the-arduino-nano-every/40023
*
*/
#define LL_PIN 7
#define LH_PIN 6 // Fast PWM
#define RL_PIN 4
#define RH_PIN 3 // Fast PWM
#define VREF_PIN A7
#define MAX_PWM_VAL 250
enum Direction {
CW = true,
CCW = false
};
Direction direction;
void setup( ) {
pinMode(LL_PIN, OUTPUT);
pinMode(LH_PIN, OUTPUT);
pinMode(RL_PIN, OUTPUT);
pinMode(RH_PIN, OUTPUT);
TCB0_CTRLA = 0b00000011; // Fast PWM for pin D6
TCB1_CTRLA = 0b00000011; // Fast PWM for pin D3
}
void loop( ) {
static uint16_t last_setpoint;
uint16_t setpoint = analogRead(VREF_PIN);
if (setpoint != last_setpoint) {
last_setpoint = setpoint;
// Potentiometer set to middle turns off the motor. Middle and above yields CW, while below middle yields CCW.
// Recall that analogRead( ) returns a value from 0 to 1023 while analogWrite( ) accepts a value between 0 and 255.
//
if (setpoint > 512) {
direction = CW;
setpoint = (setpoint - 512) >> 1;
} else {
direction = CCW;
setpoint = (512 - setpoint) >> 1;
}
if (setpoint > MAX_PWM_VAL) {
setpoint = MAX_PWM_VAL;
}
analogWrite(LH_PIN, 0); // Turn off all PWM to prevent shoot through
analogWrite(RH_PIN, 0);
digitalWrite(LL_PIN, LOW);
digitalWrite(RL_PIN, LOW);
if (direction == CW) {
digitalWrite(RL_PIN, HIGH);
analogWrite(LH_PIN, setpoint);
} else {
digitalWrite(LL_PIN, HIGH);
analogWrite(RH_PIN, setpoint);
}
}
delay(50);
}
Arduino input and processing
A single potentiometer is used to control the H-bridge. This is read using an analogRead( ) function. The resulting setpoint value is modified so that the middle position (decimal 512) turns the motor off. A CW rotation from center linearly increases the motor velocity in the CW direction. A CCW rotation from center increases the CCW velocity of the device. Scaling is uses so that:
- 512 to 1023 yields 0 to 250, with the direction bool set as CW
- 511 to 0 yields 0 to 250, with the direction bool set to CCW
Where the 250 is determined by MAX_PWM_VAL.
The potentiometer may be replaced by a signal generator as shown in Video 1. Here the Digilent Analog Discovery 3 provides a slowly changing triangle wave to control the speed and direction of the Pololu DC motor.
Tech Tip: The Arduino analogRead( ) function returns a value between o and 1023 while the analogWrite( ) return a value of 0 to 255. A common programming technique is to divide by 4 using a right shift operator as in drive = setpoint >> 2;. In the program, we use a divide by two operation as declaring 512 as zero has already divided the input value by 2.
A guard is used to detect if the input value has changed. If setpoint has changed the values are sent to the control pins.
Video 1: Operation of the H-bridge in response to a triangle wave signal provided by the Digilent Analog Discovery.
Arduino outputs
There are four control lines used by the H-bridge including both high and low side drivers for each bridge arm. The code describes these pins by side (left vs right) and position (High vs Low). As an example, the left side high driver (IR2110 pin 10) is defined by this line of code.
#define LH_PIN 6 // fast PWM
Note that the code implements that fast PWM mode specific to the Arduino Nano Every as described in this article. Instead of using the 960 Hz PWM it uses a 32 kHz. This moves the motor buzzing outside of the audible range and likely improves the system’s efficiency.
The Arduino prepares to send new commands by first turning off all H-bridge drivers. This should prevent unintended shoot through on the MOSFETs. The next step is to turn the appropriate MOSFET pairs e.g., Q1/Q4 and Q2/Q3. The lower MOSFET is held steady on while the upper is sent the setpoint derived PWM signal.
Tech Tip: Recall that the bootstrap capacitor will gradually discharge if the duty cycle is set to 100%. This is highly undesirable as the resistance of the upper MOSFET will increase leading to MOSFET overheating or even destruction. Consequently, the typical control algorithm will activate a lower MOSFET e.g. Q4 and then PWM the corresponding high-side MOSFET e.g., Q1. This technique ensures that the bootstrap capacitor will remain charged PROVIDED the high-side MOSFET’s duty cycle is limited to approximately 95%. An ultrafast diode such as the MUR120G is a critical component to charge the bootstrap capacitor as there is a brief window to charge the capacitor in a H-bridge with a 32 kHz PWM.
Next Steps
The primary objective is to learn about electronics. The next step is to harden the design. Potential ideas include:
-
Design a custom PCB with an emphasis on using the latest (smallest) surface mount MOSFETS along with advanced driver circuits. For example, consider using the Nexperia PXN012-100QSJ MOSFET with all the advanced features of the Allegro A89506KLPTR full-bridge driver. For reference the International Rectifier IR2110 is at about 30 years old and remains as popular as ever. I can remember reading about it in the old paper-based application notes.
-
Inclusion of an overcurrent detection and shutdown hardware. This could be as simple as adding fuses or as complex as incorporating current monitoring of the motor with fast shutdown capability. This would allow the driver to survive a dead short on the motor terminals such as a wire-to-wire fault in the motor’s drive cable.
-
Safely integrate a line-powered supply. The techniques introduced in this article are generally applicable switch-mode power supplies. However, there are considerable safety aspects to consider. Be sure to find a mentor to guide you through the circuit and safety challenges. Follow all local, state, and federal codes.
-
Inclusion of encoder feedback to sense and control the rotation speed. An example is PID control as described here.
-
Full 4-quadrant control for direction, velocity, and torque.
-
Software telemetry for current, voltage, temperature, and faults.
-
Move to three-phase BLDC motors ranging from small RC types all the way to IGBT-based hundred hp Variable Frequency Drives (VFD).
On the other hand, you may want to purchase one of DigiKey’s 15,000 COTS motor drivers that incorporates some or all advanced features. There are plenty of learning as you incorporate the motor and controller into your design.
Horses for courses.
Parting thoughts
The world needs engineers who understand power conversion technology. While the featured design is relatively simple, it sets the stage for complex high-powered drives. The multidisciplinary topics of semiconductor design coupled with software control form the basis of our commercial and industrial power system. The switch mode power supply in your computer has much in common with the largest grid scale Battery Energy Storage system (BESs).
Please leave your comments and suggestion in the space below.
I would be personally grateful if you included pictures of your working designs.
Best wishes,
APDahlen
Related information
Please follow these links to related and useful information:
- Digikey’s product selection guides
- DigiKey’s Arduino Education Materials
- IR2110 - Infineon Technologies
About this author
Aaron Dahlen, LCDR USCG (Ret.), serves as an application engineer at DigiKey. He has a unique electronics and automation foundation built over a 27-year military career as a technician and engineer which was further enhanced by 12 years of teaching (partially interwoven with military experience). With an MSEE degree from Minnesota State University, Mankato, Dahlen has taught in an ABET-accredited EE program, served as the program coordinator for an EET program, and taught component-level repair to military electronics technicians. Dahlen has returned to his Northern Minnesota home and thoroughly enjoys researching and writing educational articles about electronics and automation.
Highlighted experience
Dahlen is an active contributor to DigiKey’s Technical Forum. At the time of this writing, he has created over 200 unique posts and provided an additional 600 forum posts. Dahlen shares his insights on a wide variety of topics including microcontrollers, FPGA programming in Verilog, and a large body of work on industrial controls.