Relay circuit with optocoupler driven by Prop I/O
doggiedoc
Posts: 2,243
I've been "cog"jugating some ideas in my head that use A/C motors so today I experimented with controlling an A/C device with a Propeller.
I came up with an opto-isolated relay to turn a lamp on and off as an experiment. Here is the circuit:
Should I add resistors or diodes anywhere. It works fine as drawn but I've seen other similar circuits with pull up or pull down resistors and/or protection diodes. Are these needed and if so where.
Thanks in advance,
Paul
PS - before some of you guys rip me a new one, remember this is how I learn.
I came up with an opto-isolated relay to turn a lamp on and off as an experiment. Here is the circuit:
Should I add resistors or diodes anywhere. It works fine as drawn but I've seen other similar circuits with pull up or pull down resistors and/or protection diodes. Are these needed and if so where.
Thanks in advance,
Paul
PS - before some of you guys rip me a new one, remember this is how I learn.
Comments
See attached.
PE - Don't get me wrong, you can run with scissors, stick a pencil in your ear, stuff peanuts up your nose, take out your own appendix...
If the unknowing see relay coils in the emitter leg of an "opto" then they'll want to put them in the emitter leg of a transistor, too. They'll do so without regard to the coil voltage.
In a "non-opto" transistor circuit, V_e is V_b - 0.7V; in the case of a Propeller V_e will then be appx 2.5V, it won't work and they'll marvel as to why (why?). V_e must be at least V_coil(min). If it's a 5V coil or a 9V coil or a 12V coil then it's not going to happen with the load in the emitter.
So, I will teach with the coil in the collector leg always, fewer problems for "tinkerers."
Relays are "isolated" anyway. The contacts are away, separate from the coil/s, especially if/when they have UL approval. I don't get the obsession with "optos" and "isolation" and "protection"; it's like a lot of stuff around here, superstitious behaviour.
PE -- I'm "talking" NPN.
Is everything working now, however?
PE - Providing your phototransistor is OK with the relay current, then that's a wrap.
Thanks again!
I soldered it all together earlier on a proto-board and its driving a compact fluorescent bulb off and on with no "apparent" issues.
If you want to try it with a NPN, and I encourage you to do so, please note the attached circuit.
Consider what happens if the transistor driving the relay should short out. You now have the output driving that transistor connected to +12V through a low value resistor. If you have a 1K or larger resistor between the prop pin and the base of the transistor the prop should survive....probably. What if that is a 24V or 48V relay? What happens if the 12/24/48V regulator shorts and applies a considerably higher voltage to the relay coil?
Does that make sense?
There's no opto-isolation in a ULN-2803, an industry stalwart, open-collector outputs all the way, just as in the example I provided using a discrete transistor. I guess those should all be trashed; no opto-isolation, inferior, not dummy-proof, not radiation-hardened, not approved for medical, 4kV isn't 10kV isn't 100kV, man the life-boats, women and children first, klang-klang-klang!!
You WIN, kwinn !
Everyone has a 'preferred' approach. And they are always ready to provide a complete run down, as to 'why' their method is 'preferred'.
In that case, you just order another propeller. After the smoke clears.
... Tim
What I meant was that when the optos LED is on the transistor is conducting. The only limit to the current is the resistance of the coil. So presumably one has to be sure the resistance of the coil is enough to limit the current and avoid burning the optos transistor.
Previous posts were discussing individual transistors not ULN chips, which do have internal circuitry that provides a degree of protection. They are popular chips and have many uses in all the areas you mention and more. Opto isolators do provide more protection and permit you to isolate both the ground and power sides of the drive circuitry from each other when that is necessary. Which one you choose to use depends on the requirements of that particular application. It is not however a matter of obsession or superstitious behavior.
Yes, the coil current must be low enough for the opto transistor to handle. For relays that require more current than the opto transistor can provide an additional drive transistor is added. The opto transistor and drive transistor are often connected as a darlington pair. As always, a suitable diode is connected across the relay coil.
1) Outputs from an 8055 PIO card in a PC.
2) Shielded cable from PC 8055 card connector to a board containing a back of opto isolators.
3) Opto isolators output switching current to another back of optos.
4) Second back of optos driving some equipment.
5) Power for LEDS in between the two opto banks coming from a battery.
6) Power for the equipment from a bench power supply.
7) Ended up running the PC from batteries in an UPS to ensure there is no common ground between PC and the equipment.
Result, turn the bench power supply on and off and often the 8055 in the PC would reset, outputs becoming inputs.
We never figured out how to prevent that behaviour.
Are you making this up as you go along or what?
Again, there's no separate ground situation per the OP. Do you get that?
When people run optos' LEDs off microcontroller pins without limiting resistors, their worry being "protection" and/or "isolation", as I've seen often round these parts, then it IS obsession and superstition.
You offered no opto-isolation advise for the other genius who finally decided that he would run his LED backlight from 8 unused Propeller pins.
Opto isolation is not a panacea. If the rest of the circuitry has common connections they may not be any help. I had a bone densitometer that would very intermittently (once every 2-3 weeks) show a hole in a patients spine or pelvis. The data acquisition and high powered imaging electronics were isolated by opto isolators. Even after replacing all the electronics, the computer, and the detector the problem was still there. Even the UPS did not help. After many months I eventually found the cause. It was an old infrequently used X-ray machine two floors down in the opposite corner of the building. When it was powered up the high voltage was set by a mechanical rotary switch that produced huge noise spikes on the AC power lines. They were big enough to to get through the UPS transformer/filters/inverter, and the densitometer transformer/filter/regulator to show up as X-ray pulses in the electronics. Since bone absorbs X-rays these pulses showed up as holes in the bone image.
Blue LEDs have considerably more forward voltage than the silicon IR LEDs.
I just measured this with my test StickProp computer running at 3.335V.
Directly connecting the BLUE LED to an OUTA pin the voltage is 2.956V at 10.4mA.
This is well within the pin output current specification.
Second I measured the companion BLUE LED.
The open circuit voltage is 2.207V.
The short circuit current is about 1uA.
Now directly drive an IRF3708 MOSFET gate with the BLUE LED and a 10MO resister
across it to tutn it off.
http://www.redrok.com/MOSFET_IRF3708_30V_62A_12mO_Vth2.0_TO-220.pdf
The on resistance of this MOSFET driven this way is about 37mO and can drive
about 7A while dissipating about 2W which shouldn't require a heat sink.
Duane
If you are referring to:
“Previous posts were discussing individual transistors not ULN chips, which do have internal circuitry that provides a degree of protection.”
I was referring to the 2.7K resistor and the transistor between the output transistor as shown on the ULN 2803 data sheet. If the output transistor shorts they may offer some protection.
I understand that in this particular instance there is no separate ground. I am referring to the use of opto isolators in general while you are referring to the specific circuit in this thread. Calling the use of opto isolators “obsession and superstition” is a pretty general statement.
Let me state it clearly. No, in the case of this circuit an opto isolator is not required. I will also state that No, there is no reason other than extra cost for not using one.
As I said in my first post, I agree with pretty much everything posted here (to that point) except the "I don't get the obsession with "optos" and "isolation" and "protection"; it's like a lot of stuff around here, superstitious behaviour." Since your first post covered the current limiting resistor and diode I felt no need to mention it again.
I take it you are referring to the “PWM to control LED brightness & contrast” thread started by Cluso99. In that particular case there was no need for an optical isolator since he was going to be using the Vcc voltage and the power was relatively low. As for him being a genius and deciding to run his backlight from 8 unused prop pins, after reading so many his posts and replies I have a lot of respect for him, and taking advantage of unused pins rather than putting additional hardware on the board seems like a reasonable approach to me.
I would suggest you read his post from yesterday at 9:03pm.
True, and sometimes discussing the why gives you a better insight into the use of that approach.
I prefer to replace the cheaper opto isolator rather than have to reprogram and replace the prop, and possibly a lot of other circuitry like the eeprom, regulators, etc.
Opto isolators can also make some designs much easier and more flexible as well.
Doing a thing based on faith, or on the basis of not understanding, is superstition.
Your arguments are evasions. You introduce non-existent situations as a basis for objections.
Scouring a datasheet and coming up with some wagon-load that an internal bias resistor "may introduce some protection" is meaningless, more grasping at straws.
Myriad layers of delusional fail-safes and imagined stop-gaps amounting to nothing.
A relay coil is isolated from its switch contacts.
The prevalent willy-nilly implementation of opto-isolators, as though they were some sort of magic pills that counter the consequences of staggering foolishness and mishaps real or imagined, is obsessive and/or superstitious.