(top)
(I am writing this description as a means of clarifying my thinking about what I'm trying to do - in the April 2020 Covid lockdown.)
I have not yet come across anyone else with a similar aim. I specifically want the challenge of writing the (Python) software that controls my model railway. The model railway does/did not already exist and I am building it to suit this aim. When I started I did look at off-the-shelf software for controlling model railways - in fact I assumed that I would use one of those, with DCC. But I was put off that idea by several factors - North American railroad culture, cost, reported frustration making such systems work together. I had the opportunity to decide what I wanted and focus on that, not adopting generalised solutions which add a lot of unrequired complexity.
Once I had a graphical user interface controlling turnouts and traction on a simple layout I realised I wanted the software to add features such as:
- Interlocking. For example to avoid driving a train over an incorrectly set trailing turnout.
- Momentum. Realistic acceleration and braking, especially (very difficult) stopping at specifc locations.
- Having several trains in action at once - as many as possible is perhaps the real challenge.
- Trains, more often than not, stopping in stations - which is what trains are for - rather than rat-racing.
- Additional "special effects": sound effects, working crossing gates, working semaphore signals, uncoupling.
Artifical Intelligence (AI) is topical. I think what I'm building will, to some extent, replicate what a team of operators would do with a manually-controlled layout so it will have an element of AI, but I will simply call it "automation". The well-engineered McKinley model railway, possibly the largest in UK, interests me. Especially how they get trains to slow down and stop where required.
- Central to my strategy is the automation "knowing" where each train is. Precise locators are essential but they do not need to identify the train. With "DC" traction the automation supplies power for a particular train to the track district(s) where the train is, so the automation must already match particular trains to particular track districts. A response from a train locator - which must be in a particular track district - must come from the train which the automation is powering in that district.
- The automation also has to "know" how fast each train is travelling - in mm/sec or scale mph. Back EMF is often used for this. As far as I can tell it can be made to work with locomotives in good condition at higher speeds but it's not easy and could be very frustrating with well-used locomotives at very low speeds - approaching a stopping point. I decided not to touch Back EMF.
My automation will determine train speed in two stages ... ...
- First, based on the Voltage which the automation is applying to the locomotive. The Voltage/speed relationship will be locomotive-specific and depend on how much it has "warmed-up", the local track gradient and curvature, and the loading of trucks or coaches on the train - all of which are available in the automation. The automation has to know the geography of the layout, it can be told the make-up of each train, the hardest is the extent to which the loco has warmed up - initially based on how long and hard it has recently been running
- Second, then the actual speed can be checked by timing precisely when locations are reached. Conducting "time trials" will initially provide a simple Voltage/speed relationship which can be enhanced to take into account gradient, curvature, loading and warmed-upness. Then, every time a loco passes a locater, the automation can compare whether it got there sooner, or later, than it forecast - thus adjusting its algorithm, probably to take into account the hard-to-esimate warmed-upness and so effectively tracking the loco's temperature.
- To forecast precisely when a train should pass each locater
- to manage which track districts to supply power for that train
- to show movement of each train smoothly on the mimic diagram in the GUI
- - these require that the automation effectively models/simulates the movement of each train. So this, which can run independently of the layout, is the big initial challenge in the automation software, being worked on during the Covid lock-down in 2020.