EP 027 Arduino Model Railroad with DIY Jimmy

 

A conversation about Arduino Model Railroad:

Micheal:
Welcome, everybody. Thanks for joining me. I’m here with DIY Jimmy. He’s with the Model Railroad Hobbyist Magazine and he’s also got his own YouTube channel, and we’re going to be talking about model railroading with Arduino. Jimmy, thanks so much for joining us.

Jimmy:
Thank you. I’m happy to be here.

Micheal:
All right. I’m among those uninitiated people to a fantastic hobby, the hobby of model railroading. I imagine you’ve probably been into it for quite some time. Where my interest comes in is with automation and obviously the Arduino stuff and I know there’s a lot of people in our audience who happened to be into that hobby. They just love model railroads and stuff.
Just approached me as the person who doesn’t know jack. All right, I don’t know jack about model railroad hobby. I guess there’s a lot of places we could take this conversation, but I’m curious where you see how Arduino is being used generally speaking and in the hobby.

Jimmy:
Well first, one thing that’s very unique about model railroading is that it’s one of those mega hobbies where it has a bunch of sub hobbies within it where you can do things like with Arduinos, there’s carpentry involved, there’s painting involved, there’s historical research involved, there’s even 3D printing, which is another big thing that I do is involved. You can have a bunch of different hobbies built into the purpose of doing model railroading.
One that has become increasingly and increasingly more popular and more used is DIY electronics. Literally the easiest way to do that, simply because Arduinos are designed to be this way, so you use Arduinos to do all of these DIY electronics because in terms of the sophistication of electronics and model railroading, you have something as simple as basically you’re powering a DC motor. Or you had the digital command and control system and most you’re going to be operating some lights, some servers, maybe a few other things like LCDs and things like that.
But in terms of what compared to other hobbies, the electronics of it are relatively simple. They’re still pretty complex but… And it makes it easy for people to take Arduinos and modify them to do exactly what they want, to add those custom animations and add those little things like different lights and diffusing LEDs for signals and crossings and things like that. Arduinos have come into that slot where the customization of the hobby is, and now you can customize your own electronics and they really filled a void that’s been open for a while.

Micheal:
That is so cool. I love that hobby within a hobby idea. It’s like, I bet everybody listening has had that experience, either they have that uncle, like I had that uncle growing up, who had a room in his home dedicated to just an awesome track. Every time we’d go visit, it was like, “Cool, the model trains are running. You know what I mean?” It was awesome as a kid.
Or when you go to, I don’t know. Sometimes you’ll go to a museum or someplace and they’re going to have some massive display, or it’s just like you’re walking around, they got the ropes around it and you’re looking at this display and you’re like, “Oh my gosh.” People put so much wonderful effort into this.
I like that historical part you brought up. Because now that you’ve mentioned that, I see that a lot in some of, especially the really well done ones. It blows away the attention to detail that you can get. When you start seeing that electronic piece brought into it, you’ve got that motion, in addition to just the train, but you’ve got all those subtle other little details going on, I don’t know, it almost breaks a barrier. It really blows it up.
Maybe this isn’t super Arduino-related, but this is where I want to start because I’m just curious about how… Everybody listening, please excuse my ignorance. I’m sorry for this but… All right, so you’ve got a train. How do these trains even run? Is there a standard they run on when you put them on a track? Obviously you got line power. You got wall, you got your wall power. It goes to a transformer and they run and then it goes to DC or something. Then it’s running on those tracks. Is that generally how these trains are powered.

