How about a Train Controller with an Arduino! It would have to have Voltage Control & PWM.
Now you're talking!
Back in the early '90s, I build an HO gauge layout in my basement on two 4x8 pieces of plywood. Made mountains, tunnels and a lake that nearly asphyxiated everyone in the house when I poured the liquid plastic for it.
No Arduino's back then, so I controlled it with a 6502-based controller that I designed and programmed using my Apple II (still my very favorite computer). Mounted hall-effect sensors (salvaged from an old keyboard) under the tracks and magnets on the bottom of the engines to determine where the trains were. Used PWM to drive the trains. I built it for my son and occasionally I'd even let him play with it!
I'd do a model railroad controller in a heartbeat - if I only had a model railroad! Sadly I don't, I don't have space for one and I have a lot of other irons in the fire at the moment.
But I still love the idea, even if it's unlikely I could ever do it without an actual model railway to control.
"Never trust a computer you can’t throw out a window." — Steve Wozniak
Since the topic has come up I'd like to share what I started, but may never finish. 🤣
It's a long story so grab a cup of steam engine oil and get comfortable.
I have quite a few Garden Trains or "G" gauge as they are often called. I wanted to set up a huge layout in my front yard. Sadly outdoor G-scale track is not cheap. For the layout I would like to build it would cost over $1000 just for the track alone. I looked into the possibility of manufacturing my own track from aluminum bar stock as the rails. There were two problems with this. First just the aluminum bar stock would still be quite expensive at about $500. Then I would need to fabricate all the track on top of that. Including making ties and roadbed, etc. There were also major "warnings" by other Garden Train experts that using aluminum track is not a good idea for outdoor use and that brass is far superior. So they were telling me not to cheap out on the track.
Well, $1000+ dollars just for the brass track was simply not an option. I was about to give up when I got an email from a Garden Train hobbyist in England. He advised me to give up on using metal rails entirely. Yep that's what he said! He said that he uses homemade wooden rails. And he runs the trains using onboard batteries instead of trying to electrify a complex track layout. He says that this actually has a lot of benefits, which I could instantly see as well. He also shared with me photos of his layout and explanations of how he constructed it. Unfortunately all that information has since been lost due to a hard drive failure. I don't even remember who the guy was or how to contact him anymore. 😪
This all happened quite a few years ago.
That's not the end of the story though. I decided to go for it and build the wooden track and convert my trains over to being battery-operated. So I set out making a lot of designs.
Here are some of my Sketchup Drawings of my designs for homemade wooden track:
And here is my design for a special router jig for cutting the rail groove on homemade turnouts.
I actually did some work toward this dream.
I cut down an oak and cherry tree and made them into lumber on my sawmill for the roadbed, ties, and rails. I even cut up a bunch of railroad ties that I have in a box out in the wood shop.
I bought the router for making the track grooves. 🤣
And I have some G scale steam engines sitting on my kitchen table waiting to be converted to battery power. They been waiting a very long time!
Originally I was going to do the whole thing with Raspberry Pies onboard the trains. Originally I was going to use rpi A+ boards, but they were kind of big to be trying to fit inside the trains. Then I was thinking of using an STM32 Blue Pill as the microcontroller and RF link to the trains. Lately I've been thinking of using Pi Zeros as the "Train Brain". 😎
Whatever I used I was going to ultimately control all the trains via WiFi connections using a Notebook computer that would orchestrate the activity of the entire layout.
So there you have it. Yet another unfinished dream sitting around waiting for some human to bring it into fruition. Since the locomotives are sitting on my kitchen table I dream about this model railroad everyday.
Apparently I'm content with just dreaming about it. 🤣
So there you go. A long-winded story of a dream that has stalled on the kitchen table.