Best way to interface a photointerrupter to an arduino?

Thread Starter

sternpirate

Joined Dec 10, 2015
25
I've been using a 600ohm to 10k resistor in series with the photointerrupter and I keep frying it from overcurrent.
when it gets fried the output rises to 8v from 5v source.
from the datasheet of similar devices like the gp1s39 it seems they output 7-4ma,
so the arduino seems to be drawing too much current at 20m-40ma iirc.
is there an optoisolator that input switches at 2v, 4ma? to protect the photointerrupter or should I use a jfet to handle the increased current.
I need the extra current to drive a 20k each leg voltage divider to increase voltage swing to act as a switch on the i/o pins.
I'd like 0.5 volts of swing, without the divider I get 0.1v.
I tried a pc817 optoisolator but that wouldn't switch at all as the interrupter only outputs 2.5v, and needs a lot of current.
I'd prefer to use an optoisolator so that I could use pullups on the i/o pins to increase stability, and I find them easier to use, as I had to keep changing the resistor types as the photointerrupter slowly burned out..
The photointerrupter is a dual type and one of the issues I ran into was both i/o lines interacting through the voltage divider to ground. they would work fine separately, just not together.
I don't expect anyone to do the project for me but i'd appreciate an example circuit or suitable part.
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
Are you outputting to the Opto from the Arduino? I have never used Arduino but if you want to drive a Opto isolator just use a 2n7000 to drive it.
Max.
 

Thread Starter

sternpirate

Joined Dec 10, 2015
25
Are you outputting to the Opto from the Arduino? I have never used Arduino but if you want to drive a Opto isolator just use a 2n7000 to drive it.
Max.
No, I am using a photointerrupter to switch a digital input pin on the arduino, however the current draw of the arduino seems to be destroying the photointerrupter no matter what I do. what I want is a low current foolproof device to switch the input pin. I looked up the 2n7000 and it seems the turn on input current is much too high to be useful.
 

Thread Starter

sternpirate

Joined Dec 10, 2015
25
hi s,
Are you sure you have not set the Ardunio I/O pin as an Output, the input pin should only draw uAmps.?
E
bear in mind I had the project working for some weeks, but I have grown tired of changing photointerrupters so I want to rework the circuit.
according to this website arduinos sink 20 ma via the input pin.
https://playground.arduino.cc/Main/ArduinoPinCurrentLimitations

quite sure, I am actually using a teensy 2.0 but I use this arduino ide sketch for debugging.
int pin = 10; //9 or 10 is c6 and c7 for 2bit rotary encoder.
//teensy 2.0

void setup()
{
pinMode(11, OUTPUT); // LED
pinMode(pin, INPUT); // Pushbutton
}

void loop()
{
if (digitalRead(pin)== LOW) {
digitalWrite(11, HIGH); // LED off

} else {
digitalWrite(11, LOW); // LED on

}
}
 

MrSoftware

Joined Oct 29, 2013
2,188
Can you show a schematic of your circuit and the model or datasheet of the photo interrupter? The adruino input pin will draw almost no current. But it's possible the diode in the photo interrupter requires an external series resistor. If you don't have one, the diode might be passing too much current and burning itself out.
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
That is intended for 1x/2x/4x quadrature detection and direction, is this what you require? Or just a single function/count, non-direction sensative?
Max.
 

Thread Starter

sternpirate

Joined Dec 10, 2015
25
That is intended for 1x/2x/4x quadrature detection and direction, is this what you require? Or just a single function/count, non-direction sensative?
Max.
That's right, I am implementing a rotary encoder which is sensitive to direction, I only illustrated half the circuit for clarity.
 

be80be

Joined Jul 5, 2008
2,072
Your not using a resistor your trying to feed 5 volts it's only 20 ma part @ 1.4 volts put a 330 ohm resistor to limit current
 
Top