Welcome to The N-Scaler, a blog about high-tech model railroading in the 21st Century with limited space, tight budgets and the need for portability; impediments many of us with model railroading ambitions face. I know I’m not the only one out there with modeling ambitions that never see the light of day because of real world constraints.

Enough of that already, its time to make the constraints a virtue and get something done. First,I’ll give credit where credit is due: Model Railroader Magazine has been pushing the concept of smaller layouts recently, including a new publication and articles about doable projects. For quite a few years now they have explored alternatives to traditional building methods. And they are all over DCC. That’s why I’ve been a subscriber for over 2 decades. Good job, guys.

My project is to build a modular, portable N-scale layout that has a relatively small footprint, but supports multiple trains and continuous running, and is big on action, animation and modeling opportunities. The basic parameters are these:

  • It has to be built from materials readily available in a small city like Reno, Nevada, or via the Internet. If I can’t get it within a week for a reasonable price, I’ll try a different item or material. Struggling to obtain materials is a waste precious modeling time.
  • Ease/speed of building techniques is a high priority. The goal is to achieve continuing visible results with relatively small blocks of time in an otherwise busy life.
  • Cost matters. One of the attractions of model railroading has always been that it can be done on a proverbial shoe string; a blade, a straight edge and some glue can get you a long way. Most of the cost of the hobby comes from manufactured goods, and technology only makes that worse. At each step along the way I’ll be looking for ways to get the most out of my limited modeling dollars.
  • The layout will be modular, but it will not be built for use in a modular system (such as N-Trak).  For me, modularity is about breaking a layout down into manageable sections for reliable portability and ease of construction; I’m not worried about interfacing with other modeler’s work right now. Maybe next layout.
  • The layout has to be lightweight, structurally strong, and really portable. It should be easy to set up and take down, and its components should easily fit in the back of a Subaru (I’ll concede the rear seats may have to be down so we’re not too constrained here).
  • Modules have to interconnect securely and reliably, physically and electronically, every time the layout is assembled.
  • This will be a high tech layout. DCC cab control, block detection and signaling and animation. Lots of lights and animation. And sound wherever possible. Who knows where that will take me.
  •  I intend to create a layout with brains; essentially an autonomous environment within which to operate trains. No lack of ambition here! The availability of inexpensive, single board open-source microcomputers and microcontrollers(Raspberry Pi and Arduino, are well known examples) and the explosion of inexpensive robotics equipment got me thinking …. Follow along as I try a somewhat different approach to layout control.

That’s the plan. It probably won’t go exactly as I expect but that is part of the point. If I’m not running into trouble, I’m probably not pushing the boundaries in the ways that I want to.

17 thoughts on “Welcome”

  1. Just found your site – haven’t read it all but it strikes a cord. My theory is to use touchscreens for local control panels. Using an Arduino Mega and TFT touch screen, I started off duplicating the interlocking machine in the Feb 1961 Model Railroader. This led to connecting it to a model railroad, driving signals and switches. I drive multiple switch machines and signals with 16 multiplexer PWM chips via I2c communication. I use a 5 to 2.5 V voltage controller to drive bicolor LEDs.
    Another sketch drives multiple switches with routing logic. Glad to send photos and example codes if you are interested.

    • I’m impressed that you duplicated the interlocking machine from MR — I’ve seen a reprint of that article; it was impressive. I recall there was another 2 part article about an interlocking machine a few years ago — it was a particularly fine piece of craftsmanship.

      I’m always interested in seeing other people’s work. I’ve been thinking about putting together a gallery of photos from readers, so if you’d be interested in having some of your work shown here, let me know.


  2. Like David I too have just found your site and appreciate you sharing your knowledge and experience. I have committed to tortoise motors before the introduction of servos. Currently trying to use Arduino to controll routing in my storage yard. The points (16) are all on a separate circuit and I have been trying to source a DPDT relay that will allow me to talk to the Arduino economically. I will be needing later to incorporate another 24 point motors on a separate area of layout so economy is important. Eventually hoping to construct a wireless control panel to talk to my Arduino controlled points. More later. Thanks again

    • Schrack relays are generally pretty inexpensive and widely available from electronics vendors like digikey. I think tortoise switch machines draw less than 20 ma, so you won’t need high power relays (500ma type is cheap and plentiful). Get the “Bistable” type so that you can power the coil briefly to move it either way, but don’t have to continuously maintain coil power to maintain its setting. I connect to relays through a Darlington Driver (ULN2803APG) to drive the coils, because they draw too much power for the standard Arduino outputs. One eight channel Darlington can control four relays. You can connect the Darlington directly to the Arduino, or through a Shift Register network. If I’m understanding correctly, you eventually intend to have 40 motors. So what I would do to control the relays is set up a shift register / darlington driver network (you’ll find more on those topics elsewhere on the site); that would make routes super easy since all the points can be set in a single efficient operation.

      Best, Robin

  3. i just started to read this post today. where I can I find instructions on how to use an arduino to control tortise turnouts. I have ordered the arduino starter kit to learn programing.

    • I’m sorry to say I don’t have a specific reference for you. However, running a Tortoise switch motor should be easy. The motor requires a 12 volt DC power source so it can’t be directly connected to your Arduino pins. So, you would use a DPDT relay to control the polarity to the Tortoise; control the relay with a Darlington Driver IC, which you can attach directly to Arduino pins or use as part of a shift register chain. You’ll find more on Darlington Drivers (and shift registers) on this site. Relay coils generally draw too much power to attach directly to an Arduino; hence the need for a Darlington as an intermediary. Watch upcoming posts where I’ll explain how I’m using relays to handle power reversing — this will likely help you set up Tortoise machines.

  4. I’m older and do not want to go to DCC.
    I would have to replace to many train engines.
    What I have was given to me. The person’s Father built it in the 60S. He built it in section’s. The layout is 24′ x 14′. It’s all in ho scale.
    He build all the power supplies the controllers and switching relays.
    After moving and re setting up, parts started dying from old age. I replaced circuits with atlas manual switches. Replaced power supply’s and controllers with combination power supply and controllers.
    I would like to update to this new type system.
    I hope you can help me get started. I have 16 track switches, I have a turn table, and a 4 train train house. With position switch to control those tracks. I would like to make a lighted display of the whole layout with lights to show what switch is switched where.

    • That’s great. What a terrific opportunity to take an older layout and bring it forward. I can still remember the ozone those 60’s layouts could produce — an uncle of mine built one about the same size as yours, off limits to children, of course (arg! He was not good at sharing. Major character flaw.).

      The great thing about the kinds of things I’m doing here is that you can put it together one project at a time. So, for example, a lot of people tend to start with basic turnout control. From there you can add signaling, block occupancy detection, display systems and so on. The point is, though, you can start with just one turnout and build incrementally from there.

      Starting with turnouts, it sounds like they are all currently Atlas manuals, right? To automate those, you’d want to change to a Tortoise or a servo type motor. If you are interested is going servo, I may be able to guide you on mounting solutions that are better than the hot glue thing I’ve been doing. Once you’ve decided what type of motor you want to use, you’ll either build or purchase the necessary control electronics or shields (sounds like a big deal, not really), get your first Arduino and learn how to control the turnout.

      I’m always happy to help; more extensive conversations can be conducted off-line so we don’t clutter the blog.

      Best, R

  5. God evening!
    It is a very interesting project and page you have. I am just new to Arduino but have programmed a little in PHP, how ever it is obviously not the same.

    I was trying to comment on this page http://thenscaler.com/?page_id=661 but it was not possible. I had some questions about implementing (I have started but i struggles). I am trying to make a railway crossing with servo controlled gates. Maybe I could show you my code and discuss what I do wrong.
    I understand if you do not have time or are interested,

    Finally thank you for good website!
    Best Regards Johan Billow

    • Hi Johan, Glad you stopped by.

      I’m happy to try to help with your code. I’ll send my email address so we can correspond offline.

      Best, Rob

  6. Hello,

    I ask your help in setting up 16 turnouts for automatic operation.

    I have been given three incomplete HO scale modules on which there are 16 turnouts all of which are manually operated.

    I wish to convert these manually operated turnouts to automatic operation and to have LED lights on a control panel showing turnout position.

    I have read on your materials concerning turnout control several times over the past month and a half.

    I am an avid carton modeler. This layout presents me the opportunity to be able to place many of my models on something other than a small diorama.

    I am 76 years old and do not have the time left in my life to be able to make the models that I wish to make and to learn programming to automate these turnouts.

    So I ask for your assistance, for which I am willing to pay, in automating turnouts.

    I have two Arduino mega, LEDs, SG 90 Tower Pro servos, momentary contact pushbutton switches, resistors and a .PCA 9685 16Ch 12-bit PWM Servo Shield Motor Driver I2C Module Arduino Robot UKP

    I have ordered shift registers.

    Can you do the following for me?

    Should I split the 16 turnouts between two mega boards and use the sketch that you have provided to control five turnouts modified to control the number of turnouts I wish on each mega?

    It is my understanding that is his best to control the servos via a PCA 9685 16Ch 12-bit PWM Servo Shield Motor Driver. If you recommend that in this case, can you tell me exactly how to do that including providing the sketch, or sketches, and information as to exactly how to wire these?

    Any other information that you think necessary would definitely be appreciated.

    Thank you for the time,

    Gary Granai

    • Hi Gary,

      First, I apologize for the delayed response – your question got caught in the spam filters and I just saw it today.

      So one question I have about the layout you are working with is size: what are its general dimensions, what is the layout style, and other information that would give me a good mental picture of the layout. What I want to determine at this point is distances that have to be traversed. If the layout is physically large, I’d make different recommendations than I would for a small layout.

      I’ll send of duplicate of this to your email.

      Best, Rob

  7. Robin, just stumbled onto your site when looking for a way to control servos with Arduino UNO. Read thru your page and code for driving a single servo, works great. Now I’m trying to expand this to multiple servos. I also read your page on that subject. But having difficulty understanding how to add the push button code for multiple buttons to the code structure for multiple servos. And help would be appreciated. Thanks.

    • First, I would encourage you to look at C++ Objects for Layout Control, Part 1, and C++ Objects for Layout Control, Part 2 — Turnouts. OOP techniques make this a lot easier.

      Assuming that you create turnout objects along the lines I suggest, then using buttons gets simplified.

      In loop(), I always start by getting the current time in milliseconds which I use for timing movement as described in the blog. Then I run the update() process for each animated object, including turnouts. In loop I just keep calling object.update(current time) on every pass; the update process decides whether anything needs to be done on each call.

      After the animation update, check buttons & switches.

      Let’s say we have a button A attached to a pin (with pull-down resistor), and we have a turnout T. Lets assume a button push on A is intended to cause T to move to divergent position. is Here’s the algorithm:

      if(digitalRead(A) == HIGH){

      set(ALIGN_DIVERGENT) sets variables that cause the animation to run on the update() process. If you have a button B for setting the turnout to the main route, then the button press would cause a call to T.set(ALIGN_NORMAL).

      So, in your main loop() include a section that reads your buttons, and then starts off the turnout motion sequence. Remember that the raw speed of the processors makes lots of separate small actions function in unity. So just step through the processes that should happen on each loop() pass, one at a time.

      Best, Rob

  8. Hello Rob, Many thanks for the excellent project “Turnout control with Arduino & servos” which I have embraced with great success. I do have a couple of questions though. Firstly, I can not fathom out how to amend the code so the turnout remains set to it previous position when powering on instead of always favouring one way & secondly, can the Arduino be utilised in some way for frog polarity switching?

    • Hi Nick,

      Sorry for the delayed response. My real world businesses have been demanding lately.

      You have encountered a basic limitation for servos that arises because there is no way to detect the current servo position. Therefore, it is necessary to always reset servos to a known starting position when you power up the layout so you can track them from there. It is possible to overcome this limitation if you can write the current position of a servo to non-volatile memory every time it moves, then on startup read that position info and set the servo to its last known position [it won’t move if the position isn’t actually changing]. You could even determine if a turnout got stuck mid-way because power went out before the move was finished.

      You could do this with EEPROM, but its probably not a good idea because Arduino EEPROM can only sustain 50k writes before it goes dead. Best solution is to use an SD drive and record position information there. Because writing to SD can be slow, you’ll have performance issues to work through, but it can be done.

      Secondly, you can add relay support for polarity management. Conceptually, its simple: you associate a particular relay with a frog or reversing section, and set the relay according to the position of the points. As a practical matter, you’ll need to devise a logical “relay object” that the turnout “object” can manage.

      Best, Rob

Leave a Reply

Your email address will not be published. Required fields are marked *