IR trip sensor as Arduino interrupt?

I ordered this IR Emitter/Sensor pair

http://www.optekinc.com/datasheets/opb100.pdf

I’m trying to set this up as a drop sensor, for a pellet that will cross the beam for a very short time. I’d like to use that signal as an interrupt.

Here is my current circuit design:

http://img685.imageshack.us/img685/8508/circuit.png

However, just testing with a multimeter, I get no response from the transistor side when just holding the pieces together.

A couple questions:

  1. Is this the proper circuit diagram?

  2. What sort of timing is needed for an arduino interrupt?

  3. Can I wire multiple of these together to a single interrupt pin, without additional circuitry? (assuming high enough resistance).

Thank you!!!

What is the purpose of the LED to the far left? It is posible this LED is causing the transistor to conduct regardles of the beam made by the other LED.

These should be possible to wire-ored together. You will not know which beam caused the interrupt, unless you have other means.

Not sure about the Arduino timing. A change of state of just a few clocks SHOULD be plenty to trigger the interrupt.

The LED on the far left was just me trying to reproduce the schematic of what a phototransistor looks like, sorry, I may have messed that up.

http://encyclobeamia.solarbotics.net/ar … istor.html

If the transistor is the sensitive part, you do not need the diode connected to the gate. If your sensitive component is the diode, then the schematic is correct.

For the part you linked to, the sensitive part is the transistor. In fact there is no gate available on the receiver part of the sensor. You simply need to connect the emitter and collector as shown in your schematic with a sutable (~5K) resistor. The LED will need a suitable resistor calculated for the forward current (say 80ma to be safe) of the device. (5-0.7)/.080 or a 53.75 ohm resistor. Next standard size up is 56 ohms.

Edit: On a BJT the third connection is the base not the gate. Gates are for FETS.

Thanks fll-freak!

Gave it a test, and it works great. One final question (It has been far too long since I’ve worked with BJTs)

I just realized they are always “On” unless a pellet falls. I need to have up to 16 wired to a single interrupt pin on the arduino. Do I need a 2nd BJT to invert them? Any ideas on how to invert it, so if any 1 of 16 goes off, it triggers an interrupt?

DarkKobold:
Thanks fll-freak!

Gave it a test, and it works great. One final question (It has been far too long since I’ve worked with BJTs)

I just realized they are always “On” unless a pellet falls. I need to have up to 16 wired to a single interrupt pin on the arduino. Do I need a 2nd BJT to invert them? Any ideas on how to invert it, so if any 1 of 16 goes off, it triggers an interrupt?

You want to detect when any one of the beams is broken ? And you want the logic level on the interrupt to go from 0 to a 1 when this happens ? Inverting the logic level is easy, no additonal components needed. “Or’ing” the outputs, given they are saturated normally, requires some more logic.

If it were just 4 you could probably get away by wiring them in series and connecting the “topmost” collector to your interrupt port and a single pullup resistor. It’s akin to having multiple normally closed switches in series and detecting when one is opened. But with 16 the combined Vce saturated will be higher than a good logic 0. They are multiple ways to do this … I’d have to check what discrete logic ICs are still available. I assume you’d rather do that than add 16 more transistors. :stuck_out_tongue:

  1. With the Arduino you can configure the interrupt to trigger on a rising or falling edge. So if you can devise a circuit to wire or the signals together with either a falling or a rising edge, you can make this work. Unless you have a secondary reason for needing a particular edge type.

  2. Wire-oring these together can be done in series as suggested by Mee_n_Mac, or if you are willing with an inverting transistor for each sensor. The output of the second transistor would be off when the beam sensor was un-broken. These secondary transistors could then be all wired in parallel such that when any one turned on, the signal would change. Push comes to shove I could do up a small circuit diagram as a sample.

I didn’t find the old logic IC I wanted (like [Burgess Meredith, it’s obsolete :wink: ). But before we go any further down that path I’d like to point out a potential gotcha. When you say pellet, it conjures to my mind something small, and depending on far away the pellet is from the transmitter (and the alignment within the beam), it might not cast a big enough IR shadow such that the phototransistor comes fully out of saturation and shuts off. If it doesn’t, then you may not get enough voltage change at the transistor to make a good logic level and so an interrupt line may not “see” the pellet. So before “we” design some logic to interface to your Arduino, “we’ll” want to be sure that some other circuitry isn’t needed. Have you thought about the paths pellets may take and how much (or little) of the IR beam will be blocked ? You may want to experiment with 1 detector and some pellets to see what happens. I’m not sure how close to your end situation your prior test (above) was.](The Obsolete Man - Wikipedia)

Yikes! Pellets? As in BBs?

I read that as pallets! Big difference. Mee_n_Mac has a very valid point.

I use Keyence PZ-G sensors and they work great.

I can flash a screwdriver handle through the beam as fast as I can and it catches it.

groggory:
I can flash a screwdriver handle through the beam as fast as I can and it catches it.

