Making endstops from printer photo interrupters.

If you have pulled apart a printer, fax or scanner then there is a high likelihood that you have found a few photo interrupters.

A collection of 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 .

The IR LED is on the left and the photo transistor on the right.

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.

IR LED on the right and the photo transistor in the left. K for Cathode.

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?

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);

}

Other useful links include here and here. If you see a mistake above please let me know.
Advertisements

About Richard

I am a PhD candidate in Materials Engineering located in Melbourne, Australia.
This entry was posted in Mendel Build and tagged , , , , , , . Bookmark the permalink.

6 Responses to Making endstops from printer photo interrupters.

  1. nophead says:

    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.

    • Richard says:

      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?:
      Take two.

  2. nophead says:

    Yes that is correct. The pullup ensures the line goes to 5V, giving best noise immunity.

  3. DavidBuzz says:

    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. 🙂

  4. nophead says:

    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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s