O Gauge Train control

Hi Guys

I am new to this but have been building O gauge train layouts for 40 plus years What I am looking to do is use an Arduino board to control a set of relays that will switch a pair of trains between sidings using TCRT5000L ir sensor for detection and control the relays to turn power to each siding on and off and to control the track switches so that when it is running one train will run a lap come back to it's siding and key the other one to run a lap and back again I have just started searching if any you know it this has been done before I have done it with just relays and mechanical switches but uses lots of power and needs lots of maintenance because of the direct contact with the trains

Can you expand on how you plan to use the TCRT5000L ir sensor for detection?

I want to mount the sensor under the track so that when the train passes over it the train will be seen basicly I would like the sensor to see the train and fire the relays to stop one start the other and switch the tracks

Sounds as though it should work - you might need to put some reflective material on the bottom of your train .

If you know how to start and stop the trains and control the track switches, it sounds doable.

I would start by making a list of each signal (relay) needed, that will begin identifying which pins to use and how many you will need.

You will also likely need to debounce the ir sensor to prevent false triggering and make sure the end of the train has been detected.

P.S. Debounce = detect pin state change, wait x milliseconds, confirm pin state has changed, then signal new value to the program.

You might also consider using a Light Dependent Resistor (LDR) for train detection. I reckon they would be easier to use than an IR detector. I have some small LDRs that are almost invisible to the eye when placed between OO Gauge sleepers.

...R

My buddy has many N scale layouts with automated point to point sections. The LDR sensors at each end frequently get triggered by passing trains on other rails. I bought TCRT5000 sensors to get around this. (and as is typical for me, they are sitting in a box waiting for me to complete the previous project)

vinceherman:
My buddy has many N scale layouts with automated point to point sections.
The LDR sensors at each end frequently get triggered by passing trains on other rails.
I bought TCRT5000 sensors to get around this. (and as is typical for me, they are sitting in a box waiting for me to complete the previous project)

On that note I would recommend a focused sensor. I have used these http://www.goldmine-elec-products.com/prodinfo.asp?number=G20133 in the past for detecting motor shaft RPM (with the help of a piece of reflective tape , of course).

For your IR sensors, it may be possible to increase reliability by suspending an IR led above the tracks shining directly on the sensor (or at an angle from besides the tracks such as from on top of a building model, whatever works for hiding it nicely), rather than trying to reflect IR off the bottom of a train. Same for an LDR, a strategically placed street light or so could do the job here. You will get triggers in between train cars, as for a short time the light reaches the sensor again. You will have to wait for a long enough signal to make sure the whole train has passed. Finally do look into MOSFETs for switches, rather than relays. At least it'll save you a lot of clicking noises, and they're smaller and cheaper. Model railways normally use low voltage DC, and switching that is what MOSFETs are really good at.

Thanks Guys for the input I will post back as I get the hardware assembled I already have the sensors and relay blocks (relays because O gauge lionel uses high current 18v AC for track power ) I am going to get it wired up and will be back asking question on programming

For AC you can look into TRIACs as electronic switch as well. They can handle quite some current as well, 10-20A should be no problem.

Anyway good luck with your project!

wvmarle: For AC you can look into TRIACs as electronic switch as well. They can handle quite some current as well, 10-20A should be no problem.

Anyway good luck with your project!

Solid State Relays are also another option for AC control. They are triacs with builtin circuitry to guarantee operation with a given input. Triacs can be finicky with the input to turn the on/off. Either will help avoid the power spike (and arc) due to the opening contact under an AC motor load.

just out of curiosity, is this for a model train set or a real life train set?

LandonW: just out of curiosity, is this for a model train set or a real life train set?

As the subject of this thread says, "O Gauge" 1:48.