Pages: [1] 2   Go Down
Author Topic: Designing optocoupler circuit for arduino input  (Read 5477 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm designing an optocoupler circuit whose output will be give to one of the arduino input pins. I need to know for what IC current of the optocoupler I need to design the circuit. I'm concerned with the power loss and want to keep it as min as possible.

I'm using 4n35 Optocoupler.

Here's the signal flow,
230V -> Bridge rectifier + Filter -> R + R + optocoupler Input -> optocoupler output (CTR = 1) ->Arduino

Intially I thought of using 10mA as IC = IF which gives me 230V/10m=23kohm (12k + 12k standard)
But this gives me an I2 loss of 1.2 + 1.2 Watts

In case I use 1mA as IC = IF, I need a resistor of 230k (120k + 120k standard)
with a power loss of 0.1 + 0.1 Watts

1. How low current can I use? (Mainly to decide R1)

2. I don't think this current affects the arduino and it is concerned with the optocoupler. If I use the circuit below, then what VCC and resistor value R2 should I use?

Logged

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12092
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think fairly low currents can be used - this is something to test with a low voltage circuit first, but
a larger collector resistor for the phototransistor will be needed for lower currents - eventually
noise will become a problem which lower currents and higher resistances, and you will need to
debounce the input to the Arduino (or use a schmitt-trigger gate to clean up the output from
the opto-isolator) - mains waveforms are too slowly varying to drive logic inputs cleanly.

By the way on the mains side you need to use proper high-voltage design (no live conductors
exposed to the touch, plenty of space between traces, and the resistor on the input to the
photo isolator will need to be rated for high voltage (in fact use two in series to reduce the
risk of disaster should one resistor fail).
Logged

[ I won't respond to messages, use the forum please ]

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 46
Posts: 2883
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That is not a great idea... it looks good on paper BUT Line transients can kill the opto, I've tried it and every easy protection method with very little success. Over time Every opto-isolator I used died. The trick to success is to use a neon light and an LDR shielded from ambient light. For 230 V mains power I would use a 220K  series resistor and an NE2H neon light to control an LDR.

Bob
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Need to do some thinking.

Any specific method to couple Ne2H and the LDR? Any special care to be taken?

Logged

Berlin / Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I suggest, to use an additional capacitor in series with the resistor, that limits the current as well, but it does not produce as much heat. It does not just convert current to heat loss. The impedance [ohms] you can calculate with 1/(2*Pi*50*C). Some 100 nF should do. To protect the opto you just insert a Zener in parallel to the opto-LED. There are special surge supressor diodes for this usage. Your dealer should be able to help to find the right one. For a quick'n'dirty solution you could also use 3 or 4 normal diodes in series, and this (in forward direction) in parallel to the opto input.

Be careful!
Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 46
Posts: 2883
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I used black heatshrink tubing. It worked well. The only thing to take care for is that it not leak any light and an ohm-meter will tell you when the LDR is light tight.

Bob
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
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

I'd go with the circuit you originally intended, but I'd put the bridge rectifier after the resistors, design for 1mA, and use several resistors in series. Choose resistors with a high voltage rating - metal film are usually higher than carbon film. For example 4 resistors, each rated 500V or more. That way, the circuit should be able to cope with large transients.
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
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you all for your replies.

I believe capacitor in series with the resistors are used since they resist change in voltage and this may limit  transient voltage to some limit.

Quote
To protect the opto you just insert a Zener in parallel to the opto-LED. There are special surge supressor diodes for this usage. Your dealer should be able to help to find the right one. For a quick'n'dirty solution you could also use 3 or 4 normal diodes in series, and this (in forward direction) in parallel to the opto input.

I need to either use the zener diode or the surge suppressor diode. Not both right?

One more question. I'll need to make 16 such identical units for the demonstration of my project. What is the optimal solution for my problem, not too expensive, yet protective? (Combining elements of the above suggestions)
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
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

I believe capacitor in series with the resistors are used since they resist change in voltage and this may limit  transient voltage to some limit.

From the perspective of transient suppression, a capacitor is worse than a resistor, because it will pass the a short transient without attenuating it. I suggest you use just resistors.

Quote
To protect the opto you just insert a Zener in parallel to the opto-LED. There are special surge supressor diodes for this usage. Your dealer should be able to help to find the right one. For a quick'n'dirty solution you could also use 3 or 4 normal diodes in series, and this (in forward direction) in parallel to the opto input.

Personally, I don't believe you need any transient suppression if you use high value resistors (i.e. design for 1mA) with a high enough voltage rating (I suggest at least 1000V total voltage rating, preferably more). I take note of Docedison's post, but without knowing exactly what setup he was using, I can can't comment on why he experienced difficulties. But if you do want to add transient suppression then a zener or TVS diode across the opto isolator is not sufficient unless you put a resistor in series with the opt isolator as well. See attached schematic.

One more question. I'll need to make 16 such identical units for the demonstration of my project. What is the optimal solution for my problem, not too expensive, yet protective? (Combining elements of the above suggestions)

If you want transient suppression, then you can't get much simpler than this schematic. Without the zener or TVS diode and 4.7K resistor, it's even simpler and should still survive any transients that don't cause the resistors to break down.

 [EDIT: I goofed - the bridge rectifier in the schematic below needs to be rotated 90 degrees clockwise.]


* Scan 140.JPG (58.27 KB, 1653x1165 - viewed 263 times.)
« Last Edit: February 12, 2013, 09:58:14 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
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the neat reply dc42.

Will try and implement that. Thanks again for the schematic (The bridge rectifier diode directions need to be changed).
Logged

Brasil
Offline Offline
Sr. Member
****
Karma: 2
Posts: 315
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try use this..

Now, I using one capacitor to four optocouplers each one with one resistor of 1/8W, and work fine to me...
This circuirt work with 110V too, but to my need I draw the circuirt only with 220V...
« Last Edit: February 12, 2013, 10:15:52 am by mmoscz » Logged

4x Duemilanove (clone)
Uno torrado (clone)
Amiga 1200 40MB
Windows XP


Berlin / Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi this circuit is no good idea as it is, mmoscz!

This circuit MUST be completed with diodes antiparallel to the opto-LED, or they will be destroyed by the negative voltage. LED's are sensitive against negative voltage.
Additionally (surge-) suppressor diodes would help to protect against bursts on the line which are caused by most electrical machines an by dimmers as well as just switching anything on or off.
Logged

Berlin / Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is another weak point in the circuit of mmoscz:

ALWAYS connect the transistors at the inputs with their emitter to GND and the collector to the input! This is more safe against disturbances.
The resistor is not necessary, just use the command

digitalWrite(Pin#,INPUT);
digitalWrite(Pin#,HIGH);

with this you enable the internal pull up resistor.

If it is absolutely required to go your way due to any other reason, you need to use much lesser resistor value.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If I use the internal pull up resistor, then I don't need to connect the Vcc as well right? Just connect the emitter to ground n collector directly to input pin?

In case I need to use an entire port as input with pull up resistor, then will this code work,
Code:
DDRL = 0x00;
PORTL = 0xFF;
« Last Edit: February 14, 2013, 09:17:47 pm by xpleria » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
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

Correct on both counts.
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   Go Up
Jump to: