Author Topic: Building the IOT Railroad a "smart" DC layout  (Read 1366 times)

0 Members and 1 Guest are viewing this topic.

Trainmaster247

  • Crew
  • *
  • Posts: 133
  • Respect: +25
Building the IOT Railroad a "smart" DC layout
« on: June 21, 2024, 12:39:20 PM »
+1
With a new move comes a new layout and with that a new control system experiment. While we live in the modern age and things like DCC are an option I was looking for something a little different and using a "smart" version of traditional DC block control. 

The Layout
The layout is a simple dogbone style layout using bachmann e-z truck to allow for tweaks and updates as working on the control system is primary goal with scenery being secondary long term though. It is a single track main with one passing siding and 2 spur areas with one being a small yard and the other a coal mine.










Control Stages

Stage 1 (Current State): This stage of control adds manual control and 5 blocks, the 5 blocks being: Mainline, Main Passing, Yard Passing, Coal Spur and Yard Spur. These blocks will be expanded at  a later date splitting the mainline section into three blocks.


The controller for this stage is an esp32 microcontroller and 5 H-Bridge motor controllers. This is the first of at least 3 wiring boards that will be the brains of this layout.



The second piece is the node.js dashboard which makes post and get requests to the esp32 to sync across multiple tabs, the group drop downs allow syncing of blocks for easier running as well as a light control button that locks the minimum power to 10 which is enough to power the lights but not the locomotives.
Note: The domain is pointed to a local IP remote access is not enabled for the dashboard

Stage 2 (Turnout Control): This stage will add in a dashboard for turnout control, these will be controlled with relay boards with each turnout getting 2 relays to avoid burning out the solenoids. This will use a separate ESP32 to allow isolation and keep from overloading one controller.

Stage 3 (Block Detection): The final stage will allow full train routing and automation, this will include load sensors on each track block to detect current draw and an "occupied block" as well as expanding existing blocks into smaller sections for more fine tune tracking of train location. At this stage I also plan to expand to a cloud based "press to watch train run" style website with some additional access  controls and running limits in place.


If anyone had questions or areas they'd like me to expand on I'd be glad to share.
« Last Edit: June 23, 2024, 08:40:28 PM by Trainmaster247 »

Philip H

  • Crew
  • *
  • Posts: 8910
  • Gender: Male
  • Respect: +1655
    • Layout Progress Blog
Re: Building the IOT Railroad a "smart" DC layout
« Reply #1 on: June 21, 2024, 02:44:09 PM »
+1
I love breadboarding on a clipboard.
Philip H.
Chief Everything Officer
Baton Rouge Southern RR - Mount Rainier Division.


wm3798

  • Crew
  • *
  • Posts: 16124
  • Gender: Male
  • I like models. She likes antiques. Perfect!
  • Respect: +6467
    • Western Maryland Railway Western Lines
Re: Building the IOT Railroad a "smart" DC layout
« Reply #2 on: June 21, 2024, 03:52:22 PM »
+1
I'll be watching this with interest.

But I can't help but wonder what the advantage is to this.  Seems like a lot of extraneous hardware to run 5 blocks.
For now I'll be sticking to my DPDT's and much less sophisticated computer...



Lee
Rockin' It Old School

Lee Weldon www.wmrywesternlines.net

Trainmaster247

  • Crew
  • *
  • Posts: 133
  • Respect: +25
Re: Building the IOT Railroad a "smart" DC layout
« Reply #3 on: June 21, 2024, 05:20:59 PM »
0
I'll be watching this with interest.

But I can't help but wonder what the advantage is to this.  Seems like a lot of extraneous hardware to run 5 blocks.
For now I'll be sticking to my DPDT's and much less sophisticated computer...

Lee


The main reason is really pretty much just "why not" my other hobbies include a homelab and a "smart home" style setup. The idea in the end will be fully operating signals and ability to just press a button and send a train to the yard or swap which one I'm running on the mainline with the passing tracks. While likely overkill for a setup this size it gives me a good test bed to see if I'd want to commit to something larger with this style control.

John

  • Administrator
  • Crew
  • *****
  • Posts: 13386
  • Respect: +3245
Re: Building the IOT Railroad a "smart" DC layout
« Reply #4 on: June 21, 2024, 06:54:45 PM »
+1
Have you looked at Hans Tanner's IOTT channel on FB? Lots of cool stuff for the geek in us:)     https://www.youtube.com/@IoTT

Trainmaster247

  • Crew
  • *
  • Posts: 133
  • Respect: +25
Re: Building the IOT Railroad a "smart" DC layout
« Reply #5 on: June 23, 2024, 08:48:46 PM »
+1
Stage 2 and the start of Stage 3 have both been added today allowing for turnout control and very rudimentary block detection....


Stage 2 involves a relay board for turnout control, to avoid burning out the solenoids each switch is controlled by two relays and powered for ~1/2 second.



The second board while simpler in wiring (and currently temporary) is the most interesting addition. While my DC current draw detectors are delayed in shipping I've added in some temporary/additional detection in the form of a photo resistor on each of the passing sidings. These are tuned to trigger when a train is over them.






To top it off with that I'll be streaming the layout here: twitch.tv/kbots_tech every now and then. With the IOT integrations that includes twitch if you type !train in the chat it will alternate which one is running

Trainmaster247

  • Crew
  • *
  • Posts: 133
  • Respect: +25
