L&NC Update; Running Lots of Turnouts

Its been a long stretch where there has been too much going on in real life and little time to write about model railroading. But I’ve been working away on the first module of the L&NC and have made lots of progress, so there’s plenty to write about.

This module has nine turnouts, presenting resource management problems that would arise in any substantial yard or staging facility. If you are familiar with the servo library then you know that you are limited to about 10 servos per microcontroller. With that many servos, your microcontroller will have few resources left to do anything else. This post will focus on a solution that problem, expanding the number of servos and other PWM devices a single microcontroller can manage.

Progress Tour

But first, a quick overview of progress to date.

Here’s the module in its current state:

Progress on the 1st Module as of June 2017. Fascia and dressing up of the edges will be the very last step; its pointless to do that while I’m disturbing things with new features and gear. Wires hanging out the pipe at the bottom of the photo are Anderson Powerpole connectors (track and master power) to the upper level.

As you can see I’ve done quite a bit of detailing. I realized early on that I need to complete all the basic scenicking and detailing of the module before moving on to the next. The big reason is having the module alone on a work table gives the best possible access, especially for electronic or animated items that require access to the underside. That’s not to say detailing will not continue after I move on to the next module, but it will mostly be passive rather than active elements.

By the way, if I were to build a room-sized layout, I’d use a modular (some call it “sectional” because you build it in sections) approach to construction even though the layout would not be portable. After laying mainline and other track spanning sections and cutting gaps between sections, I’d pull each section and do most of the remaining work in a work area under optimal conditions. When ready its just a matter of returning the section to its place in the layout and (literally) plugging it in.

Lets take a quick tour of some details so far.

Roundhouse / Turntable

If you’ve read the previous posts about the Roundhouse and the Turntable, you know these have been long term projects.

The turntable rotating beacon comes on whenever the turntable is in motion.

Then stove fire simulation inside the hut is visible through the door. It’s managed by a little PWM code that will the subject of an upcoming post.

The parking lot side of the Roundhouse has been enhanced with Rix power poles and some EZLINE power cables (which comes in two thicknesses and several colors. I use fine, and chose green–old copper–for its visibility). I fabricated a simple power connection and breaker box for the roundhouse out of a piece of styrene and a brass rod, and an EZLINE cable.

A Woodland Scenics light pole casts a pleasant white-yellow light over the parking lot in night mode. Figures, such as the worker (a Woodland Scenics prepainted figure) at the turntable end of the parking lot breath life into a scene.

Having gone to all the trouble to light the Roundhouse, I’ve started populating the space with some appropriate gear and figures.

A view of the lit Roundhouse interior.

Red Bluffs Yard

The Red Bluffs Yard area has its first structure — a fully lit Yard Office — plus a pickup truck with lighting passing by on the adjacent road.

The Red Bluffs Yard Office is fully lit for night operations. The Woodland Scenics light pole works just fine with my Duino Nodes controlled by an Arduino; treat it like any other 20 mA LED. The truck tailights in the background are from LEDS placed in the rear wheel wells, with the light allowed through tiny holes in the fenders.

Its amazing what a couple of SMD LED headlights can do for a really basic pot metal pickup truck kit from Micro Engineering.

The first of three planned scratch built Signal Bridges has been erected to control one of the approaches to the yard interchange.

And, finally, here is the underside, which is rapidly filling with gear supporting the layout above. This module, with its yard, multiple main tracks and turntable is one of the most electronically “dense” parts of the layout plan, to be exceeded only by the city scene planned for the upper level — that is going to be quite a project and I can hardly wait to finish the lower level and get started on the top!.

The underside of this module is rapidly filling with gear. Obviously overhead soldering is not an issue since I can put the module on its side. That said, I rely primarily on screw terminals and crimped fittings for connections.

PWM Drivers for Turnouts and Other Uses

