Really need help with what is probably very simple IR emitter/receiver question

Hey,

Bought this: Photo Interrupter - GP1A57HRJ00F - SEN-09299 - SparkFun Electronics trying to measure RPM. I can handle the code on my own (probably) but I'm trying to put together a simple circuit to just test that I have everything plugged in right first.
According to the diagram, the anode on the emitter (positive like an LED, right?) is opposite the GROUND pin on the receiver, and then what I'm confused about is what the heck the middle pin is used for on the receiver. In the diagram, which I find a little unclear, it seems that the middle is v0, and the other pin is Vcc. I'm not sure what these mean to be honest, I'm new to electronics, but I think of them as the positive side.
I put together this circuit (or tried) http://www.instructables.com/id/Arduino-Based-Optical-Tachometer/?ALLSTEPS
Unfortunately, it won't work. The LED never pops on when I interrupt the optointerrupter beam, and I count 0rpm forever. Please, please help. I'm at my wit's end ;p

Here's my take:

PIN
1 -- Anode of the of the LED -- Attach a 330ohm current-limiting resistor to +V
2 -- Cathode of the LED -- Attach to GND
3 -- Vcc -- Attach to +V
4 -- Vo -- attach to Arduino digital pin configured as an input (no need for internal pull-up resistor)
5 -- Gnd -- Attach to ground

Pin 4 should go low / high as the beam is interrupted

Hi Prism,

Looking at the data sheet you provided, and specifically the schematic on the first page, it seems that this works as follows... (someone correct me if I'm way off)

Pin 3 goes to Vcc (your power supply, probably 5V from an arduino, check the data sheet to see what the actual specifications are)

Pin 5 goes to your ground

And pin 4 is used as your signal pin. When the beam is transmitting uninterupted, a current is applied to the transistor pictured in the citcuit which connects Vcc and Pin 4 to ground, so it should read 0V. When the beam is interupted by an object, the current stops flowing to the transistor, and pin 4 is connected to Vcc with no connection to ground, and it should read high.

TL:DR -- pin 4 is what you read off to see if your beam is interupted. If it's interupted, it should be high, if its unobstructed, it should read low (or it may be the other way around, admitedly, I don't know what some of that circuitry does).

To test that your detector is actually reading... hook everything up to pins 1, 2 (don't forget a resistor on the LED if you need one, check the data sheet), 3, and 5, and then read the voltage off pin 4 as you interupt the beam,

Let me know if that helps

Wait up. I tried this and I fried my sensor, what mistake did I make? Weird... Smelly, too.

Did you fry the sensor or the LED because you didn't use a resistor with it?

Are you using an arduino for the 5V supply? If not, what is the voltage?

two guys working on this same thing today
what are the possibilities?

Oh... the pins don't match the drawing -- you have to look at the physical drawing (same page, further down)

optint.JPG

optint_correl.JPG

Wait.. is it just me or are those drawings showing the same pin configuration?

Also, I fried the sensor, not the emitter. Now I have to wait another week for my new part...................

EDIT: Oh, ok. I think I was reading the diagram thinking that I was looking at the device from the bottom and not the top. That would do it, I suppose :wink: Looks like I should learn how to read a circuit diagram, eh? But this also means that the long leg of the IR LED is NEGATIVE in this situation, is that right?

EDIT EDIT:
Woa, this thing still works after smoking more than I did in Cambodia.

Wrote this code:

// include the library code:
#include <LiquidCrystal.h>

int sensorPin = 2;
unsigned long rots = 0;
int rpm = 0;
unsigned long time;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(20, 4);
  lcd.clear();
  
  Serial.begin(9600);
  pinMode(sensorPin, INPUT);
  attachInterrupt(0, rotEncoder, RISING); 
}

void loop() {
  
  time = millis();
  rpm = rots / (time / 1000);
  
   // Print a message to the LCD.
  lcd.setCursor(0, 0);
  lcd.print(rpm);
  lcd.setCursor(0, 1);
  lcd.print(digitalRead(sensorPin));
  lcd.setCursor(0, 2);
  lcd.print(time / 1000);
  lcd.setCursor(0, 3);
  lcd.print(rots);
  
  delay(20);
}

void rotEncoder() {
  rots++;
}

And it works well enough, but I have this problem where RPM reports -1 for a sec, and that messes up my LCD display. What's the deal with that?

It looks like it may not conform to the prevailing assumption.
That's an easy thing to check.
The best thing to do is confirm with a DMM, get out the ohmmeter (low ohms or 'diode check') - it will show signs of conducting in one direction (but not the other).