H-Bridge (Quasi-Square Wave Inverter)
by fahadqalbi in Circuits > Arduino
2226 Views, 9 Favorites, 0 Comments
H-Bridge (Quasi-Square Wave Inverter)
An H-bridge is a crucial electronic circuit that enables the control of a DC motor's direction. Named for its distinctive "H" shape, the H-bridge consists of four switches (transistors or MOSFETs) that work in pairs to allow current to flow through the motor in either direction. This ability to reverse the motor's polarity makes H-bridges indispensable in a wide range of applications.
H-bridges are widely used in robotics, where precise control of motor direction and speed is essential for navigation and operation. They're also found in various motor control systems, from simple projects like RC cars to complex industrial machinery. Additionally, H-bridges play a vital role in power inverters, where they help convert DC power to AC power, providing a crucial function in renewable energy systems and uninterruptible power supplies.
H-Bridge's Working:
An H-bridge is used to convert DC (Direct Current) power to AC (Alternating Current) power. Here's a brief explanation of how an H-bridge functions in an inverter circuit:
Basic Configuration
The H-bridge in an inverter circuit typically consists of four switches (transistors or MOSFETs) arranged in a manner that allows current to flow in alternating directions through a load (e.g., a transformer or a motor). The switches are labeled as:
- Q1 and Q2 at the top
- Q3 and Q4 at the bottom
A DC power source is connected across the entire H-bridge, and the load is connected between the two legs of the H.
Operation
Generating AC Power
To convert DC to AC, the H-bridge alternates the direction of the current flow through the load by switching the transistors on and off in a specific sequence.
Positive Half-Cycle (Quasi Square Wave)
- Close (turn on) Q1 and Q4: Current flows from the positive terminal of the DC source through Q1, through the load, and then through Q4 to the negative terminal of the DC source.
- Q2 and Q3 remain open (off):This creates a positive voltage across the load.
Negative Half-Cycle (Quasi Square Wave)
- Close Q2 and Q3: Current flows from the positive terminal of the DC source through Q3, through the load in the opposite direction, and then through Q2 to the negative terminal of the DC source.
- Q1 and Q4 remain open (off): This creates a negative voltage across the load.
Pulse Width Modulation (PWM) Control
- By rapidly switching the transistors on and off using Pulse Width Modulation (PWM), the H-bridge can generate a quasi-square wave or approximate a sine wave, which is more suitable for sensitive AC devices.
- The frequency of switching determines the AC frequency (e.g., 50Hz or 60Hz), and the duty cycle of the PWM signal controls the RMS (Root Mean Square) voltage of the output.
Protection and Efficiency
- Flyback diodes are often added across each transistor to protect against voltage spikes caused by the inductive nature of the load.
- Using MOSFETs instead of BJTs can improve efficiency due to their lower on-resistance and higher current handling capabilities.
Example Sequence for Quasi Square Wave Generation
- First half-cycle: Q1 and Q4 are on, Q2 and Q3 are off.
- Second half-cycle: Q1 and Q4 are off, Q2 and Q3 are on.
By continuously repeating this switching sequence, the H-bridge generates an AC voltage across the load, effectively converting the DC input into an AC output.
This method allows the creation of simple inverters that can power AC devices from a DC source, making H-bridges a fundamental component in many inverter designs used in renewable energy systems, uninterruptible power supplies (UPS), and various other applications where DC to AC conversion is required.
In this Instructable we'll build an H-Bridge and test its working.
Supplies
List of tools and components:
- Soldering Iron
- Solder
- Cutter, pliers, and tweezers
- Mini drill
- Resistors 10 ohms *4
- Resistors 10k ohms *2
- Resistors 1k ohms *4
- Resistor 330 ohms *1
- Led
- 1N5817 *8
- 1N4007*2
- LM7805 voltage regulator
- Cap 1000uF 12V
- Cap 22uF 12V
- Cap 330uF 5V
- Ceramic Cap 0.1uF *4
- Film Cap 0.1uF *1
- IR2113 gate driver IC *2
- IRFZ44N or any N channel Mosfets *4
- Heatsinks, thermal pads, screws
- Terminal blocks
- Brass standoffs
Schematic and PCB
The first step in creating your DIY H-bridge inverter is to design the schematic and PCB layout. This will serve as the blueprint for your circuit and ensure that all components are correctly connected and positioned. Here's how you can do it:
1.1 Design the Schematic
Choose Your PCB Design Software
- Popular options include Proteus, KiCad, and Altium Designer. These tools provide the necessary features to create detailed schematics and PCB layouts.
Create a New Project
- Open your chosen software and create a new project. Set up the project parameters such as board size and the number of layers (typically one or two for DIY projects).
Draw the Schematic Diagram
- Place Components: Use the component library to add symbols for each part of your H-bridge inverter circuit, including transistors (or MOSFETs), diodes, resistors, capacitors, and connectors.
- Connect Components: Draw wires to connect the components according to your circuit design. Ensure that you correctly wire the H-bridge configuration with the appropriate connections for the DC input, load (motor or transformer), and control signals.
Label and Annotate
- Clearly label each component and add annotations to make the schematic easy to understand. This will help during the assembly and troubleshooting stages.
1.2 Design the PCB Layout
Switch to PCB Layout Mode
- After completing the schematic, switch to the PCB layout mode in your design software.
Place Components on the Board
- Position the physical representations of your components on the PCB. Pay attention to component orientation, spacing, and placement to ensure efficient routing and minimal interference.
Route Traces
- Draw the copper traces that will connect the components. Use the software’s auto-router feature if available, but manually adjust traces as needed to optimize the layout. Ensure that power and ground traces are sufficiently wide to handle the expected current.
Design Rules Check (DRC)
- Run the Design Rules Check to identify any potential issues such as traces being too close together or components overlapping. Resolve any errors flagged by the DRC.
Export the Design Files
- Once satisfied with the layout, export the necessary design files. This usually includes Gerber files for the PCB manufacturer and a PDF of the layout for the DIY PCB transfer process.
1.3 Prepare for DIY PCB Making
Refer to My DIY PCB Making Instructable.
Populating PCB With Components
Now it's time to populate the PCB. I've designed my PCB to allow through-hole technology (THT) components to be soldered as surface mount components. This approach avoids the hassle of drilling tiny holes, which can be challenging and often results in broken drill bits. Here are some tips and steps to follow during the soldering process:
Tips for Soldering
- Start with Small Components: Begin by soldering the smaller components first, such as resistors and small capacitors. This makes it easier to handle and place them correctly without larger components getting in the way.
- Use a Temperature-Controlled Soldering Iron: Set the temperature to between 360°C and 380°C. This range is ideal for preventing damage to sensitive components, ICs, and MOSFETs.
- Use Strong Jumpers: For jumpers, I used breadboard jumper wires and the excess leads cut from diodes, which are thicker and stronger.
Soldering Components
- Bend the Legs: Carefully bend the legs of the component to fit the pads on the PCB.
- Trim Excess Leads: Cut one leg to the appropriate length, leaving enough to make a good solder joint.
- Pre-Solder One Pad: Apply a small amount of solder to one of the pads where the component will be placed.
- Place the Component: Using pliers or tweezers, hold the component in place and solder it to the pre-soldered pad.
- Adjust and Solder the Second Leg: Adjust the component as needed to ensure proper alignment, then solder the second leg to the corresponding pad. Trim any excess lead.
By following these steps, you will methodically and efficiently populate your PCB, ensuring good solder joints and proper component placement.
Arduino Code
We need an Arduino code to generate a control PWM signal with dead-time so that during alternating phases we don't short our mosfets. The following code is designed to control an H-bridge inverter using two high-side MOSFETs to generate a quasi-square wave output at a specified frequency and duty cycle. The setup involves defining the MOSFET pins and calculating the period and durations for the high and low states based on the desired frequency and duty cycle. In the loop, the code alternates the state of the MOSFETs to switch the output between high and low states. Dead-time is introduced between switching states to prevent short circuits and protect the components. This process ensures a stable AC output from the DC input, suitable for various applications requiring a quasi-square wave signal.
#define HIGH_SIDE_A 5 // High-side MOSFET on side A
#define HIGH_SIDE_B 6 // High-side MOSFET on side B
#define FREQUENCY 60// 60 Hz
#define DUTY_CYCLE 50 // 45% duty cycle
int dt=15; //dead-time
unsigned long period;
unsigned long highStateDuration;
unsigned long lowStateDuration;
unsigned long lastChangeTime;
bool isHighState = true;
void setup() {
pinMode(HIGH_SIDE_A, OUTPUT);
pinMode(HIGH_SIDE_B, OUTPUT);
period = 1000000 / FREQUENCY; // Period in microseconds
highStateDuration = (period * DUTY_CYCLE) / 100; // High state duration
lowStateDuration = highStateDuration; // Low state duration is equal to high state duration
}
void loop() {
unsigned long currentTime = micros();
if (isHighState && currentTime - lastChangeTime >= highStateDuration) {
// Switch to Low State
digitalWrite(HIGH_SIDE_A, LOW);
delayMicroseconds((period * dt) / 100); // 10% of period as dead time
digitalWrite(HIGH_SIDE_B, HIGH);
lastChangeTime = currentTime;
isHighState = false;
} else if (!isHighState && currentTime - lastChangeTime >= lowStateDuration) {
// Switch to High State
digitalWrite(HIGH_SIDE_B, LOW);
delayMicroseconds((period * dt) / 100); // 10% of period as dead time
digitalWrite(HIGH_SIDE_A, HIGH);
lastChangeTime = currentTime;
isHighState = true;
}
}
Upload this code to the Arduino.
Note: Make sure that Arduino and the gate driver IC's 5V logic have a common ground.
Downloads
Simulation
A simulation is always a safe way to test your circuit and it's working beforehand.
Downloads
TESTING
To test the H-bridge circuit:
Apply Power:
- Connect a 12V power supply to the H-bridge.
Check Voltages:
- Using a Digital Multimeter (DMM), verify that 5V is present at the 5V pin of the IC.
- Ensure that VCC is present at the VCC pin of the IC.
Monitor MOSFETs:
- Confirm that the MOSFETs are not heating up when there is no control signal applied.
Connect Load and Arduino:
- After completing these initial tests, turn off the power.
- Connect the load and the Arduino to their respective terminal blocks.
- Ensure the grounds of the Arduino and the H-bridge are connected to a common ground.
For the load, I am using two power resistors in series as a dummy load. Here’s how to proceed:
Turn on the Power Supply:
- After connecting the load and Arduino, turn on the 12V power supply to the H-bridge.
Monitor the Output with an Oscilloscope:
- Connect an oscilloscope across the load to visualize the output waveform.
- Observe the oscilloscope results to ensure the H-bridge is generating the expected waveform.
Temperature Checks:
- Measure the temperature of the MOSFETs at room temperature to ensure they are not overheating.
- Check the temperature of the load resistors to confirm they are drawing power and to ensure the MOSFETs are operating correctly.
The END
In this project, I demonstrated how to control an H-Bridge using an Arduino with dead time in the code and observe its effects on the output. I created two PCB layouts for this project, simply for the enjoyment of the process. You can explore both PCB layouts and see how they work. I hope this Instructable inspires you to build your own H-bridge inverter PCB and dive deeper into the world of DIY electronics.