Pulse Width Modulation (PWM) is used to output a timed pulse, where the output is on only part of the time. The width of the pulses — the percentage of time the pulse in the on state — is used to control external devices like servos or to vary the brightness of an LED.

Some, but not all, Arduino digital outputs are hardware PWM capable. Some of the PWM pins are SPI pins and the two serial pins, leaving only 5 or 6 PWM pins available for unrestricted use depending on the board model. If you want to make extensive use of PWM, that just won’t cut it.

PWM can also be synthesized with timed interrupts on any pin, which is how the servo library works and why it does not require you to attach to PWM pins. Unlike hardware PWM pins, PWM synthesized with interrupts represents a hidden load on your board that can affect the performance of your sketch.

External PWM Boards or “Drivers”

External PWM drivers allow  you to greatly expand the number of PWM devices a single Arduino can manage. PWM is used extensively in robotics, so PWM drivers are fairly ubiquitous and inexpensive. Aside from expanding the number of PWM devices you can control, PWM drivers allow you to off-load all of the PWM overhead and timing routines to the external device, freeing your Arduino for other tasks.

I decided to try Adafruit 16-Channel 12-bit PWM/Servo Driver for servo control and a couple of lighting applications on this module. Adafruit also sells a similar device in shield form.

Adafruit 16-Channel 12-bit PWM/Servo Driver, assembled with original terminal block (blue) that did not hold up to use. I eventually soldered leads to the underside of the board.

I chose the independent board rather than the shield because it has a number of advantages, not least of which it is chain-able with up to 61 additional boards, for a total 992 PWM outputs. A single chain of these can handle the servo needs of most club and museum sized layouts! A more modest layout could use these for both turnout servos and all lights and lighting effects, effectively centralizing and simplifying control of all connected devices. It uses the shared I2C interface for fast communication without using any regular pins on your Arduino. For more details, and a tutorial, see the Adafruit product page.

Assembling the board was straight forward, though there are a lot of pins to solder. The terminal block in the center provides independent power for the servo outputs (V+ center pin on outputs) per standard servo wiring; independent power is required by servos because of their substantial current draw. LED’s and other devices that draw their power from the PWM signal itself will not use the independent power.  Be warned: the terminal block Adafruit supplies is poor quality—substitute a better quality part or solder power leads directly to the board. The headers on the sides are for input and output, transferring both data and power to subsequent boards in a chain.

Adafruit 12 bit 16 Channel PWM Driver installed and connected to servos and lighting.

Connecting servos is just a matter of having a male->female servo extension the right size, or combining multiple extensions for longer runs. Any robotics supply store should have an assortment of extensions; as does Amazon. I have three different sizes to work with, which has worked well so far.

On the board positions 0 through 8 (1st 2 banks of four, plus the first pin of bank 3) are attached to the 9 turnout servos. Positions 9 and 10 are for headlights and taillights on the pickup truck. Using PWM I can have the headlights go between low beam and high beam, or have the taillights brighten as if the brakes have been applied. I have some thoughts about an animated animal crossing in front of the truck from time to time….

Using Adafruit’s PWM Driver Software

Adafruit’s software library for this device is available from their GitHub site. Using the software you create an object that you then use to control the board outputs:

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

Creating the Adafruit_PWMServoDriver object without arguments uses the base SPI address to access the board; any different address has to be specified as an argument (and the appropriate jumpers on the board have to be closed). With multiple boards, you create a pwm object for each board using its unique SPI address.

From there, the PWM pulse is set on any output by calling the setPWM() member function:

pwm.setPWM(pin, on, off);

where pin is the board output (a number between 0 and 15), on sets the point in the cycle when the signal goes from low to high (usually 0, the beginning of the cycle, but it can be another value) and 0ff is a number between 0  and 4095 setting the point in the cycle when the signal transitions from high to low.

With the Adafruit driver board you do not use degrees to set a servo’s position. Instead we use timing “tick” values that control the signal transitions from low to high and back. There are 4096 “ticks” (12 bits of resolution) during each cycle. That turns out to be a good thing. For servos, the correct off tick values (assuming the on tick is 0) range from about 150 (the minimum or 0 degree position) to 600 (maximum position, 180 degrees).

Directly setting the cycle through ticks at 12 bits of resolution confers highly granular control and extra smooth servo motion.  Using degrees for position, as the standard servo library does, results in jerkier motion since a degree represents a lower resolution–between 8 and 9 bits–than the 12 bit resolution of the Adafruit board. For LEDS and other lighting, you can vary brightness from off to full on in 4096 steps, allowing fine control of lighting effects.

If you ask me, the smooth motion you can achieve with this board makes its $14.95 price more than worthwhile.

The only difference in your code between working with the standard servo library and the Adafruit driver, is in the object and member function you use to cause the servo to move. Every other aspect of your code and logic should remain the same.

What’s Next?

More coding, and I promise I won’t make you wait long. In the next installment I’m going to introduce you to simplified Object Oriented Programming (OOP) in C++ with the Arduino IDE. I’ll demonstrate a different way to code that, I think, improves several aspects of working with multiple turnouts, and makes the intent and flow of your code easier to understand and maintain. We’ve done it procedurally; we are going to take what we’ve learned and create some OOP code to do the work using either the Adafruit driver or the standard servo driver (Hint: we’ll use a compiler directive to select which driver gets implemented, making the object itself agnostic on the issue and universally usable around the layout).

Until then, happy railroading!

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;
  for(i = 1; i <= 180; i++){
  for(i = 180; i > midpoint; i--){
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.


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!




Wiring Module 1 of L&NC

After a long pause, I’ve starting in on wiring the L&NC by doing the basic wiring on module 1, lower level (each module has two levels). Module one is the largest of the three modules at 54″ long, and is the intended entry point for all the incoming power and control connections. Everything I do here is intended to set the methods and practices for the remaining modules.

Applying Lessons from the Past

Test Loop wiring. Block sensors were added in Phase 2. Phase 3 signals and lighting in progress.

Test Loop wiring. Block sensors were added in Phase 2. Phase 3 signals and lighting in progress.

My early layouts were primitive from a wiring perspective (and other perspectives…. but lets not dwell on that ….). I never did get into the suitcase connector thing, but the old layouts were wired using a single bus pair connecting to feeders every few feet.  Not much to it, so there was not much to organize. Like many layouts, the wiring was somewhat exposed and disorganized underneath.

While I was experimenting on the Test Loop, the wiring was built up in layers without a master plan.  For example, the power distribution from a central barrier strip was fine at first, but later it became necessary to create secondary distribution points to support various power needs. I ended up with wiring  less than optimally organized. On the plus side, I found that small circuit boards with banks of screw terminals are an excellent way to distribute power to to individual feeders or devices.

The other major lesson from the test loop is that it is a pain in the rail to add a major electronic component after everything else has been wired up. Major components should be sited and accounted for before interconnecting anything.  Components that move—e.g., servos, turntable mechanisms or whatever—get priority to ensure they get the placement and space they need — everything else has to adapt to their needs. In this case I will be installing the servos and the turntable early … but I’m getting ahead of myself again.

Special Issues with the L&NC

The L&NC has to be wired with a different aesthetic given that it is intended to be dissembled, moved and reassembled reliably. I am using the Digitrax Empire Builder DCC system, along with my Arduino-based independent control system and a multi-voltage power system supporting the layout — with power provided by a converted computer power supply. Computer power supplies can furnish 300 or more watts of fully regulated power at 12, 5 and 3.3 volts, perfect for every need other than track power.

L&NC Lower Level, Version 2

L&NC Lower Level

The lower level of module 1 (left-most module in the drawing) is fairly complex to wire because it contains the Red Bluffs Yard and the Roundhouse/Turntable complex. Including the feeders needed for the Roundhouse/Turntable area, 24 track feeders with current sensors have to be managed.

Yikes! That’s a lot of feeders for a 54″ x 27″ layout section! Its because of the yard, Roundhouse and turntable. Each roundhouse bay, the turntable bridge and any adjacent track segments adjoining the turntable all need individual feeders; the turntable is a reversing segment. Then each leg of the yard needs feeders, plus the base feeder for the ladder, to support occupancy detection and reliable operation. The main track loops each have two feeders. It all adds up…

So there is a lot more wiring in the L&NC than might be considered normal, and it has to be secure and well organized.

Step 1

With most track laid (I’m deferring the Roundhouse area until the turntable is installed) and the locations of all feeders and turnouts established, the first step is to place the primary distribution nodes then route, terminate and secure the main power bundle, the track bus and the LOCONET bus.

Connection Panel

Connection Panel

At the far left end of the module I placed a connection panel fabricated from styrene. There are four connections:


  1. Main power (4 conductors: 12 volt, 5 volt & 3.3 volt, plus ground);
  2. track power connection (2 conductors: Track A & Track B);
  3. LOCONET RJ12 jack (6 conductors); and
  4. Ethernet RJ45 jack (8 conductors).



My primary color coding scheme:

  • Black = Ground
  • Yellow = 12 volts DC
  • Red = 5 volts DC
  • Blue = 3.3 volts DC
  • Green = Track A (right-hand rail)
  • Violet = Track B (left-hand rail)

For the two power connections, I’m using Anderson Powerpole 15 Amp connectors to create polarized, color coded connectors. 2 connector and 4 connector brackets secure the receiving connection to the panel. I really love these connectors because they are easy to assemble (provided you invest in the crimper), come in a wide variety of colors, allowing you to assemble plugs and matching receptacles that can only be connected together one way. I get my supplies from Powerwerx.com.

Connection Panel, Inside

Connection Panel, Inside

From the panel, the wires run a few inches to a barrier strip.  Here the power is split – one branch going off to feed other parts of this level, with another branch heading to the upper level.

To supply power to the upper level I installed a short piece of PVC pipe from underneath the module, running up next to the corner post, terminating above the bottom edge of the upper level (when installed) I ran wires from the barrier strip up through the pipe, leaving 8″ or so extra cable extending from the top of the pipe, terminated with Powerpole plugs coded for the two power bundles.

Center Barrier Strip

Center Barrier Strip

To get to other areas of the lower level I ran cables from the first barrier, along the edge of the frame, using screw-in eyelets every 6 – 8 inches to channel the cables.  I terminated the cable run at a strip near the middle of the module, then ran an addition  set of cables from the middle strip to the right hand edge of the module.  Leaving 8 inches of slack, I terminated the cables with Powerpole plugs to be connected to a panel on the adjoining module.

The RJ11 jack has leads that I soldered to a six wire cable, then run that cable along the front edge of the module, opposite the power cables, to the location of a Digitrax UP5 universal panel (attached to the frame pending the addition of fascia), terminating the cable with an RJ11 plug as required to attach to theUP5. I fabricated another cable to run from the UP5 to interconnect bundle at the right side of the module.

Track power distribution block with ACS712 current sensors.

Track power distribution block with ACS712 current sensors.

The Ethernet jack on the panel is one end of a prefabricated cable available from Adafruit Industries. The other end will connect to a small Ethernet switch which will install at a later date. From there I’ll  make custom Ethernet cables (my crimper does both 6 and 8 conductor connectors) to fit where needed. Ethernet wiring will be added after I know the location of the Arduinos it will be supporting. I have an 8 port unit ready for the task.

I set up two track power distribution areas with a current sensor for each block, one on each end of the module. At this point I’m keeping the center area clear pending installation of the turntable. A third distribution area will be setup in that area to service the Roundhouse, turntable, service  and approach tracks.

Wiring phase 1

The big picture: wiring step 1 done

Now that the basic wiring is in, its time — finally! — to test the track installation, and fix what ever problems I find before moving on to the next step.  Until then, happy railroading!

Correcting track problems for flawless running.

Correcting track problems for flawless running.


Chasing Electronic Gremlins

I built the test loop for a couple of reasons. First I needed to revive my long unused track laying skills. Second, I needed a place to test and repair locos and rolling stock. Third, and perhaps most importantly, I needed to learn how to deploy Arduinos on a layout in a bullet-proof sort of way, before investing time and money building the main layout.

If you’ve been following along, you know that lighting is one of my big challenges in building the layout in the chosen location. The soffits above the bar are a thin skin of paneling, with little structure supporting it, hiding HVAC duct-work. Standard light fixtures are not possible here.

Addressable RGB LED Strip

Addressable RGB LED Strip

That constraint started a search for a lighting solution that was light enough to affix to the paneling with 3M Command Strips, but would produce enough light to effectively light the layout. When I found strip ALEDS, I knew I’d found a solution. The first two light bars I made are demonstrated here (a simple light show accompanied by a little Debussy):

The bars are easy to create.  Mine are sized at 26″ long; the right size to both light from above and install on the underside of the top level of the layout to light the lower level.

To make them I split 1/2″ PVC pipe on a table saw, then cut the pipe halves to length [TIP: PVC pipe from your home store is dirty stuff. I clean the cut halves with denatured alcohol before final assembly]. I attach 1/2″ reflective Mylar tape to each inside half of the pipe (creating a reflector), leaving a strip of bare PVC down the center of the pipe.  A bead of Liquid Nails for Projects down the middle holds a prepared (with JST 3 wire connectors at each end) 38 LED strip.

My standard RGB LED light bar.

My standard RGB LED light bar.

The demo above shows two bars chained together. You can keep lengthening the array by adding additional bars, at least until you reach the limits of your power supply.

Not So Fast

I have to admit that when I made and tested 4 bars together (152 LEDS), I was  disappointed with the amount of light I was getting. It was good, but just not quite enough.  Two more bars (228 LEDS) ought to do it I thought.

What I got when I expanded the array to 6 bars was a very obvious light intensity drop off (and resulting color change, since these are RGB LEDS) from the beginning to end of the array. Nowhere in the information I’ve assembled about ALEDS has there been any mention of this problem.  I got out the multi-meter and, sure enough, the supply voltage drops steadily as you progress along the strip; and the greater the total number of ALEDS chained together, the more pronounced the effect throughout the strip.

Well, I’m a model railroader and I know all about resistance and current drop off; this is our classic problem of current loss over long runs. The solution? A 16Ga supply bus that injects current every two bars.

Light Controller and Bus Bar

Light Controller and Bus Bar

Head end of the lighting bus bar.

Head end of the lighting bus bar.

A strip of plywood provides the mounting surface for the required capacitor near the first LED, the bus wire (I CA’ d it to the wood) and circuit board fragments with with PCB screw terminals.

The test loop under lights.

The test loop under lights.

Problem solved.

Booting a Loaded Arduino

The basic reliability of the Atmel platform used by Arduino boards is impressive. So when I started seeing boot problems, I was puzzled.  In all cases, the problem occurred on initial power up; rebooting the affected board by hitting the reset button solved the problem.

This was not a good development.

My first three loaded up Arduinos are installed on the Test loop, Lighting Control and the Control Panel.  All three have an Ethernet Shield and are attached to additional devices. All three evidenced cold boot problems in one form or another.

It had to be a power problem.  The additional load from the Ethernet Shield and other devices (although, in most cases I supply power to attached devices separately so they don’t draw from the Arduino’s limited current handling capacity) had to be the issue. One of the confusing things about UNOs is that you can power them from USB at 5 volts DC, or from a separate DC power supply at 7 – 12 volts.

Umm, how much power should I be supplying?

Enercell Power Supply

Enercell Power Supply

In the context of the control panel, where an UNO has an Ethernet shield with multiple digital and analog connections to the touchscreen, I found that I need to supply 12 volts.  At that level the rig is 100% reliable, something I easily established with the help of an adjustable power supply. The trade-off with the control panel, because everything is enclosed, is heat buildup, requiring a fan I didn’t originally plan for.

New deployment rule: the standard power supply for Arduino boards with built-in voltage regulators (primarily UNOs and MEGAs on this project) will be 12 volts DC. Connected devices will run at the standard logic 5 volt level. Smaller Arduino boards without a voltage regulator will get 5 or 3.3 volts DC as required.

Modified Computer Power Supply

Modified Computer Power Supply

I use converted computer power supplies with simultaneous outputs at 3.3, 5 and 12 volts DC, so my layout bus has all three feeds.

It may not seem like it, but that is progress.

Powering Up In Order

Unlike the control panel, the lighting controller did not settle down with a 12 volt supply. There, the Ethernet Shield would go into an initialization loop (attempting to start up and failing, over and over) on power up — but would work fine after a hard reset.

On the test loop, the problem was even subtler: upon cold power up everything appeared normal and the sketch would start to execute…. then freeze at the point where it is supposed to send a broadcast message across the network.

It had to be something about power again that manifests only on a cold start, but what? Faulty Ethernet shields?

Here the clue was a little warning from Adafruit about neopixels (ALED strips): always make sure the power supply to the strip is on before the data connection from the Arduino goes live, or the strip could be damaged.

I always figured that if the Arduino and the ALEDS (and other peripheral sensors and actuators) were powered from the same source and came on simultaneously, Adafruit’s warning would be satisfied.  Since I’ve never had damage to the strip, and I’ve been working with the same strip for some months now, I think technically I was right.  However, it seems that from the Arduino side, simultaneous start up is not necessarily so blessed, especially when attached to an Ethernet shield.

I conducted a simple experiment on the lighting controller:  I unplugged the power from the board/shield combo then powered up the ALEDS before plugging the power into the board.

BAM. Worked perfectly every single time. No confused Ethernet shield; perfect response to commands; no hitting the reset button.

Of course, manually plugging a fleet of embedded Arduino boards was not going to do at all.

Automating Power On Delay

Consulting the Internet Machine, I found a simple power-on delay circuit.  In my first attempt I built it as shown, except for substituting a variable resistor for R2 (on original schematic) to allow some adjustment of the delay.  For the relay, I chose a low power signal type — adequate for the power draw of the Arduino/Shield, but possibly not sufficiently durable for this application. Only long term experience will tell.

Anyway, as built it provides about a 50 – 100 millisecond delay in powering on the board. That turns out to be enough.  With the delay circuit attached, the lighting controller powers up perfectly every time.

I modified the circuit slightly for my second build, including both input and output indication LED’s [ green for input power on, and blue for output power on. ] and increased the size of the capacitor to 100µf. The bigger capacitor gives a little more time range to the delay (as adjusted by R4; if you go out of range either direction on R4, the circuit will not work.) from about 1/10th to 1/2 second. The I/O LEDs really help see the timing of the delay.

Here’s schematic of the board as I’m building it now:

Power-On Delay Circuit Schematic

Power-On Delay Circuit Schematic

Built on one quadrant from an SB4 Snappable Breadboard (these are my go-to, two sided solderable breadboards), the top looks like this:


Power-on Delay Circuit Top

Power-on Delay Circuit Top

And, the bottom:

Power-on Delay Circuit Bottom

Power-on Delay Circuit Bottom

Installed on the test loop and in operation:

Uno, Ethernet Shield and Power-on- Delay board.

Uno, Ethernet Shield and Power-on- Delay board, mounted under the Test Loop.

From here on, power on delays circuits are another standard component for reliable operation, though I think I’m going to double the size of the resistor on the blue led to tamp down its brightness more!.