Model Train Forum banner
1 - 20 of 137 Posts

· Registered
Joined
·
2,525 Posts
Discussion Starter · #1 ·
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.
 

· Registered
Joined
·
2,525 Posts
Discussion Starter · #6 ·
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.
 

· Registered
Joined
·
21 Posts
That'll be awesome. I had a great time getting into JMRI and making a panel and setting routes. And now setting up SwitchList on my mac. Your level of programming is beyond me but I can sure appreciate it. Have you heard of McKinley Railway? They have a great youtube channel and they have been automating train movement. They use rfid to identify each coach.
 

· Registered
Joined
·
2,525 Posts
Discussion Starter · #8 ·
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!
 

· Registered
Joined
·
2,937 Posts
Sounds like an interesting project.

I write code for a living (mostly business applications, but some SCADA involving RFID), so it's the last thing I want to introduce into a hobby.

Nevertheless, it'll be fun to watch this progress. :thumbsup:
 

· Registered
Joined
·
2,525 Posts
Discussion Starter · #10 ·
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.
 

· Registered
Joined
·
2,937 Posts
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.
Once the foam is down you'll never see that joint. But you strike me as the kind of person for which that just won't do. ;)

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 needed some extra-long wire for my turnout motors and I found some stainless steel orthodontic wire. That stuff is extremely stiff/rigid/tough (it nicked the blades on my Xuron track cutters) and might alleviate the need for tubing. I'll see if I can dig up where I bought it.
 

· Registered
Joined
·
2,525 Posts
Discussion Starter · #12 ·
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.
 

· Registered
Joined
·
2,525 Posts
Discussion Starter · #15 ·
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.
 

· Registered
Joined
·
258 Posts
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.
If that gap is going to bother you one solution is use an angle measuring tool like in this pic and divide that in 1/2 cut each board at that and when they come together there will be no gap. At least due to the non 90 degree angle anyway.
 

Attachments

· Registered
Joined
·
2,525 Posts
Discussion Starter · #17 ·
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!
 

· Registered
Joined
·
2,525 Posts
Discussion Starter · #18 ·
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!)
 

· Registered
Joined
·
2,525 Posts
Discussion Starter · #19 ·
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.
 

· Registered
Joined
·
2,525 Posts
Discussion Starter · #20 ·
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.
 
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.
Top