Go Down

Topic: MOSFET H-Bridge (Read 7310 times) previous topic - next topic

raschemmel

#15
Nov 24, 2014, 05:46 am Last Edit: Nov 24, 2014, 06:01 am by raschemmel
Correct:
Specifically, you should have a function called ON, and one called OFF, (or FORWARD, and REVERSE if it
is bi-directional , which is probably the case. The delay should be at the beginning of these routines before
the actual HIGH or LOW signal which drives the fets. Personnaly I would use boolean flags to monitor the
state of the fets and set a flag before the delay and clear that flag AFTER you turn it OFF.
ie:
If you have 4 routines;
1-FORWARD ON
2-REVERSE ON
3-FORWARD OFF
4-REVERSE  OFF

If you preceed either FORWARD or REVERSE with OFF, you can CLEAR the forward_flag AFTER the OFF
routine at the beginning of the REVERSE routine and CLEAR the reverse_flag at the end of the OFF at the
beginning of the FORWARD routine.

The sequence would then be:
CLEAR ALL FLAGS
forward_flag = false;
reverse flag = false;

FORWARD
if (reverse_flag == false)
[turn ON forward signal]
SET FORWARD FLAG
forward_flag = true;

FORWARD OFF
[turn OFF forward signal]
CLEAR FORWARD FLAG
forward_flag = false;


REVERSE
SET REVERSE FLAG
reverse_flag = true;
[turn on reverse signal]

REVERSE OFF
[turn OFF reverse signal]
CLEAR REVERSE FLAG
reverse_flag = false;

@Paul_B,
Since you are a real programmer as opposed to an amateur hack such as myself, how does the above sound ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

en28

raschemmel:

This looks good to me, though I may go a different route and just use _delay_ms() to add a delay every single time I switch, no matter what. Another question I have about the MOSFETs you recommended though: Looking at the datasheets it seems to me that the FETs won't be fully on at 5V from the microcontroller (the P-channel one especially). Does this increase resistance across the FET or decrease current? Are there any negatives to not having the FET fully on?

Paul__B

P-CHANNEL
You might consider using these.

N-CHANNEL
FQP30N06
The P-channel one looks almost plausible.

The FQP30N06 is no better than the IRF9510 first cited.

What delay are we talking about now?

As far as avoiding "shoot through", it would be sufficient to switch FETs  simply using different (separate) DigitalWrite instructions - as long as no smart-arse "optimiser" in the IDE decides "Oh, we could do all those operations in one go"!  But I do not think the optimisers here would do that.

raschemmel

#18
Nov 27, 2014, 02:54 pm Last Edit: Nov 27, 2014, 03:28 pm by raschemmel
The problem I see with the P-channel is that based on Fig-2, page-3 of the datasheet, you need -5V dc
to get 20A. The Gate Threshold Voltage is -2V to -4V. You would need a -5V dc supply (a two conductor
wall wart with floating output leads so you can connect the "+" to your GND so the output is -5V
with respect to GND. You could then use that as the -V supply for an op amp and use a Gain of 1 Inverting
amplifier to convert the Arduino HIGH from +5V dc to -5V dc. Your VD for the fets will of
course have to be a proper negative supply voltage that is the mirror image of your VD for
your N-channel fets. (-30V to -60V for the P-Channel mosfets, with respect to circuit GND). This can be
accomplished using the same method you use for the negative op amp supply, namely a floating (two wire)
wall wart with the positive lead connected to circuit GND.

Ideally , what you need is a level converter that converts 0V - 5V  to +5 - 5V range so the arduino LOW (0V) give +5V . The op amp inverter only converts +5V to -5V.  It does not convert the arduino logic LOW
from 0V to +5V.

ie:

UNO OUTPUT           P-CHANNEL OFF             P-CHANNEL ON
LOW=0v                                +5V
HIGH=+5V                                                                      -5V


To do this you need a GND, a +VDD and a -VDD
Arduino connects to only GND, and signal IN
P-CHANNEL GATE connects to signal out
+VDD is your system +5V dc
-VDD is your -5V obtained by using a floating 5V supply connect with POS lead to GND,
so the NEG lead reads -5V with respect to GND.

The voltage Level Converter would take the arduino 0 - 5V from a digital output pin and convert it
to +5 / -5V , with +5V being the output for a 0V in and -5V being the output for a +5V in.

TTL/CMOS level converters only convert 3V to 5V or vice versa so those won't work.
I know this kind of level converter can be done using an op amp comparator running on +5V/-5V.
The logic would reversed so instead of using a HIGH to turn ON the fet, you would output a LOW
which , if properly configured, would give a HIGH output of +5V from the Comparator.  A HIGH would
give -5V from the Comparator output.


Truth Table
Vref = 1V (arduino LOW is always LESS than 1 V, therefore Vref=1V distinguishes a LOW from a HIGH)

Vin < V ref => +5V
Vin > V ref =>  -5V

http://cornerstonerobotics.org/curriculum/lessons_year1/ER%20Week15,%20Comparators.pdf


I recommend the LT-1215 op amp but there are many other alternatives.

http://www.linear.com/product/LT1215
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

runaway_pancake

Quote
"The problem...with the P-channel is that based on Fig-2, page-3 of the datasheet, you need -5V dc
to get 20A." [and so on]
Schemmel, it's relative to the source potential (you should know this.)
If the P-channel source is at +V then it starts to turn on when its gate is less positive than the source (potential).
If the source is at +15V, then the P-FET is good and on when its gate is 5V less than that: when VG is +10 (with respect to Gnd.)
"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!

raschemmel

@Runaway Pancake,
Thanks for the clarification.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

polymorph

Hello all,

I need a little bit of help designing an H-Bridge Circuit for a 4-6V motor that draws max 140 +/- 50 mA at 6 VDC when operating in no load conditions.
This does not matter. What matters is the stall current. When the motor is first turned on, it is not moving, so the current will be quite a lot higher than the no load current. Or if the motor gets jammed for some reason, your H bridge must supply this current for an extended period.

You need to design for -this- current, not the no-load current.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

raschemmel

#22
Nov 29, 2014, 10:35 pm Last Edit: Nov 29, 2014, 10:36 pm by raschemmel
FYI, there is a way to limit the current. It's called FOLDBACK CURRENT LIMITING

Here

is an example of such a circuit for smaller currents.

I might get slammed for introducing such a topic to a noob but I'll live.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

polymorph

Foldback current limiting is going to possibly disturb operation of the circuit. It is more of a fault condition thing.

Regular current limiting might be better.

In any case, the OP needs to tell us the stall current of the motor.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

raschemmel

#24
Dec 03, 2014, 06:01 am Last Edit: Dec 03, 2014, 06:04 am by raschemmel
Yes. I would post your proposed software BEFORE running it with the mosfets and motor connected.
There are a hundred different ways to do simulations with electronic circuits. The simplest methodology is
to simply assume the worst case.
If I turn on the wrong outputs in the exactly the wrong way, how can I know without blowing anything up ?
Do you have any boolean logic experience. What logic expression (GATE) represents the following ?

IF A or B , is HIGH but NOT A AND B, the output will be HIGH.

?

if A is a signal meant for one of the two mosfets in series, and B is the signal meant to drive the other one
in series, if BOTH A & B are HIGH at the same time , will both mosfets turn on ?

This can be done in software.

Note- you are allowed to use resistors and leds when testing software. Also, you are allowed to SLOW THINGS DOOOWWWNNN.... so it is easier to see what is happening when you are testing logic. You can
then reduce your delay progressively if everything looks ok and eventually remove the series leds and
resistors you added to test your software.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

en28

Hi guys, I'm SO SORRY for not replying to this as I got a little caught up in the competition. Anyway, what I did finally end up doing was very very simple and I actually used the FETs suggested by raschemmel -- the FQP27P06 and the FQP30N06L. These FETs turned on at low gate voltage thresholds and the Arduino was more than enough for that. This:

ie:

UNO OUTPUT           P-CHANNEL OFF             P-CHANNEL ON
LOW=0v                                +5V
HIGH=+5V                                                                      -5V

was especially helpful (since I am a noob and didn't realize this at first), though in the end I did not use level shifters or op-amps as they were not needed. Also thanks to polymorph for pointing out that I needed stall current conditions.

In the end, my H-bridge simply consisted of 2 P-FETs on top and 2 N-FETs on the bottom. That was actually all that it took. Thanks for all your help!

polymorph

Thank you for letting us know that you found a resolution.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

raschemmel

Glad that worked out for you.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Go Up