Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Are these H-Bridges correct?

Status
Not open for further replies.

Jacky Lee

New Member
I'm a beginner at electronics, any any feedback would be helpful. So, the basic rundown: I have two motors, and I would like to run them both backwards and forwards, so I need an h-bridge circuit. However, I'm not sure if I am wiring them correctly.

Here are the h-bridges:
**broken link removed**

The D pins refer to pins on an Arduino UNO, which are capable of digital writing.

Here's my thinking:

On Motor 1, if I want to move it forward, I will turn on Digital Pin 1, and turn off Digital Pin 3. If I want to move it backwards, I will turn Digital Pin 1 off, and Digital Pin 3 off.

Also, will I need capacitors / flyback diodes for the motors?

Thank you for any help!
 
Your biggest problem is the upper MOSFETs as these will require a gate voltage that is 8V higher than their source voltages. With a 7.5V supply (upper source voltage) they will need around 15V on their gates to turn on. Normally the high side MOSFETs are P-type that need a low voltage on the gate. Your other problem is charging the gate fast enough from an Arduino. Depending on what current your motors require I would choose a suitable chip.

Edit, you will need a snubber circuit for the motors. Google DMOS H-bridge and study some of the datasheets.

Mike.
 
Last edited:
And it is best to use four port pins on the Arduino to guarantee that you always turn off the upper PFET first, followed by waiting for the motor to coast to a stop, followed by turning off the NFET, followed by turning on the opposite NFET, followed finally by turning on the opposite PFET, with delays of 10 of us to 100 of ms as appropriate.

Everybody that tries to do this with just two port pins ends up blowing FETs before they get it right.
 
As Pommie has indicated, complimentary switching is conceptually the simplest/best way to do an H-bridge. The only problem you might run into is you can't simply connect the gates of opposing switches directly, as you have done in your schematic. If you try and do it this way you will get shoot through, due to the asymmetric on/off time of the switches. Not accounting for this will --nine times out of ten-- end in destruction of the switching parts and sadness.

To do the above right you need either one digital pin per gate and the correct dead-time control, properly tuned delay hardware (RC + diode bypass) on your gates, or you need a purpose built driver chip. It is, in fact, more involved than it first appears.

That being said, you actually can use N-FETs all around fairly easily *if* you use boot strapping caps. Though this too is involved, and you can't go up too 100% duty cycle for very long this way. Great for solid state motors, which don't normally drive any one phase to 100% duty cycle.

If all you need is on/off speed control, and you go one direction more than the other, you can go retro and use relays with break before make logic.
This is just about the easiest way to go.

Lastly, an independent supply to give voltage above batt V+ is not as naive as it first appears either. A simple drop in DC-DC boost converter will work fine.
-()b

Edit: MikeMl beat me to shoot-through issue.
 
You may use P channel MOSFETs with inverter to drive the upper MOSFETs, however the easiest way is to use L293B Chip, it provides you with 2 channels to d5rive either 3 motors bidirectionally or 4 uni bidirectionally with up to 1 A each
 
Okay, so I have changed all the upper N-MOSFETs to P-MOSFETs, and each MOSFET is connected to its own individual pin. If I understand correctly, I will need to use delays when programming in Arduino so I can control all the gates properly. Here's the updated schematic:

**broken link removed**
Is there anything else that I need to change, or have missed?
 
Last edited:
Your P-FETS wont turn off properly and your N-FETs won't turn on properly which will lead to both emitting smoke. Learn about how MOSFETS work or use a chip as suggested above. Sorry to be so blunt.

Mike.
 
Logic-level NFets can be controlled directly from 5V powered Arduino pins; PFets where their Sources are connected to a voltage higher than 5V cant. You need some sort of level-shifter logic between the port pin and the PFET gates. Either DIY or a chip made for the purpose...

When you use four pins to control the four FETs, how many total states are there?
Which ones will instantly blow up the FETs?
Which ones are useful to run the motor?
Which are used to when braking a spinning motor?
Which ones let the motor coast?
How do you apply PWM to control the speed of the motor?

Write out a truth table to show you understand...
 
Last edited:
Here's my understanding: N-MOSFETs work with a source, gate, and drain. When no voltage is applied to the gate, current is not allowed to flow from the source to drain. However, when a voltage is applied, current is allowed to flow, completing the circuit.

I was planning to use this N-MOSFET in my first schematic:
https://www.sparkfun.com/products/10213