Re: Building the IOT Railroad a "smart" DC layout
« Reply #6 on: June 24, 2024, 12:07:24 PM »
0
Have you looked at Hans Tanner's IOTT channel on FB? Lots of cool stuff for the geek in us:)     https://www.youtube.com/@IoTT

Watched some of his stuff last night, some really cool bits of inspiration there for me

John

  • Administrator
  • Crew
  • *****
  • Posts: 13386
  • Respect: +3245
Re: Building the IOT Railroad a "smart" DC layout
« Reply #7 on: June 24, 2024, 06:24:22 PM »
+1
I purchased the speedometer car kit.  Now just need to put it together

Trainmaster247

  • Crew
  • *
  • Posts: 133
  • Respect: +25
Re: Building the IOT Railroad a "smart" DC layout
« Reply #8 on: June 27, 2024, 01:19:41 PM »
0
With the latest updates I've gotten the new IR sensors installed and their detection is much more reliable with no false triggers, the downside is I do need to rework my code to handle the extra load of the digital vs. analog sensors. Prior to this I was polling the esp32's from my web server but I think reversing it and having the detector send updates to my web server will be the way to go, this does mean redoing a lot of code but I think I've reached the state where a rework is due anyway. I'll keep things updated as I make progres.

Trainmaster247

  • Crew
  • *
  • Posts: 133
  • Respect: +25
Re: Building the IOT Railroad a "smart" DC layout
« Reply #9 on: July 06, 2024, 08:24:02 PM »
0
Had some time to sit down and code today so everything is back up and running. Need to rebuild my control dashboard but the streaming portion is back online with a new dashboard as well.  Been working on some structures as well. Next steps after structures are to add in some additional block sensors and considering breaking up the mainline into 1-2 additional blocks or at least relays with one controller for more isolation.

For those interested in seeing it grew the twitch stream should be up 24/7 as long as the bugs and hiccups stay out of the way.

https://www.twitch.tv/kbots_tech

Trainmaster247

  • Crew
  • *
  • Posts: 133
  • Respect: +25
Re: Building the IOT Railroad a "smart" DC layout
« Reply #10 on: July 20, 2024, 11:37:42 PM »
0
After a few days of down time my tweaking has finally gotten me to what should be a final stable state. I've moved away from the regular post/get request style to using MQTT servers and clients. This so far has provided a more stable operation but still some quirks where it doesn't work with the sensors exactly right.
 
On top of this for adding more routes I've moved to a json config style way of designing my routes following the basic structure below and building up an array of these blocks with the "sensor" piece being what should signal the end of that block:
Quote
{
                            "track": "de-staging",
                            "tracks": ["RED", "GREEN"],
                            "turnouts":[
                                {
                                    "id": 1,
                                    "state": "Alternate"   
                                },
                                {
                                    "id": 4,
                                    "state": "Main"   
                                },
                            ],
                            "direction": "F",
                            "speed": 70,
                            "trigger": {
                                "sensor": 0,
                                "state": 0
                            },
                            "bypass": False
                        },

I've also begun the work of adding more views with a second webcam and planning to add a third once I find my other one.
 

 
As for the layout itself physically after a few close calls and full on plummets I've also added some acrylic paneling as can be seen above to keep everything on the layout and limit damage for not if but when something derails. I have a few more plans for tech components like building lights and some more advanced sensor routes to continue with still but after that the scenery will begin.

randgust

  • Crew
  • *
  • Posts: 2756
  • Respect: +2256
    • Randgust N Scale Kits
Re: Building the IOT Railroad a "smart" DC layout
« Reply #11 on: July 23, 2024, 09:59:11 AM »
0
Wow, I think it was back in the 80's.... has to be.....

Our local Master Model Railroader, Richard Bradley, well known in HO circles as the Pennsylvania & Maryland, was a 'retired' designer of Burroughs computers.   Proven genius type.

He had a fairly simple around-the-walls HO layout; single track with multiple passing sidings.   But OMG, the control system.   All DC, and automatic block assignment.  As near as I can remember, when you crossed from block-to-block, the computer would automatically assign your block to your cab as soon as it touched an insulated joint, and then drop the block behind it as 'open'.

And it was all relay and digital based.   Under the layout, and behind the curtain, was a mass of wires and control equipment, basically, a home-brew mainframe.   As you ran, you'd hear relays firing all over the place under the layout.  It worked, but it was, without question the highest level of complexity I've ever seen applied to what was a relatively straightforward continuous running loop with passing sidings.   No signals.  But no DPDT's anywhere, either.  You just ran.

That's all gone now, but I'll never forget it either.   

Trainmaster247

  • Crew
  • *
  • Posts: 133
  • Respect: +25
Re: Building the IOT Railroad a "smart" DC layout
« Reply #12 on: August 16, 2024, 02:23:59 PM »
0
Thats close to how this projects is starting to feel, I have it back to basic operation but decided to make it double track so need to completely rewire the sensors and everything. Also added two more turnouts with that but goal is to have something full automated overtime.

Trainmaster247

  • Crew
  • *
  • Posts: 133
  • Respect: +25
Re: Building the IOT Railroad a "smart" DC layout
« Reply #13 on: August 19, 2024, 01:00:03 PM »
0






Did some base scenery work over on the coal mine side this weekend and got the stream back up and running on a set schedule rather than 24/7. It has officially hit 50 followers so now just needs an average of 3 viewers to get twitch affiliate which will give some additional perks and things I can use to help fund the stream and make things better. Check it out below streaming Mondays, Wednesdays, Fridays and Saturdays from 4pm CST to 10pm CST
 
https://www.twitch.tv/32bitrailroad