Photo Interrupter with Hardware Status LED

Hi,

Im in the process of building a new lap timing&counting system for my slot car club. See http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286950257/3 for background if you are interested. Im a newbie around electronics, so please forgive me for any dumb questions or incorrect statements that Ive made.

The basics are a slotted photo interrupter which is mounted in each slot (4 lanes), which gets cut by the car's guide-flag just prior to the start / finish line. The arduino will be responsible for providing lap timing, and probably track power on/off. Laptime data will be sent a race control application on a PC via serial-usb. I havent quite decided on exactly which functions the Arduino and PC will control at this stage.

Anyway, at this point, Im building up a hardware test harness for proving the Arduino logic and PC s/w as I write it. I havent decided whether I will replace existing sensing hardware and logic boards at this point.

Below is the circuit I have set up for a single lane. This circuit will be duplicated 4 times, with different coloured LEDs as the lane colours are Blue, Red, Yellow, Green. Obviously with different R values.

Data Sheet for Photo Interrupter: http://www.jaycar.com.au/products_uploaded/ZD1901.pdf

As it sits, the logic Im getting at the digital input pin on the Arduino is what I want, which is HIGH when the PI is blocked, and LOW when non-blocked. The logic I am seeing is kind of strange to me, as I would have thought the logic would be opposite (PI = switch-closed when unblocked, which I would have thought would be HIGH?).

Anyway, my issue / question; I am presently getting the opposite logic to what I want on the indicator LED. When the PI is un-blocked (closed?), the LED is lit, and the LED is dark when the PI is blocked (open?). What I want is for the LED to light when a car's guide blocks the PI.

Ive spent several days researching in the forums, and on the web, but Im not yet conversant enough with the electronics side to figure out how to reverse the LED logic.

Hoping someone can help!! Rob.

Yes, that is exactly the way they work. When the photo-transistor in the opto-interrupter is illuminated, it turns “on” and conducts electricity. That makes the LED indicator illuminate, and it also pulls the logic output “low”.

Richard, thanks for the quick reply. What Im seeing is the OPPOSITE to your statement. I was expecting to see what you have stated.
What Im seeing is that the pin is LOW when the PI is not-blocked, and the LED is LIT when the PI is not-blocked. :-?

[edit]Apologies. It was a late night last night, and I didnt read this closely enough. So the behavior is as expected based on the circuit, but not quite what Im after. I want the LED logic reversed[/edit]

My question is: What exactly is the LED indicator supposed to indicate? I would have expected that it would indicate the “winner” or the lane which got triggered first. If that is what you want, then you need to drive the LED indicators from the Arduino, independently from the opto-isolator sensor inputs. Otherwise, even if you invert the logic, the LED indicator will only indicate when the car is blocking the beam. Is that really what you want?

The LED is initially for hardware debugging so I can see whats going on visually. In the final system (and our existing system), there is an LED which flashes for the lane as the car crosses it. This is to help the human race controller watch for missed laps as its much easier to see the LED flash out of the corner of your eye while watching the car going past to see which lane it is on.

While our track has 4 lanes, I want the system to support up to 8 lanes eventually so that other clubs can use the system. It will end up with control buttons and potentially a LCD as well. In that case, Im going to start running out of pins.

Additionally, this system must support <= 1ms timing accuracy for me to bother doing it, and so (to me) anything I can do to reduce wasted CPU cycles is going to help. If I can deal to the LED in hardware, that saves me 4 (or 8) pins, and means I dont have to do lane identifcation logic in the pin interrupts.

Background: intention at this point is to use pin change interrupts, and read the IO ports directly, and send the byte data along with a millis timestamp back to the PC. The PC can then deal with identification of which lane did something, and then display the laptime. To me, at this stage, the Arduino is there as a high precision timer and data capture device.

Im just in the tinkering / ‘getting conversant with it all’ stage which will help me hammer out final design decisions.

This circuit might work. The 10k resistor might be too high....play with it!

-- The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons

Thanks guys. I feel like such an idiot for my blunder above.

I was about to start having a go at figuring out how to put the transistor in the circuit, and then getting you guys to review it for me (its all about the learning!!).

RuggedCircuits; Thanks for the circuit. Appreciated!! If you dont mind, I'll take that as the basis for my having a bash at getting a schmitt trigger into it as well (though I dont presently seem to be having any bounce issues) and also extending the duration of the LED being on.

Cheers, Rob.

OK. Im officially still confused !!

I dont understand why the photo interrupter provides a logical LOW to the input pin when unblocked (illuminating the photo transistor) and current is flowing. I would have thought that flowing current would have provided a logical HIGH eg 'theres voltage in them thar hills'.

Is it because when unblocked, the base is excited, and the transistor starts to flow current. The current is being 'drawn from' the input pulling the input pin low? But if thats the case, then Im still confused, as doesnt current actually move from negative to positive? EG from Ground to the Pin? Sorry if this is a really dumb question!

As a former pointy-head physicists, in fact my tower wasn't ivory but a 70s concrete and steel affair, let me say it just doesn't matter which way round you think of current flowing as long as you stick to one way. Have you ever thought why a transistor's connections are called emitter and collector, they only make sense if you think of it in terms of electron flow. But in semiconductors you also have conduction due to the flow of holes. Holes are positively charged carriers brought about by the lack of an electron. So conventional current (the sort that flows from + to -) is just a way of describing the flow of holes. So your confusion over:-

The current is being 'drawn from' the input pulling the input pin low

is only caused if you use inconsistent mental models, because you are mixing up the term low from conventional current flow with current direction from electron flow. In the olden days when there were only PNP transistors all circuits were drawn with the -ve rail at the top, and it was convenient to think about electrons flowing from top to bottom. When NPN transistors came along this was simply swapped over. Remember old cars used to have a positive chassis for exactly the same conceptual reason. As Richard says don't mix the two and just think practically as electricity flowing from + to -.