Model Train Forum banner

21 - 40 of 44 Posts

·
Registered
Joined
·
865 Posts
Wow, what an ambitious project you have going on here! I’m floored that you’re planning to write all this software yourself. I’ve been using TrainController software on my layout and it seems overwhelming to me to try to replace it. I’d love to have you give a bit of explanation about your software as you develop it. Things like what data structures you’re using and for what purpose, how the logic works, etc. Just basic summaries, I’m not asking you to explain it in detail. I think those of us that have some computer programming experience would find it fascinating.

- Mark
 

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

·
Registered
Joined
·
865 Posts
Sounds like you've been thinking about this for quite some time. I look forward to following your progress.

I agree with you that having automated schedules without any randomness can be boring. I've set up some randomness on my layout by using probabilities to determine which schedules will be run next. This has worked out fairly well for me, but I've added software virtual buttons to my control panel to be able to force certain actions to occur next. For example, my passenger train doesn't stop at the station every time in comes around the layout. There is a probability that it should stop that increases each time it doesn't stop. Even so, I added a virtual button to force a stop since sometimes when I have guests, I want to show them the train stopping at the station and I don't want to wait for it to happen randomly. Just something to think about.

One other issue that I haven't really solved to my satisfaction is how to avoid deadlock situations when running multiple trains. You may run across this as well. I've got a single mainline with a few passing sidings. I like to be able to run trains both clockwise and counter clockwise on my layout. Running 2 trains is generally not a problem, but when 3 are running, I would get occasional deadlocks. The solution in TrainController is to mark certain blocks as "critical", meaning trains must be able to pass through that block and on to the next before it can be reserved. So all my single track mainline blocks are all marked critical to ensure a train can pass through them to at least one passing track. Then also having the automated scheduler look ahead and reserve a few block ahead allows me to avoid deadlocks, but it also seems too inefficient and causes unwanted spacing and delays for some trains. Maybe that's the best that can be done, but I am hoping to get better efficiency. Anyway, something else for you to think about if you haven't already.

- Mark
 

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

·
Registered
Joined
·
2,139 Posts
Discussion Starter #25
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. :)

IMG_0517.JPG

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.
 

·
Registered
Joined
·
2,139 Posts
Discussion Starter #26
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.
540656


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.
 

Attachments

·
Registered
Joined
·
2,139 Posts
Discussion Starter #29
@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.
 

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

·
Registered
Joined
·
2,048 Posts
I use a 1" belt sander to make the frogs, but for the points I've been using proto87 points. No filing and the point nestles right up to the rail, with no notch on the rail either! I tried their frogs, but they really need a resistance soldering machine, which I don't have. Here's a couple of close up os the proto87 frog. The throbar is actuated by a SwitchMaster motor and you can just see the wire protruding up in the middle of the throbar.
540676
540677
540679
 

·
Registered
Joined
·
2,139 Posts
Discussion Starter #33
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?
 

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

540834
 

·
Registered
Joined
·
2,048 Posts
It is a macro photo and while it looks big, the point is milled to fit right to the rail. I have more problems with flange removal and filed down rail for the points than the milled point. It really fits neatly to the code83 ME rail and does not get "Picked". You might get a set from the Proto87 store (and watch their turnout builds). I like my hand build frogs, but the Proto87 points are much simpler to use.
 

·
Registered
Joined
·
465 Posts
🌈 I only want to add:
I can never understand this idea of making a 'test layout' before making the full layout; especially when one has the skills you already have...Your switch/turnout construction is A1 which tells me you know all that one needs to construct a great layout already...
If you have the space and the resources now, why not start the full size RR now, but perhaps by employing your test design as the starting point on an already built (assuming open grid, L girder, or, cookie cutter) full bench work ?
IE. Why build this nice design you have now, only to eventually dismantle it ?
 

·
Registered
Joined
·
2,048 Posts
In my case, there was no room for any substantial RR. Thus a "test" layout to get something useful for DCC seemed appropriate. The test layout has 2 levels on one side and 2 mainlines, thus there is interaction between mainlines and switch spurs on both "straight" sections. I have routes programed into the DS64's that run the turnouts, so there was lots to learn, besides trying different construction techniques. Most of all I like the thinking that goes into just determining what and how to build, so now that I have room I think i'm better prepared with what I want and like to have in an around the room layout.
 

·
Registered
Joined
·
2,139 Posts
Discussion Starter #38
@telltale -- the two combined turnouts above will make #11 and #12 of all the turnouts I've ever made, so I don't have a huge amount of experience at the art. Even on this one I just threw away a point I was working on because it simply wasn't turning out quite right and I was afraid it would cause trouble down the road. I've done enough to make them look good now, but I need to put something in use to make sure I won't have any long-term issues. However I thank you for the kind words!

I also have almost no experience with landscaping, so this will be my first chance to try working with rivers, bridges, rocks, and roads. Soldering rails together is precision work, which I'm good at. Creating landscaping is more free-form, which I'm not so good at.

As for dismantling it later on... Not a chance! This is semi-permanently installed above my computer workbench so I can work on the programming, but I'm also trying to design it to be broken down so I can take it to train shows. I've never actually seen a shelf layout at a train show and I think it would be interesting to others to see the possibilities in smaller layouts. Also the main layout will be on a winch in the garage, and thus probably cold in the Winter, so the shelf will give me something else to play with during that time.
 

·
Registered
Joined
·
2,139 Posts
Discussion Starter #39
Whew! I finally finished that double-turnout yesterday. I have one more easy (single) turnout to build, then I'll be ready to lay the mainline.

I've been thinking about how exactly I want to layer the shelf. I have 7/16" plywood, then 1" foam. I plan to put a sheet of foam board on top of that (about 3/16" thick) and start building the track on top of that. However, the control rods for the turnout will go between the two layers of foam and there will likely be some 'fiddling' to get it all working smoothly. I think maybe some cheap double-sided tape might be the answer so I can easily remove the foam board, then use something more durable once I know it's all working right.

The foam board comes in 30" lengths. I think I'll connect it all together with masking tape so I don't lose my alignment between pieces or between the turnout rods. It will also make a lighter piece to take outside for spray-painting the base colors. I probably won't start on the scenery until I'm done with all the controls though.
 

·
Registered
Joined
·
2,139 Posts
Discussion Starter #40
There's been some ups and down this past week. The hard drive on my desktop just up and stopped working, so I've been recovering everything from another computer I haven't used in three years. Lost a lot of information but I'm back up and running again.

I finished the last mainline turnout and have gotten started on prepping for laying the track. As I was thinking before, I picked up a small spray bottle and made a mixture of white glue and water. It's been working good enough, but I'm having a LOT of trouble with the foam board warping. I've been pressing it on a table while the glue dries, but once I take it out and expose it to the air the board starts curling up again. I've been experimenting with towels and other ways to control the moisture, and I think I'm keeping it square enough. With all the issues, I decided to create some T-nuts on the 3D printer that I can embed right into the foam board and scenery, but will hold the foam board tight to the pink foam. This gives me an easy way to pull off the top layer as I work on the electronics and sensors.

No pics yet, but I should have the plans for the first side glued down soon, then I can start figuring out where all the servos will sit and cut the slots for them in the pink foam. I was also thinking about using lever-style micro-switches to juice the turnout frogs. I could glue the switches on the bottom side of the foam board, just under each turnout, so the piano wire hits the switch as it moves the points. Still so much to do before I even start laying the track.
 
21 - 40 of 44 Posts
Top