# How to stall a train before an intersection



## kkl (Mar 17, 2017)

Hi, I'm planning to make use of Arduino IR sensors TCRT5000 for occupancy detection on an intersection so other trains don't get into the intersection when another train has occupied it. I'm running DCC sounded locos, and I'm wondering how I can determine which train to stall and how to slow it down when occupancy is fed back by Arduino. Can someone provide a pointer?


----------



## RT_Coker (Dec 6, 2012)

kkl said:


> Hi, I'm planning to make use of Arduino IR sensors TCRT5000 for occupancy detection on an intersection so other trains don't get into the intersection when another train has occupied it. I'm running DCC sounded locos, and I'm wondering how I can determine which train to stall and how to slow it down when occupancy is fed back by Arduino. Can someone provide a pointer?


I think you have a major case of insufficient Arduino-input information. DDC-locomotives are basically dumb. Even if they knew were there were and what they were doing they would not be able to communicate that information back to the Arduino. 

In theory the Arduino could control the operation of DCC locomotives starting from “known” locations for a little while before the current locations would become basically unknown. You would need to be able to frequently (and successfully) bring the locomotives to a complete stop at “known” locations before everything got out of control. Once that is achieved you will need to add code that will protect the operations from the typical operation problems that can occur, unless you also what train wrecks as a random part of the operations.
Bob


----------



## gregc (Apr 25, 2015)

you would need to send DCC commands to slow a locomotive which, as Bob describes, is complicated.

on the other hand, if you're trying to prevent a collision and locomotives don't have keep alives, you could simply cut power to the track using a relay. You may be able to cut power to a longer length of track if there are keep alives.

one approach is that as soon as a train is detected on the one track, power is cut on the other and reapplied when the opposite track becomes clear.

greg


----------



## ncrc5315 (Jan 25, 2014)

Been awhile, since I've read about this feature, but, I think you can setup a decoder, to not run on DC, but keep the lights and sound on. Have the Arduino, switch the track power from DCC, to DC. Once the other train clears, switch back to DCC, and your train should take off.


----------



## gregc (Apr 25, 2015)

ncrc5315 said:


> Once the other train clears, switch back to DCC, and your train should take off.


how long does it take for a decoder to switch from DCC to DC mode?


----------



## kkl (Mar 17, 2017)

Thanks everyone for the input. It appears I can make use of the TCRT5000 sensors to detect if there is still a train occupying the intersection (say running South-North) and switch the East-West relay from DCC to DC, and vice versa for trains entering the intersection East-West. Is there additional hardware required to handle the short when the loco is sitting on the gap between the blocks (DCC/DC)?


----------



## ncrc5315 (Jan 25, 2014)

gregc said:


> how long does it take for a decoder to switch from DCC to DC mode?


If I remember correctly, the switch is instantaneous, but if momentum is set up in the DCC decoder, it will take the decoder that amount of time once it hits the DC section.


----------



## kkl (Mar 17, 2017)

Is there a way to prevent short circuits when part of the truck is on DC while the other part is on DCC?


----------



## wvgca (Jan 21, 2013)

if you're going to use the 5000 sensor, it's more consistent with being fed a slightly higher voltage with a dropping resistor on each sensor, and then fed to a 'duino ..


----------



## gregc (Apr 25, 2015)

kkl said:


> Is there a way to prevent short circuits when part of the truck is on DC while the other part is on DCC?


 have to consider long locomotives, as well


----------



## ncrc5315 (Jan 25, 2014)

kkl said:


> Is there a way to prevent short circuits when part of the truck is on DC while the other part is on DCC?


I believe you can wire a light bulb between the two sections, and the light bulb takes up the "shock". I'm thinking you would have to have a section of track long enough to hold all of the locomotives, then some type of sensor to switch to DC once all of the power is on that section of track.


----------



## DonR (Oct 18, 2012)

It is generally thought that one should not have both
DC and DCC power active at the same time on a layout.

There cannot be any mechanical or electrical connection
between a section with DC power and a section with
DCC power as you likely would damage your DCC 
Controller. The damage can occur when a loco crosses
over insulated joiners and the power pick up trucks span
both the DC and DCC powered tracks thus 'shorting'
the two systems together.

When both power systems are to be used on a layout it
is generally advised that you use a Double Pole Double
throw switch between your track and the controllers.
The switch in one direction sends DC power to the
layout, in the opposite direction the track gets DCC
power but NEVER both at the same time.

If you want to have a DC powered track section you
should not have any way that a loco can 'get to' a
section that is powered by DCC, no turnout connection.

Use caution when running DC locos on a DCC track
If left to idle you can burnout the loco motors.

Don


----------



## gregc (Apr 25, 2015)

kkl said:


> Is there a way to prevent short circuits when part of the truck is on DC while the other part is on DCC?


why would you have both?


----------



## wvgca (Jan 21, 2013)

you probably don't need both active, just shut off the DCC area in the switch if that's all you're looking for, a relay or something simple like that ?


----------



## ncrc5315 (Jan 25, 2014)

gregc said:


> why would you have both?


If you set your set up your decoder properly, it is possible, once ALL of the locomotives on the DC/DCC track, to switch the track from DCC to DC, (i.e. at a stop signal) the train will coast to a stop, with the lights on, and the prime mover running. When switch back to DCC, the train will take off again.


----------

