help connecting Arduino UNO to n-ch MOSFET via Optocoupler

Wired up as you said, tested without Arduino (from 5V AC-DC adaptor), and it worked. Further testing will follow :smiley: Thank you, sir! Will have to measure current at FET base, as you said, tomorrow.
What I still dont understand is how doesnt power from one optocoupler go through the pulldown resistor onto negative lead and then leak in on other pulldown resistor and activate the other FET.

What I still dont understand is how doesnt power from one optocoupler go through the pulldown resistor onto negative lead and then leak in on other pulldown resistor and activate the other FET.

Because once the current is at the negative lead it is home, it won't go anywhere else but into the battery. This is because it can only flow where there is a voltage difference to drive it.

Terraviper-5:

Grumpy_Mike:
I mean:-
The emitters of the optos should be connected to ground, the -ve of your 24V source and the FET gates should be connected to the collector of the FETs.

Oh, now I get it (I read the sentence wrong). Do you mean like this?

Not at all like that. You are grounding your gates; there is no chance those FETs will turn on.

Also, there is no such thing as a "collector" of a FET. There are collectors on BJTs, and on phototransistors.

Each of the FET gates should have a resistor going to ground, and the phototransistor going to control voltage. That means that, with no photo action, the gates are pulled to the ground, and the FETs are not conducting. When the phototransistor is conducting, there will be voltage pulled up to positive. Exactly how much depends on the resistance of the phototransistor and of the pull-down resistor. I would try a 1 kOhm pull-down and see how that goes. As long as you don't drive these guys at PWM rates (just on/off,) that'll probably be fine.

Edit: I see on the next page you actually got it right with the revision.

jwatte:
Not at all like that. You are grounding your gates; there is no chance those FETs will turn on.

Ofcourse, facepalm, how could i be so stupid >.<

Also, there is no such thing as a "collector" of a FET. There are collectors on BJTs, and on phototransistors.

Yes, that's whats been bothering me. I did not know what exactly grumpy_mike meant with collector, so I looked on Wiki and saw that its the drain.

I would try a 1 kOhm pull-down and see how that goes.

Then the resistors Im currently using could be too low value? I calculated I = 7.5/470 and it comes out around 20 mA.

As long as you don't drive these guys at PWM rates (just on/off,) that'll probably be fine.

And what could I do to also allow PWM? Cooler or some better component?

This is the latest version: (if anyone will be reading this thread in the future). If any mistakes show up, I will update.

And here is a video: Mini bell striking system - YouTube

I did not know what exactly grumpy_mike meant with collector, so I looked on Wiki and saw that its the drain.

Wehe I said the collector I meant the collector. There is only one component with a collector and that is the output of the opto isolator.

If you are determine to miss represent what I said I am out of here.

Grumpy_Mike:

I did not know what exactly grumpy_mike meant with collector, so I looked on Wiki and saw that its the drain.

Wehe I said the collector I meant the collector. There is only one component with a collector and that is the output of the opto isolator.

If you are determine to miss represent what I said I am out of here.

Sorry Sir, I meant no disrespect, but you said

Grumpy_Mike:
... and the FET gates should be connected to the collector of the FETs.

and I wasnt sure what the collector was at FETs, so I went on Wiki and saw

All FETs have source, drain, and gate terminals that correspond roughly to the emitter, collector, and base of BJTs.

so I assumed that collector was the drain. Nothing else. Sorry if I said something wrong. Its quite possible that I only understood the sentence wrong.

And what could I do to also allow PWM? Cooler or some better component?

The danger with your pull-down resistor being as low as 470 ohm is that the optocoupler may not be able to pull the gate high enough to fully turn on the MOSFET. There are two concerns with driving MOSFETs for high power:

  1. Get a high enough gate voltage to drive it all the way on. This is often a voltage that's twice the rated "Vgs threshold" voltage -- 10V is not uncommon. 7.5V can do it for many devices, too.
  2. Get enough current to turn it on quickly. You want ideally several amperes for a handful of nanoseconds in the really high-power cases. Working with milliamperes means it will take much longer to turn on the device, which is still often OK, as long as your duty cycle is long (so, no PWM in that case.)

The problem is that the photo transistors aren't high-current drivers. If you want to drive heavy loads with PWM, you want a dedicated MOSFET gate driver circuit, such as the International Rectifier series: International Rectifier - Product Information Power Integrated Circuits or ST microelectronics: http://www.digikey.com/product-detail/en/TD351IN/497-4440-5-ND/725331
Note that those drivers, in turn, ONLY allow PWM; they don't work well with prolonged 100% on cycles, because of the way the gate boost capacitor works.
Sadly, most of these chips are going obsolete, because power switching is going all surface mount and integrated controllers now. Something like the FAN7390N would make a nice driver chip, too.

