Happy Independence Day weekend to my US readers. Well its been several months where time for railroading has been limited. Top of the list, our nine-year-old beagle developed serious back/neck problems a few months ago that ultimately required surgery.
Lewis the beagle; 2 weeks after back surgery.
Little fellow is recovering and doing well with his rehabilitation program–exercises given to us by the specialty vet. Things like stairs are going to be a problem for him for a while, so he won’t be joining me in the layout room, as he usually does, in the near future.
Even so, I have some L&NC construction news along with updates on on-going projects.
ACS712 – How Low is Low Current
I’ve been exploring the limits of low current sensing with ACS712 sensors. Sparkfun markets a sensor board combining an ACS712 with an OP Amp that they characterize as a low current sensor. I had no luck calibrating and using that sensor; if someone reading this has used it successfully, please leave a comment explaining how you calibrate and use it. Additional experiments with Op Amps, including creating a fairly stable instrumentation amplifier, have not been encouraging though I haven’t entirely given up and have a few possible circuit designs yet to try.
The fundamental constraint with ACS712 sensors is that their output noise inhibits current sensing below 20 mA (officially, Allegro says that you can’t detect below 20 mA without a specially designed version of the chip; which they will happily work on for a paying customer). At higher currents, the sensor works pretty much as advertised and can be used with or without filtering. At and below 20 mA it is difficult to tell the signal from the noise without some sort of mathematical filter; the RMS method I use can detect down to around 15 mA with an UNO’s 10 bit ADC. With a Mayhew Labs 14 bit ADC, I seem to get a little more sensitivity, around 12 mA, using the RMS algorithm.
Below 12 mA noise takes over, at least so far as short term measurements go. So I’ve been looking at data collected over longer time periods and have a preliminary method that can discern a low current signal down to around 8 mA. In essence, a low current change causes the long term output noise range to shift up or down depending on whether the current is increasing or decreasing. Capturing this range shift should improve practical detection sensitivity considerably. Its promising, but I still have kinks to work out of the system.
Is 1 mA sensitivity—the holy grail for detecting a single 10k resistor wheelset—possible with an off-the-shelf ACS712 sensor? Probably not, and that may matter to people who want to use off-the-shelf 10k resistor wheelsets.
That does not make these inexpensive sensors useless. If you don’t mind making your own resistor wheelsets, then a single 1.5k resistor (assuming one resistor wheelset per car; two wheelsets at 3k—in parallel producing a net 1.5k resistance—one at each end of the car, would be a better idea for a bunch of reasons) will be detectable while still drawing under 1/10 watt (at 11.5 volts DCC n-scale standard; higher voltages allow for more resistance). 100 wheelsets would draw less than one Amp total current. More on that when I get the system operational.
Nevertheless, I’m curious whether a 16 bit ADC will help further resolve the low current signal. I’ll be giving that a try this summer so we will see.
Laying Track-Bed at the Red Bluff Yard.
I finished drawing in the track plan, including some additional yard space, on the lower level modules and started in on laying roadbed and track.
Roughed In Turntable
Roughing in the turntable was fairly straight forward. After preliminary rough siting, I installed the roundhouse base and drew in the track center-lines. That located the turntable center (the intersection of the track center lines), enabling me to cut out an appropriately sized circle to accommodate a pit I’ve already created using a plywood base and styrene strips.
Building the Turntable Pit with Styrene Strips glued to a plywood base.
The turntable project is a major layout item in its own right and will be the subject of multiple future posts.
Laying Track for the Yard
It took a few sessions, but I laid all the lower level track except for the turntable/roundhouse area (which I will do when I install the turntable) and joined it with the helix.
Track-laying on Lower Level Done.
Track Laid and Ready for Painting and Ballast.
For those interested in the nitty-gritty of track laying techniques, I used adhesives rather than mechanical fasteners for all roadbed and track. I use Liquid Nails for projects (water based) to adhere foam to wood, and anything else to foam. For the track I used DAP ALEX clear latex silicone caulk, deploying T-pins to hold the track in position while the caulk cures (just a few hours). What I like most about this method is that once cured the adhesive is completely invisible creating a nice base upon which to detail the track. Now that I’ve used clear caulk for track laying, I can’t imagine using a grey (and definitely not white) product unless the color closely matches the intended ballast color.
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
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):
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.
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
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.
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
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.
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?
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
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
And, the bottom:
Power-on Delay Circuit Bottom
Installed on the test loop and in operation:
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!.
One of the casualties of 15+ years of moving box storage was a Walthers (Heljan) Union City Roundhouse with 6 bays. No longer in the catalog, this was a really nice brick structure with a little extra decorative masonry, as might have been built in a prosperous town in the early 20th century. The “modern” roundhouse models widely available today are more shed-like and (to my mind, anyway) less elegant.
Roundhouse in pieces
The damage could have been a lot worse; mostly it came apart at glue joints. A little breakage, but not much. I originally built this twenty years ago as an exterior model; no interior lighting or details. It was nicely enough colored that it worked well unpainted (though I intended to get to that…. some day). No anti-crazing glue was available in those days, so the windows which look fine on the outside look atrocious on the inside.
The model did not have the common decency to completely disassemble itself, which would have made this much easier, so I had some choices to make. In contrast to the glue joints that failed, the rest were showing no signs of giving up easily.
First and most obvious was whether to rebuild the 6th bay, since most major pieces were intact. For the sake of the space available on the L&NC, cutting back to 5 bays makes sense without diminishing the impact of this model. I could have gone to 4, but the broken frame for the 5th bay door presented a nice weathering opportunity, which we’ll see later.
Secondly, what kind of lighting and how? I was thinking incandescent, and hanging lights would be authentic, so some sort of hanging lamp with an industrial style shade seemed like a good idea. I found both led and incandescent options; I decided to try the incandescent type.
Removing the floor turned out to be the easiest way to open up the model, so I decided to reconstruct the model with a solid top structure that is removable from a separate base. Putting aside the floor, I reassembled the top structure, leaving one roof section off where I planned to route wiring.
Main structure, partly reassembled
That decision, along with the intended orientation on the L&NC, spawned a few other choices. Now, when in operation, the interior will be viewable primarily through the doors and secondarily through the windows and skylights. Since the most open sight line will be through the doors toward the back, I decided to attempt some improvement of interior finish along the back wall.
Painted Interior Window Castings
I pried off the clear styrene, which was as difficult as I would have expected, requiring some grinding and sanding to get rid of stubborn bits holding on to the green window part. Then I painted the window part brick, leaving muntins and a thin window frame green. Having done the back wall I re-evaluated the other sight lines and concluded that removing the glazing elsewhere was probably not worth the trouble (I’ll keep that option open for later).
Light coming through simulated glass.
Since the glazing was gone, I decided to try using Testors Clear Parts Cement & Window Maker to make ‘glass’ in one pair of rear windows. It was easy enough to do if you follow the instructions, and the effect is interesting. I probably used a little too much, but the material seems to have a lens effect in windows this small. This simulates older glass nicely, but does not create a “see-through” window (for purposes of viewing the interior). The way the Roundhouse will be oriented on the L&NC, the back window will face a blocked (by the furnace) area, so you will not be able to directly look through these windows in any case. So I think I will do the rest of the rear windows the same way.
Model paint is notoriously expensive (over $5 per oz, discounted) and, frankly, nothing special beyond formulating specific colors that duplicate prototype colors. In this respect I’m lucky there is no convenient hobby shop here; that has forced me to look to other solutions which, to my delight, are vastly cheaper.
Liquitex BASIC Acrylic Paint (available at all major art/craft store and on Amazon), at $5 per 4 oz tube (cheaper in even larger quantities, or sets) is a good deal. It is available in a wide range of standard artists colors that are easily mixed to create any color you want (just keep track of the formula!). These are formulated for general artist use so they are thicker than standard model paints. I mix small amounts of paint with acrylic thinners to get whatever consistency I want.
My brick color is a simple mix of 50%Red Oxide and 50% Burnt Umber. My color for light colored mortar, masonry, stone and concrete is Titanium White with 5% Yellow and 5% Grey (a 50% Grey) – basically a dab of each into a larger amount of white.
Installing Lights, Round 1
I found some Miniatronics parts, counter-intuitively called “Lamp Shade with Bulb,” that I thought would make good hanging lamps for the interior, so I bought 10 of them from Hobbylink.
Miniatronics ‘Lamp Shade with Bulb”
Here two are mounted in 1/8″ Styrene u-channel that has been painted Floquil Weathered Black (from my limited collection of old paints) to match the interior girders. To size them, I studied the interior clearances relative to locomotives and realized that clearance was limited in the tall section, and non-existent in the shorter fore and aft bay sections.
Hanging Lamps in Bay 1
My feeling at that point was these lamps were not suitable for the short sections, since they would not be visible mounted up against the ceiling. That feeling increased after mounting and lighting the first pair.
Miniatronix Lamp Shade with Lamp – Lit
I guess I should not have expected much from a 1.5 volt 30mA lamp. Still, I’d hoped it would cast more light than that! As a decorative lamp it works fine at N scale – you get little peaks of them if you look in and they seem right. For casting light on the broader scene, even if I doubled up on them, another solution is needed.
I’d already been working with Addressable RGB LED strips as a solution to bringing light to the layout, and it occurred to me that adding ALEDS as a hidden light source would allow me to more fully light up the interior. So that is what I did.
RGB LEDS for General Lighting
The individual pads are cut from a 5 meter strip and wired together with 30 GA wire. As you can see from the picture of the completed interior below, there are 10 of them with addresses 0 to 9.
Soldering Addressable LEDS
To solder the very thin wire to the pads, I taped the leads down and slipped the pads underneath. That was more than stable enough to make the soldering fairly easy. This particular LED is #0, so the left hand leads are heavier (22ga) for incoming power and data (for durability and handling), and the right hand leads out to the rest of the strand.
I fabricated the strand in two halves with 5 LEDS each, soldering leads from the two halves together during installation. Each half strand had to be carefully threaded through the girders. I did break – and repair – a couple of connections the first time I tried. After I got them threaded successfully, I glued the pads down to the styrene roof with dabs of Liquid Nails for Projects (low VOC, foam safe). You can bet I tested the lights before gluing them down!
Completed Roundhouse, from below
The LED wiring is simple and efficient – 1 connection to a digital pin on the Arduino, plus 1 wire each for power and ground. The incandescent lamps were more complicated since I had no intention of giving over 10 pins on the Arduino. Further, turning them on and off individually was not necessary, so I decided to run them in “bay pairs.” Unfortunately, the 60 mA draw of a pair of these is more than you want on an Arduino pin, so that meant some sort of relay or transistor would be necessary to switch the current.
A Shift Register and a Darlington Array
Current isn’t the only problem: there aren’t enough digital pins on an UNO to control everything I have planned. So a pin preservation strategy is called for.
I decided to use a 74HC595 serial-in-parallel-out shift register. One data pin plus two timing pins (total of 3 pins) allow an Arduino to control 8 digital outputs; additional shift registers can be wired in series to extend the total number of outputs available without additional Arduino pins. The parallel output of these chips means that after the Arduino sends instruction bits serially, all the outputs are turned on or off at the same time (parallel output), a useful property for animation and lighting control.
Because of the higher current (and also different voltage) of the lamps, I put a UNL2803 darlington array — a transistor array that can sinkhigh current — between the shift register and the lights. The only downside of a darlington is some current loss.
Both chips are inexpensive, running about $.60 each in small quantities at digikey. Now that I’ve worked with them I’d say they are very useful basic parts for the Arduino enthusiast.
Power Distribution to Lamps
I fabricated a little circuit board for the roundhouse, to join the “bay pairs” together and provide a 1/8 watt resistor for each lamp to be able to run at 3.3v. The darlington array sinks current rather than sourcing it, so the circuit is a common anode (common power) with the resistors and control on the ground side. Works fine. The circuit board was cut from a standard Radio Shack pre-etched PC board, and fits into the wiring space in the back of the Roundhouse.
I fabricated another board–version 1 of what will become a standard, chainable shift register board for layout control (but about half the size of this one) — to be mounted under the roundhouse base, it interconnects the two ICs, taps into layout power, connects to an Arduino and connects to the structure above. The board uses +5v power for logic and LEDs, and +3.3 for distribution to the incandescent lamps.
Roundhouse Controller with an Uno
The roundhouse board has an unused connector that would allow 3 more +3.3v lights to be added. I’ll probably use that capacity for some lighting outside the roundhouse structure when it is mounted on the layout, but I haven’t decided anything yet. That, by they way, is part of the essential elegance of the Arduino way; so long as a connection pin is available, adding more lights or functionality is as easy plugging things in and modifying your software to use them.
Here is a video tour of the project and demonstration Roundhouse lighting!