layout under construction includes return loops, three in parallel to be exact. need a reversing loops controller and pondering on advice.
ideally not bank breaking, some of the commercial ones are serious cash, others less so but still not cheap.
the layout has block detection equipment, current sensing (and lets be honest if stuff doesn't draw current for a reverse loop it may as well no be there) and wondering on using that, could go with IR detectors as well though.
thinking this through and interested if anyone can spot the logical problem.
1. track power is reversed via a DPDT relay
2. each end of the reverse section gets two detectors, one say two inches either side of the join, the two detectors at each end are connected via an OR gate - point being not to care which way a train approaches the gap - just that the polarity needs to match at that end
3. this provides two feeds into a micro controller which keeps an eye on them
4. when the detector for say end "A" indicates a train is present the controller checks the state of the relay, and if needed adjusts it - in practice it can set the state each time, if its set for that end there will be no actual change. if the detector at the other end triggers then the relay is set accordingly
5. the relays logic drive line can have an LED for logic HIGH and for logic LOW (and if its in an unknown state both will illuminate)
this won't prevent an actual short circuit, or indeed detect it, but it should work to spot trains.
possible issues:
- layout needs to operate under artificial light and a level of darkness, will need to validate how well the IR sensors work
- IR sensors can be a pain working with black painted underframes, could adapt to use a beam that crosses the track so the train cuts the beam - I have done this for slot car lap counters and it works
- current sensing means a lot of blocks are needed, probably overkill
the thinking though is this is cheap, I already have the relays, finding a spare Arduino or similar around here is hardly a problem, all 12 sensors drives 6 OR gates and 6 logic inputs, then three relay outputs, this is hardly going to tax an Arduino.
seems cheaper than the Digitrax AR-1 which seems to be the cheapest of the short circuit detecting modules out there
thoughts?
DCC return loop module
-
- Posts: 1526
- Joined: Thu Apr 29, 2021 9:48 pm
- Contact:
Re: DCC return loop module
Your idea for a non-shorting solution is an excellent one. The control methodology is quite straightforward since it is a simple event driven process - 'if a sensor changes state set the appropriate relay state'
If you have doubts about making effective reflective I.R sensors I would recommend that you consider using IRDOT sensors. These are incredibly effective at detecting a reflection from underneath the blackest of stock and have excellent immunity from ambient light.
Will the loops be used bi-directionally or always in the same direction? If always in the same direction you just need two sensors, one before entering the loop, and one before leaving which halves the number of sensors required.
Loops are often connected to a single point which you can use to set the polarity of the loop without needing sensors.
I know that you already have some relays, but give some thought to using twin coil latching relays that can be driven directly from the logic outputs of your microcontroller. This has a few advantages:-
1. You don't have to save the state of the relay in your code (more to worry about and go wrong). For latching relays you just send a pulse each time a sensor is triggered.
2. You don't have to worry about the power consumption of having a relay energised for a long time.
3. It will always power up in the correct state as you left it so no need to worry about parking a train in the loop.
If you have doubts about making effective reflective I.R sensors I would recommend that you consider using IRDOT sensors. These are incredibly effective at detecting a reflection from underneath the blackest of stock and have excellent immunity from ambient light.
Will the loops be used bi-directionally or always in the same direction? If always in the same direction you just need two sensors, one before entering the loop, and one before leaving which halves the number of sensors required.
Loops are often connected to a single point which you can use to set the polarity of the loop without needing sensors.
I know that you already have some relays, but give some thought to using twin coil latching relays that can be driven directly from the logic outputs of your microcontroller. This has a few advantages:-
1. You don't have to save the state of the relay in your code (more to worry about and go wrong). For latching relays you just send a pulse each time a sensor is triggered.
2. You don't have to worry about the power consumption of having a relay energised for a long time.
3. It will always power up in the correct state as you left it so no need to worry about parking a train in the loop.
-
- Posts: 1526
- Joined: Thu Apr 29, 2021 9:48 pm
- Contact:
Re: DCC return loop module
the loops will, generally, be one directional, however they will need to allow for reverse movements (in the short term the "other end" terminal to reverse stock the other way won't exist). life is slightly complicated here as each loop will be storing two trains, as such only half of it will be reversed which makes using the points settings awkward (also three in parallel which could have different requirements so points logic while possible is awkward)
I did think on latching relays, in theory the saving state bit doesn't matter, though it does require code changes to manage the pulse (not a huge issue) and ideally to save the state once its known internally so as to only pulse when a change is actually needed - to be honest the current draw of a relay isn't huge in the scheme of things - also slightly complicated by the reversing bit will go over two board joins.. plan is a relay on each board so only the signal wire needs to be run (may end up using wifi for this as the layout has it anyway). the saved state shouldn't matter much as it will reset as a train approaches the end - though latching relays will hopefully remove the problem if power goes out while a train is crossing the isolated join and then power comes back on so overall a very good shout on that
for the sensors "da plan" as it currently stands is an IR LED set into the track between the sleepers and a 3d printed gantry over the tracks holding the sensors - so the trains cut the beam, no requirement for reflection and since this is a non-scenic area the fact this will look a bit unprototypical is fine
I've got some bits on order to have a play around with it at least
I did think on latching relays, in theory the saving state bit doesn't matter, though it does require code changes to manage the pulse (not a huge issue) and ideally to save the state once its known internally so as to only pulse when a change is actually needed - to be honest the current draw of a relay isn't huge in the scheme of things - also slightly complicated by the reversing bit will go over two board joins.. plan is a relay on each board so only the signal wire needs to be run (may end up using wifi for this as the layout has it anyway). the saved state shouldn't matter much as it will reset as a train approaches the end - though latching relays will hopefully remove the problem if power goes out while a train is crossing the isolated join and then power comes back on so overall a very good shout on that
for the sensors "da plan" as it currently stands is an IR LED set into the track between the sleepers and a 3d printed gantry over the tracks holding the sensors - so the trains cut the beam, no requirement for reflection and since this is a non-scenic area the fact this will look a bit unprototypical is fine
I've got some bits on order to have a play around with it at least
Re: DCC return loop module
I am sure the theory is sound and clearly you enjoy this, but as one who had at short notice to get some unfamiliar industrial plant operating, which proved to be dependent on a 'single man' devised sensor and relay logic network to operate, I would want a sensor and relay function check at the start of the operating session to verify 'all working'. Just saying...
-
- Posts: 1526
- Joined: Thu Apr 29, 2021 9:48 pm
- Contact:
Re: DCC return loop module
have mucked about with enough stuff now to generally include startup diagnostics.Bigmet wrote: ↑Tue Aug 13, 2024 11:29 am I am sure the theory is sound and clearly you enjoy this, but as one who had at short notice to get some unfamiliar industrial plant operating, which proved to be dependent on a 'single man' devised sensor and relay logic network to operate, I would want a sensor and relay function check at the start of the operating session to verify 'all working'. Just saying...
actually pondering adding a power relay, normal, not latching, so no power is on until commanded, and have the thing monitoring all the sensors shut down if sensors at both ends of a loop activate at the same time.
the whole thing is not safety critical thankfully as its only toy trains but its always worth doing stuff like this
same as how a transistor drive for a relay needs to include the blue resistor shown below, this ensures the thing really is off until told to be on, plus the two LEDs provide definite state indication, shown as 100k.
output indicator LEDs are optional but can be useful
- Bufferstop
- Posts: 13904
- Joined: Thu Mar 11, 2010 12:06 pm
- Location: Bottom end of N. Warks line
Re: DCC return loop module
Commercial reverse loop modules rely on detecting the short circuit caused by the emerging loco faster than your short circuit protection system does. There's a problem in the design. Can you guarantee it won't cut out quicker when the system is busier? Go for the photo electric option, deliberately short circuiting a supply isn't good practice in any design. Talk to Dad-1 about the problem he had with frog juicers.
Growing old, can't avoid it. Growing up, forget it!
My Layout, My Workbench Blog and My Opinions
My Layout, My Workbench Blog and My Opinions
-
- Posts: 1526
- Joined: Thu Apr 29, 2021 9:48 pm
- Contact:
Re: DCC return loop module
quite, my main rail experience is 1:1 scale and there the idea you would allow a short circuit, then detect and swap something before it does damage wouldn't exactly pass muster. mind you the idea of jucing a multiple unit through the rails could raise the odd eyebrow.Bufferstop wrote: ↑Tue Aug 13, 2024 8:48 pm Commercial reverse loop modules rely on detecting the short circuit caused by the emerging loco faster than your short circuit protection system does. There's a problem in the design. Can you guarantee it won't cut out quicker when the system is busier? Go for the photo electric option, deliberately short circuiting a supply isn't good practice in any design. Talk to Dad-1 about the problem he had with frog juicers.
in the curious situation of needing to put the gubbins in, but the actual reverse loop won't wrap around for a while yet (half is on current board, half yet to be built - in effect this becomes a siding with the ability to flip the current about.. think I will be making just about long enough to get both detector arrays in, can at least use one of the siding tracks to experimentificate before it goes right around.
plus side, when I did this for slot cars I was trying to detect the blade in the slot, going north of 5 m/s which doesn't sound much but was, and also trying to read a digital signal from the underside of the car at the same time.. amazing what even a 16MHz Arduino can do really
pictures will follow as the bodging continues
-
- Posts: 1526
- Joined: Thu Apr 29, 2021 9:48 pm
- Contact:
Re: DCC return loop module
a simple test of the detector side has been undertaken, a very simple one - IR LED, 3mm so it fits between sleepers and a "Flame Sensor" module from eBay - this is basically an IR Phototransistor with a comparator to provide a digital on/off output.
ignore the Arduino, its purely there to provide the +5V supply via a USB lead at this point.
the idea is IR LED below the tracks pointing up, the sensor above, pointing down. will normally "see" the LED, which will be blinded when a train is there - works nicely at a bit over the 3" vertical gap and has a reasonably narrow field of view so should be ok with a few of these adjacent to each other - especially if the LED is put in a bit of black painted tubing.
when I get the time I will get an actual prototype set up to test with rolling stock, working on getting power to the part of the layout to connect it to at present.
the sensors will pull double duty to report when the entry to the loop road has been cleared by the trailing vehicle - I may do that with a software delay or add a timing circuit to the output basically so it doesn't flicker as vehicles go over when it sees the gap - maybe a 1s - 3s timeout feature so when it reports "no train" you know one has properly cleared - will experiment more with that
ignore the Arduino, its purely there to provide the +5V supply via a USB lead at this point.
the idea is IR LED below the tracks pointing up, the sensor above, pointing down. will normally "see" the LED, which will be blinded when a train is there - works nicely at a bit over the 3" vertical gap and has a reasonably narrow field of view so should be ok with a few of these adjacent to each other - especially if the LED is put in a bit of black painted tubing.
when I get the time I will get an actual prototype set up to test with rolling stock, working on getting power to the part of the layout to connect it to at present.
the sensors will pull double duty to report when the entry to the loop road has been cleared by the trailing vehicle - I may do that with a software delay or add a timing circuit to the output basically so it doesn't flicker as vehicles go over when it sees the gap - maybe a 1s - 3s timeout feature so when it reports "no train" you know one has properly cleared - will experiment more with that