This MOSFET will work with the Arduino (3-5v), and I figured that using four of these in one h-bridge circuit would be okay - turn on the correct two N-MOSFETs and the other two off, and current should flow through the motor and power it.

I based my first schematic from an example H-Bridge my professor used:
**broken link removed**
 
Your professor didn't know that you were going to connect Vbattery to a voltage higher than the 5V supply that powers the Arduino, and it is obvious that he/she never tried to build the Hbridge with four NFETs..

If the upper devices are NFETs, to turn them on fully, their Gate has to be 3 to 5V more positive than their Source at 7V, so to develop the correct Vgs, there needs to be a third supply which is 7+3=10 to 12V. The Arduino pin cannot swing below 0V or any more positive than 5V, so you need an interface between 5V and 12V.

If the upper devices are PFETs, to turn them on fully, their Gate has to be 3 to 5V more negative than their Source at 7V, so to develop the correct Vgs, their Gates need to be pulled from 7V down to at least 4V or lower. Since the Arduino pin is at either 0V or 5V, you still need an interface...
 
Last edited:
But the N-MOSFET is specifically designed to allow voltage to flow through with just 5v from an Arduino.

From the comments on the product page:
"These mosfets are logic level mosfets and they have something similar to a charge pump built into them already, these will turn fully on when applying a 5v signal from a microcontroller."
 
That just describes what happens at the NFETs, where their source is connected to oV, the same oV as the Vss pin on the Arduino. The 0 to 5V swing of the Arduino pin, when connected to the Gate makes the Vgs either 0V or 5V, so everything is good.

Now you describe to me what happens if you connect the Source of the PFET to +7V. What voltages does its Gate have to swing to turn it on? To turn if off?

You still owe me a state table... This is homework to make up for the failings of your Professor.
I can ask for this; I am a retired Professor...
 
Last edited:
Ah, I see. Okay.

If I connect the Source of the PFET to +7V, its Gate needs a voltage of 0 (ground) to turn it on, and a voltage of 7v (Vcc) to turn it off.

When you use four pins to control the four FETs, how many total states are there?
- 24 total states (4! = 24)

Which ones will instantly blow up the FETs? - When two FETs on the same side are on at the same time

Which ones are useful to run the motor? - FETs diagonal from each other

Which are used to when braking a spinning motor? The two that were not used to spin the motor in that particular direction

Which ones let the motor coast? (I didn't really get this question) When they are all off after a motor spins

How do you apply PWM to control the speed of the motor? Digital writing with a value between 0-255 from the Arduino will change the duty cycle (PWM)
 
Last edited:
Good as far as you went. There are 2^4=16 total states.

I will return to this on Wed evening. Running for a flight now... Maybe one of the other experienced members can pick this up...
 
Ah, I just wrote out all the states possible, and it is 16. Not quite sure why I used a factorial.

But, okay! Thank you for all your help so far. I really do appreciate it.
 
Wh said factoral. It's 2^(n-1); where n is the number of bits. 2^(4-3) or 16. Or 4 bits can represent 0000 to 1111 or 0 to 15 which is 16 states.

Note: Fixed math
 
Last edited:
Have a look at the L6203 chip as this will do what you need. If you have to design one using mosfets then it's a lot more tricky than your lecturer has indicated.

Mike.
 
I was planning to buy this chip: https://www.sparkfun.com/products/9479

I'm probably going to end up not making my own H-Bridge circuit, as it's a huge headache.
I dont like that chip much. The voltage drops across the PNP and NPNs are such that if you start with a 7V motor supply, you will only get ~4.5V across the motor.

Here is useable (but not great) H-bridge that will work with the 5V Arduino. I would hook Porta and Portb to PWM-able pins. Since the Arduino PWM rate is only 500Hz, the losses (heating of the FETs) wont be too bad. Q1 and Q2 provide the requisite level shifting. When writing the code, watch out for all the non-allowed states... With a 7V motor supply, M1 through M4 should be suitable logic-level-gate FETs.

73.jpg


I recently made an Arduino-controlled reversing PWM-ed speed-control for a 12Vdc permanent-magnet motor. I used a DPDT relay controlled by a single Arduino port pin to do the reversing. I used a single Arduino PWM pin to drive a logic-Level NFET to do low-side switching of the motor current. Uses only two Arduino pins, and works fine. I can do forward-reverse, ramp speed up, ramp speed down, up to 5A. The motor gets like 11.8V from a 12V supply.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top