Jimmy:
Up until, I’d say the last 30 years, model railroading has actually been around for a long time. The electric side of it is DC power. What it basically is is if you think the rails are electrified and you’re basically just completing a circuit with a electric motor inside the shell of a locomotive. That’s the base. It’s DC because it’s direct current, so it’s called DC in the hobby.
Now, over the past 30 years, digital, like with everything else, has seeped into it and has brought in DCC, which stands for Digital Command Control. That uses a form of AC and pulse with modulation to be able to send commands to a chip in a locomotor that we all call a decoder because it decodes signals and tells the motors. In this case you also have speakers in there for sounds and you can control the LEDs and all the lights and everything in there to make them very realistic.
But these decoders, they basically just take the signal that’s sent through the rails and is picked up in the wheels, and it runs through to the decoder and basically it just tells a locomotive what to do. That’s what all my model railroads do now and that’s pretty much where the hobby’s going. It was very, very extensive at first and it’s really come in price to where it’s very accessible.

Micheal:
Wow, that’s cool. You’re just modulating that DC current and then that’s how these trains are picking up the commands. Can you target a specific train then? Do they have an ID that they pick up in that signal kind of thing to talk to one device over another kind of thing then? Is that how that works?

Jimmy:
Yeah, that’s one of the biggest benefits of doing a DCC setup versus a simple DC setup. When you’re doing DC, obviously you’re just applying voltage to the track and it’s going to power up everything that’s on the track. DCC locomotives, that decoders they have addresses. They can either be a short address, which is a two-character address, or they can be a long address, which is a four-character address.
Typically, most locomotives have a four-number identification in the real world, so a lot of times you just program that address to be the locomotive number so you can look at a locomotive program at M once you’ve got it set up, and you can control the locomotives individually on the same track. That’s the big benefit of DCC, is you don’t have to have overly complex wiring compared to DC to be able to control multiple locomotives on the same layout.

Micheal:
Wow, that’s fantastic. Now are these decoders, are they their own integrated circuits, they’re specially built for that thing?

Jimmy:
Yeah, there’s a bunch of different ones. They’re basically just tiny little PCBs that have all… They’re custom made. They’re designed to fit in certain locomotives. A lot of locomotives just have a big piece of metal that’s the weight and then the motor sits inside and it’s a warm drive in there that goes to where the wheels are on the track. Typically, the decoder will sit on top or if it’s got a little plug, that’ll plug into, depending on the version and the company that makes the locomotive and the DCC decoder.

Micheal:
Okay, that’s cool. Is the auxiliary stuff like… When I say auxiliary stuff, I’m talking about roadway lights or the fence that goes up and down or like that other stuff, can that also be on the DCC then? It’s all just part of integrated into that or is that specifically for the cars or the trains themselves?

Jimmy:
It can be. You have stationary decoders that can control different things as well. As long as you can get it to be powered by the track and you get a run through, which you can do through a couple of different pieces of electronic hardware to be able to convert that voltage over, to be able to convert if you’re building your own. Or they do manufacturer stationary decoders that can control different things. But a lot of times if you have automated things, you can do them through completely different power circuits as well, such as crossings.

Micheal:
When Arduino comes into this picture, is it being used to generate the code? Is that where it’s coming in? You’re being able to generate the different signals and target different things, or is it… I’m curious where it fits in in that infrastructure? Is it separate from that infrastructure?

Jimmy:
Until 2015, I would have told you it was separate. But a very brilliant coder, who’s also a model railroader named Gregg Berman, he wrote the system called DCC++. Obviously, it’s got a C++ code so that’s where the name comes from. Basically, he took an Arduino Uno, slapped an L298P motor shield on it, connected a couple of feeders where he jumped a pin five to 13 and pin 10 to 12, and was able to do use pulse with modulation to emulate a DCC signal.
You could just plug it in and you had to hook it up to a computer through a system called a Java Model Railroad Interface, or JMRI is what it’s commonly known as. You had to connect it to something like that to control it. But you could control and send out a DCC signal with an Arduino. Now most recently, a group of guys have taken this code because it was open source and have improved on it. I know your listeners will not be able to see this, but I have one sitting right here.
This is a what’s called DCC++ EX and I’ll describe to your listeners. It’s sitting on an Arduino Mega, that’s got an L298P motor shield, and then it’s got a Makerfabs WiFi shield on it. They’ve been able to code in to build a wifi server that can connect to one of the cell phone apps that’s out there to be able to control your drains from your cell phone directly with this without a computer.
You connect to it. You can either use it as an access point or it creates its own WiFi network or with mine, I have it connected to my whole network and all you got to know is the IP address and the port number, and you can connect.

