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.
Walt
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.
jrc
As was said, Being discussed in the MRH forums since about 2012. They are a bit more advanced there then here.
Search for Arduino mrh.
Rich
If you ever fall over in public, pick yourself up and say “sorry it’s been a while since I inhabited a body.” And just walk away.
There's actually quite a bit. NMRA DCC library, Loconet library, and a CMRI library.
So you can make a generic DCC accessory decoder, a Loconet device, or a CMRI node out of them.
--Randy
Modeling the Reading Railroad in the 1950's
Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.
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.
Mike Lehman
Urbana, IL
rrinkerSo you can make a generic DCC accessory decoder...
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.
Walt - SIs anyone else making use of the Arduino?
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.
mlehmanthe 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
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.
mlehman mlehman 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 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).
mlehman 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
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.
Colorado Front Range Railroad: http://www.coloradofrontrangerr.com/
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.)
rrinkerAfter 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
any examples?
greg - Philadelphia & Reading / Reading
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'm encouraged by the response to this thread!
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.
You could always build your own DCC system
http://model-railroad-hobbyist.com/node/19397
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 trim values that adjust the whole curve to compensate for differences in forward and reverse motion - gear lash, side rods on steam locos, etc). A true 128 step curve, or 256 (although 256 discrete pulse widths may be excessive, as in no noticable difference between speed 230 and speed 231 - 128 in DCC seems to be a fine compromise between memory and signal encoding and actual speed changes in the running loco) would of course require 128 bytes, plus two trim bytes, or 256, per loco. It would certainly be possible to encode such a table rather than use raw data, which could greatly reduce the storage requirements.
Walt - S 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
Walt,
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.
Mike said:
"...hacking like you're doing which broadens the hobby's appeal to younger folks, whether they're 15 or 55."
I'm 71 :)
There's a cool Arduino project on Instructibles, basically a self balancing ride on like a Segway except you sit on it instead of stand, it uses the motors from an old motorized wheelchair, guy welded up a frame for the seat and used some high current motor driver board controlled by an Arduino to balance it and make it go when you lean, and you steer with a stick.
Guy's 81!
I hope I'll still be playing around with this stuff when I'm 81. The whole phenomenon is just amazing. I'm just a little too old, having started long before there was an IBM PC and the closest thing to a microcontroller was the Intel 8048. I have some old magazines where Imsai advertised a single board machine based on the 8048 and in the add they had model trains shown as part of the "what you can control with this" angle. Usually the current crop of technology is the playground of the young, who grew up with that level of technology always around them. But in a way I think this had jaded them. Neither of my boysd, in their early 20's, is the least bit impressed when I show them my first computer, which I built from a kit and uses a hex keypad and LED displays to program. They're too abstracted from the hardware - I still remember most of the 91 instructions that old CPU had as its entire instruction set. Modern CPUs probably have more than 91 instructions just to add two numbers together. Programming a current Intel CPU in machine language is an exercise in futility. Even modern microcontrollers - you have C or C-like languages, or variations of BASIC (I have one for PIC chips), you don't program them by hand assembling programs like I did for my first computer. Things like Arduinos at least get you back in touch with the hardware - in high level machines running a modern OS< be it Windows, Linux, or OSX, far abstract the programmer from the hardware, everything is virtualized and accessed via some black box of a driver, they are deliberately made to NOT allow direct hardware access. Arduino and PIC and other microcontrollers are completely the opposite.
Remember TI's being the most advanced and then the Atari's, my first and last attempt at programing.
Can anyone point to a good bit/byte/packet level description of DCC? I've read the nmra boiler plate and done many google searches but it's fairly dry out there. I understand there is a basic packet and extended more or less but I'm not clear on things like the bi-directional components, etc. I've got some hardware and code working that basically spit out the DCC stream in hex format but other than the address, I'm not sure what I'm looking at...
The Location: Forests of the Pacific Northwest, OregonThe Year: 1948The Scale: On30The Blog: http://bvlcorr.tumblr.com
Can you possibly elaborate on the wireless implementation? I'm interested in doing something similar.
Martin
rrinker "I'm just a little too old, having started long before there was an IBM PC and the closest thing to a microcontroller was the Intel 8048.... --Randy" Would you believe punching cards for Fortran in 1971? No such thing as a 'personal computer' or even a desktop. The most advanced 'desktop' was a Wang programmable calculator with nixie tubes. jrc
"I'm just a little too old, having started long before there was an IBM PC and the closest thing to a microcontroller was the Intel 8048....
--Randy"
Would you believe punching cards for Fortran in 1971? No such thing as a 'personal computer' or even a desktop. The most advanced 'desktop' was a Wang programmable calculator with nixie tubes.
martan3dCan anyone point to a good bit/byte/packet level description of DCC?
there's a bunch of info on the NCE-DCC yahoo group
It looks like there's code for testing under the Files tabs in that group, including some code for a controller un Misc_NCE_Info.
Bear in mind, NCE uses PIC processors. Mark Gurries web page has lots of info.
jrcBozeWould you believe punching cards for Fortran in 1971? No such thing as a 'personal computer' or even a desktop. jrc
Yes, except for me I was learning Fortran IV around 1978/79 at California State University Sacramento (CSUS) otherwise known as Slack Stat, er Sac State. My first class in Comp Sci was punching Holerith cars and running a stack through the card reader and waiting for the output to be put in a bin. Not long after, the cats meow was to get a Heathkit terminal and old style modem that you plugged the telephone handset into and wrote your code using a text editor and then submit the job without the punch cards! I found that coding was too tedious for me so I switch to chemistry and then geology, which is what I earned my B.S. and later M.S. degree's in. But eventually I went back to IT (MCSE) to put food on the table and model trains on the tracks, but not before I took an assembly language class and wrote a two pass assembler - woo that was tedious.
Rio Grande. The Action Road - Focus 1977-1983
martan3d Can you possibly elaborate on the wireless implementation? I'm interested in doing something similar. Martin
I did a write-up here a few months ago, which shows how I put the whole thing together.
I used a pair of XBee modules to cover the wireless aspect. These are essentially transparent to the Arduino - as far as the Arduino is concerned, it's sending and receiving across a serial link. The software aspect of the transmission was handled by the EasyTransfer library (http://www.billporter.info/2011/05/30/easytransfer-arduino-library/).
Essentially, the controller reads the input from the rotary encoder, function button, etc. and puts it into a data structure. This structure is then put out over the serial link via the EasyTransfer library. The XBee takes this data from the serial link, and sends it to the receiving XBee in the base station. When the data is received by the base station, it's a reverse of this process. The struct is read in, and the base station generates the DCC packets, allocates the locomotives, etc. accordingly.
The automatic staging system also uses the XBees - a spare one I had after experimenting with the various antennas. The base station transmits the address of the loco to the staging controller, using the same XBee on which it receives from the controller. As there's only one loco running at the time, it's safe for the staging system to 'assume' that the last engine allocated is the one entering staging.