Go Down

Topic: help connecting Arduino UNO to n-ch MOSFET via Optocoupler (Read 8886 times) previous topic - next topic

dhenry

You should look at the datasheet for your device.

Generally, the If specification is between 5ma - 20ma - I typically do 10ma to maximize ctr. Your runs at ~20ma, so it is properly done.

The phototransistor side is not. The ctr is generally 50 - 150%, and I typically design for 50%. That means your phototransistor side's Ic is about 10ma - likely lower with earlier opto-couplers. At 10ma, your Vgs, fully on, is about 7v - not bad but not great either.

Outputting on the emitter is not common: it is often done for speed or to reduce ctr. Most of the times, the output is done on the collector - it produces sharper on/off behaviors. If you look at your datasheet, it shows that as well.

I would put the opto-coupler on the bottom and use a zener to protect the gate.

dhenry

I put this simulation together to get you a comparison between two approaches to switching.

The plot is about power dissipation on the mosfet, switching a 12amp / 24v load.

The emitter output approach dissipates about 14w over the mosfet 50% of the time. The collector approach dissipates 14w for about 2.5% of the time. That means that you can run the mosfet (to220) without heat sink in the 2nd approach but not the 1st approach.

So try not to output on the emitter.

Terraviper-5

#17
Dec 15, 2012, 09:10 pm Last Edit: Dec 15, 2012, 09:13 pm by Terraviper-5 Reason: 1
Thank you for explanation.
Sorry it took me so long to answer, I have been very busy and did not have much time for this project. Now I have assembled this:


But I still got problems: To test the circuit before I connect Arduino to it, I connected a 5V power supply where Arduino pins should be. It activated the motors, but when I disconnected, the motors were still on. They were also still on if I disconnected the main power and then reconnected it. Only after disconnecting the MOSFETs from Optocouplers did the solenoids return to off-state. Im probably missing something important that I do not see because Im a newb. I again ask for your help!

PS: I know that I should put separate resistors for each OC, but they will not be all online at the same time.

Thank you!

Grumpy_Mike

What a very confusing way to draw a schematic.

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.

Terraviper-5

#19
Dec 15, 2012, 11:23 pm Last Edit: Dec 16, 2012, 12:13 am by Terraviper-5 Reason: 1

What a very confusing way to draw a schematic.


Sorry, I have made very few schematics and am still learning how to make them better.

Quote

The emitters of the optos should be connected to ground


Do you mean to the - of the 24V? But that makes all three optos connected, if one opens all three FETs open.

Quote

the -ve of your 24V source and the FET gates should be connected to the collector of the FETs.


Isnt the FET gate same as opto's emitter, since the two are connected?
Do you mean drain by collector?

dhenry

Quote
But I still got problems:


I think you may save a lot of time / money by buying a ready-made board.

Terraviper-5

#21
Dec 16, 2012, 12:18 am Last Edit: Dec 16, 2012, 12:26 am by Terraviper-5 Reason: 1

Quote
But I still got problems:


I think you may save a lot of time / money by buying a ready-made board.



But then I wouldn't learn anything :\ And I already bought all the components :( True though, this thing is taking far too long.
I successfully made it without the optos, im having trouble now when Im trying to add them with a separate power supply since 24 V is too much for the FET's (which have max 20V).
A pre-made boards like Arduino Motor Shield R3 usually have only two outputs, and I need three. If I bought two of these, it would cost me 45 € + shipping, while these components cost me 10 € max. Sure I could probably find one with more outputs, but shipping would still be the problem (as its expensive and I cant get those things in my country).

I cant believe that I have so much trouble assembling such a simple circuit...

Runaway Pancake

Quote
"I cant believe that I have so much trouble assembling such a simple circuit..."


It's always a deceptively easy looking prospect.  (:
"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

dhenry

Quote
But then I wouldn't learn anything


Sure.

Try this:

from the mcu pin: use a small value resistor (330 or 390 ohm for example) to the opto's anode. its cathode to ground.
on the opto's phototransistor side: a 1k resistor from the 7v source to the phototransistor's collector. Its emitter to ground.
the mosfet: its gate to the phototransistor's collector. Its source to ground. Its drain to the load, parallel'd by a diode (pay attention to the polarity). The other end of the load to the 24v source.

If you cannot make that out or make it work, you should just buy a ready-made board.

dhenry

Note: depending on the load and diode used, such an arrangement will have a lot of rf noises. I would put a bead on the mosfet's drain.