Micheal:
Whoa, so you’re able to granularly control all this stuff from a phone app or something like that. That is insane. That’s pretty recent. What’d you say, like 2015-ish? That’s within the last six years of this recording.

Jimmy:
Yeah, about 2015 is when all of that came out. Arduinos have really exploded in the hobby. I know your listeners can’t see but you can see, I’ve got these things laying around everywhere. I got to [inaudible 00:10:56] all sorts of them laying around. My small model railroad that I have back here, it’s a little one. It’s purely powered by Arduino. It’s got three Arduinos. It’s got a Mega, an Uno and a Nano powering different features in it.
It’s really taken the hobby by storm and I think it’s just the ease of use of an Arduino even when you’re comparing to even something like Python. Just that ease of being able to code and ease of being able to understand because of the way it was originally created to be a learning device. That has made it just so easy to use for people who have never coded before. Because I was one of those people who before Arduinos I’d never coded before, and now I’m able to build my own Arduino sketches and run my stuff, so Arduinos really came in gangbusters to this hobby.

Micheal:
That is fantastic. Now with the DCC++, is that… I guess with this Arduino code, are there functional libraries you’re using that are specific to the railroad hobby or are you having to roll your own type of code to interface with some of the stuff?

Jimmy:
For some of the more basic ones, it’s just usually 100% code without a library, but a lot of the DCC++ in DCC++ EX has libraries that the guys who created it wrote for it. Actually, the NMRA, the National Model Railroad Association, which does all our standards for our hobby, the track gauge and all those things, they actually have created a DCC library for Arduino so that you can take Arduinos and actually turn them into decoders through a few pieces of circuitry.

Micheal:
Wow. That’s cool. I’m curious, I don’t know, what are some interesting things that you’ve seen people doing with the Arduino in track that stands out to you? Can you think of anything you’ve done maybe that’s a little bit different and somebody might not be expecting?

 

 

Jimmy:
The first thing that got me into using Arduinos is really trying to figure out block signaling. Which is when you drive across a crossing and you’ll see some lights on signal towers and things like that. Those are called blocks signals. Those basically tell the train, no, you can’t go, or you can go. We’ll be ready to stop the next signal. Or you can go all the way. That’s what the red, yellow and greens mean on those.
They’re different for each railroad, so you have to be able to customize them, which sometimes makes it difficult to find a pre-made product. I wanted to figure out a simple way to do this in an automated way rather than having to flip it manually and do it myself rather than buying a product. One got me into it. First I did infrared sensors and I placed them in the track and it’d be able to pick up and it would know that our train’s in there until it left on the other side.
That’s what really got me rolling and I was able to just do a lot of different things. Recently, I was able to build my own current sensor that can pick up an isolated section of track and can pick up if either a train is on there or we have resistor wheel sets that are for the car. If a car is on there, it has one of these resistor wheel sets, which typically has a 10K resistor on it. It would be able to pick it up and say, “Hey, this section of track is occupied.” That’s one thing that I’ve done over there as well.

Micheal:
Wow, that’s really cool. I guess I never even thought about the blocking. All right, so it’s like, hey, this train can start, this train can go, kind of thing. When you start talking about multiple tracks, does each track end up having its own isolated system or do the track start talking to each other, kind of thing?

