If you have pulled apart a printer, fax or scanner then there is a high likelihood that you have found a few photo interrupters.
Some of these may be pre-packaged in a plastic housing with three wires attached which you can modify to use as endstopsuitable for reprap/repstrap.
The most common three wire photo interrupters you will find consist of a infrared (IR) LED and a photo transistor packaged facing each other. When in use the IR LED is always on and exposed to the photo transistor allowing a current to flow. When the IR LED is blocked it will stop the flow of current through the photo transistor and this change is detected by a .
To use a photo interrupter with your reprap you will need to identify the three wires leaving the photo interrupter. The are Vcc, Gnd and signal. Vcc is connected to the IR LED anode (+) , signal is connected to the photo transistor collector (+) and ground is connected to both the IR LED cathode and the photo transistor emitter.
If the photo interrupter is mounted on a PCB then it should be fairly straight forward to identify which wire is which by following the traces and any markings.
However if its mounted to a plastic base then you will need to pop off the shroud (the black plastic in the image below) and by using your multimeter identify which wire is connected to one of the legs for both the IR LED and also to the photo diode. This is the Gnd. Then identify which wire is connected to the other leg (non Gnd) of the photo diode, this is the signal. The photo diode is normally tinted or black. The last remaining wire is Vcc to the LED anode.
Once each wire is labelled its time to construct a small circuit from stripboard so that the photo interrupter can be interfaced with your reprap host electronics. Construct the circuit seen below.
Once finished it might look similar to the setup below. The PCB above the strip board is the standard endstop PCB used by a Mendel.
You can test it with the sketch below that was taken from the reprap wiki and modified a little.
#define ENDSTOP_PIN 2 //what pin are we using?Other useful links include here and here. If you see a mistake above please let me know.void setup()
{ pinMode(ENDSTOP_PIN, INPUT); Serial.begin(9600); Serial.println(“Starting opto endstop exerciser.”); }
void loop() { if (digitalRead(ENDSTOP_PIN)) { if (0) Serial.println(“open.”); else Serial.println(“blocked.”); } else { Serial.println(“open.”); } delay(500);}
The 10K should be a pull up, not a pull down, and I wouldn’t make it bigger than 10K.
The way you have it wired in the diagram will make the LED glow dimly when it should be off and the logic ‘1’ level at the arduino will be marginal.
Thanks, this is all still relatively new to me. Using a 100k pull down resistor resulted in so little current draw that I couldnt tell if it was on or not.
So the correct way of doing it would look like this?:

Yes that is correct. The pullup ensures the line goes to 5V, giving best noise immunity.
OK thanks, all fixed up.
Arduino Pins have built-in pullup resistors, so it’s just a case of enabling the pullup/s on the appropriate pins, and you can leave that resistor out entirely.
pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors
see:
http://www.arduino.cc/en/Tutorial/DigitalPins
for more.
Infact, 4 days ago, I added support to the firmware ( in SVN) for precisely this:
http://reprap.svn.sourceforge.net/viewvc/reprap/trunk/software/firmware/FiveD_GCode/FiveD_GCode_Interpreter/cartesian_dda.pde?r1=3886&r2=3896
Buzz.
( who happens to be using printer optos too).
Mine are all conveniently labeled on the back of the plug/opto pcb with “GOV” ( Gnd, Output, VCC ), so the 3 pins are obvious. 🙂
Yes they are only 20K though, so a bit on the high side. When you use the 4 pin optos the value actually sets the gain of the photo transistor, so affects the sensitivity. Hard to say what the ideal value is without the datasheet for the opto.
Hi, I used your idea but as a pcb I used an switch type endswitch (mech endstop v1.2) and removed the micro switch. This give’s you a pcb with connector, led, pullup etc. You can use the three solderplaces of the switch to connect the wires to the opto board, only the 150R must be added somewhere. It can in schrink tube in the plus wire. NO= Gnd, NC=VCC, COM=Output (the collector of the phototransistor in your drawing). If you like I, can send you a picture.
Grtz Jan The Netherlands
My opto switches are labeled with “A” “G” “C” and per the above diagram I take it to mean A=anode, G=ground, and C=collector with Anode going to positive, ground going to negative and collector going to signal on my Arduino. Sound right?