Dual Motor Driver As Robot Base
by Arnov Sharma in Circuits > Robots
1293 Views, 9 Favorites, 0 Comments
Dual Motor Driver As Robot Base
Hey everyone, what's up?
So here's something awesome, a Microrobot Base that is equipped with a few FETs to make an H-Bridge for driving two motors.
These FETs are used for driving small gear micromotors with a 3.7V Li-ion cell.
Apparently, common motor drivers like L293D work with a minimum voltage of 4.5V to 36V, so it wouldn't work with our current setup, and we need to increase the battery voltage from a single 3.7V cell to a battery pack composed of two or three cells in series. Electrically, this is ideal, but because we are making a two-wheeled small robot, using a 3-cell battery pack will increase the weight and size.
The best option here was to make a DIY motor driver from scratch using Mosfets.
So I prepared a simple H-bridge setup that utilizes four N-channel MOSFETs connected in an H configuration for controlling each motor. Two motors are used, so two H-bridges were made with 8 FETs.
This setup is just a base for the upcoming robot project. This Instructables is about how this Dual Motor Driver Base works and how it's prepared step by step, so let's get started.
Supplies
Following are the materials used in this built-
- AO3400 N channel Mosfet SOT23 Package
- Custom PCB
- 10K resistors 0603 Package
- 2R 1206 package
- JST connectors
- Vertical Header pin male connector
- Micro gear motor
- 3D printed Motor Holder
Mechanical Design for Robot's Base PCB
I first prepared a simple double-wheeled robot in Fusion 360, the whole model was made around the Micro Gear Motor.
I prepared a Base Board of size 95mm x 36.2mm, which was later utilized in the PCB design.
The motor is added to the base by using two motor mounts that we 3D print and later attach with PCB standoffs to the base body.
PCB DESIGN
For driving motors, we tend to use common drivers like L293D or its higher version the L298N, which are both H-bridge-based motor drivers that have two channels or two motor outputs.
H-bridge is a unique circuit that can switch the polarity of the voltage applied to any load, it's generally used with motors for changing their rotation from backward to forward and can be made out of switches.
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.
There are a total of two H-bridges on the Base Board which is for controlling both motors.
Additionally, I have added four Load Resistors between the Battery Positive and the input of the H-Bridge. this will limit the current going into the motors.
There's also a CON4 header pin that separates the gates of both H-bridges so we can connect them to a microcontroller to drive the motors.
After finalizing the schematic, PCB was prepared by following the outline provided by the mechanical design of the robot.
PCBWAY
After preparing 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.
White PCBs look great with black silkscreen in general.
I 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.
PCB ASSEMBLY
PCB Assy consists primarily of four processes, which are as follows:
- Solder Paste Dispensing Process
- Pick and Place Process
- Hotplate Reflow
- THT Components
Solder Paste Dispensing
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.
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.
Hotplate Reflow Process
After the "pick and place process," we carefully lifted the whole circuit board and placed it on my new Mini Hotplate.
https://www.instructables.com/PCB-Hotplate-Mini-Edition/
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.
THT Components
Next, we add header pins to this board: vertical male header pins for connecting this setup with an Arduino board for testing, JST connectors for connecting two motors to FETS, and one for adding a 3.7V Li-ion cell.
Adding Motors
After adding THT components to the board, we connect both motors with the JST connectors.
I already soldered male JST wire harnesses to both motors, so we can easily add them to the base PCB without doing any soldering work. this makes assembly a lot easy.
Motor Holder
Next, to hold motors in their place, we add 3D Printed Motor Holders with help of four M3 Screws, these screws will later be replaced by PCB standoffs for adding a second layer to this base. the second layer will contain the Microcontroller setup which is yet to be finalized.
Adding Wheels
I have purchased small wheels for micro motors that were used in a previous project which was this-
https://www.instructables.com/Micro-Fighter-BOT-With-Bluetooth/
I repurposed those wheels and used them in this design.
These are regular plastic rims that have a rubber wheel which is great for gripping the surface and running smoothly without oversteering that happens a lot if the wheel is made from completely plastic material.
Arduino Setup
As for the current setup, we need to add an external microcontroller for testing the board.
I used an Arduino nano for controlling the gates of MOSFETs.
D2, D3, D4, and D5 I/O pins were connected with the FETs gate along with an additional GND Pin which is connected with the GND of Arduino.
Power to the Motor driver was provided by a single Li-ion cell which was connected to the Baseboard through a JST wire harness.
TEST SKETCH
Here's the code, and it's a simple one.
int in1 = 2;
int in2 = 3;
int in3 = 4;
int in4 = 5;
void setup() {
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
void demoOne() {
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
delay(2000);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay(2000);
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay(2000);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay(2000);
}
void loop()
{
demoOne();
}
We upload the above sketch into the Arduino Nano, and the H-bridge works.
I already tested this setup before and prepared an article about this which you can check out here-
https://www.instructables.com/H-Bridge-From-Scratch/
The previous version was totally makeshift so I prepared this dual H-Bridge PCB which I will next use in the robot project.
This approach of making something and then improving it from time to time is what makes engineering so much fun and interesting.
What's Next?
The second part or level of this project is to make a microcontroller layer that will have an MCU connected on the top side and a Li-ion cell holder on the bottom side.
There will also be an MPU6050 sensor for obtaining accelerometer readings so that this robot can stand still on two wheels.
I already made a similar self-balancing robot in the past and will be using slightly modified code from that project in this bot.
This is it for today folks. Stay tuned for the next version.
Special thanks to PCBWAY for supporting this project; do check them out for great PCB service at a lower cost.
Thanks again, and I will be back with a new project soon.