Jimmy:
With DC, that’s how it was, where you had to isolate each to be able to control each individually. With DCC, you’ll typically hook everything up to a bus. The only thing you have to make sure is you have all your wires hooked up on the correct rail so that you don’t short circuit. But they’ll all be hooked up together and you just isolate them. You do have a, just making a tiny cut in the rails or you can use insulated plastic rail joiners if you have it at the end of a section of track that you’re installing.
You just have to have an isolated section to be able to do the current sensing. But in terms of just, all the rails can be interconnected to the same power bus. Basically you’ll just run a connection from your DCC system to the power bus, and then all of the feeders go out to the different areas of tracks.

Micheal: the power?

Jimmy:
It depends. You can certainly do the conversions. The trains are getting their power from the DCC system and sometimes you have to have boosters and things like that. But a lot of times with the Arduinos, I’m powering them from a separate… I’ll give an example right here, is I have a 12 volt and a five volt bus, just for accessories in there, because some of the LEDs, they’re going to explode if they come up to 12 volts.

Micheal:
I know, like a servo.

Jimmy:
But they’re still five volts. There’s a lot of servo use as well, a lot of relay use. Relays are used a lot of time to cut power to track or to throw turnouts. Servos are used as well to do more realistic throwing of turnout, so if you want to do something that’s a little slower. Because typically… I turn out the switch. I’m sorry.

Micheal:
Okay, I was going to ask you that. I’m like [crosstalk 00:16:18]-

Jimmy:
I’m going into terminology mode right there, so I’ll turn out as a switch. I’ll say switch. I’ll try and say switch. But if you’re throwing a switch to a different direction in the real world, it would go a bit slower. So you would use a servo and just have it underneath, and you just drill a tiny hole and you have a little pin, come through and it’ll push through and typically, the switches have a little hole for that pin, so you can move it like that.

Micheal:
All right. The Arduino or… Well, I guess you could power the Arduino from… I don’t know what the DCC voltage is for a track. Was it like 12 volts or 15?

Jimmy:
It’s 12 to 15, 16. That’s typically what it runs. This one’s 12 volts. Downstairs I have a 15 volts. It’s right around that range. It also depends on the scale. If you’re getting up into the big scales, like the G scale, what you see outdoors, you’re looking more towards the 18 volts, so [crosstalk 00:17:11] like that.

Micheal:
Okay. So you’ve got the one part, you’ve got the DCC that’s actually providing the power for the trains, and then you might have an auxiliary bus for the lower power auxiliary stuff. I gotcha. That’s cool. Then so the Arduino’s just still able to read the signal from the DCC but then the actual devices themselves are getting powered by something else?

Jimmy:
Yes. And so that, and some of them are completely independent. For the switch control that I have on there, it’s completely independent because I’m just pressing buttons to activate them. I just have a couple of momentary push buttons that these are able to be thrown using an F298N, so they’re disabled. I got two switches per driver and I’m able to just push a button and it can throw them for us. I actually have that completely independent, but you can definitely cook them up DCC. No problem.

Micheal:
Okay. F289N, what was that? Now I’m [inaudible 00:18:10]?

Jimmy:
It’s a motor driver.

Micheal:
Okay, gotcha. Motor driver. All right. That’s cool. I don’t know, I love watching trains go, I love watching them do interesting things when they’re moving around, either going through a tunnel and lights come on or adjusting turning back. How much of the hobby… This is such a broad question. Maybe this is a credit question. But how much of the hobby is moving into the DCC as opposed to just DC? Is the DC still being made regularly and people are using it, or is DCC pretty much taken over kind of thing? I’m just curious.

Jimmy:
A lot of DCC equipped locomotives can run on a DC system. Sometimes it’s not the best for them. You just got to know your locomotive, but a lot of locomotives are also sold what’s called DCC ready. Which means they’re DC, but they have a socket to where you can plug that DCC decoder in and it’ll be DCC. It’ll run DC, and that’s what it’s originally going to run. But if you want to convert it, it’s ready to be easily converted.
I would say the hobby is definitely moving almost completely towards DCC. That’s where all of the investment is. That’s where a lot of it is. But there are still tons and tons of people who run DC and run it extremely well and have a ton of things with it. It really comes down to a personal preference. DC is obviously going to be cheaper because you’re taking out the complex circuitry and you’re taking out the investment that the companies have made to make these chips. But DCC is generally the direction that the hobby is moving.