The driver chips can replace both your opto coupler and your pull-down resistor.

jwatte:

And what could I do to also allow PWM? Cooler or some better component?

The danger with your pull-down resistor being as low as 470 ohm is that the optocoupler may not be able to pull the gate high enough to fully turn on the MOSFET. There are two concerns with driving MOSFETs for high power:

  1. Get a high enough gate voltage to drive it all the way on. This is often a voltage that's twice the rated "Vgs threshold" voltage -- 10V is not uncommon. 7.5V can do it for many devices, too.
  2. Get enough current to turn it on quickly. You want ideally several amperes for a handful of nanoseconds in the really high-power cases. Working with milliamperes means it will take much longer to turn on the device, which is still often OK, as long as your duty cycle is long (so, no PWM in that case.)

The problem is that the photo transistors aren't high-current drivers. If you want to drive heavy loads with PWM, you want a dedicated MOSFET gate driver circuit, such as the International Rectifier series: International Rectifier - Product Information Power Integrated Circuits or ST microelectronics: http://www.digikey.com/product-detail/en/TD351IN/497-4440-5-ND/725331
Note that those drivers, in turn, ONLY allow PWM; they don't work well with prolonged 100% on cycles, because of the way the gate boost capacitor works.
Sadly, most of these chips are going obsolete, because power switching is going all surface mount and integrated controllers now. Something like the FAN7390N would make a nice driver chip, too.

The driver chips can replace both your opto coupler and your pull-down resistor.

Thank you for those insights, I will surely consider them next time I'm building something.

I can easily boost the voltage from 7.5 V to 9 V or 12 V. That would raise current from 16 mA to 19 mA or 25.5 mA, still well within range of 50 mA,

which is max. Of course I would have to account for voltage fluctuations from the adaptor, since those loads are very small, but that shouldn't raise the current to more than 32 mA (with those resistors).

The danger with your pull-down resistor being as low as 470 ohm is that the optocoupler may not be able to pull the gate high enough to fully turn on the MOSFET.

But isn't lower resistor -> more current -> better switching? Please, correct my logic. Or did you mean low current?

You want ideally several amperes for a handful of nanoseconds in the really high-power cases.

Wow, that's is high. Then again, when I checked the specs I was surprised when I saw

that allowed Gate -> Source current was 62 A.

Note that those drivers, in turn, ONLY allow PWM; they don't work well with prolonged 100% on cycles, because of the way the gate boost capacitor works.

If drivers cant work 100% on cycles and optocouplers are too slow for PWM, is there any way to have both, PWM and 100% on cycles?

  1. How much current do your solenoids take?

  2. Which optocoupler are you using?

Depending on the answers, you may be able to use low-frequency PWM (e.g. at the Arduino default frequency of 490Hz) in that circuit as it is, or by changing a few component values.

Other alternatives are:

  1. Do away with the opto isolators, if a common ground between the Arduino and the 24V supply is acceptable. You can drive a logic level power mosfets from an Arduino output pin through a 100 ohm resistor. This is OK for low-frequency PWM if the power being switched is not too high.

  2. Use a TC4420 or TC4429 mosfet driver between the opto isolator and the mosfet gate. These can provide 6A peak gate current, and work with or without PWM.

that allowed Gate -> Source current was 62 A.

That's allowable Drain -> Source current, with the stipulation that the Gate/Source voltage is 10 V. This tells me that a 5V driver will not "open" the MOSFET fully, and you will see a higher Rdson than the specified value. That being said, if your solenoids are just drawing a few amps, that probably doesn't matter much.

But isn't lower resistor -> more current -> better switching? Please, correct my logic. Or did you mean low current?

You need both high current AND high voltage, and the high voltage is more important than the high current for large loads, whereas the high current is needed for quickly switching on/off.

If drivers cant work 100% on cycles and optocouplers are too slow for PWM, is there any way to have both, PWM and 100% on cycles?

There are drivers that can work 100%, as long as they are only used as low-side drivers. Looking at your schematic again, I think that's what you're doing, so I think you're good, as long as the 7.5V can be used as your gate voltage.
The kind of driver I'm talking about can generate a higher gate voltage (even higher than your VDD!) by charging a capacitor, but that capacitor slowly discharges and thus it needs the down-cycle to re-charge.

Okay I have now tested the circuit operation for a month and established that it works. Now I want to move it from a protoboard onto perfboard and since Im going to permanently solder it together, I came across a few things that I might be able to improve before doing that.
First, I saw that h-bridges have capacitors on them to smooth out voltage spikes caused by the motor. Its usually 10uF caps. From what I have seen, none of the solenoid driver examples for Arduino I find online have them. Is there any special reason for that or is it left out to leave the example circuit as simple as possible?
Second thing, I want to get rid of the additional power supply (7.5 V) because its very impractial for such a simple circuit to require two adaptors. With Arduino, they need three: 5V, 7.5V and 24V. Here I bump onto a problem: The max gate voltage for FET is +- 20 V (and this goes for most FETs I find in stores), so I cant directly use the 24V power supply for switching. The optoisolators have max collector-emmiter voltage 80, so they dont have a problem with this. What can I do to be able to use the power supply for solenoid also for switching the FET? Voltage regulator? Any ideas? What is usual practice for this kind of things?

