Designing a Dual Channel 10 Amp PWM DC Motor Driver (Based on Relays and MOSFETs)
by FHKarim in Circuits > Electronics
1384 Views, 1 Favorites, 0 Comments
Designing a Dual Channel 10 Amp PWM DC Motor Driver (Based on Relays and MOSFETs)

This is an H-Bridge motor driver designed by me to run DC motors. A bit of head up as I'm not a fully qualified Engineer (still in undergrad), I have proficient skills in electronics but not ideal, hence this Instructables (looking forward to criticism on my design). A little background, we have an undergrad competition in my deptt (NERC National Engineering and Robotics Contest) where the whole degree has to make their own robots and make them perform certain tasks in the Competition. we are not allowed to use commercially available motor drivers hence we have to make our own. There are many popular designs going around since generations based on Darlington pair BJTs or different MOSFETs but none of them have a robust design to handle stalling current of motors used in the robots, majority of the time they fail due to coding errors or larger current draw. The major problems faced during designing an H-Bridge are as under.
- Not Having a sufficient current rating (corresponding to motor's application)
- Not Having a full range of PWM (those who design H-bridges using MOSFET driver ICs like 2110, 2103or similar, they always run into this problem because they were never meant to run motors since the bootstraps capacitors need to recharge then are unable to give out continuous and a full range of PWM.)
- Having short period short circuits ( if you use P-channel and N-channel for high and low sides respectively you usually get a different time of the MOSFETs turning off and on this results in very short periods of short circuits so if the timing is a little bit off in draining current to turn the MOSFET off you can blow out all your MOSFETs)
- Not Having good isolation. ( using a hobbyist H-Bridge usually fries your microcontroller or messes up something else due to the noise.)
- Should be able robust enough to handle abuse by the person coding/ interfacing with the microcontroller. ( usually, the hobbyist design either sacrifices the switching speed for PWM to get somewhat of faulty input protection or goes without protection resulting in sparks flying when given wrong inputs)
- Being able to be fabricated easily ( I considered this because at a beginners level people do not have good skills in fabricating a PCB and soldering so this design also keeps that in mind)
- Being able to be diagnosed easily (once you have made your h bridge and somethings is faulty in this design it can be diagnosed easily).
- Non Availability or cost of the components. (things like TIP147, TIP142, ir2110, or P-channel MOSFETs are hard to come by in local markets considering near me.
All of these problems have been addressed in my design. This Instructables contains a step by step instructions to design your own H bridge using my methodology and basics on the working of an H bridge works (for Hobbyist and my undergrad juniors). Also if you find anything I'm doing wrong or needs to be addressed do comment and let me know how I can improve my design.
Supplies

So first let this out of the way and then we will move towards the actual Designing part. Following are the components that I used to make my design.
Component Description Quantity (only minimum written, do get extras)
- JQC-3F (T73) Relays 10 Amps, 5V coil x4
- LM7085 5 Volt Regulator x1
- PC817 Optocouplers x4
- 1N4007 Diodes x4
- 500 Ohm Resistor x2
- 220 Ohm Resistor x4
- 10k Ohm Resistor x4
- 1k Ohm Resistor x2
- 150 Ohm Resistor x2
- 0 Ohm Resistor for Jumper x1
- 0.22 uF Capacitor x1
- 10 uF Capacitor x1
- 2N3904 Transistor NPN BJT x4
- 2N2907 Transistor PNP BJT x2
- IRF540 Transistor N-channel MOSFET x2
- T220 Heatsink MOSFET Heat sink x2
- 2-Pin T-Block Connectors x3
- 5-Pin T-Block Connectors x1
The Components mentioned are the minimum amount that is required. Do get extras if you are a beginner.
If you are here just for the design then skip to Step-5 because the following steps are here explain what the design does and how it does it.
Basics of How an H-Bridge Works


Alright, how do you control a motor? Obviously, a simple switch would be your answer. Things get complicated when you want more control over the motor than just blindly running it, like running the motor at a controlled speed or reversing the motor. So how do you do it? Well since you are here the answer is obvious an H-bridge.
This type of controller is named the H-Bridge because the connections resemble the letter H. Consider 4 switches in the following arrangement. (conveniently named S1, S2, S3, and S4).
If the switch S1 and S4 are closed at the same time the current flows in one direction and if the switch S2 and S3 are closed at the same time the current flows in the other direction reversing the direction of rotation of the current. (video attached)
If however the switch S1 and S3 are closed at the same time then the current has the direct path to flow to the ground and results in fireworks of your H bridge. (second photo for reference).
These switches can be implemented by the use of anything such as BJTs, MOSFETs, or Relays (or even optocouplers cuz why the hell not).
Anyways the objective here is to make an H-bridge using Relays.
Implementing an H-Bridge Using Relays

The H-bridge using Relays can be implemented in the way shown above it can be used in the following manner using SPDT (Single Pole Dual Throw) relays. (video attached).
One thing that you wouldn't noticed is that by implementing the H-Bridge using the common terminal of the relay I have eliminated the possibility of having a straight short-circuit because the relay cannot physical close the S1 and S3 at the same time hence eliminating the possibility of this sort of error. Also further on you will see this allowed to assign a single pin for direction.
But this is not an ideal world we would have to implement certain things like the following
- A diode across the coil of the relay to drain the spikes created when the turning the coil off.
- Since there needs to be isolation included so the switches that energies the relays should be implemented using optocouplers.
- Things here are just piling up but need to take in consideration about the current limitations foe example the optocoupler can channel 50mA on the output but the coil needs 71mA soo we would need to add a BJT to drive that thing.
- Also this needs to be done on proteus if you want the thing to actually be on PCB. (i said proteus cuz at the moment i only know how to work on proteus)
Implementing the H-Bridge on Proteus


I added a few resistors. 220Ohm to control the current input to the PC817 optocoupler this resistor is important because if the fry the optocoupler you won't know have any good indication if it is working or not and will create a lot of hassle. 10K to pull down the BJT (just good practice near me). 500 Ohm to control the current to the BJT.
The relays are arranged in a way the normally closed terminal one of the relays is connected to power and the normally closed terminal of the other really is connected to ground so when the coils are not energized the motor will run in one direction and when they are both energized they motor will run in another direction. So through this, I only have to give one input for the motor to change direction ( 0 for clockwise and 1 for counter-clockwise). The coils are being run by a 5V Voltage regulator that is connected to the output of the optocouplers and then energizes the coils based on the input given to the optocoupler.
Now the only thing left to do is is to control the speed of the motor that will be done in the next step.
Implementing the PWM Function


Now, whenever you would think of giving PWM to Relays you would imagine that relay is flipping its contacts really fast. Although that would be a fun sight to see that would be really inefficient while working because the switching time of the relay is very long if given a frequency like 490Hz that is normally given out by an Arduino then it is a possibility the relay is just flipping and isn't conducting during its whole operating time.
To implement a PWM function I have added a MOSFET between the H-Bridge and the ground. It doesn't matter which direction the motor is going then have the same ground at the end hence that is a place where we can add a MOSFET to control the current of the whole H-bridge. as displayed by a simple Switch in the first photo. (also demonstrated in the video attached).
To implement this I used a push and pull configuration on a MOSFET to turn it on and off when required which again is being controlled by an optocoupler. (Shown in the second photo).
that rules out the PWM part all that is left is to implement it on all on proteus and make a PCB layout.
Complete Schematic

This is the complete schematic made. I have attached the PDF of the schematic which is to some point properly labeled, which will help in further understanding the circuit. I have added T-blocks here as well just for the ease of making a PCB for it. I have explained what each component does and to an extent lead to a simple design this complete schematic is for a dual motor and all the components listed above are for this complete design. for giving the inputs there are 5 inputs the center one is for the ground (because there is complete isolation you need to provide the ground of the controller to the optocouplers to function properly). The next one is for the PWM control and the furthest one is for the direction control.
Downloads
PCB Designing

This is how I have designed the PCB for this project. I added multiple traces to increase the width of the copper that would allow more current flow and less heat. there is only one jumper with the 5V regulator.
Attached are also the PDF files for the PCB traces and Components
Fabricate Your PCB





The last process left is it fabricate your PCB. I used to toner transfer method to make my PCB and it worked out great. I am not going to go into much detail about how to fabricate your PCB there are many methods on youtube that will assist you on that. The pinout is also attached
TEST Your H-Bridge

I have tested this design on multiple motors and it is also able to handle the stall current of those motors. I found it to be a robust design that could take a little abuse and still will not fail on the user. In case this design isn't working it can be easily diagnosed as there are optocouplers present we only have to short the output pins of the optocoupler and they would mimic the inputs of the microcontroller and according to its behavior we could see what is working and what isn't.
Conclusion
This design was a scaled-down version of what I was thinking to make. Originally the plan was to make an H-Bridge that could handle up to 40Amps without any problems and could work on above 20KHz (silent motors). That would have been overkill but who knows I might design that in the future. If you are willing to go there, this design is the perfect basis you only need to change relays, you would need BJTs with higher switching speeds and a little tweaking with the resistors. Otherwise, this is scalable and a robust design. I am happy with the results I got. Considering this was cheaper to make and the components were easily available.
also if you find that I need to improve something let me know. Looking forward to the criticism