Introduction: Mini DIY H-Bridge Made From Fets
Hey, what's up, everyone? So here's something small and interesting.
A Mini H-bridge board that can power any DC motor and switch its polarity by using two GPIOs from a microcontroller
By using this small 20mm x 20mm board, we can power small DC motors that operate at a lower voltage, like below 5V, from a single Li-ion cell.
This driver can be used in projects that require less space to work with, for example, I prepared a mini-rotating table for capturing rotational videos of components.
I used this motor driver to power a mini rotating table by putting together a small Attiny85-driven driver setup that is both small and functional.
This driver uses four N-channel MOSFETs connected in an H-bridge setup, H-bridge is a unique circuit that can switch the polarity of the voltage applied to any load. It's generally used with motors to change their rotation from backward to forward and can be made out of switches.
In this case, MOSFETs are used as switches, and they are controlled by two INPUT pins. We connect any MCU to these two INPUT pins for changing the polarity of the motor.
This Instructables is about the building process of this Motor driver and how we can use it in any motor-based project.
Let's get started.
Supplies
Following are the things used in this built-
- Custom PCBs
- AO3400 N channel Mosfets
- 2 Ohms 1206 Package resistors
- 10k 0603 Package resistors
- Header Pins Vertical
- Attiny85
- Arduino Nano
- Breadboard
- DC Motor
- 3D Parts for Mini Rotating Table
Step 1: PCB Design
The PCB design is pretty simple, we have four Mosfets connected in the general H-bridge configuration.
Here's how this H-Bridge works: Four FETs are connected in such a way that the first two FETs (Q1 and Q2) Drain is connected to the VCC or Power source that will drive the motor.
The sources of Q1 and Q2 are both connected to the positive and negative sides of the motor.
Two more FETs Q3 and Q4 Drain are linked to Q1 and Q2 sources, as well as the motor terminals.
The Q3 and Q4 Sources are linked to GND.
The gates of Q1 and Q4 are connected together, and the gates of Q2 and Q3 are connected together. If we apply a signal to Q1, Q4 will also get activated, and if the signal is applied to Q2, Q3 will get activated.
1 and 0 will be denoted for HIGH and LOW, respectively. We set Gate of Q1 to 1 and Gate of Q2 to 0, and this turns the motor in one direction. If we set Gate of Q1 to 0 and Gate of Q2 to 1, the polarity of the motor changes, and it starts rotating in the opposite direction.
If both Q1 and Q2 are 1, then a short circuit will occur.
After completing the schematic, a PCB file was prepared.
Because there are just a bunch of components in the circuit, it was easy to cram everything into a nice 20mm by 20mm square outline.
Step 2: PCBWAY Service
After finalizing the PCB and exporting the Gerber data, we sent it to PCBWAY for samples and placed an order for a white solder mask with a black silkscreen.
I received PCBs within a week, and they were excellent, as expected.
I really love the quality of PCBs made by PCBWAY. There are other manufacturers available, but their service is always on another level.
check out PCBWay service for getting great PCB service at less cost.
Step 3: PCB Assembly
- Solder Paste Dispensing Process
- Pick and Place Process
- Hotplate Reflow
- THT Components
Step 4: Solder Paste Dispensing Process
The first step is to apply solder paste to each component pad.
We use regular Sn-Pb solder paste that has a melting temperature of 140° to 270°C, and to apply the solder paste, a solder paste syringe with a wide nozzle is used.
Step 5: Pick and Place Process
We then used an ESD tweaker to carefully pick and place all the SMD components in their assigned places one by one, which took like 30 seconds tops, but the result was a perfect PCB with all the components placed in their locations.
Step 6: Hotplate Reflow
After the "pick and place process," we carefully lifted the whole circuit board and placed it on my new Mini Hotplate.
The hotplate heats the PCB from below up to the solder paste melting temperature. As a result, the solder paste melts and components get solder on their pads.
Step 7: THT Components
Next, we add a CON4 vertical header pin and a CON2 JST connector to the board by using a regular soldering iron.
The CON2 JST connector is for adding a DC motor to the circuit, and CON4 connector is for adding the motor driver to the breadboard for testing and controlling.
Step 8: Arduino Setup
The DC motor and motor driver are then connected via the CON2 JST connector, and the motor driver is placed on a breadboard to prepare a basic Arduino Nano setup.
we follow the below wiring-
- VCC of the motor driver to 5V or 3V of Arduino Nano
- GND to GND
- A of Motor drover to D3 of Arduino
- B of Motor driver to D5 of Arduino
Step 9: Testing and Working
After preparing the breadboard setup, we upload the below sketch to the Arduino board, and the motor will start spinning.
int in1 = 3;
int in2 = 5;
void setup() {
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
}
void demoOne() {
analogWrite(in1, 60);
digitalWrite(in2, LOW);
delay(2000);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(2000);
digitalWrite(in1, LOW);
analogWrite(in2, 60);
delay(2000);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(2000);
}
void loop()
{
demoOne();
}
Controlling this motor driver is an easy thing to do, there are two pins, A and B.
- We set A HIGH and B LOW, Motor rotates in one direction.
- We set A LOW and B HIGH, Motor changes its direction.
Because both input pins are connected to Mosfet's Gate, we can give a PWM signal to both pins and control the speed of the motor. we just have to make one pin LOW and then provide the other pin with a PWM signal.
Step 10: Result and Further Use
The motor driver is easy to control and can work with low voltage levels and small motors pretty well.
Next, to prove this concept, I prepared a small rotating platform that will be used in future videos for capturing fancy rotating videos of small components.
Step 11: Rotating Platform 3D Design
Here's the rotating platform, which is a two-part design consisting of a base that holds the motor and a rotating part that is added to the shaft of the motor.
There is a space in the base part for adding a small circuit inside for controlling the speed and direction of the motor rotation.
Step 12: Attiny85 Setup
We prepare a small ATtiny85-based Based Setup on a perf board, we add the motor driver to this setup, and use the ATtiny85 MCU to control the motor driver.
Attiny85 was connected with the motor driver by the following pinout-
- VCC of Attiny85 to VCC of Motor Driver
- GND to GND
- D0 to A Pin of Motor Driver
- D1 to B Pin of Motor Driver
The code was also the same for this, we just change the Pin declaration and PWM values along with delay time so the motor would rotate for long.
int in1 = 0;
int in2 = 1;
void setup() {
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
}
void demoOne() {
analogWrite(in1, 50);
digitalWrite(in2, LOW);
delay(10000);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(2000);
digitalWrite(in1, LOW);
analogWrite(in2, 50);
delay(10000);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
delay(2000);
}
void loop()
{
demoOne();
}
For Programming the Attiny85, I utilized one of my previously made projects that you can check out from here-
https://www.instructables.com/Multiple-ATtiny8513A-Programmer/
Step 13: Result
Here's the overall result, the rotating platform works, and the motor driver was able to drive a small DC Gear motor from a lower voltage source which was the goal of this project.
The next Level or phase of this H-Bridge project is to prepare a small two-wheel robot that uses the FETs H-Bridge and a 3.7V Li-ion cell to work.
This is it for today folks, if this article was helpful then do leave a comment.
Thanks, PCBWAY for supporting this project, Do check PCBWAY for getting great PCB service for less cost!
Will be back with a new project shortly, Peace.