gregcConsider using shrink tubing to better isolate the detector from the emitter
You know I read this and thought it a useful tip at the time, then later when I started the actual build I got so involved in the postioning of the sensors and trying to use reflective tapes and such I totally fogot about it.
After about two weeks of fussing around trying to fine tune the detection I remembered your post, tried it and bamm, the detection works perfect now. Seems it was putting out too much IR light or something and the heatshrink really narrowed it down. Thanks again Grecc!
Here are a few more pics of my progress. I managed to add longer leads from the LEDs to the sensor board, which seems to work just fine. The leads are about 5” in length, giving plenty of room to run under the layout and mount the control boards in a more convenient location.
Also if anyone is doing this the “flat” (negative) on the LED cases both point toward the center of the board. So the LED wires are: from left to right (looking at the top from the LED side) detector positive, detector negative, emitter negative, emitter positive.
I also made a temporary track model to experiment with the positioning of the LEDs. After trial and error I found they work best pushed down into their holes and not be sticking out. When they were above or level with the track bed, I could not get a reliable, repeatable trip setting, but when pushed down a mm or so, they work perfect. I know someone mentioned heat-shrinking them in an earlier post to help with extraneous light, so I assume this achieves a similar effect.
Now to add leads to 3 other modules and move them all over to the layout. Since my track is already glued down where I plan to mount these, I will need to bore under the baseboard a bit. I will probably also need to desolder the LEDs from their wires on the module I already done and re-solder them after running the wires through the bore holes.
ATLANTIC CENTRALWow Cisco, that's a lot of parts for that simple task? I get that you don't like the concept that the auto reverse modules use, I don't care for it either.
The parts really aren’t too bad, it just looks more complicated than it really is I think. I just don't like the idea of using a short (which most commercial auto-reverser’s seem to use) to detect the loco and then switch polarity. I know it (gap-short method) is successfully used all over, so it is probably more of a preference than a real concern.
Anyway, I enjoy electronics as a hobby as well, so it is fun for me to do my own thing. I am not really doing anything unique as I found the inspiration from other people who have already done this type of circuit before, I am just enhancing it a bit. I also feel I can add more functionality later utilizing the Arduino and sensors, as I am just starting work on my layout.
As far as the momentary pause and/or switch in polarity I am not sure yet. The sensors activate the relays in real-time, so there is only a ms delay there as you said. I not sure how quick the relays are, they are mechanical so there will be some delay. This will only be a concern leaving the loop though, as before entering the loop section from outside, the loop will already have switched by the time the train enters.
The switching polarity under the loco concern would be the same as with a standard auto-reverser I believe, as the train wheels would need to bridge the gap before it switches. It might be faster with a solid-state relay but the polarity still needs to switch. The gap-short method would also cause a momentary blip I think.
Since it is DCC, which is basically a square wave form of AC, I think the decoder’s rectifier circuit would just filter out the momentary change in phase. I am not sure about any DCC commands coming across the wire at the time, but I assume they are sent multiple times within a short amount of time for redundancy.
I will need to research some on those other topics, but I think right now the reverser circuit will work just fine.
Wow Cisco, that's a lot of parts for that simple task? I get that you don't like the concept that the auto reverse modules use, I don't care for it either.
I don't get the four relays doing the job of one, and I'm not sure what happens when you reverse the phase of the DCC signal under the moving train.
Seems to me the relay (or relays) will result in a millisecond pause in track power? Will all decoders ignore that?
The auto reverser detects the short and changes the phase before the loco is in the loop.
I don't use DCC and it has been a while since I helped any friend with it. So I'm just wonder here.
Sheldon
The test setup works great as expected. I think the only challenge going forward will be mounting the actual sensor LEDs (emitter/detector) under the tracks.
I think I will try to desolder a pair of LEDs from one of the module boards and attach small leads (4-6 inches) to them and work from there. That way I will have more room under the shallow layout in this section to work with. The only question for now is if adding a length of wire to the LED and detector will have any effect on the boards operation.
Cisco_Kid Well I am not sure what I am thinking, maybe I am overthinking it to be honest. I have added an image below showing my working notes so far: I put in the order, but I haven't received any components yet to experiment with, but this is my general plan. The module I will use only has single-pole double-throw relays on-board, so I will need two at a minimum. The other two relays being a power cutoff, I thought of a train stopping right on the gap (short) at power up, not that this is likely but things happen. The delay to apply track power to the loop section would allow the rest of the logic to detect the train and set the polarity relays appropriately before power is applied.
Well I am not sure what I am thinking, maybe I am overthinking it to be honest. I have added an image below showing my working notes so far:
I put in the order, but I haven't received any components yet to experiment with, but this is my general plan. The module I will use only has single-pole double-throw relays on-board, so I will need two at a minimum.
The other two relays being a power cutoff, I thought of a train stopping right on the gap (short) at power up, not that this is likely but things happen. The delay to apply track power to the loop section would allow the rest of the logic to detect the train and set the polarity relays appropriately before power is applied.
I am no wiring guru and will consistently bow down to those here who are, but some of the solutions you are putting forth seem to be somewhat mind boggling, at least to me. I have two reverse loops on my layout, each wired with a PSXX-AR, gaps not offset, and have never had an issue with either doing its job. Other than making sure my longest trains will fit into each loop (not a big issue for me) I have no other back ups in place and it's never been a problem. When wiring, I try as much as possible to keep to the "KISS principle" - less to mess with and to trouble shoot.
Cisco_KidIf power goes out while a train is traversing a gap there would be an unknown state when power comes back on and a chance of the wrong polarity being set.
not sure what you're thinking, but i don't see a problem. If the loco or cars are straddling the gaps, they should be detected when power is restored and the polarity set to match that end by the logic
Cisco_KidI also think I will need a 4-relay board, as two relays will control the polarity reversal, as outlined previously, the other two would control power to the loop.
again, not sure what you're thinking but you should only need a single DPDT relay that is wired as a reversing switch. the detectors at one end would close/open the relay to match the polarity at that end. the detectors at the other end do the opposite
any code simply acts as a SR-flip-flop being in one of 2 states. As a train enters the reversing loop, the detector may cause the logic to togle the relay and togle it again when exiting.
If a train is inside the loop at start-up, there's no need to do anything. the relay may be togled when the detectors sense the train exiting
Cisco_KidThe IR module might work well but would be harder to install as it is on a small circuit board. I might need to see if I can remove the LEDs and attach them to the board via a short wire. I will also keep in mind your shrink tubing idea.
if these are what you have, i replaced the LEDs with smaller ones with longer leads
greg - Philadelphia & Reading / Reading
richhotrain One thing that I should mention is that I use Circuitron Opto-Sensors for occupancy detection and they do not trigger if I reach over them. They only trigger if completely covered by a locomotive or rolling stock. Otherwise, there is sufficient light to keep them deactivated. Rich
One thing that I should mention is that I use Circuitron Opto-Sensors for occupancy detection and they do not trigger if I reach over them. They only trigger if completely covered by a locomotive or rolling stock. Otherwise, there is sufficient light to keep them deactivated.
Rich
Thanks Rich, I will keep the Circuitron Opto-Sensors in mind. It gives me hope for the optical solution I outlined above and if the Amazon supplied detectors don't work out so well I have a second option to look into.
After more thought on this, I am thinking reed switches might be out for detection. If power goes out while a train is traversing a gap there would be an unknown state when power comes back on and a chance of the wrong polarity being set. One of the optical solutions would detect not only the locomotive, but also any car within its range.
I also think I will need a 4-relay board, as two relays will control the polarity reversal, as outlined previously, the other two would control power to the loop. When the system first comes on, the power control relays would be normally open, so no power at all would be going to the loop. I would code in a startup delay, maybe 500-1000ms to let system initialize and determine if any of the sensors are active.
If a pair of sensors is active, set the appropriate polarity via the polarity relays before turning power on through the power relays. If no sensors are active, I would simply code one path Track A or Track B to be the default state and turn power relays on after the delay as well. The circuit would then detect which way the polarity would need to be switched once the train activated a set of sensors, as it normally would.
gregc presumably you have IR emitter/detector pairs that work by reflecting light from the bottom of a car rather than depending on room lighting. If not, IR sensors may not work with fluorescent or LED lighting. Consider using shrink tubing to better isolate the detector from the emitter the IR sensors approach would handle cars with metal wheels as well as a loco
presumably you have IR emitter/detector pairs that work by reflecting light from the bottom of a car rather than depending on room lighting. If not, IR sensors may not work with fluorescent or LED lighting. Consider using shrink tubing to better isolate the detector from the emitter
the IR sensors approach would handle cars with metal wheels as well as a loco
Correct, I ordered the IR pair modules (emitter and detector on same board) which also have a trim pot for sensitivity adjustment. I supply 5v, and it returns either a high 5V when nothing is detected or low 0V when it detects something nearby. They also have a small led right on the module for real-time fine-tuning via the on-board trimmer potentiometer.
I also ordered plain old photo-resistors in a 20-pack, which will work similar to the IR modules, except they are free-stranding components. I hook one end up to the 5V ground and when it detects light it is lower in resistance than when it is dark, so it will pull low with nothing blocking light, and when it gets dark resistance goes up and the pin will go higher. I will need to use the analog pins on the Arduino for this detection though, as it will not produce a solid high/low as the IR modules will. Also, these may not work if I have a darkened room as they rely on the ambient light for detection.
Then I also ordered reed switches which will works as above except when a magnet is nearby (glued to bottom of loco).
I figure I will experiment with each type of sensor to see which will work best. The photo-resistor would work best for easy implementation, as I drill a small hole in-between track rails and it would sense when something pass over, but as mentioned I am not sure about false positives or if room would become too dark.
The IR module might work well but would be harder to install as it is on a small circuit board. I might need to see if I can remove the LEDs and attach them to the board via a short wire. I will also keep in mind your shrink tubing idea.
I think the reed switches would be the most reliable, I just need to figure out the magnet mounting situation.
I am amazed by the low-cost sensor/module options available for the Arduino projects. I guess I knew about it but never really looked into utilizing the platform for projects before. Finding out about all these different types of sensors, motor control modules, etc. that are available for very low cost is going to open up a lot of possibilities for me even outside of model railroading.
Cisco_KidI was thinking the IR modules might work best, but was reading about how reaching over the layout could trigger the circuit accidentally, same as with the photo resistors.
Cisco_Kid I was thinking the IR modules might work best, but was reading about how reaching over the layout could trigger the circuit accidentally, same as with the photo resistors.
I was thinking the IR modules might work best, but was reading about how reaching over the layout could trigger the circuit accidentally, same as with the photo resistors.
Alton Junction
I think I am going to try my hand at wiring up 4 sensors to an Arduino, output that to a dual relay module and switch my loop polarity that way. I found a pretty good write up on exactly what I think I need by a guy named Rudy B, so will follow in his footsteps.
I not sure of which type of sensor will work best, so I ordered the Arduino, dual relay module, a bundle of black reed switches (match the rail ties) with magnets, 10 pack of IR modules, and 10 photo resistor sensors.
It all was only around $35 on Amazon, and if it doesn’t work out I can use the Ardunio and sensors for signaling or something else.
I was thinking the IR modules might work best, but was reading about how reaching over the layout could trigger the circuit accidentally, same as with the photo resistors. I might use them elsewhere though and they are all cheap anyway. The reed switches might work best, but the only downside is I need to place magnets on the locomotive to trigger them, but that might not be too bad.
wrench567We had the same type of loop with a double x over. We ended up having to put another AR on the X over. Some X overs are not too well insulated and the single AR would get confused and see it as a short instead. Putting the second AR for the X over solved it.
would like to see a diagram and know if the rear rails of both mainline were the same or opposite polarity.
You could use Circuitron Opto-Sensors.
Thanks to everyone for the additional input.
I plan to keep the reversing loop separate from the crossover, the insulated gaps will be closer to the actual loop portion and the straight-away section going toward the crossover will be back to parallel track wiring well before it gets the crossover (about 96” or 8’).
Keeping the reversing loop its own entity for now and controlling the crossover separately seems to be the easier way to proceed. My loop will be over 136”, so it should be plenty long enough for a ~25 car train.
I am still evaluating the best choice of reversing circuit, the earlier suggested PSXX-AR seems well suited when also controlling a crossover, but since I am just using the loop portion alone I wonder if there are other solutions.
I would actually be interested in any sensing type circuit not relying on a short to detect the train’s presence. Maybe something using optical, IR, proximity, or some other type of detection to reverse the polarity before the train enters or leaves the loop. I seen some homemade type units in my research, but there doesn’t seem to be much in the way of off-the-shelf products like this.
I have a large double mainline layout with four reversing sections, each controlled by a separate PSX-AR. If you unfold my layout, it is a long narrow oval consisting of two 165' double track mainlines. In the center are four double slips to permit trains running in either direction to cross over to another of the four tracks. Each of the four end loops is its own reversing section. All of the track, including the four double slips, between these end loops form a single non-reversing section. All of my gaps are directly across from one another on each pair of rails. I have never had a problem, not even once.
We had the same type of loop with a double x over. We ended up having to put another AR on the X over. Some X overs are not too well insulated and the single AR would get confused and see it as a short instead. Putting the second AR for the X over solved it.
Pete.
CharlieMI'm not sure the 3/4" offset is necessarey but I did it because DCC Specialties recommended it.
we're having a problem when a train comes out of a reversing loop. looks like the PSX-AR is not reversing fast enough and the the PSX breaker the train enters is shuting down
the PSX only monitors one rail for a short. this suggests that if the gap closer to the reverse section is NOT on the rail the PSX monitors, that the AR will trip before the train gets to the 2nd offset gap the PSX monitor and the PSX won't trip.
this may be at least one explanation for offsetting the gaps
I'm not sure the 3/4" offset is necessarey but I did it because DCC Specialties recommended it. I presumed they had a reason. I can imagine, with no offset and a bit of locomotive bounce, there might be some confusion to the reverser.
Re the loop length, I have found a 25 car max length to be plenty. Although I model in HO the principles are the same. If you plan any operations at all you will find train length limited by passing track length, staging length, and/or yard track length. Added loop length is not harmful but may not add much benefit unless you just like running really long trains. Also, if you ever consider using the PSXX to control the crossover, you need to leave adequate distance between the track breaks and the crossover. In HO I leave 24-30 inches to ensure the turnout has time to operate with the trains approaching at 60 scale MPH. That distance will change with N scale and your maximum train speed but be sure to consider it.
Charlie - Northern Colorado
richhotrain No need for the offsets. My gaps are always directly across from one another.
No need for the offsets. My gaps are always directly across from one another.
Ok, I was basing the offset gaps off of the PSXX-AR manual. Good to know it works without the offsetting.
Thanks everyone for all the useful information, I would rather clairfy what I need to do now than find out later I was wrong and blow something up.
I now need to figure out if I need to extend my isolated loop end. Right now I have about 136 inches of track inside the loop. I am running N scale (not sure if I mentioned that earlier) and the longest 60' boxcar I have is just shy of 5" measured from coupler end to coupler end.
So using 5" for my average car length would allow me to run around 25 cars with a loco. I don't even have 25 cars yet, so it may be enough but I could probably move the gap down the straight tracks more toward the double crossover, say 15" giving room for 6 more cars or a roughly 30 car train.
You are correct regarding the wiring protocol inside the reversing section. The wires that power the auto-reverser connect from the main bus directly to the input side of the auto-reverser. The wires that power the reversing section connect to the output side of the auto-reverser.
Thanks for your input as well.
So from my understanding, I need to make sure the isolated loop section is longer than my longest train and gap the tracks of the reversing section with offsets of 3/4" (21 mm) in two places to create the iosolated zone.
It also seems I need to power the auto-reverser from the same bus that is feeding the parallel tracks and the auto-reverser feeds the isolated loop section.
Seems simple enough in concept, but this will be my first additon of an isolated loop section so it is still new to me.
I second Charlie's suggestion. Wire the parallel tracks the same way to maintain proper polarity. It won't matter which way you wire inside the loop since the auto-reverser will match polarities.
Alright, thanks.
I figured I would need some type of auto reversing circuit. I'll look into your recommendation.
Cut gaps in both rails of both tracks someplace near the beginning of the loop section. This should leave the loop section long enough for your longest train. Power the resulting isolated loop with an auto-reverser such as the DCC Specialties' PSXX-AR or PSXX-ARSC depending on how or if you want to control the crossover.
Trying to figure out how to wire this up so that the upper rails on both lines end up with the same (negative) polarity for a DCC system. I know I will need insulators, but do I also need a reverse loop device. I obviously will need to get the polarity correct before coming back and hitting the double crossover.