Noise on slotted opto sensor

Hi guys, wondering if anyone could help me understand a problem I'm getting with false readings on a ktir0611s opto coupler. I'm self taught so hopefully I'm getting the terminology correct.

So basically I'm using the slotted sensor to detect a slot cars (scalextric) guide blade passing through the slot; hopefully the diagram below shows the wiring.

The sketch sets input pullup on the input pins on the collector side of the sensor, and for the most part works; however occasionally the car when it is nowhere near the sensor causes a false reading. I'm assuming it's RFI caused by the slotcar motor, and some cars exhibit the problem more than others.

https://drive.google.com/open?id=0B9_HatT62M5BMVV1VzNEQ1FtSDA

I'm guessing an oscilloscope would help me, but I don't have one (or know how to use it). I've re-routed all the wiring which is done with cat5 twisted pairs and played around adding a capacitor to the input, which seems to hide the issue but at the expense it misses some readings. I've also made sure the power to the arduino is separate from the power to the track.

Any tips would be gratefully accepted, and is this the sort of issue I can expect to deal with when sensors are around motors.

If you're using 200 ohm in series with the IRLED, then there'll be (5-1.2)/200 = 19mA through the optic side. The CTR (current transfer ratio is 14%) giving a maximum of 2.66mA available to switch through the transistor.

The internal pullup is somewhere around 30-50K which is rather weak and the signal will be susceptible to noise. I suggest using a 10K pullup (the transistor will switch 0.5mA through this). Adding a capacitor (0.01µF to 0.1µF) from the emitter to GND should eliminate any noise picked up through the wiring.

Thankyou very much for the reply. I'll give that a try, always wondered why people tend not to use the internal pullup.

Adding a capacitor (0.01µF to 0.1µF) from the emitter to GND should eliminate any noise picked up through the wiring.

More might be accomplished if the cap is place from Collector to GND instead.

The internal pull-ups are fine for on-board use, but not an external cable coming in. Cables act as antennas all too easily - unless you specifically take other steps to exclude interference, lower impedance pull-ups will reject more interference.

pwillard:
More might be accomplished if the cap is place from Collector to GND instead.

You’re correct - I misinterpreted the connections as having the collector tied to 5V.