Micheal:
Okay, I see. Now, what about… I can think of my father, for example. He loves model railroading. But I know he has older trains. When he was a kid, he was into it and he’s gotten back into the hobby a bit. Are people converting older trains to DCC? Is it like a similar thing where they’re able to slap on a chip thing? Is that something that goes on?

Jimmy:
I have seen it done. There’s an old product [inaudible 00:20:11] called [Ather 00:20:12] in blue boxes. It’s by a company called Ather that’s still around and makes great stuff. But they used to be these just simple little kits that you would build on. They had locomotives, they had cars, all these different things, and I’ve actually seen people that are able to convert those.
There are some DCC decoders that come with the feeders all wired out so that you can actually just wire up and do the proper connections and be able to do that without having to solder directly on a circuit board. People are doing that. It’s not as common and it’s not the easiest thing in the world to do, especially when you get into the smaller scales, like what I model which is in scale, which is one 160th size, and there’s even smaller scales on that.
But you do see it, but it’s something that you don’t see a lot of. But it’s a way that some people found the safe money, if they can make it happen, and you can make a DCC locomotive out of an old DC locomotive for pretty cheap.

Micheal:
That’s interesting. What’s your go-to Arduino board when you’re doing this stuff?

Arduino Boards:

Jimmy:
When I’m prototyping, I typically like a Uno, just because it’s going to be the easiest to find shields for, it’s going to be easiest to connect to and just have sitting down. And plus in terms of costs, they’re dirt cheap. It’s not like Megas are really expensive, but when I’m actually implementing, if it’s a very small project, I’ll use either a Nano or a pro-mini, if I can find a pro-mini.
If I’m doing something that requires a lot of inputs and outputs, obviously I’m going to go for the Mega. But those are probably, I would say, Uno is my prototype and Nano is going to be my small project implement, and then Mega’s going to be my big implementer.

Micheal:
Okay, so let’s say somebody who’s listening to this show right now, and let’s say they’re into the hobby, the model railroad hobby. But they’re new to Arduino, new to programming, maybe a little intimidated by the whole thing. What would you tell them? What would you say to them?

Jimmy:
Let’s say if I can do it, anybody can do it.

Micheal:
That’s an honor too.

Jimmy:
I think if people, I think if they want to get started, it’s really harder to just look at something and say, I want to make something. You really have to figure out exactly, something that you want. How I got Arduinos was I saw something that I wanted to do, and I did research and I stumbled across Arduinos. I was able to get into Arduinos that way.
But just figure out something that you want to do and work on that one direction. Don’t try to figure out everything about code. Don’t try to figure out libraries. Don’t try to figure out all these different things. Just figuring out how to do that one specific thing. Then once you do that, build upon it.

 

 

Micheal:
Absolutely. There’s something about reaching towards the goal that makes all the difference. You know what I mean, working on it. I think when you’re new to code and you start learning about it, it can just be so exciting. I feel like you can just learn… I don’t know. Even when you don’t know a ton, especially Arduino, I feel like you can still do a lot once you start learning a little bit. You run into a lot of hiccups along the way. I just think that’s the natural process, but like you said, that aids to the learning.
All right, so here’s the next audience person I want to address. Let’s say somebody is out there and they’ve kicked around getting into the model railroading hobby, because they think it’s cool. They had that uncle or aunt, or they went to that thing and they saw this awesome display and like, “This is pretty neat. I’m interested in it.” Where would somebody get into the hobby from that perspective? That might be also, if they’re listening to show, they’re probably interested in programming electronics. What would be a good entry point for somebody like that, do you think? Any thoughts there?

