I did a search for “Arduino” and all I got was some video links to a DCC controller.
I’m really surprised that there is not more interest in using this versatile and inexpensive device in model railroading. I have a small N scale switching layout, and never have the need to run more than 1 train at a time, so I built a throttle that used the Arduino’s PWM (Pulse Width Modulation) output to directly feed the tracks. This is essentially the same waveform that a DCC decoder supplies to the motor. No, I don’t have sound or lighting control, but I also spent less than $50 and I have far better low-speed control than I ever had with DC. I programmed momentum and braking into the Arduino, but I took it out since I prefer to have tight control over the locomotive.
I’m in the middle of using an Arduino with a stepper motor to control a turntable. Initially I will just have a “run” and “jog” function in each direction, but when I can get a detection circuit I’m happy with, I plan to have the turntable automatically position at the selected track.
Is anyone else making use of the Arduino? If anyone wants my sketches, I’ll be happy to share them.
I developed a system for signaling and have signaled about 1/3 - 1/2 of my railroad. Of course, I’m not by any means the first one to do so. You can read about my system at: “warrena623.wordpress.com”, including sketches (small programs) and wiring details. One guy I know of has had an article waiting for publication for quite a while, same kind of idea. There is also a group in Southern California doing Arduino applications to DCC, etc, with a Yahoo group called the ‘arduini’. Then there is Dr. Geoff Bunza’s blog on MRH ezine (Model Railroad Hobbyist).
It does seem a rather natural application of very flexible technology to model railroading.
There’s a fellow doing some work with Arduinos over in the Layouts forum on his On30 logging line.
I’m sure there would be interest in a TT stepper drive controller. I’ve wondered about how to do that cheaply myself since stepper motors now appear regularly in surplus shops and vendor catalogs. I have a nice NYRS drive on my big TT, but paid a nice sum for it, too.
My wife is a programmer and the hot little unit in town here is the RaspberyPi because of the CS and EE programs at UIUC. Supposedly, there’s a build with it in JMRI that lets it run the layout, etc via Decoder/Panel Pro so you can use it as a dedicated computer controled via remoate over the network instead of needing a laptop attached to the layout itself
That’s probably a bigger set of tasks than an Arduino could handle, but there’s certainly some interest here from what I’ve seen in these new types of micro computers.
That would be a very useful application, especially if it could drive multiple devices, such as serving as a swicth machine controller. Serve that up with some Macros adressable in the DCC formats used by different mfgs and you have something very useful.
But even a remote for a single turnout could be useful if the net cost was comparable to commerical DCC accessory products.
I’ve got a setup that I used at Christmas that consists of an Arduino, a motor shield, PIR motion sensor, and infrared receiver with a remote. I have an N-scale loop of track that I place IN the tree and an HO scale loop that I place on the ground around the tree. The system has two modes of operation - manual and automatic - which I can switch between using the remote. In manual mode I can control the trains using the remote - volume up and down for faster and slower for one train and channel up and down for faster and slower for the other. In automatic mode, when the motion sensor was activated, the controller would automatically start one train, then wait a few seconds and start the other. After a short period of time it would stop one and then the other. Using PWM to drive the motor shield, the starts and stops were never sudden but always gradually ramped up and down.
This just in…my wife found the RaspberryPi and case she thought she had sitting around that a friend gave her when he left town. BNIB. Now if my buddy who is on the JMRI list can only figure out which files I need to set this up with JMRI. Supposedly, the whole thing runs off an SD card, but that’s about as much as I know about it. Will start me own thread when that happens. Just wanted folks to know there’s usually a couple of pots bubbling on the electronic stove around here, even though I’m an e-school washout (by choice).
Arduino Nano is a chip-size unit effectively equivalent to the Uno - the Uno is easier to connect stuff to, so is better for development, but if you want to produce a few finished devices to install around your layout, the Nano is the one to use. They are under $3 on eBay. You need to add a few parts for the DCC interface (another couple of dollars tops) and then it can directly drive 4 servos for turnouts PLUS a bunch of LEDs for signals. You aren’t going to get a commercial DCC stationary decoder for that price.
And they are stupidly simple to work with. After a few tutorials I am almost having to unlearn some of what I know, lots of prior programming experience may not actually be a plus when learning to program Arduino.
I used a RaspberryPi with JMRI to control the signals on my layout (now disassembled due to a move). I have not yet got it to run in headless mode but was able to boot when I powered up the layout and be able to run the logic used to control the signals. I interfaced it with Loconet via a LocoBuffer USB. I also run my Speedometer off of the Raspberry Pi to speed match locomotives.
Well, that’s a start. No signals on the narrowgauge, even one as busy as mine, but if it can keep track of that it should be able to deal with what I need. I need a WiThrottle server, a webserver, and turnout tables (and macros if I ever get that figured out.)
Stuff like configuring the pins for different types of output - MUCH simpler than PIC (probably simpler than native Atmel too, but I never used them).
Not really more than you get switching back and forth between multiple programming languages - some are 0 based for arrays and position indexing, some are 1 based. Some use If…Then…Else constrcuts, some use End, others use End If or EndIf to end an If block. Maybe not a common thing, but I am always working on different projects, wiringt PowerShell scripts one day. T-SQL another, VB the next. Then weeks with no coding of any sort. Nature of the beast working as a consultant.
I first learned about Arduino’s in an old-school RMC about layout animation, maybe late 2013, early 2014? Shortly thereafter, I started stumbling across a wave of YouTube videos about using Arduinos, such that one handyman channel included a humorous mocking statement “Blowing out your lawn sprinkler system - now 100% Arduino free”.
I haven’t implemented anything with one yet, but obviously useful for things like crossing gate controllers (as this guy demonstrates) and traffic light sequencers (indeed, considering the incredible crappy real-world traffic light controllers on Long Island which routinuely fail/fall out of synch, perhaps they should replace those with Arduinos - it could only help).
While I don’t have a turntable, I have created a 3 chime horn using the Mozzi sound synthesizer (an Arduino library), and am in the process of developing a system of turnout activation via ifrared (old DVD player remote). I’m happy to share the train horn code, but just finished (with bug!) the turnout code.
I have completed a breadboard version of a turntable controller. The Arduino part of it has two pushbuttons, fast and slow, for each direction of rotation. I’ll publish the sketch and wiring diageams here in a few days, once i’m confident it is working properly.
I am using a stepper motor and timing belt from an old printer, and I turned an 8"disc with a groove around the perimeter for the belt, to drive the turntable shaft. The stepper motor already has a pulley that is grooved to match the belt, and just friction is enough to drive the large disk on the turntable.
On the train control side, as I said, I use the PWM output from the Arduino, connected to the track as in a DC configuration (through a motor controller shield). One improvement I’d like to add would be to have the same position of the throttle knob result in the same speed from every locomotive. Does DCC actually achieve this? I was thinking, if there was some way to use the back EMF from the motor, that might provide an input to the Arduino that would be proportional to speed. Any ideas?
Yes, DCC does that, if you configure speed tables in each loco so that the same throttle positin results int he same speed for each loco. Your BEMF idea for DC would work, but you would have to have the same sort of speed table configured in your throttle (and everyth throttle, if there will be more than one) so that for each loco you associate a certain amount of BEMF with a specific speed - no two locos will ever be the same, they will either have different brands of motors or different gear ratios, or both. So you need to develop a table for each loco, so that throttle position X equals speed Y, and then when you adjust the throttle, the Arduino controller can increase or decrease the track voltage as necessary to maintain that specific speed. That’s how it happens with DCC< except that it all takes place in the loco, with the decoder adjusting the motor PWM to keep the speed at the desired setting. There is no analog voltage involved with DCC. The track voltage is constant, and the drive from the decoder to the motor is PWM.
Thanks, Randy. That makes sense. BTW, I’m applying the PWM signal to the track, not DC. I realize I’d have to use a selector switch for each individual loco - isn’t that what you have to do on a DCC throttle? My dilemma now is how to measure the back EMF, and I’ve found a couple of Internet sites that come close to explaining it. It looks like I will have to abandon my motor controller shield in favor of a home-made H bridge in order to make that happen. I just love the fact that model railroading allows me to combine three of my favorite hobbies - railroading, electronics and computers! I’m so glad I got back into model railroading after a 25 year hiatus! So much has changed! Very exciting!!! Walt
If you google “arduino model railroad” you’ll find tons of sites with projects of all sorts. There’s a section on the Arduino forms for model railway control. There’s also a Yahoo group on using Arduino in model railroading. In addition to looking at the web page hits on Google for arduino model railroad, switch to the video results - there are numerous videos on YouTube with demos of Arduino-controlled layouts.
The major difference between switching between locos with DCC and with a system witht he config information in the throttle is that it makes each throttle more complex - and you need to find a way to synchronize the speed tables in each throttle. That’s fine on an experimental basis where you only have one controller but on a more practical basis with multiple throttles in use it can be interesting. With DCC that information is stored in the decoder in the individual loco. so the throttle doesn’t have to know about any of that, the throttle just says run at speed step 20 and the decoders makes the loco move at whatever speed it has been programmed to move at speed step 20. Storage of all this data might be an issue with Arduino, even ones with 32MB of program storage - for a large fleet you might need to use a CF card and read data from there for the selected loco (probably too slow for real time, but if you load only 1 loco at a time into the program memory, you can store hundreds on the CF but have fast response for the one being driven at any given time.). The other thing to keep in mind is possibly compressing the speed data - DCC decoders only have 29 data points, most decoders do interpolation so the speed tables can still work when used with the much finer 128 speed step mode (which is really about 125 steps, some are reserved). That uses 28 bytes, plus there are forward and reverse t
There are people who grump about all the cool whiz-bang electronics (not all, some just prefer DC) as nothing but useless glitz. But I think your reaction is one that a lot of folks share. People worry about the health of the hobby, but it’s new developments like DCC, computer-driven programs like JMRI, and plain ol’ fashioned hacking like you’re doing which broadens the hobby’s appeal to younger folks, whether they’re 15 or 55.