Grumpy_Mike

Quote
Isnt the FET gate same as opto's emitter, since the two are connected?
Do you mean drain by collector?

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.

Quote
Do you mean to the - of the 24V?

Yes.
Quote
But that makes all three optos connected, if one opens all three FETs open.

No. Each FET gate should be connected to the collector. Each emitter should be connected to the same ground.

The circuit as you drew it is just not going to work. Transistors work with current flow, there is no where for the current to flow if you connect the emitter directly to the FET's gate because a FET has such a high input impedance.

Please ignore dhenry he is our resident idiot.

jwatte

Quote
Transistors work with current flow


This is kind-of ambiguous, because every component "works with" current flow of some sort, or it wouldn't be a very useful component. I think I know what you meant, but someone new to electronics might not.

This is basic stuff. I feel it will help anyone who's not yet clear on it and reads this thread:

BJTs (NPN and PNP transistors) work such that the flow through Collector-Emitter is proportional to flow through Base times the amplification factor, with polarity depending on the type. Thus, a BJT transistor needs current flowing through the base to let current flow through the controlled path.

FETs (N-channel and P-channel transistors) work such that flow through Source-Drain is proportional to the charge built up between the gate and the source. The gate is like a capacitor, so while a small amount of current will flow into it to build up that charge, no current will flow through the gate once it's built up, and the MOSFET will still conduct. The only reason to keep the gate voltage on is to replenish leakage current from the gate. This is also why disconnected (floating) MOSFET gates may stay turned on after disconnection, or even spuriously turn on, or off, if there is not enough impedance to either gate voltage or ground.

This is also why it's OK-ish to leave a BJT base floating when you're not driving it -- no current flows, so it will not conduct. But for a FET, that's not true. You must make it so that the gate is ALWAYS connected to either a voltage, or ground. Typically, you do this through a pull-up or pull-down, depending on what you want the default condition to be.

For an opto-coupler that pulls the gate up to turn it on (N-channel FET) you need to also keep a pull-down to ground to the gate, so that the gate turns off when the opto-coupler is not transmitting current. Perhaps a 2 kOhm pull-down will be sufficient, if you're not trying to switch the FETs at too high an on/off frequency.

Grumpy_Mike

Quote
This is kind-of ambiguous, because every component "works with" current flow

No a FET as you point out works on voltage, there is no current involved in making it work. Leakage current is just that: current that leaks, it is not current that makes it work.

Terraviper-5

#28
Dec 16, 2012, 02:27 pm Last Edit: Dec 16, 2012, 02:31 pm by Terraviper-5 Reason: 1

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?



Quote

The circuit as you drew it is just not going to work. Transistors work with current flow, there is no where for the current to flow if you connect the emitter directly to the FET's gate because a FET has such a high input impedance.


I though that if I connect a 7.5 V power supply through the optos and to the gates of FETs, the optos will block the path when they are off, and when they are on, they will let the current through and to the gates of the FETs, which will then turn on. At first I though about using the 24V supply for this too, but then I saw the limit on the FETs : +-20V absolute max.
Probably stupid thinking, seemed logical to me though since I know very little about electronics (for now).


The gate is like a capacitor, so while a small amount of current will flow into it to build up that charge, no current will flow through the gate once it's built up, and the MOSFET will still conduct.


Ohh, so thats why the solenoids stayed on (when I reconnected the pwr, ofc) even if I turned off the power and then turned it on again.

Quote

For an opto-coupler that pulls the gate up to turn it on (N-channel FET) you need to also keep a pull-down to ground to the gate, so that the gate turns off when the opto-coupler is not transmitting current. Perhaps a 2 kOhm pull-down will be sufficient, if you're not trying to switch the FETs at too high an on/off frequency.


Im actually not sure if my optos are pullup or pulldown. I didnt know where I can get this information. grumpy_mike mentioned they are pulldown on previous page

No prob about the frequency, they will work slowly :)

So basically, I add a connection between the gate of FET and -ve of 24V source (trough 2kOhm resistor)? Wont that transmit power to all other FETs as well, so when one is open, all are open?


The transistor in an opto coupler can only pull down, so there is nothing to supply the voltage to the FETs gate.


That means they are actually inverse of what I need?

dc42

#29
Dec 16, 2012, 02:45 pm Last Edit: Dec 16, 2012, 02:47 pm by dc42 Reason: 1
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.
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.

Go Up