I’m less concerned about the response time vs whether the beam gets interupted well enough to cause a “trip”. It all depends on the OPs physical setup … of which we know nothing.

Sorry for the late reply.

The interrupt works fine for the pellet (food pellet, fyi!). I had to add quite a bit of virtual ‘debounce’ (I think) to keep the interrupt from triggering multiple times per pellet. Anyway, the series-based Transistors should work great as an “and” gate.

I’m worried that if I add any chip-based logic between the sensor and the arduino, it will no longer trigger.

Thanks everyone!

So, here is my planned schematic, based on Mee_n_Mac’s idea of a serial connection. Does the double BJT make sense? Should I use FETs for the arduino shield instead? Will they switch fast enough?

http://img135.imageshack.us/img135/407/circuitplan.png

Here is the feeder

http://img148.imageshack.us/img148/8692 … 932210.jpg

And here is the small hole in which the Sensor views the falling Pellet.

http://img812.imageshack.us/img812/3412 … 016944.jpg

DarkKobold:
So, here is my planned schematic, based on Mee_n_Mac’s idea of a serial connection. Does the double BJT make sense? Should I use FETs for the arduino shield instead? Will they switch fast enough?

I suspect switching speed is not an issue. As for your schematic, I’ll try to review it later tonight but at first glance I have several questions.

  1. Are you now going with 8 sensors vs 16 ?

  2. Am I correct in interpreting the 8 Q’s (2 strings of 4) as being the sensor outputs ?

  3. Are the 2 Q’s in series, tied to the interupt pin, some other switching transistor ? That is, they are not sensor outputs.

  4. Given you can detect rising or falling edges, can I assume you don’t care which polarity is used to trigger the interrupt ?

One note, if I’m right on #3 then you need a resistor in-line with each base to limit current. I’d perhaps do that final stage differently but that’ll have to wait until later tonight.

EDIT: OK, I’m definitely not sure your design will work. It might but there’s no guarantee it will. Here’s the main problem … to assure a logic 1 on the interrupt line it needs to have at least 3.6V. With 3.6V there, it means that the base of the BJT “above” it is about 4.2V. And that means there’s only 0.8 split across the sensor outputs. That might work (0.2 V each) but the max Vce(sat) in the spec sheet is 0.4 V. And then the situation is a bit worse for the “top” BJT. So I’d rearrange the sensor outputs (still in series) to tie to ground (instead of 5V) with a pullup resistor from the “top” collector to 5V. Then at the junction of that resistor and the top sensors collector, I’d run a trace through a diode (? or 2 ?) to the base of one of your BJTs. I’d do the same for the other set of 4 sensors and tie the collectors of the 2 BJTs together and to the interrupt input and another pullup resistor. The emitters ofeach BJT are tied to ground putting the BJTsin parallel. I’ll put together a schematic tomorrow if I have time.

What happens then is the sensor outputs are normally all saturated which starves the BJT(s) of base current. As a result their collectors are at 5V via the pullup on the BJTs. So the interrupt line sees a solid logic 1. Then when any of the sensors is blocked, it’s output no longer conducts current and the BJT tied to that string will get current via the sensor pullup and diode(s). It will then saturate it’s collector and put a solid logic 0 on the Arduino interrupt line. Each string of sensors may drive it’s respective BJT into saturation but since the BJTs are “wire OR’ed” together that works, putting a logic 0 on the interrupt when any sensor is blocked.

At least it seems to work, if only in my mind. We’ll see if I still think so after I’ve had a chance to schetch it up. Of course if you can understand my ramblings above, fell free to give that a shot.

I took your approach (which was slightly different from what I originally had in mind) and altered to fix what I thought were some potential gotchas. The result is below. Now it’s possible you could “stack” more sensors in series but I’d be worried about the variance in Vce(sat) stacking up for any more than 4 and resulting in more or less current through their outputs than expected. So given you were happy with 4 in series I am too. Note that if you need to add more sensors (you showed 8 but orignally mentioned 16) that you can just build more modular “sections” and add them in parallel with the sections shown. Lastly note there is only one R6 no matter how many sections you have, and it’s tied to the common collector point of all the sections and the Arduino interrupt input as well. I’ll let you pick the R values but will opine that R1x, R2x, R3x and R4x are (obviously) all the same and should set the current through the transmitter inputs to something like 20 - 50 mA … if I’ve read the sensor datasheet correctly. It seems more current may be allowed but I’d think it unneccesary unless the transmitter and receiver portions are widely separated. Once built you’ll want to measure the Vce for the sensor outputs to verify they are in saturation. If not, then more input current may be needed. If their Vce(sat) is on the high end (0.4V is the max per spec) then it might turn out the there’s just enough voltage at the base of Q1x to start to have it conduct. If that’s the case you can add another diode in series with D1x and D2x. R5x might want to be in the 2k - 5K range and R6 perhaps the same. Their values are not critical. I’ve assumed you’ll be using some reasonably regulated 5V supply and current availability is not a big issue.

If I’ve goofed somewhere here, hopefully someone else will catch it and comment.