calculating optocoupler resistor values

Thread Starter

yusim

Joined Apr 27, 2009
10
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

thanx in advance,
yuda
 

beenthere

Joined Apr 20, 2004
15,819
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.
 

hgmjr

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

hgmjr
 

Thread Starter

yusim

Joined Apr 27, 2009
10
thanx for the promt replies :)
beenthere said:
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
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 always use a fair sized resistor in the collector circuit of the detector - around 47K, with the emitter straight to ground
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:
Another parameter that would be helpful to know is what frequency do you plan to use in driving the photo-coupler?
a very low freq. maybe a few times per second
 

Thread Starter

yusim

Joined Apr 27, 2009
10
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
 

mik3

Joined Feb 4, 2008
4,843
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
Ok but why you need this kind of isolation?

Does the microcontrollers have different power supplies?
 

Thread Starter

yusim

Joined Apr 27, 2009
10
mik3 said:
Ok but why you need this kind of isolation?
the user/patient must be galvanicly isolated from the mains power supply of the tv sceen

mik3 said:
Does the microcontrollers have different power supplies?
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.
 

Thread Starter

yusim

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

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

SgtWookie

Joined Jul 17, 2007
22,230
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.
 

Zenock

Joined Jun 1, 2009
36
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:

SgtWookie

Joined Jul 17, 2007
22,230
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.
You wouldn't want to do either of those things. Interfering with the ground path of a uC just would be a bad idea.
 

Thread Starter

yusim

Joined Apr 27, 2009
10
SgtWookie said:
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 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 ?
 

hgmjr

Joined Jan 28, 2005
9,027
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
 

Thread Starter

yusim

Joined Apr 27, 2009
10
hgmjr said:
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.
that parameter is talking about the cappacitance loading of output pins
- im looking for the specs for an input pin - or is it the same thing??
 
Top