Pages: 1 2 [3] 4   Go Down
Author Topic: help connecting Arduino UNO to n-ch MOSFET via Optocoupler  (Read 7208 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 78
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looking at your schematic in reply #7, it shows the mosfet drain and source terminals the wrong way round. But I think you must have wired them up the right way round, otherwise the solenoids would be permanently on.

What you need to do to get that circuit working is:

1. Connect a pulldown resistor between the gate terminal and the source terminal of each mosfet. 470 ohms is about the right value.

2. Do away with R4, you don't need it because you are supplying the optocouplers with only 7.5V and it will prevent enough voltage getting to the mosfets gates (once you have added the pulldown resistors). Connect the collectors of the opto isolators direct to +7.5V instead.

One problem with using opto isolators with mosfets is that opto isolators turn off quite slowly. This in turn means that the mosfets they are connected to turn off slowly, which causes them to dissipate more power. Probably not a problem if you are just turning the solenoids on and off, but a problem if you want to use PWM.

Like this?



How slow is that? Because true that I am only turning the solenoids on and off, but they have to be on for like only 80 millis, because I am striking the bells with them and if they are on too long then the bell sound gets dimmed (just remembered that now). I got this working without the optos, but it did not feel right since I read that if diode doesn't react quickly enough, some voltage might leak and slowly destroy Arduino Pins. Id rather see the optos destroyed, since they are so cheap. Even if all is ok, I want the optos just to be on the safe side. On the other hand, what is the alternative to optos, that turns off fast (enough), if I may ask? About power dissipation, they will not be on for longer periods, so that is not a problem for now. I have planned though to make another circuit for swinging the bells, which would use PWM to smooth out the edges when brushed motors reverses direction. The heat problem would start to pester me then, I would guess?
« Last Edit: December 16, 2012, 10:57:57 am by Terraviper-5 » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6619
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, like that.

The speed at which the opto turns off will be of the order of 100us or better, so fast enough for your application.

The 2.2K resistors connected between the opto isolators and the Arduino pins are too high in value. Try about 220 or 330 ohms instead. Before you connect the solenoids, check that when the Arduino output is HIGH, the mosfet gate voltage rises to around 7V, and drops to zero when the pin goes LOW again.
« Last Edit: December 16, 2012, 11:02:28 am by dc42 » Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 78
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wired up as you said, tested without Arduino (from 5V AC-DC adaptor), and it worked. Further testing will follow smiley-grin 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.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34183
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
God Member
*****
Karma: 4
Posts: 813
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 78
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 >.<

Quote
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.

Quote
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.

Quote
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: http://www.youtube.com/watch?v=7T6uwoXUbP8&feature=youtu.be
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34183
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
« Last Edit: December 16, 2012, 06:56:14 pm by Grumpy_Mike » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 78
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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

... 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

Quote
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.
Logged

Offline Offline
God Member
*****
Karma: 4
Posts: 813
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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: http://www.irf.com/product-info/cic/fsgatedriverics.html 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.

Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 78
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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: http://www.irf.com/product-info/cic/fsgatedriverics.html 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).

Quote
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?

Quote
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.

Quote
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?
« Last Edit: December 17, 2012, 04:57:12 pm by Terraviper-5 » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6619
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
God Member
*****
Karma: 4
Posts: 813
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Quote
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.

Quote
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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 78
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34183
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6619
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

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.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Pages: 1 2 [3] 4   Go Up
Jump to: