Model Train Forum banner

My first shelf layout

10150 Views 136 Replies 13 Participants Last post by  Shdwdrgn
After a recent discussion of shelf layouts, I realized that this would be an ideal way for me to build some test track where I could try out ideas before starting on my full layout.

My goal is to build a small switching layout where I can test the idea of completely automating yard functions, allowing a computer to reliably move cars around to various locations. Bonus points if I can also write an algorithm which allows the locos to sort individual or groups of cars into a specific order without having to dictate every step of the process.

This layout will be built in HO scale as an 'L' shelf, and I believe the yards on each end will provide a variety of situations that I can test. There is also a mainline track (highlighted in gray) which the switchers will need to keep clear, further complicating procedures. Once I started reading in to switching puzzles, I realized that the right side is actually a variation of the classic 'timesaver', so that gives me at least one known puzzle to work with.

I hope to build this with some easy slopes so it's not completely flat, but otherwise plan to keep it fairly simple.

This weekend I took advantage of some spectacular weather and got some 1/2" plywood and 1" foam cut for the shelves. Last night the shelf brackets were mounted on the wall and everything put up in place over my computer desk. For reference, each leg is 12" wide and 72" long, so it really makes a pretty decent sized setup for HO.

I will be using arduinos to build a version of DCC++, and DCC-controlled servos for the turnouts. The 1" foam gives enough room for the servo horn, so I think I can just cut out a notch for each servo. To keep everything easily accessible, I'm going to try and mount all of the servos to the front of the shelf (inside their respective notches) and slide piano wire up to each servo. Then I will cover the whole layout with a final sheet of 1/4" foam to cover the electronics, and a piece of wood trim across the front will hide the equipment but be easily removable for access.

The turnouts are a hand-laid design I came up with to help crunch all the track into a small space. Basically they are each a 15-degree curve of 20.75" radius. I will be running Bachmann 0-6-0T switchers and cars that are 40' or less, so everything should easily handle the tight turns.

Since I have so many details to work out initially (plus building all the turnouts), this will be a fairly slow project to get started, but I'll post pics whenever something interesting happens.
See less See more
1 - 20 of 137 Posts
I use xTrkCad. About the only thing it won't do is 3D views.
Eventually I'll add in RFID, but I don't think it will be needed for this layout. Ideally the computer should know where all the cars are at before and after each move. Most of the detection should be simple IR LEDs at the beginning of each spur so the computer can count how many cars go in and out. I also want to start working with occupancy detection based on resistors across the wheels. Basically the more information I have to work with, the more reliably the computer can move things around.

Coupled along with this, I've been working on a design for an ESP32-based loco decoder. Once I have the basic movements worked out from a desktop computer, I want to set up something where there is a posted schedule of what cars need to go where and when, and the locos will perform tasks based on if they are a mainline or a switcher.

I've always had a passion for model trains, but I just love writing computer code and making things happen. Being able to combine the two just makes me feel like a little kid again.
See less See more
Yeah RFID is fairly straightforward when you have an arduino to read the data. I have some RFID stickers that can even be programmed with specific data, so for example you could put in the road name, car number, and other data, then you wouldn't need a lookup table to figure out what you're looking at. I don't plan to have readers everywhere, but placing one at the head of each yard would allow easy management of what goes in and what comes out, plus it would allow for double-checking the data managed by the IR LEDs.

I haven't played with JMRI at all, but one of these days... That video looks interesting, I'll have to watch it when I get a chance.. Thanks!
Yeah I'm certainly an odd duck in that regard. I work with computers and write code all day, then I come home and work on my own servers and projects at night. Or sometimes I work on my servers at work, then write code for work over the weekends. I just have a real passion for computers. :)

I've run into one unfortunate issue already. I spent so much time making sure I got my 45-degree angles cut just right so my shelves would fit perfectly... and it never occurred to me that the damn ROOM would be out of square. We have snow and cold temps predicted through the rest of the week, so I have no idea when I'll be able to fix this. Oh well, it's still gonna be awhile before I need to worry about that.

I think for the idea of having the servos at the front of the shelf, I need to find some tubing for the piano wire. Will have to check what the local hobby shop has on hand, at the very least I know they have a supply for RC vehicles that might work.

I also picked up a roll of Woodland Scenics foam bed to use for my mainline, then I'll transition down to putting the yards directly on top of the pink foam. I have almost no experience with the landscaping stuff beyond a bit of work with roadbed gravel, but I want to make sure the mainline on this shelf stands out distinctly.

I've been looking around for a latch I can 3D-print. I'm trying to find something that is relatively flat, but where I could put a couple of them across the joint in the center of the L so I could take the shelf apart, and when it is latched back together the frames are lined up precisely. Although it might be easier to have some kind of alignment dowels buried under the pink foam with just a simple latch on the exposed underside? Yeah, just one more thing I need to really figure out before I start gluing things in place.
See less See more
Sorry, I guess I forgot to mention that I like to make things portable so they can be shown. You see a lot of huge layouts at train shows, but you rarely see something small that people can actually do in a small space (except for Z-scale of course). I think it would be great to bring something on a smaller scale that shows people an alternative, and obviously not everyone is into endless loops of track.

So yeah, the gap could easily be filled in a permanent layout, but I think it would be better to cut everything to a precise fit. If I take it to a train show nobody is going to notice it isn't exactly square, but I do need a good fit to build around.
Cool, thanks. Always good to bookmark another supplier.
At the train club meeting last night I brought up the issue of my non-square room corner, and after talking with several people a simple idea was suggested... I'll just stick some weather-stripping foam on the back of the boards and let it squish to fill the back gap.

Unfortunately no other progress yet other than laying out some of the electronics on the shelf. I should probably start getting the arduinos programmed at least, but I really need to mock up a servo motor with a turnout and get that part figured out. And I need to decide on the landscape topology so I can determine where I might need to work around the turnout wires.
Whew, two pages in and I haven't even posted pics yet. Well there's not really much to look at, but here's what I have...

So as a recap, each leg is 6' long at the back edge, and this will be in HO scale. The short length of foam on top of the second picture is where I will be testing out setting up a servo to run a turnout. The hobby shop has this nice stiff black tubing (about 1/8" diameter) which is used to hold RC antenna wires. I plan to put the servos along the front edge of the layout so they are easily accessible, then run some small piano wire through the tubing and back to each turnout. Of course the servo horn moves much more than the throw of the turnout points, so my idea is to put a 90-degree elbow in the piano wire where it exist the tubing. With about 1" of wire after the bend I think it should give enough flex to take up the slack from the servo movement, and do a good job of pinning the points in each position. I picked up some foam board last weekend, and plan to use that to cover the tubing and servo, and leave a slot for the end of the piano wire to come through and move the turnout points.

I hit ebay last night and today to pick up a 15VDC power supply and a 5V voltage regulator. I have an ESP32 flashed as a DCC++ base station, and an arduino nano flashed as a decoder for the turnout servos. I will probably add another arduino as an S88 module to pick up various IR LEDs for sensing when cars get to the ends of the sidings. The 5V regulator will be to run the ESP32 and arduinos.

Yeah, there's a lot of pieces in play right now, but the biggest challenge is figuring out the servo activation of the turnouts, and I need the DCC system up and running to work on that. Still a lot of work to go before I can even think about running a loco on it!
See less See more
Yesterday I finished building the first turnout for the shelf, and I'm ready to test how it works under servo control. Problem is, I don't have any electronics! No worries, I have some items already flashed and ready to hook up.

I ran into a problem almost right away. I ordered a 15V 3A power pack off ebay which arrived earlier this week. Feels awfully light weight, and when I plugged it in, the meter briefly read about half a volt and then started dropping towards zero. Yeah this one is crap. I pulled the power off my loop layout and it works just fine. I had a small circuit board I started previously, cut to roughly the same size as my ESP32 board and set up with header pins so the ESP can be plugged in and removed. This board holds a transistor and a couple resistors, a 2-pin header for power, and a 5-pin socket which feeds the control wires to the H-bridge. All together this creates my DCC++ command station.

I have a couple pieces of flex track laid on the shelf and was able to run the loco back and forth without any problems. Good deal, everything works! Now I just need to hook up an arduino nano to run the servos.

I have some 0.032" piano wire to control the turnout points. I bent some up and determined that the maximum throw of the servo will be about 3/8". With a 1" elbow on the end of the piano wire, it allows plenty of flex to move through the full servo swing without stressing the turnout. This springiness also helps make sure the points seat into position, so I think it's going to work very well.

So that's about it for today. I need to get the turnout and servo temporarily mounted, then I can test the operation through DCC. Once I know for sure the concept will work, I can actually start laying down foam and track. (Oh... I'm gonna need to order some track!)
See less See more
More progress... I got an arduino set up for S88 last night and it successfully registers when I short the inputs to ground. Now I need to play with some IR LEDs and block detectors. Just putting an IR sensor at the end of every track will require 12 sensors already, but it would help to have a few others in place. The arduino can handle 16 inputs each, so I'll need at least two for the S88 network.

I got two boxes of flex track ordered! Guess I better get to work building turnouts now so I can start laying down track once the boxes arrive.
I have two different circuits for the IR sensors now -- one is normally-open and the other is normally-closed (meaning the first triggers when something breaks the beam and the second triggers when the beam is seen). I have one set up at each end of the track and wrote a bit of PHP code that simply monitors the command-station output (essentially it is the JMRI code) to stop and reverse the loco when it gets to each sensor.

Within the code I am trying to set up a simple structure that reacts to the sensors being triggered. I'm pretty sure there is something similar in JMRI, but this is going to be the basis for my own code to perform complex operations automatically, even though what I have now could potentially be built into something that appears pretty complex. I'm hoping to make my code a bit more reactive -- for example if there is an IR sensor over a decoupler, I want to tell the train to back up until 3 cars have passed, stop and pull forward, and if the sensor gets triggered again then the cars did not decouple and the operation needs to be tried again.

There are still a couple more things I want to try before I get started laying track (and get back to building turnouts)... I need to test two other sensor types: a magnetic reed switch, and a track occupancy detector. And I have a sensor for RFID stickers that I want to try and read.
See less See more
The shelf is actually a great test-bed for what I have planned for my full layout. To summarize, I really love fully-automated devices, but when it simply has to follow the exact same motions over and over again it gets boring to watch. The rough overview of my goals are to build a system where each loco is given a task to fulfill. Switchers move the cars for loading and unloading, and prep a string for pickup. Mainline locos pick up the strings and take them from town to town.

Now sure, I can program a set routine for each loco, but again that's just boring. So to begin with, I'll throw in some random factors. A car didn't get unloaded in time, so it'll have to be rescheduled for tomorrow's pick-up. A loco stalled while climbing the mountain, so it fouls one of the mainlines while waiting for a helper loco, causing reschedules or using alternate routes. Get the idea?

Having a short train isn't too difficult to work around. The software just needs to realize that only two cars are being dropped at a siding instead of three. But rerouting and rescheduling on the fly... that's where the real meat of the software will be. Part of the task is to map out the entire layout, so if one route is blocked, an alternate route can be selected. But wait, if another train is already scheduled on that route, can I slip in around it? There will also be priorities for each train, so a passenger train looking for an alternate route could supersede a freight train. How do we calculate priorities? Well someone on this forum posed an interested question last year regarding if anyone worked with budgets on their layout, calculating the cost of running a train per the weight and value of the loads. It made me think that if I could have lookup tables of the dry and loaded weights of each type of car (plus or minus some randomness of course), and the value of each load per ton, and throw in a generic running cost for the loco to pull the train... now you've got something that allows you to calculate a general cost/value of each train, and a way to automatically prioritize who gets to use the available mainlines.

There are a few more random variables that can be tossed in. For example, if I have a string of 10 hoppers with the same load, but I only need to drop off three at the first industry, which three do I drop? I could take the first ones after the loco, I could take the last ones before the caboose, or I could slice three from the middle. This will ensure cars get mixed up so you don't always see exactly the same hopper right behind the loco. Another way to mix them up is to have industries with varying needs. The lumber mill needs 5 flats today, but a big order requires 8 flats tomorrow.

So to begin with, the software needs to always know where every loco is at. Between a combination of block detectors, IR sensors, and RFID tag readers, I hope to keep track of everything. And I need good block control with trains respecting the signals. Then I need sensors for when cars are approaching the end of a siding, and sensors over the decoupling magnets to verify the cars were released. The RFID readers can also verify the string of cars leaving a yard match the itinerary.

If you've followed so far, you can see where a tight shelf switching layout with a couple active switchers sorting cars can provide a multitude of situations to test out a large number of the ideas above. So HOW am I going to do it? Good question! :) Piece by piece, I'll start with the basics of moving trains around and go from there. Various pieces will need different data structures, some parts might be handled by a server while others are done in arduinos. I might model the structure of what cars are going where after the various types a yard card systems that people have described, but another piece may have to be designed from the ground up. It's gonna be a wild ride...
See less See more
  • Like
Reactions: 1
I like that idea of forcing an action to happen, will have to keep it in mind! And yeah, I've been working out the idea in my head for a few years now.

The layout I'm designing is dual-gauge and is basically a point-to-point with reverse loops on each end. There are essentially three mainlines though, one of each gauge, and one dual-gauge line, so that helps provide alternate routes, or in some cases keeping a train on its own gauge so other lines aren't blocked. There's still plenty of opportunity for lines to get deadlocked so my scheduling system will have to keep track of where all the trains are expected to be and whether a passing siding is available when trains are moving in opposite directions. For example, the narrow gauge line through the mountains doesn't have a passing siding, so if two trains are going in opposite directions then the entire mainline between cities would have to be considered a single block, but for two trains going in the same direction, regular signalling between blocks would work just fine. I also have to consider train loading -- the mountain pass is fairly steep at around a 2.5% grade, so an unloaded hopper train might be able to make the trip uphill, but a loaded train will need to be double-headed, and if a second loco isn't available then that train would only be able to use the tunnel and have no alternate paths available. There's just so many possibilities that I will need to account for in the mapping and scheduling programs...
See less See more
I've been playing more with my code to run the train back and forth. The latest code is working pretty smooth. Basically I set up an array that lists out all of the sensors a train should go through and what to do at each of those sensors (even if the action is 'nothing'). I can immediately change the speed or add a timer to do something a few seconds later. I also am keeping a record of the amount of time needed to travel between sensors, and the code will give a countdown of the expected time to reach each sensor, or tell me if the train is running late. This information could be used to indicate a problem with a train or have a train slow down before reaching a station.

One more little detail I need to add to the program... When the train gets to either end of the track it stops at that sensor instead of going through it, so reaching the sensor triggers an action, but then when the train pulls out again the sensor responds again once it is cleared (and thus starts the timer towards the next sensor). The sensors in the middle of the track, where the train always passed through completely, only respond when the train first reaches that sensor (stopping the first timer and starting a new one). Now the problem is that the apparent distance between sensors can be larger or smaller depending on how many cars the loco is pulling. What I need to do now is create a small inventory of the cars on the layout, including the length of each car, and then add that information so the length of the train can be calculated. That should allow making adjustments in the expect timings so the code knows a longer train will reach the next sensor sooner when leaving a siding. (Hope that makes sense, it's still too early here.)

I also noticed that when I first start the train running, it runs slow and I get a few warnings about the train being late to the next sensor. I guess we all need a warm-up period in the mornings. :)

Electrical wiring Cable management Electronics Electrical supply Room

I also received the box of flex track this week. It'll still be a bit before I'm ready to begin laying it (still have to make a bunch of turnouts) but at least I pretty much have all my supplies on hand now.
See less See more
I've started building turnouts and hopefully can begin laying the mainline soon. Today I finished up the four turnouts needed for the mainline on the right leg of the shelf, and this coming week I'll try to build the three turnouts needed for the left leg. Once that is all done I should be able to lay about 11 feet on continuous track, plus two sidings. That will give me a bit of track to play with while I work on the last seven turnouts.

There will be a short section of straight track connecting these two assemblies together. Then one end will continue off the edge of the shelf and the other end goes into a curve at the corner of the 'L' shelf.

I've seen cables welded across joints in tracks and thought I could use that idea to attach sections of flex track together. It's probably not prototypical for the turn of the century, but it does make a nice strong joint and ensures electrical continuity.

A generous dab of flux paste helped to get a good solder joint without completely melting the plastic ties. The track will get finished off with some ultra-flat earth brown spray paint, then some rust colors brushed onto the side of the rails. The remaining ties will be filled in with basswood. With three different materials used for the ties, I'm hoping the base coat of paint will blend them all together.

I think the next thing I need to do is get the slots cut out for the turnout servos, and start prepping the tubing and piano wire control wires. I received an order of ten servos in the mail today so I believe I have nearly everything on hand to build the turnouts, complete the track work, and lay down most of the wiring. After I get a little further along I can see what connectors I'll be needing to join the wiring on both halves of the shelf and I can get those ordered.


See less See more
@Mark VerMurlen -- They're actually not too complex, just time-consuming. You do need to have a little experience with soldering so you can get the rails to stick well to the PCB ties. I use a regular pair of pliers to make the bends for the guard rails, and the curves are done by hand. Then you have to grind tapers to put together the two rails for the frog, and of course reduce the points into a fine tip. For that I use some small hobby files and a dremel. I spend by far the most time working on the points so I get a nice smooth alignment. Like most things, the first one or two you make are going to be crap, but then once you see how it all works out and you get everything aligned, you start getting really nice results.
I did! :) I'm actually thinking of writing something new to make a block that holds the rails at the right angles for grinding the frog. And maybe one of these days I'll get back to the jig itself -- I'm thinking I just need to rewrite the whole thing again. I have a better idea for performing the calculations but it'll take some work.
I don't understand... Your pictures seem to show a huge amount of point sticking out from the edge of the stock rails, like about half the width of the full rail head? How do the train wheels keep from snagging on that?
One thing about working on a shelf is that spacing can be tight. I have a spot on the mainline where two turnouts are stacked immediately after each other. I started looking at this spot last night and checking the alignment. I made a slight adjustment so the ties would still be neatly in line, and this morning I started building both of them together as a single unit. So far so good! :) The diverging route on the left will lead into a small ladder yard, and the right side will begin a run-around and branch to a couple industrial sidings. I'm expecting to finish the points on these turnouts tomorrow, then I only have a single turnout left to complete for the mainline.

See less See more
  • Like
Reactions: 3
1 - 20 of 137 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.