Jimmy:
There are plenty of… Just like with anything, there are starter kits for model trains. There’s train sets. I think everybody that’s seen model trains knows what a train set is. This is everybody’s starting point and there are plenty of resources online, Model Railroad Hobbyists and TrainMasters is one of them that have just a wealth of information of how to take that starter set and make it something neat.
But their starter sets are really where you go, and you can get DC starter sets and you can get DCC starter sets. You just play around with it. We got to figure out how much space you have because trains can really, really eat up some space depending on what you get. If you’re thinking about the old school, I think if someone’s going to know a train brand, they’re going to know Lionel. Those are pretty big. Those are 148 scale, so those engines are not like that.
Those can eat up some space and that’s one reason why I don’t do Lionel even though I love it. But you just got to do your research, figure out what scale you want and then get a starter set and just start playing and tinkering. Because the thing is, is there’s no wrong way, unless you’re doing something that’s going to catch on fire from a bad electrical thing. There’s no wrong way to do model railroading.
It comes down to, are you having fun? If you have zero interest in scenery and you want to see what automated things you can do with an Arduino and a model railroad, then you are doing model railroading correctly. Model railroading is one of those hobbies that’s also, it’s one of those compared to a couple others that are like this. It’s really a big STEAM hobby, science, technology, engineering, art, math. It’s got everything in it.
If you’re an Arduino guy or you’re a DIY electronics guy, and you’re looking for a fun way to apply all these things that you know and all these little projects that you do that you’re like, “Well, now what do I do with it?” Model railroading is a fantastic outlet for applying all those DIY electronics projects as well.

Micheal:
Man, that is so cool. Hey, this is a great place to wrap it up, Jimmy. Thanks so much for taking the time to talk. Hey, if somebody wants to find you online, I know you do work with Model Railroading Hobbyist Magazine, but is there another place online they could find you?

Jimmy:
Yeah. Well, first of all, I do the TrainMasters TV is where you can find me. That’s trainmasters.tv. I do a show on there called Jimmy’s Trainworks. It’s really just been starting up. I’m only on my third episode. I do have about once a month, but there’s plenty of other guys, there’s layout tours to give you inspiration and things like that.
But I’m also on YouTube. I have the DIY and Digital Railroad. if you search that, you’ll come across my YouTube channel and I’ve got loads of Arduino tutorials, simple things. Now, I have a feeling that with your base, you guys are going to look at me and go like, “Well, there’s a way easier way to do some of the stuff he does.” Honestly I welcome that because if I can find ways to simplify the code and make it easier, I love hearing because I’ve improved a lot of projects from people giving me suggestions.
Because like I said, I’m not a coder. I’m actually a professional video producer by trade so this is just, I’m a tinkerer. I’m not the best coder, but that’s the great thing about Arduinos right there.

Micheal:
Yeah. Hey, I’m right there with you. It’s all about learning, the journey. Fantastic. Jimmy, thanks so much for your time.

Jimmy:
Thank you so much. This has been fun.

Micheal:
Yeah. I agree. See you.

Speaker 1:
This show is produced by Programming Electronics Academy, an online technology education company. We exist to help you create the technology you want in your life. If you are interested in learning more about Arduino, we welcome you to sign up for our free Arduino crash course. A 12-part video series with the accompanying, written lessons, designed to teach the basics of programming Arduino. To register for the course, simply text your email address to 440 701 5311. Or you can visit programmingelectronics.com and sign up there.

 

 

AppLab Bricks open in background with actual brick

Arduino AppLab Bricks → Marketing Garbage or New Powerful Interface?

Arduino Ventuno single board computer - top side

New Ventuno Q Dual Brain Single Board Computer

AppLab Pip Install

How to Add Python Packages in Arduino AppLab (No pip install needed)

Arduino Power Section Schematic

Kit-on-a-Shield Schematic Review

Just how random is the ESP32 random number generator?

Just how random is the ESP32 random number generator?

Leave a Comment