Author Topic: Playing with Arduino and PC817 optocoupler - Voltage measurement doubt  (Read 5353 times)

0 Members and 1 Guest are viewing this topic.

Offline davTopic starter

  • Regular Contributor
  • *
  • Posts: 133
  • Country: it
I was playing with Arduino and a PC817 optocoupler.
Simple circuit: using an Arduino digital pin, I wanted to switch on and off a 5mm LED via an optocoupler.

So, digital pin -> 220R resistor -> pin1 optocoupler (internal LED anode)
pin 2 optocoupler (internal LED cathode) -> GND

and

+5V (external power supply) -> pin 4 optocoupler (collector)
pin 3 optocoupler (emitter) -> 220R resistor -> 5mm LED -> GND

LOW level on Arduino digital pin -> 5mm LED off
HIGH level on Arduino digital pin -> 5mm LED on

Ok

The question:
Let's measure the voltages on the 2nd side of the circuit across the components, in both working conditions.

HIGH:
Vce= 0.2V
V across the resistor: 2.7V
V across the LED: 2V
Ok

LOW:
Vce= 3.5V
V across the resistor: 0V
V across the LED: 0V
???  What's happened to Ohm's law???

I tried to disconnect all components on the first side of the optocoupler and took again the voltages in LOW case.
Same as before

Where I'm wrong?
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Playing with Arduino and PC817 optocoupler - Voltage measurement doubt
« Reply #1 on: January 22, 2017, 12:07:17 pm »
Post a  schematic with part numbers on devices, eg. optocoupler, so
forum can help you.

Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 
The following users thanked this post: nugglix

Offline radiogeek381

  • Regular Contributor
  • *
  • Posts: 125
  • Country: us
    • SoDaRadio
Re: Playing with Arduino and PC817 optocoupler - Voltage measurement doubt
« Reply #2 on: January 22, 2017, 01:19:33 pm »
This is a really cool question.  And the answer
lies in how you did the measurement.

Remember that your DMM has a finite resistance.
It isn't the ideal meter that we imagine in theory.

Let's say that your meter has a 10Mohm effective
resistance between + and - leads.  Then when you
had the meter across the C and E pins on the opto
coupler you read 3.5 V.  That works out to 3.5/(10*10^6)
or 350 nA through the meter.


This is big enough, compared to the dark current --
spec'd at 100nA max -- that the meter is disturbing
the measurement.  It is dumping an additional 350nA
into a diode whose resistance at that point may be
really really big.  (Note that a diode is NOT a
resistor -- it's current follows an exponential
curve.)

Small changes in diode current can lead to big
changes in voltage.  If you get I1 at a voltage V1,
and I2 at a voltage V2,

V2/V1 is about 20 to 40 times the ln of (I2/I1)
(At low voltages, the multiplier is closer to 40.)

so if the current goes up by a factor of 10, the
voltage may rise by a factor of 50 or even 100!

In your case, if your DMM has a resistance of 1M ohm,
the ratio of the current will be at least 35:1.
But the leakage on the optoisolator has no min spec.
If the max is 100nA, it isn't unreasonable to expect
some devices to get to 10nA.  That's a 350:1 ratio

In that case, 40 * ln(350) = 234
              40 * ln(35) = 142

So, if V1 was 1.5 V,  then the voltage you might
measure across the diode could be as low as
6 mV or as high as 11mV.

And that voltage gets lower, given that the DMM
is "bleeding" some of the current away from the
diode.

You're on a steep curve.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Playing with Arduino and PC817 optocoupler - Voltage measurement doubt
« Reply #3 on: January 22, 2017, 01:21:06 pm »
+1. <snip> explanation: Radiogeek did it better!

If you re-measure everything with the meter negative permanently connected to 0V (GND) and take differences to get the voltage across each part, it will all make sense and follow Ohm's law with no surprises
 

Offline davTopic starter

  • Regular Contributor
  • *
  • Posts: 133
  • Country: it
Re: Playing with Arduino and PC817 optocoupler - Voltage measurement doubt
« Reply #4 on: January 23, 2017, 07:43:19 am »
I did other tests:

first side of PC817 open
Vce: 3.5V
V across the 5mm LED: 0V

then, with my Brymen DMM on the optocoupler, I  simultaneously took the voltage across the LED (using my Fluke).
Well, inserting the 2nd DMM, both voltages instantaneously changed!
Vce: 3.5V
V across the 5mm LED: 1.4V

 :D

2nd test:
I used my Fluke to take the DC current in the circuit and my Brymen for measuring Vce.
Well, without inserting the brymen, I=0
When I took the Vce, the current change to 0.4uA.
« Last Edit: January 23, 2017, 07:52:03 am by dav »
 

Offline chrisl

  • Regular Contributor
  • *
  • Posts: 90
  • Country: us
Re: Playing with Arduino and PC817 optocoupler - Voltage measurement doubt
« Reply #5 on: January 23, 2017, 09:41:49 am »
Try to keep the load (LED) on the collector side of PC817, not on the emitter side.
5V -> 220 ohm -> LED -> PC817 pin 4
PC817 pin3 = GND.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Playing with Arduino and PC817 optocoupler - Voltage measurement doubt
« Reply #6 on: January 23, 2017, 09:59:30 am »
It doesn't matter whether you use the opto's phototransistor on the high side or the low side of the load.  It can go *anywhere* in a series circuit as long as the polarity is correct.

As the PC817 base isn't brought out, the output side is effectively a two terminal device. If the base was brought out, it could still be used on the high side, but in high EMI environments, protecting the base against noise pickup would be more problematic.
« Last Edit: January 23, 2017, 10:04:19 am by Ian.M »
 

Offline davTopic starter

  • Regular Contributor
  • *
  • Posts: 133
  • Country: it
Re: Playing with Arduino and PC817 optocoupler - Voltage measurement doubt
« Reply #7 on: January 23, 2017, 01:17:19 pm »
Another test:
I setup my Korad power supply limiting the current to 20mA and do a sweep from 0 to 2V, with 0.01V steps, directly powering the 5mm LED (with my Fluke in series for current measurement).
Well, at 1.4V on Korad display, my Fluke exactly measures 0.4uA  :D

So, it's exactly as radiogeek suggested:
my Brymen DMM drains 0.4uA which flows in the LED, estabilishing a 1.4V voltage across it.

Input resistance of my Brymen is really:
3.5V / 0.4uA = about 9Mohm  :D
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf