Running a Small Layout with an Uno

Arduino Uno R3

Arduino Uno R3

A reader on another thread had questions about running multiple turnouts on a small layout with an Uno. Primarily he wants to control turnouts with a control panel and feedback indicators.  I thought that his needs are pretty typical for small layouts, and would be a good example for others planning and building on a similar scale.

So this post is bottom-up exercise in planning and implementing single UNO control on a small layout. I hope it will be helpful in planning and building your layout.

The Requirements

The layout has 5 turnouts that will be controlled with push buttons. Control is toggle-style: each button push causes the turnout to toggle between positions. Turnouts are run by micro servos. The control panel will have a layout map with turnout push buttons and LED position indicators.

First Decisions

The UNO is the first board many of us encounter and is certainly up to the task of managing 5 turnouts and a control panel, with capacity to spare. There are other Arduino boards suitable for model railroading use; but the UNO is cost-effective and easy to work with.

That said, the issue you have to contend with eventually is the number of connections required to support all the devices and LEDS that will be attached to the microcontroller.

Arduino boards provide three different types of connections/pins:

  • Digital: digital pins are basic on/off binary connections. In output mode they are either fully on (emitting 5 volts, with a max current of 40 mA) or off. In input mode they read the incoming current as either HIGH (on) or LOW (off). When used as inputs, digital pins may need pull-up or pull-down resistors so that they will function correctly.
  • Digital PWM: some, but not all, digital pins are also capable of PWM – pulse width modulation.  The output of a PWM pin, if not fully on or off, is a series of pulses that cause the output to to on a percentage of the time.  The pulses are used to control servos and other PWM devices. PWM with LEDS lets you vary their brightness between 0 and 100%, supporting a variety of interesting lighting effects.
  • Analog: Analog pins are primarily used to read sensors that produce a variable output. Pin inputs are fed to the on-board ADC (analog-to-digital converter) for conversion to a number between 0 and 1024. Current and temperature sensors are example of analog devices read through analog pins / ADC. What you may not know about analog pins is that they can also be used as basic digital pins.

It is essential in early planning to determine all the devices to be connected to the microcontroller and the type of connection each requires to determine what connection issues you will need to resolve. In some cases, going to the UNO’s bigger cousin, the MEGA, will solve connection limits.  But even the MEGA has limits. In some cases it makes sense to use pin-multiplying techniques using external chips to drive banks of LEDS, servos or other devices, even when you otherwise have enough pins.

A Connection Plan

The UNO has 14 digital connections, numbered 0 to 13, of which 6 (pins 3, 5, 6, 9, 10, and 11 ) are PWM. It also has 6 analog connections that can be used as digital connections with digitalRead() and digitalWrite() when referenced in the sketch as A0 through A5. That is a grand total of 20 digital pins, of which 6 are PWM.

Of those, two pins are generally off limits on an UNO: digital pins 0 and 1. They are Serial RX and TX respectively, and should be avoided for other uses on any UNO where you expect to use the USB interface — that would be most of the time. On boards without the built-in USB, pins 0 and 1 are fair game.

For five servos we need five digital pins. Even though PWM is used to control servos, the Arduino servo library creates the necessary pulses on any digital pin. However, using the library disables PWM functionality on pins 9 & 10, so some of the UNO’s native PWM capacity is sacrificed in any case.

For the five turnout control buttons we need five basic digital pins. For the control panel indicators, assuming one LED for each leg of each turnout, we need 10 basic digital pins.

That means we need 20 connections; but with pins 0 & 1 reserved for the USB interface, we’re short 2 connections. Many would want to use bi-color red/green LEDS so the state of each leg is continuously shown. That would require 10 additional basic digital connections.

Need Connections? No Problem!

That’s OK. Its exactly what I expected to happen when I started in on this exercise. Both inputs and outputs can be multiplied with external chips and boards; multiplying the basic digital outputs is far and away the easiest to implement, because the circuits are simple and the compiler includes native software support without add-on libraries.

I would use shift registers to control all the control panel indicators. That reduces the connection load on the UNO to just 3 connections for all LED indicators, no matter how many you end up with. With that, and the 10 pins needed to read the buttons and control the servos, the total digital pins requirement is 13. That leaves 5 available pins, one analog and up to three digital PWM, for other uses.

There is a great tutorial on controlling LEDs with shift registers, and chaining multiple registers together, on the Arduino website. That tutorial is mandatory if you are unfamiliar with shift registers; the circuit(s) shown are what you will be using for control panel LED indicators. The balance of this post assumes the basic knowledge contained in that tutorial.

Build A Control Board

Use a shift register chain to run your panel indicators. I use a TI 74HC595 chips that I buy from DigiKey. At less than $.50 each in lots of 10, they are a bargain. $5.00 worth of chips supports 80 outputs. Its the cheapest way I know of to extend the capabilities of an Arduino and run a lot of low current devices.

Decide how many shift registers you need — the 74HC595 has 8 outputs — and create a board based on the tutorial circuits to hold the chips and provide connection points for your LEDS. A single LED for each leg of each turnout (to show which leg is open to traffic) will need 10 connections—use two shift registers (use the two-chip circuit in the tutorial). Add a third chip (after the tutorial you will know how to do that) and your connection count rises to 24, enough to support red/green bi-color LEDS on each turnout leg on the panel. With 4 connections left, who knows what else you might light up?

Each push button will need a 10kΩ pull-down resistor connecting its pin to ground.  The purpose of the pull-down resistor is to drain stray current and keep the pin LOW unless the button is pushed and full current flow is applied.  See the diagram below. The resistor should be placed as close to the pin as possible.

Servo Control by Button

Basic Servo Control by Button

Power Issues

While you can run one or two servos off the power supplied by the UNO’s +5 volt pin, more servos than that would exceed the board’s power handling capabilities. Accordingly, you will need to supply power to the servos from a separate power source. VERY IMPORTANT: the ground for the servo power source must be tied to UNO ground or the servos will not work correctly.

One Sketch To Run it All

Alright. The control panel is built and wired; the servos are installed (see this post for my latest methods) and connected to power and the UNO. What you need now is a sketch to run the control panel and the servos.

Here is a demonstration sketch to get you started:

//////////////////////////////////////////
//
// Small Layout turnout control
// Demonstration Sketch
//
//////////////////////////////////////////

#include <Servo.h> // include the Servo library

////////////////////////////////////////
//
// Definitions
//
////////////////////////////////////////

////////////////////////////////////////
// Basic parameters; adjust for your actual setup
#define NUMBER_OF_TURNOUTS 5
#define NUMBER_OF_SHIFT_REGISTERS 3
#define STEP_DELAY 70  // servo movement step delay, in milliseconds
///////////////////////////////////////

///////////////////////////////////////
// Data Structures
///////////////////////////////////////

//////////////////////////////////////
// TURNOUT_DEF holds all configuration
// information about turnouts and panel LEDS
//////////////////////////////////////
typedef struct TURNOUT_DEF {
  uint8_t button_pin; // Digital or analog pin for the button associated with this turnout
  uint8_t servo_pin; // Digital pin for the servo associated with this turnout
  int pos_main; // servo position for the MAIN leg, in degrees
  int pos_div; // servo position for the DIVERGENT leg, in degrees
  int panel_LED_main_green; // The position(s)of panel LEDS in the shift register chain
  int panel_LED_main_red; // Example assumes a bi-color (red/green) LED for each turnout leg
  int panel_LED_div_green; // modify these elements to reflect the actual LEDS you are using
  int panel_LED_div_red;
};

/////////////////////////////////////
// TURNOUT_DATA is wrapper structure holding
// both configuration and runtime data for turnout operation
/////////////////////////////////////
typedef struct TURNOUT_DATA {
  TURNOUT_DEF data; // configuration
  bool is_moving;
  byte alignment;
  int pos_now;
  int target_pos;
  unsigned long last_move;
};

// Alignment state values
#define ALIGN_NONE 0
#define ALIGN_MAIN  1
#define ALIGN_DIVERGENT 2


// pin ids for shift register chain controlling panel LEDS
#define LATCH_PIN 7
#define CLOCK_PIN 8
#define DATA_PIN 9

