# calculating optocoupler resistor values

Discussion in 'General Electronics Chat' started by yusim, Jun 10, 2009.

1. ### yusim Thread Starter Member

Apr 27, 2009
10
0
hello all
this is my first post i think

i'm trying to build a circuit that isolates two PIC16F877As using a quad optocoupler - pc847

this is a sample of the circuit i built

i was wondering if someone could explain to me what the ideal value for resistor R2 would be

yuda

2. ### beenthere Retired Moderator

Apr 20, 2004
15,808
295
You may have some trouble with your circuit. It will only allow a few milliamps through the emitter. IR emitters are rated up to 50 ma. You would be better off using a Darlington array for enough current.

I always use a fair sized resistor in the collector circuit of the detector - around 47K, with the emitter straight to ground. The transistor does not get much drive from photons, and CMOS likes to see the input switch between Vcc and ground, which is hard to do in an emitter circuit.

3. ### hgmjr Retired Moderator

Jan 28, 2005
9,029
219
Another parameter that would be helpful to know is what frequency do you plan to use in driving the photo-coupler?

hgmjr

4. ### yusim Thread Starter Member

Apr 27, 2009
10
0
thanx for the promt replies
beenthere said:
the ir led can be lit by as low as 5mA with a ctr of 120% giving up to 6mA output - in my circuit (~4.7v-1.1v)/560 = ~6.5mA
being that the output goes to the input of a PIC i thought that would be enough

beenthere said:
i tried the circuit i made and it seems to work fine
i tried 1K ohm Voh was about 4.88v which was ok but this takes about 4.7mA
using 13 of these in a low power circuit is a bit much
i then tried 1M ohm but i got a VoL in the hundreds of millivolts - too high

what im looking for is a way to calculate the ideal value for R2

hgmjr said:
a very low freq. maybe a few times per second

5. ### mik3 Senior Member

Feb 4, 2008
4,846
70
Why do you need this isolation?

6. ### yusim Thread Starter Member

Apr 27, 2009
10
0
this is all for a biofeedback system that outputs a composite video signal
one microcontroller does al the calculations and the other creates the video signal

7. ### mik3 Senior Member

Feb 4, 2008
4,846
70
Ok but why you need this kind of isolation?

Does the microcontrollers have different power supplies?

8. ### yusim Thread Starter Member

Apr 27, 2009
10
0
mik3 said:
the user/patient must be galvanicly isolated from the mains power supply of the tv sceen

mik3 said:
Yes, the PIC that takes care of the calculations is battery powered and the PIC that creates the video signal is powered by an AC adapter.

9. ### yusim Thread Starter Member

Apr 27, 2009
10
0
ok, back to the original question

is there a formula to calculate the best value for the pull-down resistor R2?

10. ### SgtWookie Expert

Jul 17, 2007
22,201
1,809
The PICs' pin has a small amount of capacitance. Whatever resistance you chose will drain the charge from the pin when the transistor turns off.

I suggest using a 10k pull-down resistor for R2. It's a decent compromise between power consumption and pin discharge time.

11. ### Zenock Active Member

Jun 1, 2009
36
1
Have you considered putting a small resistor or possibly a diode on the ground pin of the second PIC?

I don't know, there's $\sout{possibly}\ probably$ some reason why you shouldn't do this.

Z

Last edited: Jun 16, 2009
12. ### SgtWookie Expert

Jul 17, 2007
22,201
1,809
You wouldn't want to do either of those things. Interfering with the ground path of a uC just would be a bad idea.

13. ### yusim Thread Starter Member

Apr 27, 2009
10
0
SgtWookie said:
i cant seem find the spec for the input pin capacitance in the datasheet
i found the "Capacitive Loading Specs on Output Pins" in the data sheet but nothing about the inputs

where might i be able to find it ?

14. ### hgmjr Retired Moderator

Jan 28, 2005
9,029
219
Take a look at parameter D101 in the PIC16F87X datasheet. It appears that the capacitance at all but the three SPI pins is 50 picoFarads.

hgmjr

Apr 27, 2009
10
0
hgmjr said: