optocoupler to control solenoid

Thread Starter

anthonymac

Joined May 16, 2011
3
My background is in software. I have a solenoid with a coil that operates on 24VDC at no more than 10W so max current is 420mA. I would like to switch it on and off with a micro-controller so bought an mbed(ARM). Digital out is 3.3V when on. I found a "transistor as relay circuit" and read the description on how the transistor worked so I calculated the appropriate resistor values and was proud of myself. The solenoid/coil are about 12 feet from the desired location of the controller. I can see that distance being up to 100 feet. My plan is to have a 24VDC adapter located near the solenoid / coil and 2 wires between them (coil and adapter) and the controller. Although this may never be more than a "hobby" project, I would like to build to commercial specifications.

I e-mailed the schematic to a friend of a friend. He told me that I need an optocoupler, which before yesterday, I had never heard of. Would a 4n25 be a good place to start? Do I need any resistors on the diode side? If so what would be appropriate. In the Fairchild spec there is a graph with 10mA /1.2V somewhere in the middle; is that my target?

I don't really know what to do on the transistor side. I bet a reversed diode would still be used in to protect the transistor from kickback voltage. The original design used and PNP transistor and the 4n25 appears to use a PNP. I clearly need to do more research. Any help would be greatly appreciated.
 

GetDeviceInfo

Joined Jun 7, 2009
2,196
the 4n25 requires about 5ma to drive the optocoupler. See if your micro has the capability to sink that current, and calculate your resistor to obtain. Opto isolation is a good choice. You do require the diode for flyback. I haven't checked but I'm sure the 4n25 is NPN
 

Thread Starter

anthonymac

Joined May 16, 2011
3
This is an attempt to post my original schematic. It seemed natural to me to switch the high side. I will try to try to switch the low side just to see if I can figure out the resistor values etc. This might help me with my understanding of the optocoupler.

"the 4n25 appears to use a PNP" Oops, I did mean NPN.
 

Attachments

Last edited:

eblc1388

Joined Nov 28, 2008
1,542
Sticks with the high side switching design if you are using an optocoupler.

4N25 has a Vceo of only 30V and using it on +24V system would be pushing it a bit. You should consider a type of Opto with higher Vceo (~70V) like the CNY-17 series.

2N3906 is a bad choice as its collector current is about 100mA only. Your solenoid takes ~450mA.

For high side switching, looks for a PNP(not NPN) with more than 1A collector current.
 

Jaguarjoe

Joined Apr 7, 2010
767
A 3906 has max Ic of -200ma. It won't handle the 420ma solenoid. Generally, the max ratings for a device is on the front page of the datasheet.

For this circuit, the ground of the solenoid, the ground of the 4001 and the ground of the μC need to be all connected in common.

As it is, when DO1 is low about -5 ma of current will flow through the 4400Ω resistor and the B-E junction of the 3906 turning it on. Depending on the Beta of the transistor it will try to energise the solenoid. When DO1 is high not much changes so the 3906 never turns off. To turn it off, its base needs to be higher than about 23.4 volts so the B-E junction is no longer forward biased.
 

ErnieM

Joined Apr 24, 2011
8,377
As I don't see why you need isolation I'm going to ignore that <grin>

Here's how it could be done without any isolation; ground from adapter is connected to the ARM ground.



1N4001 is fine for the catch diode. The transistors could come from Radio Shack, any NPN for Q1 and something like their 276-2017 (TIP31) for Q2.

You should not need any heat sink.
 

eblc1388

Joined Nov 28, 2008
1,542
Rather than to use two transistors to make a darlington, just buy a darlington transistor instead.

The TIP131 is a NPN darlington.
 

SgtWookie

Joined Jul 17, 2007
22,230
ErnieM,
You don't have a base current limiting resistor for Q2, nor a base return resistor. The lack of the first will likely cause Q1 to overheat, and the lack of the base return resistor may cause Q2 to draw excessive collector current when it's supposed to be off.

Radio Shack doesn't carry the TIP131, but they do carry a TIP120, which is a Darlington transistor capable of sinking up to 5A continuous current (if properly heat-sinked).

6mA base current should be more than enough for your 450mA load current.
Note that the BE junction in the TIP120 will be the equivalent of two forward-biased diodes, or roughly 1.4v drop.

So, if you're powering the TIP120 base from your 3.3v Vcc supply, you'll need to use a (3.3v-1.4v)/20mA = 1.9/0.02 = 95 Ohm resistor (91 Ohms or 100 Ohms would be close enough) from either your micro-controller output to the base, or from Vcc to the 4N25's output transistors' collector; the output transistors' emitter goes to the TIP120's base.

If using the 4N25, you should also use a 1k resistor from the TIP120's base to ground; this will ensure that the Darlington turns off quickly when the optocoupler turns off.
 

ErnieM

Joined Apr 24, 2011
8,377
Good find, I was looking for a darlington for him at RS.

A resistor B-E is good, I did forget to add it. However, I don't know of any darlington that have a second series base resistor, as it is unnecessary.
 

SgtWookie

Joined Jul 17, 2007
22,230
]<snip>[/I]However, I don't know of any darlington that have a second series base resistor, as it is unnecessary.
My bad - I was somewhat distracted while looking at the schematic; missed the reverse-EMF diode, and had the impression that Q1's collector was connected directly to the 24v supply.

A 2N2222 is good for up to around 500mA (rated for 800ma, but Vce is really pretty high at that point) but would need 50mA base current.

I'm not real fond of Darlingtons anymore, as the saturation voltage is pretty high (~0.7v and up, depending on the Darlington in question and the collector current) but in this case it'll be around a volt, and ~500mW power dissipation in the Darlington. A heat sink would be a good idea.
 

Thread Starter

anthonymac

Joined May 16, 2011
3
Thanks everyone for your input. It has caused me to do some research and learn something. I have come up with a design that I like. I have split the design into 2 physically separate boards. I am putting an optocoupler on the 24V solenoid/coil board and the only thing coming from the microprocessor board are the 2 lines to turn on the LED part of the optocoupler. I will use a darlington with heat sink for the coil. This setup has a couple of advantages. If I want to use the same microprocessor board to drive a different device, then I just have to change the device board. Also if I want to put some AA batteries, a resistor and a dip switch on a mini controller board then I can manually control the solenoid while I continue developing my micro controller. The software is what I hope makes this project worthwhile. Wish me luck. I will continue to check this site for a while so please continue to comment. I will let you know if my design works or if I need some help trouble shooting. Unfortunately there are no more Radio Shacks in Canada so I will have to take a little hike to an Electronics warehouse in a nearby city sometime next week. Again, thanks for your help
 
Top