//////////////////////////////////////////
//
// Global variables
//
//////////////////////////////////////////

//////////////////////////////////////////
// TURNOUT_DATA Array
// * A0, A1, etc refer to analog pins which are used for buttons in this example
// * Replace pos_main (93) and pos_div (117) with real values for each turnout
// * LEDS are identified by their output position in the shift register chain;
// the identifier is a number between 0 and (NUMBER_OF_SHIFT_REGISTERS * 8) - 1. 
// Example assumes LEDS are connected to shift register outputs sequentially 
// from the first output of first register. You can connect LEDS to any output in
// any order; just set the identifiers accordingly.
//
// Only the TURNOUT_DEF part of the TURNOUT_DATA structure has to be initialized here; 
// The remaining elements are managed internally and are initialized automatically
//////////////////////////////////////////

TURNOUT_DATA turnouts[NUMBER_OF_TURNOUTS] = {
  {{A0, 2, 93, 117, 0, 1, 2, 3}},
  {{A1, 3, 93, 117, 4, 5, 6, 7}},
  {{A2, 4, 93, 117, 8, 9, 10, 11}},
  {{A3, 5, 93, 117, 12, 13, 14, 15}},
  {{A4, 6, 93, 117, 16, 17, 18, 19}}
};

// servo objects
Servo servos[NUMBER_OF_TURNOUTS];

// array to hold shift register state bytes
byte panel_LEDS[NUMBER_OF_SHIFT_REGISTERS];

void setup() 
{
  // Setup pins for shift register chain
  pinMode(LATCH_PIN, OUTPUT);
  pinMode(CLOCK_PIN, OUTPUT);
  pinMode(DATA_PIN, OUTPUT);
    
  // initialize each turnout 
  for(int i = 0; i < NUMBER_OF_TURNOUTS; i++){
    // attach the servo
    servos[i].attach(turnouts[i].data.servo_pin);
    // set the pin mode for the button pin
    pinMode(turnouts[i].data.button_pin, INPUT);
    // test and position the turnout by moving
    // to divergent then to main positions
    servos[i].write(turnouts[i].data.pos_div);
    turnouts[i].pos_now = turnouts[i].data.pos_div;
    setTurnout(i, ALIGN_MAIN);
    }
} // end of setup

void loop() 
{ 
  // get elapsed milliseconds at loop start
  unsigned long currentMillis = millis();

  // loop through the turnouts array
  for(int i = 0; i < NUMBER_OF_TURNOUTS; i++){
    if (turnouts[i].is_moving) {
      // if sufficient time has elapsed since the last move
      if ( (currentMillis - turnouts[i].last_move) >= STEP_DELAY ) {
        // move the turnout one degree
        turnouts[i].last_move = currentMillis;
        if (turnouts[i].pos_now < turnouts[i].target_pos) { // if the new angle is higher
          servos[i].write(++turnouts[i].pos_now);
        } else {  // otherwise the new angle is equal or lower
          if (turnouts[i].pos_now != turnouts[i].target_pos) { // not already at destination
            servos[i].write(--turnouts[i].pos_now);
          }
        }
      }
      // if target position reached, stop turnout motion
      if (turnouts[i].pos_now == turnouts[i].target_pos) {
        turnouts[i].is_moving = false;
        turnouts[i].last_move = 0;
        setIndicators(i);
      }
    } else {
      // if a turnout is NOT in motion, check to see if its button is pressed
      int button_state = digitalRead(turnouts[i].data.button_pin);
      if(button_state == HIGH){
        // toggle position
        if(turnouts[i].alignment == ALIGN_MAIN){
          setTurnout(i, ALIGN_DIVERGENT);
        } else {
          setTurnout(i, ALIGN_MAIN);
        }
      }
    }
  }
}// end of main loop

////////////////////////////////////////////////////////////////
// Supporting Functions
////////////////////////////////////////////////////////////////

void setTurnout(int id, int align){
    // Set indicators to show turnout in motion
    turnouts[id].alignment = ALIGN_NONE;
    setIndicators(id);
    // Set values to trigger motion on next loop iteration
    switch(align){
        case ALIGN_MAIN:
          turnouts[id].is_moving = true;
          turnouts[id].last_move = 0;
          turnouts[id].target_pos = turnouts[id].data.pos_main;
          turnouts[id].alignment = ALIGN_MAIN;
          break;
        case ALIGN_DIVERGENT:
          turnouts[id].is_moving = true;
          turnouts[id].last_move = 0;
          turnouts[id].target_pos = turnouts[id].data.pos_div;
          turnouts[id].alignment = ALIGN_DIVERGENT;
          break;
      }
}

void setIndicators(int id){
  switch(turnouts[id].alignment){
    case ALIGN_NONE: // means the turnout is in motion and not aligned
      panelWrite(turnouts[id].data.panel_LED_main_red, HIGH);
      panelWrite(turnouts[id].data.panel_LED_main_green, LOW);
      panelWrite(turnouts[id].data.panel_LED_div_red, HIGH);
      panelWrite(turnouts[id].data.panel_LED_div_green, LOW);
      break;
    case ALIGN_MAIN:
      panelWrite(turnouts[id].data.panel_LED_div_green, LOW);
      panelWrite(turnouts[id].data.panel_LED_div_red, HIGH);
      panelWrite(turnouts[id].data.panel_LED_main_green, HIGH);
      panelWrite(turnouts[id].data.panel_LED_main_red, LOW);
      break;
    case ALIGN_DIVERGENT:
      panelWrite(turnouts[id].data.panel_LED_div_green, HIGH);
      panelWrite(turnouts[id].data.panel_LED_div_red, LOW);
      panelWrite(turnouts[id].data.panel_LED_main_green, LOW);
      panelWrite(turnouts[id].data.panel_LED_main_red, HIGH);
      break;
  }
}
/////////////////////////////////////////////////
// Shift Register Functions
/////////////////////////////////////////////////
void panelWrite(int id, byte state) {
  int reg = floor(id / 8);
  int pos = id % 8;
  bitWrite(panel_LEDS[reg], pos, state);
  panelRefresh();
}

void panelRefresh(){
  // Prepare to shift by turning off the output
  digitalWrite(LATCH_PIN, LOW);
  // shift all bits out in MSB (most significant bit first) order
  for(int i = (NUMBER_OF_SHIFT_REGISTERS - 1); i>=0; i--) {
    // shift out the bits
    shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, panel_LEDS[i]);
  }
  // turn on the output to activate
  digitalWrite(LATCH_PIN, HIGH);
}

The sketch compiles into a compact package leaving plenty of memory and resources for additional functionality.

The main loop is built around a simple multitasking model, allowing you to control task timing and balance multiple competing tasks.  In this case, the main benefit of this methodology is control of the movement rate of turnout servos. On my test loop this methodology allows block occupancy detection to work in the background along with signal logic.

UP995 at Signal 34. Dual Searchlight Signals, Scratch Made with BLMA Signal Heads.

UP995 at Signals 3 & 4 on the Test Loop. Dual Searchlight Signals, Scratch Made with BLMA Signal Heads.

Troubleshooting

If you build the circuits accurately, everything should work out of the box (as it were). I am an obsessive tester — so I test things at critical stages as I build them.  Build and test your shift register circuits on a breadboard first, before soldering everything to a prototyping board.

To test the sketch I set up a simulation on a breadboard.

To test the sketch for this post I set up a 3 servo simulation on a breadboard.

Getting the connections to the UNO correct is key. If the LEDs don’t light at all, check all three connections, plus power connections; LEDS are polarized, so make sure the anodes are connected to incoming power and the cathodes to ground. Tracing power flow with a multi-tester should help you find problem areas quickly.

If your LEDs light but alternately flash odd/even, you probably reversed the LATCH_PIN and CLOCK_PIN connections.

For 3 or more servos, you must have an independent power supply to power them. BE SURE TO CONNECT GROUND FROM THE SERVO POWER SUPPLY TO ARDUINO GROUND.

Do Something with Unused Outputs

Old style hard wiring, without the help of a microcontroller, is a messy business at best, which tends to limit what you can do. DCC can help bridge the gap, but layout control is something of an afterthought for DCC (it was designed for locomotive control only) and is, frankly, awkward to use (my opinion; your mileage may vary).

To get the kind of functionality we have here without Arduinos — turnout control with a synchronous control panel — it would have to be hard wired. Or you could connect a full computer and run JMRI; that would require DCC (plus stationary decoders for the turnouts and a USB->DCC interface) to work . You would have to use stall-motor type turnout motors or add microcontrollers (Peco now sells a “smart” turnout system using servos and custom controllers) to interface with servo motors. So if you want to use servos instead of stall-motors, you can go Peco or do it the Arduino way from the start. As much as I appreciate Peco’s efforts here, the openness of the Arduino platform is a big part of what makes it useful and cost-effective.

Adding another function to a small layout — lets say a signal to protect a turnout — is a matter of connecting the signal leads to unused outlets and writing some code to run it.  If you’ve gotten this far, you’ll spend far more time thinking about exactly how the signal should run in conjunction with the turnout it is protecting, than you will connecting the device and adding code to the sketch.  Once you get into this way to doing things, I guarantee you’ll never look back.

So what will it be? Signals?  A fire simulation (using PWM and LEDS)? A lighted structure? Let your imagination run wild!


UPDATE

I starting working with shift registers a while back.  They are so effective my habit is to always use shift registers with LEDs, such as for signals, structure lighting and control panel applications.  The habit is so ingrained that I forget to mention the other important reason for using them: power management.

The power handling capability of an UNO is limited to 40 mA per pin and 400 mA for the entire board. LEDs typically draw between 20 and 30 mA.  So if you are directly powering 20 LEDs from an UNO, you are exceeding its power handling capacity and will burn out the board.

In the example given in the post, no more than half the LEDs well be lit at any one time so we are unlikely to exceed the 400 mA limit overall. A few more lit LEDS, though, would put it over the top.  Shift registers duck the problem altogether because each register is powered—and supplies power to connected devices—independently.  Other than the total load on your power supply, adding devices/lights to shift registers or even adding additional registers, puts no significant power load on the UNO.

Above I mentioned that an independent power supply is needed to run the servos.  From a “best practices” perspective, one should always power external devices with an independent power supply. Arduino’s current handling limits are tight; always using external power supplies avoids that problem.


UPDATE

Several readers asked if I have a fritzing image of the 3 servo demo.  I did not, but I put one together for those who might find this helpful.

3 Servo Demo

This circuit is intended to work with the above sketch, with the turnouts variable shortened to 3 elements instead of 5:

TURNOUT_DATA turnouts[NUMBER_OF_TURNOUTS] = {
  {{A0, 2, 93, 117, 0, 1, 2, 3}},
  {{A1, 3, 93, 117, 4, 5, 6, 7}},
  {{A2, 4, 93, 117, 8, 9, 10, 11}}
};

Always cross check all connections on a circuit like this against appropriate data sheets before powering it up for the first time! Be sure to connect the ground of your Arduino to the ground of your external power supply.

Wiring the L&NC — Adding Servos

This it the second installment in a series (Part 1) about the build out of Module 1, lower level of the L&NC. This series covers all the basic steps I’m following to install all wiring, electronics and mechanical objects throughout the layout, so in subsequent phases of this project I can focus on the unique aspects of other modules. Step 1 was to install the basic wiring trunks and connection points, create track power distribution nodes then connect track feeders to the nodes.

Step 2

I tested the track with one of my most challenging locomotives—a Broadway Limited EMD E8A DCC with Sound. I say “challenging” because it has two 3-axle trucks, a long wheelbase and no big capacitors to buffer track power, making it susceptible to derailment or operational problems with faulty track.  If this loco can run a stretch of track problem-free, it’s good track!  Naturally I found and fixed a few (cough …. ) places where there were problems.

Correcting track problems for flawless running.

Correcting track problems for flawless running.

After tinkering with the problem zones, I realized that the “course of least resistance” was to rip out and re-lay a few short strips of track. The caulk adhesive track laying method makes this a piece of cake: after cutting the rails, run a long bladed knife under the track section you want to remove and its free in seconds. The ease of fixes really adds incentive to be fussy at this stage and get it right. I had everything in good order in a couple of hours including drying time for fresh caulk adhesive.

Step 3

The next step is to mount the servos running the 9 turnouts on this level. Installing them now is the best way to ensure they have the space they need for normal operation and maintenance.

test loop servo 1 in place

Servo mount on the Test Loop.

I’ve previously done a basic demo of the mounting method I used on the Test Loop. I chose that particular mounting method because it simplified the connection between the servo and the rod connected to the turnout; the rod fits easily but snugly through the hole in the horn. In this mounting method the base plate of the mount provides the fulcrum or pivot point for the rod.

Turnout operation on the Test Loop continues to be 100% reliable. The only issue with that mounting method is that noise is transmitted to the layout through the mount, so servo operation is noisier than it should be.

A New Low Noise, Low Profile Servo Mount

In addition to noise control, the equipment space beneath the layout level is about 1 3/4 deep, the width of a 1″ x 2″ frame member. For both protection and aesthetics, I need all equipment to fit inside that space. The old servo mounting method requires more space than that, and would stick out below the edge of the frame.

The solution is to mount the servo on its side, allowing the horn to rock a rod back and forth setting the turnout points. Several obvious ways to do that came to mind.  But I also wanted to make sure that alignment of the servo is easy and foolproof.

Layout Prep

I drilled holes for the turnout rods when I laid the track. To make installation and alignment of the servo easy, I  drilled the holes so that the rod would be in the 90 degree position (perpendicular to the plywood base) with the points aligned one direction or the other. I tried to keep the holes through the plywood small to serve as fulcrums  (mostly succeeded), then widened the holes in the foam and roadbed beneath the track so the rod can swing between the two positions of the points.

I inserted a 3″ rod cut from 1/16″ music wire (you need a hard wire cutter for this stuff) and made sure the positioning of the rod was correct. The advantage of the music wire is that it can flex without deforming, allowing you to apply pressure to the points.

Fulcrum pad for turnout 5

Fulcrum pad for turnout 5

That said, 1/16″ music wire I’m using is fairly stiff in the short lengths needed here. It is stiffer than the wire typically use with stall motor turnouts, stiff enough that it easily overcomes resistance from the built in springs in the Peco turnouts I’m using on this layout. Many people recommend removing the positioning springs in Peco and similar turnouts, since they can cause turnout movement to pause while overcoming resistance of the spring. Using 1/16″ music wire the servo is able to move a sprung turnout smoothly. I took a few springs out before I realized it was completely unnecessary.

 

At this point I made sure the rods could move the points properly.  In a few cases, the fulcrum hole was a little too large because of sloppy drilling; the easy solution is to fit a plywood plate with a fulcrum hole in the right diameter over the old one.

Servo Prep

Preparing the servo requires testing and setting it to the 90 degree position. Then with the case on its side, orient the output shaft to either the right or left (which ever you need for a given situation) and install a standard single arm horn pointing up, perpendicular to the case.

The offset shaft allows you to select the right orientation. In either case, 0 degrees is 1/4 turn to the right of center, 180 degrees is 1/4 turn left of center.

The offset shaft allows you to select the right orientation. In either case, 0 degrees is 1/4 turn to the right of center, 180 degrees is 1/4 turn left of center.

Here’s a sketch to test the servo by running it from 0 to 180 degrees (the travel of a typical micro servo), then to the required mid-point position:

#include <Servo.h> 
 
Servo myservo;  // global servo object
int midpoint = 90;  // in degrees
int pin = 6; // control pin

void setup() 
{ 
  int i;
  myservo.attach(pin);
  myservo.write(0);
  delay(1000);
  for(i = 1; i <= 180; i++){
    myservo.write(i);
    delay(50);
    }
  delay(1000);
  for(i = 180; i > midpoint; i--){
    myservo.write(i);
    delay(50);
    }
  delay(1000);
  myservo.write(midpoint);
} 
 
void loop() 
{ 
  
}

Mr. Hot Glue Strikes Again

If only micro servos came with side mounting tabs instead of just the ones on top. They do not. To do a side mount like I’m doing you need only fabricate two parts: 1) a strip of .080″ styrene, cut to about 2″ x .5″ and predrilled with holes at each end to accommodate mounting screws; and 2) a piece of 1/32″ brass wire with a loop (a little over 1/16″ inside diameter), a short straight section (about equal to the thickness of a servo horn) leading to a 90 degree bend and a longer straight section.

These two parts allow you to side mount a micro servo, and connect its horn to a rod.

These two parts allow you to side mount a micro servo, and connect its horn to a rod.

First I remove any labels on the side of the servo that attaches to the mount, then I put a dab of hot glue on the servo and press the styrene strip against it, centering and aligning the strip with the built in fins. Then I put a bead of hot glue down each side of the servo where it joins the mounting strip. Its probably overkill, but I want the servos mounted solidly and resistant to torsional stress.

Micro servo glued to a side mounting strip.

Micro servo glued to a side mounting strip.

The brass wire is threaded through the top hole of the horn, with the long leg aligned along the length of the back side of the horn and the loop parallel to the base. Apply dabs of hot glue to adhere the wire to the horn.

Here you can see how the brass wire is glued to the horn, and the turnout rod is threaded through the loop.

Here you can see how the brass wire is threaded through the top hole glued to the horn, and the turnout rod is threaded through the loop. Note the clearance between the rod and the horn.

Installation

Here a servo has been aligned to the motion of the rod, marked on the plywood.

Here a servo has been aligned to the motion of the rod, marked on the plywood.

First it is necessary to determine the plane along which each rod moves; that will depend on the angle of the turnout relative to the rest of the layout.

With the plane of motion marked and the rod set to its 90 degree position, I slip the rod through the loop glued to the horn and place the servo next to the rod, parallel to the plane of the rod. Placing just a little tension on the rod and maintaining even clearance between the horn and rod, I mark and drill mounting holes for the servo. Sometimes its easiest to do one mounting hole, attach the servo at that hole then—after adjusting positioning—drilling the second hole and completing the mount.

After a test fitting, I remove the servo and apply a strip of 3/4″ Rubber Splicing Electrical Tape (Scotch #2242) to the bottom of the mount to inhibit noise transmission. I remount the servo in its final position.

Servos 1, 2 and 9 mount in their final positions.

Servos 1, 2 and 9 in their final positions.

Problems at Turnout 4

The location for turnout 4's servo.

The location for turnout 4’s servo.

Turnout 4’s rod comes down at an awkward spot, close to a frame cross member, the edge of the layout, the main wiring bundle and three feeder sets. The feeders are the main problem; I should have located them further from the turnout. While moving the feeders is an option, I also realized that the fulcrum hole was too large so I was going to have to put in a new fulcrum plate anyway.

The solution I came up with was to fabricate a mounting plate from a couple of pieces of scrap plywood, that would provide a new fulcrum and cantilever over the feeders. Everything screws down so that it is removable and repairable.

Mounting solution for Turnout 4.

Mounting solution for Turnout 4.

 

Turnout 4 Servo Mounted. The horn swings UP in this photo, so the wire bundle below the servo does not interfere.

Turnout 4 Servo Mounted. The horn swings UP to change the position of the points (as oriented in this photo), so the wire bundle below the servo does not interfere. Its snug but effective.

Gathering Servo Positioning Data

At this point it makes sense to test each servo and determine the positions for each point setting.  Each servo installation is different so each one will have unique settings for turnout positions. The size or “looseness” of the fulcrum hole and the length of the rod are the main factors affect servo positioning

On this module and level it takes approximately 20 – 30 degrees movement of the servo to change the points. Once I determined that, it was easy to calculate initial positions that could then be fine tuned for individual installations.

I'm using CadRail's layers to record information. Here I've recorded feeder positions (in red) and turnout servo positioning data.

I’m using CadRail’s layers to record information. Here I’ve recorded feeder positions (in red; turntable area not yet built) and turnout servo positioning data (green). The two positions are “S”, straight or Mainline; and “D”, divergent.

The goal is to have the points firmly pressed against the rails at each end of their travel, without making the servo work so hard it gets noisy. A light hum while the servo is holding a position is OK; but it should not become a loud buzz and the servo should not feel “buzzy” to the touch. Try moving the turnout manually – you should get resistance to moving the points against the servo, but the flex of the music wire should still be evident. Tinker with this for a while and you’ll start to get a feel for it.

Next step is a big one: install the turntable mechanism, install the Roundhouse base, lay track, and so on. Until then, happy railroading!

 

 

 

Look Mom, No Nails!

I decided to try a track laying method that has been shown a few times in Model Railroader Magazine and elsewhere: adhering track to the roadbed with caulk. I hate nailing track. At HO its doable, but at N I find it very difficult. So I really wanted the caulk to work.

ALEXI evaluated several products at the store before settling on DAP ALEX Painters Acrylic Latex Caulk. ALEX fills the bill because it is designed to adhere to a range of building materials, including impermeable plastics and vinyl. Easy cleanup is a nice bonus.

To my delight it works well as a track adhesive. Initial ‘grab’ is great, but you can move things around a bit while it is fresh; using thin layers, all that is necessary to solidly adhere track to roadbed, you get about 5 minutes working time.  I used about 20% of a tube for all the track on the test loop.

I’m finding quilter’s T-Pins incredibly useful for laying both cork roadbed and track. I bought two sizes, 1 1/4″ and 1 3/4″, at Michael’s. (Woodland Scenics markets a version of these as 2″ Foam Nails). The 1 1/4’s are perfect for holding N scale track down which the caulk is setting–they fit through the nail holes in the Atlas N sectional track I’m using for the test loop. Push them down until the head rests on the tie and the track will be secure. Remove them after the caulk sets. The bigger ones worked by inserting them between ties and using the head to hold the track down. Either way, T-Pins are a great help; the smaller ones at Michael’s seem just the right size for working in N scale.

While the test loop is mostly old Atlas sectional track, I did use a piece of Peco code 80 flextrack from my ample supply to do the spur. This turned out to be a little more challenging because the Peco flextrack I have (bought quite a while ago) does not have nail holes in the ties. The key to putting the 90 deg, 9 3/4″ radius bend into the track was in the deployment of pins: mostly along the outside rail to hold the bend, with a few pins between ties along the inside rail to hold the track down, while the caulk set.

In my arid climate the caulk sets sufficiently within 1 hour to allow removal of the pins.

While you want to keep the caulk layer thin to avoid goo getting above the ties, there is such a thing as too thin–adhesion will fail as it dries if there was not enough caulk. If you can see through the caulk layer, it’s too thin.

This caulk layer is too thin.

This caulk layer is too thin.

I had to go back and correct a couple of spots where there was insufficient adhesive. When you get the amount right it works perfectly.

Just right.

Just right.

Without really thinking about it I selected white caulk at the store. There is some possibility white caulk would show through ballast; another color might be a better idea. The product is paintable, so a thin wash could be used to disguise the caulk after it has dried.

I kept the caulk well away from the moving parts of the turnout — an area it might show through anyway if ballast coverage is thin for operational reasons. As to the test loop, I’m not going to ballast it for the time being.

Test Loop ready to go for DC operation.

Test Loop ready to go for DC operation.

I created 4 electrical blocks, using some ugly orange Atlas insulating joiners where needed. Fine for the test loop, but not the way I’ll do it on the layout. I soldered all the track at the metal joiners along with one feeder set for each block. One wouldn’t normally do multiple blocks on something like this, but it’s a test bed, right?

Mikado first run on the test loop.

Union Pacific USRA Heavy Mikado

First test with a real loco was a success with no serious problem spots!

I have to say the test loop is some of the smoothest track I’ve ever laid. I won’t call it perfect, but the improvement from prior efforts is quite apparent. I  have to give credit to the materials, and particularly to the caulk adhesive track laying method. I’m pretty sure now that reliance on nails to hold track down in the past was the root of a lot of track problems.  With the caulk method it is easy to avoid the subtle distortions of track from the laying process that are hard to find and fix.

test loop servo 1 in place

Tower Pro Micro Servo 9g, with a brass rod attached to the turnout.

An off-the-shelf micro servo (about $5) controls the Peco short turnout.  How does that work?  That is the subject for another post.