Shop OBEX P1 Docs P2 Docs Learn Events
Please help with IR Source and Sensor Interfacing — Parallax Forums

Please help with IR Source and Sensor Interfacing

djh82ukdjh82uk Posts: 193
edited 2007-07-08 18:00 in Propeller 1
Hi Guys

I need to sense when something passes over the soure + sensor, But I cannot figure out how to interface them, I presume I need Pull-up Resisitors, but don't know which ones.

Here are the datasheets

Source
http://www.rapidonline.com/netalogue/specs/58-0100.pdf

Sensor
http://www.rapidonline.com/netalogue/specs/58-0100.pdf

Also isn't the 3.3volts coming out of the prop going to be too much? Do I also need a resistor fromt he prop leg to the source for instance?

I have tried reading up on it, but have found very little of use.

Please can someone advise.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-06 12:45
    Your "source" is a standard IR LED which needs a resistor in series with it to limit the current (regardless of how you're using it). There are some special LED drivers that internally have circuitry to limit the current and don't need a separate resistor, but not here.

    If you look at the datasheet you posted, the forward voltage is about 1.3V at 10ma. This is a typical current for an LED and is within the capabilities of most microcontroller I/O pins (like the Propeller and the Stamps). The resistor has to "drop" 3.0V - 1.3V = 1.7V since the Propeller's I/O pins will produce about 3.0V with a 3.3V supply voltage. Ohm's law gives R = E / I = 1.7V / 10ma = 170 ohms. The closest standard value is 180 ohms. Typically, you connect one end of the resistor to +3.3V and the other end to the anode of the LED. The cathode of the LED you connect to the I/O pin. You set the I/O pin to a logic low (zero) to turn the LED on. You set the I/O pin to logic high (one) or to a high impedance (input mode) to turn the LED off. It's done this way usually because I/O pins are often asymmetric ... they have a little higher current capacity on the low side than the high side. The Propeller I/O pins are pretty symmetric as these things go.

    You didn't give a link for the sensor, but it's probably a phototransistor. You usually connect the emitter to ground and a pullup resistor from the collector to +3.3V. The I/O pin is connected to the collector and becomes a logic high when there's no IR detected and a logic low when IR is present. A typical resistor value is 3.3K to 10K. The datasheet will give some idea of the optimal range of current and you use Ohm's law to figure out the necessary resistor value.
  • djh82ukdjh82uk Posts: 193
    edited 2007-07-06 12:50
    Hi Mike, the Datasheet for the sensor is posted above, Thanks for the info, this is exactly what I was looking for [noparse]:)[/noparse]

    By my understanding the sensor is looking for around 1.5V? Would that not just be the same value resistor again?

    Could someone just check the datasheet for me so I don't blow this thing?

    Thanks again mike

    DJH
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-06 13:02
    You posted the link for the IR source twice, not the sensor link.

    The sensor (probably a phototransistor) conducts a certain amount of current depending on the amount of light it "sees". You want to choose the resistor value to: 1) Not waste too much current that you don't need. 2) Limit the current to something that the phototransistor will conduct with the expected light level. Something between 300ua and 1ma should work. When the phototransistor is fully "on", the voltage across it should be around 0.3V (saturation voltage). Ohm's law again gives R = E / I = 3.0V / 300ua-1ma = roughly 3.3K to 10K.
  • djh82ukdjh82uk Posts: 193
    edited 2007-07-06 13:09
    Gah

    Im stupid

    Heres the link.

    http://www.rapidonline.com/netalogue/specs/58-0105.pdf

    does that shed any extra light?

    Thanks

    DJH
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-06 13:56
    The extra information really doesn't change anything. It's a pretty standard phototransistor.

    More importantly, what are you trying to do with this thing? If you're trying to do short range (a few cm to maybe 1/2m) on-off sensing without a lot of ambient light, these will work fine. If you want to do longer distances or there's a lot of varying ambient light, you probably want to use modulated IR and you'd want to use a different sensor that detects this. Parallax and others sell these detectors for IR distance sensing and there's a lot of existing code examples for the Propeller and the Stamps. See Robotics with the Boe-Bot (www.parallax.com/dl/docs/books/edu/Roboticsv2_2.pdf) chapters 7 and 8.
  • djh82ukdjh82uk Posts: 193
    edited 2007-07-06 14:05
    it's to sense a model train, sensor and source will stick up a little from the below the track with heatshrike around them to force the IR straight up.

    Distance will be about 2-3CM max, it's for my train speed detector. Would it maybe better to have the sensor read as analogue? and then just trigger it at a preset level? Would that help cut out false positives if the preset level was quite high?

    DJh
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-07-06 14:25
    The circuit will already trigger at a preset level determined by the resistor value used and the voltage that defines a logic high on the propeller.

    It sounds like you want to use the sensors in reflective mode sensing the the light reflected back from the train, as Mike said ambient light may be a problem as it will come straight down and hit the photo transistor.

    Why not try one of these:

    http://www.rapidonline.com/netalogue/specs/58-0938.pdf

    it combines the emitter and photo transistor and the plastic cuts out visible light.

    Take a look at the graphs for current vs card distance and then look at the tests themselves.

    Graham
  • djh82ukdjh82uk Posts: 193
    edited 2007-07-06 14:39
    He he

    I actually have a few of those lying around, I have both the darlington and non darlington versions

    Which would be best?

    Same interface circuit as mike described?

    I read the datasheet this morning, read that they were for cassete tape readers etc and instantly disregarded it, ignorance on my part I think

    Regards

    DJH
  • djh82ukdjh82uk Posts: 193
    edited 2007-07-06 14:53
    Actually I only have 2 of the darlington type and one of the non-darlington.

    i need to sets of source/sensor so would like to try the darlington version I think for now.

    just need to know if it would be the same type of interfacing circuit (assume it would)

    DJH
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-07-06 15:36
    A darlington is effectively an amplifier, the phototransistor drives a second transistor meaning you will get more current flowing through the device at a given level (it can probably drive an led directly for example). For what you are doing, creating a signal for the propeller I doubt it will make a lot of difference.

    Same circuit. If I was you I'd read the basics on transistors, its not complicated and you will then understand what you are doing better.

    Cheers,

    Graham
  • djh82ukdjh82uk Posts: 193
    edited 2007-07-08 17:17
    woohoo got those little tiny ones working [noparse]:)[/noparse]

    I used my digi camera to make sure the transmitters were working, then played with the sensors, and they can sense my hand at a range of about an inch or so, plus that was in direct sunlight too [noparse]:)[/noparse]

    i have it just outputting o's and ones on screen very fast at the moment, but if I run my hand over it, looks like something out of the matrix, still im very happy and very gratefull for your help.

    I now just need to play around with the resistor values as i did not have many here, so had to make do with 220R and 3.3k

    Thanks [noparse]:)[/noparse]


    DJH
  • deSilvadeSilva Posts: 2,967
    edited 2007-07-08 18:00
    If you want to use just A LITTLE BIT of the Propeller's power, you can very effectively cut out ambient light issues by simply pulse the LED and detect that frequency in the Prop. You can use various techniques for that.
Sign In or Register to comment.