Infaread LED & Detector System
I have a home project where I will need to detect 8 sections of my model railroad hidden stagging tracks to make sure there isn't a train blocking the turnout at each section.· If the section is blocked I want to light a LED on the panel display so that I would know to move the train on that section of track.
Can I use the SX28 Proto Board·to send and read the INFR LED pulses to 8 separate detector sections and then turn on a separate section of 8 standard RED LEDS or do I need other chips to help keep the current drain within range?
I have thought about using the Piezo Vibra Tab·under the sections of track instead of the across the track IFR beams but was concerned about false indications due to vibrations of trains on neighboring tracks.
I didn't want to go the current drain indicator route that most model railroad layouts use as I use DCC in N Scale and wanted clean track power throughout the layout.
I think I can use the infaRed detectors for the hidden section as they are not visible from the layout and I don't have to worry about various room lighting conditions.· A simple blocked section of track by any part of the train would light the red LED to indicate the blocked section.
I would welcome any suggestions from those in the know as I have found reading post on this site a true education that could never be learned via books or schooling.
Roy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Can I use the SX28 Proto Board·to send and read the INFR LED pulses to 8 separate detector sections and then turn on a separate section of 8 standard RED LEDS or do I need other chips to help keep the current drain within range?
I have thought about using the Piezo Vibra Tab·under the sections of track instead of the across the track IFR beams but was concerned about false indications due to vibrations of trains on neighboring tracks.
I didn't want to go the current drain indicator route that most model railroad layouts use as I use DCC in N Scale and wanted clean track power throughout the layout.
I think I can use the infaRed detectors for the hidden section as they are not visible from the layout and I don't have to worry about various room lighting conditions.· A simple blocked section of track by any part of the train would light the red LED to indicate the blocked section.
I would welcome any suggestions from those in the know as I have found reading post on this site a true education that could never be learned via books or schooling.
Roy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Comments
What you are describing can probably be done fairly easily without a microcontroller at all! A 555 could modulate the IR emitters while 8 modulated IR detectors look for reflections (or loss of signal) caused by the presence of a train.
- Sparks
I like your idea but I am clueless as to how to go about doing this on a breadboard.· I could probably figure out how to set up the 555 chip but would I need a 555 clock for each of the 8 Infred LED emmitters or do I drive them all with the same 555 hz signal?
If this can be done, then how do I wire up the 8 detectors such that when the infared beam is broken/blocked, I can light a remote LED to indicate the blocked section of track?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
But you can easily use the SX interrupt to run IR emitters (multiples at different times). In SX/B your interrupt would be something like:
INTERRUPT 77_000 ' 38_500 hz * 2
And the Interrupt handler just switches a pin on and off:
Interrupt_Handler:
IRledPin = ~IRledPin
RETURNINT
You can wire the output of that pin to all your IR LED anodes, then tie each IR cathode individually through a resistor to a different SX pin. Which ever cathode pin is LOW rather than HIGH or INPUT, will light that IR led with the 38_500hz frequency. Then read a corresponding input pin for that detector OR just tie the detector outputs to your display LEDs.
The trick on the SX with the former approach is pins -- if you use, say, RA.3 for the 38_500hz output, and RB for 8 IR leds, and RC for 8 detectors, that only leaves with you 3 pins on SX28. With shift register(s) on those 3 pins you could run lots of display LEDs. Or get the SX48 protoboard (www.parallax.com/detail.asp?product_id=45300) which has another 2 ports.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture
San Diego Miramar College
Totally. Yes. Actually you don't even need 100ms. <1ms per LED and detector would do it. And that way you are not flooding your layout with IR when it's not needed.
Yeah, if you need more display LEDs or whatnot. If shift registers are used for LEDs, only 4 pins would be needed -- data, clock, and two CS lines (one for each bank of 8 leds, whether IR or display). But that said, at $10, an SX48 protoboard would provide plenty of pins so almost almost no external parts (except resistors) would be necessary and it has the regulator and connectors and stuff already built on.
Regardless, say you have the modulated 38.5khz coming out one pin, then 8 pins for IR leds and 8 pins for detectors (just to pick round numbers). You only need to have one IR led on at time, which will keep current draw through the SX down, plus not give you IR "echos" and noise. Rough code might be something like this:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
Post Edited (Zoot) : 10/28/2007 1:49:33 AM GMT
Good point. An SX48 board does have plenty of ports. ... I knew I was missing something obvious!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture
San Diego Miramar College
I envision the detection being done by a modulated IR sensor. It outputs a digital high or low signal depending on whether or not it is detecting an IR modulated signal source. You could either place an emitter on one side of the track and a detector on the other side of the track to detect a train blocking the beam path or else place them on the same side of the track to detect the beam being reflected by the presence of a train. You should be able to dim the emitters by reducing the current flowing through them to achieve the sensitivity required without falsely triggering other detectors nearby. Some light shielding might help to narrow the emitted beans the detector’s view as well.
It is just an idea but I know that this detection scheme is used quite often on mobile robots for object detection.
- Sparks
You might want to experiment a bit on the sensors you use for the detectors. Although using a modulated signal can make detection more accurate and can eliminate false triggers from ambient light it may not be needed for your application. In many cases you can just use some of the reflective sensors as is. Some simple ones are the QRB1114 and QRD1114 parts. A small current limit resistor ~ 330ohm on the IR led is common. Just use two I/O pins for each sensor. One to turn it on and the other as the sense pin. You can still cycle through them and turn on each one at a time so they don't interfere with the other sensors. If you have a bunch you could use something like the 74hc138 so that 3 lines select the 8 and only one is active at a time to tell which one to turn on.
I've seen more of the modulated IR for object avoidance, etc but usually don't see modulated IR when used in encoders or sensors for a home position. If you don't need to modulate the light is makes it much easier to put together.
Another factor may be the color on the bottom of the trains. You may need to attach a reflective strip on the bottom to help with detection. If possible setup a small test track with some of the sensors to test your circuit and program.
With a few more sensors scattered about you could probably calculate scale speed and automate things a bit.
Have Fun,
Robert
I ordered one of th QRD1114's to test out. If it works on the N-Scale layout (distance between railroad ties and bottom of engine then this would be better than an across the track method. If I can pulse and read each set via pairs then there shouldn't be a problem reading false infrared.
I have 4 lengths of track with need detectors on each end so I could use something that woud pulse and read a pair on each end then move to the next pair this way all tracks could be read and I would only need a 2 byte variables to set the pulse and reads.
What do you think about?
L1p L2p L3p L4p R1p R2p R3p R4p = Pulse Out Left & Right Track 1
0 0 0 1 0 0 0 1
L1d L2d L3d L4d R1d R2d R3d R4d = Detect Pulse Left & Right Track 1
0 0 0 1 0 0 0 0
If I can work out the binary bits I could use a simple for x = 1 to 4 next x with some multiplyer to set the pair of bits for the pulse and detects
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·