Supply decoupling in the form of capacitors is always a good idea
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

Replace the 7.5V supply with the 24V one and have a separate resistor of 1K going from each opto collector to the +24V. In that way then the opto is turned on the FET only gets a proportion of the 24V determined by 1K and 470R in a potential divider.

Terraviper-5:
First, I saw that h-bridges have capacitors on them to smooth out voltage spikes caused by the motor. Its usually 10uF caps. From what I have seen, none of the solenoid driver examples for Arduino I find online have them. Is there any special reason for that or is it left out to leave the example circuit as simple as possible?

If you mean capacitors between the positive supply and ground, then yes, this is a good idea. These capacitors are usually much larger than 10uF, more like 1000uF.

Terraviper-5:
Second thing, I want to get rid of the additional power supply (7.5 V) because its very impractial for such a simple circuit to require two adaptors. With Arduino, they need three: 5V, 7.5V and 24V. Here I bump onto a problem: The max gate voltage for FET is +- 20 V (and this goes for most FETs I find in stores), so I cant directly use the 24V power supply for switching. The optoisolators have max collector-emmiter voltage 80, so they dont have a problem with this. What can I do to be able to use the power supply for solenoid also for switching the FET?

If you are using the schematic you posted earlier (i.e. opto isolators driving the mosfets, with 470 ohm pulldown resistors), then all you need to do is connect 680 ohm resistors in series with each opto isolator output. These, in conjunction with the 470 ohm pulldown resistors, will create voltage dividers that reduce the gate voltage from 24V to about 10V.

Thank you both! Please tell me if I put it right (I omitted the other two instances because I will solder each separately so that if there comes a need to add another solenoid I will just solder up another one):

Could you please tell me how to calculate the voltage at the gate? I was thinking, if I at any time later for any reason wish to use this driver for, example, 12 V motor, the gate voltage will also drop, yes? To about 5-6 V? This means I can only use 12 - 24 V motors here? How are drivers usually designed so that they can be used for as wide voltage range as possible? (I hope I am not asking too much).

The 470uF andf 0.1uF capacitors are in the wrong place. They need to be connected directly across the 24V supply (but physically close to the mosfet). Otherwise, the schematic is OK.

Unless you are using fast PWM, the diodes in parallel with the solenoids do not need to be Schottky diodes - ordinary silicon rectifier diodes will do.

You do draw your schematics in a very odd way.
I would connect those capacitors across the supply not the solenoid.

if I at any time later for any reason wish to use this driver for, example, 12 V motor, the gate voltage will also drop, yes?

Yes.

How are drivers usually designed so that they can be used for as wide voltage range as possible?

They are more complicated with a regulator giving you that extra voltage source you had in the first place.

Grumpy_Mike:
You do draw your schematics in a very odd way.

Yeah, its about time I read some tutorial on how to make schematics.

Anyways, I have read around a little bit, found out that multiple smaller caps are better than one big.

Also, if I leave the circuit online 24/7, the caps will be charged all the time even if they are only used for small fraction of that time. Will because of that their life expectancy be smaller? Should I add another FET that will block the entire power supply when its not needed? (sorry if the question sounds stupid, Im later planning on building a h-bridge and am accumulating knowledge for later also)

There is nothing wrong with the capacitor values, it is just that you have them in the wrong place.

Terraviper-5:

Grumpy_Mike:
You do draw your schematics in a very odd way.

Yeah, its about time I read some tutorial on how to make schematics.

Anyways, I have read around a little bit, found out that multiple smaller caps are better than one big.

Also, if I leave the circuit online 24/7, the caps will be charged all the time even if they are only used for small fraction of that time. Will because of that their life expectancy be smaller? Should I add another FET that will block the entire power supply when its not needed? (sorry if the question sounds stupid, Im later planning on building a h-bridge and am accumulating knowledge for later also)

That can be the case when the cap is being used to bypass noise to ground for sensitive loads, but your solenoid does not give a hoot about what little extra noise that smaller cap might be bypassing to ground. The big cap is just to have a little extra initial current available to drive the solenoid load on, in case the power supply is not a 'stiff' one. In simple passive loads like a solenoid you don't even require a regulated power supply, just filtered with enough current capacity to handle the solenoid load. But yes move the cap(s) to be across the PS +/-.

Lefty