Adding Signals to the Test Loop

Tomar Signals

Tomar Signals

With block occupancy detection running on the test loop, it was time  to start experimenting with signals. Automated signaling is an important part of the plan for the L&NC.

Signaling potentially involves a great deal of wiring. It isn’t particularly difficult when done the Arduino way, but it does force you to deal with common capacity issues that come into play whenever you want to control a lot of lights or other kinds of devices.

I think of signals as the simplest form of animation a layout can and should have. Creating a signaling system is a good starting point for developing more complex automation and animation for the layout.

Initially, I bought a couple of Tomar Industries n scale signals to try out something off-the-shelf. These particular ones are nicely made and fully wired with red and green LEDS. A three aspect (red, yellow, green) version is also available.

With two outputs required to power each signal, it became clear that directly powering an entire signal system from a microcontroller would be impractical because there aren’t enough pins to work with. Further, The Tomar signals turned out be wired in the common anode configuration, which had additional implications. Common anode wiring is not unusual in off-the-shelf accessories.

Current Limitations

Arduino boards have design limitations when it comes to powering and controlling external devices. The amount of current an Arduino can source or sink on any one pin is limited to 40 mA, enough to light a couple of LEDS. The ground pins can sink a maximum of 400 mA. Accordingly, an UNO could power a maximum of 10 pins with no more than two 20 mA LEDS on each. The I/O pins cannot handle enough current to run most solenoids, relays or motors.

Common Anode Devices

Common anode devices present further problems because Arduinos are common ground devices. Even through the IO pins can sink current, you can’t switch them into a ground state the way you can switch them into a high voltage state.

Most of us are used to common ground — or common cathode — wiring style to control multiple lights or other electronic objects with a minimum number of wires. There, the positive feeds are isolated from each other so individual devices can be controlled, but they all connect to a common ground.

Common anode wiring is the reverse, where multiple devices share a power feed, but their ground sides are isolated from each other for control. Where resistors are needed to control current, as with LEDS, they are put on the cathode side instead of the anode side.

Extending the Pins

Running signals and other animation to any significant extent requires a strategy to multiply the outputs an Arduino can control in a way that is broadly compatible with available devices. Fortunately, there are readily available components that can significantly extend the I/O and current handling capabilities of an Arduino Board and allow control of common anode devices.

Shift Registers

HC595 Shift Registers (I use the 74HC595 variant) are logic ICs offering a basic way to multiply the digital output pins the Arduino can control. Using just three digital pins, an Arduino can control 8 output pins on the shift register.  Better still multiple shift registers can be serially connected, without any additional connections to the microcontroller, to extend the number of outputs under control to span many shift registers. I’ve previously written about shift registers in the Roundhouse rebuild.

To control a shift register, a byte of memory is needed to represent and manage the state of the register’s 8 pins. Accordingly, the maximum number of outputs you can control in a single chain of shift registers is primarily limited by the amount of memory available for managing them.

Consider, though, that a 100 bytes of memory allows you to control 800 digital outputs using just three Arduino pins. Let that sink in for a minute.

Shift registers are serial input, parallel output devices; the Arduino writes the bits serially, then all connected registers output on all data pins at the same time when the write is finished. Shift register outputs maintain their state–on or off–indefinitely until changed.

Darlington Drivers

Another basic tool is a ULN2803APG Darlington Driver, an IC that can switch higher voltages and higher current than an Arduino or shift register can handle. These are current sinking transistor devices, using NPN Darlington pairs; the addition of internal clamping diodes allow them to handle inductive loads such as relays, solenoids and motor driver applications like running unipolar stepper motors. LEDS and incandescent lights work well in common anode configuration controlled through a darlington driver.

Darlingtons allow a logic system (the microcontroller and attached Shift Registers) to control a set of outputs that are powered independently. So, for example, a 5 volt logic system can switch a 12 volt load (up to 50 volt max).  Very useful, yes? For current up to 500 mA per channel, Darlington Drivers can be a viable alternative to expensive relays.

The Good

An HC595 Shift Register plus a Darlington Driver extends the number of digital outputs a single Arduino board can control, using a common anode wiring solution that can handle virtually any kind of layout animation or control device. Using using Shift Register/Darlington Driver pairs and going to common anode wiring as my standard makes all connection and access methods uniform across a variety of devices.

The Bad and the Ugly

In theory, you just connect the output of the shift register to the corresponding inputs of the darlington driver, connect the darlington outputs to your devices, and you are good to go. Trouble is, the chip designers didn’t get the memo on that! The chips are a little difficult to interconnect: you can’t place the chips side by side and have respective outputs and inputs facing each other in the correct order. In fact, the HC595 connections are arranged a little oddly, requiring at least some connections between it and the darlington to cross over each other no matter what.

My first try was the roundhouse controller board. My problem then was trying to run some low voltage incandescent bulbs from 3.3 volt power. The darlington driver allowed me to do that with the 5 volt shift register.

Roundhouse Controller with an Uno

Roundhouse Controller with an Uno

See all those green jumper wires? That was my first solution to the interconnect problem on a single layer board; it works but it is awkward, bulky and hard to replicate. The additional interface for the addressable LEDS further complicates the board.

For signals on the test loop, I decided to try to shrink the board size, incorporate the necessary resistors (they are on a separate board in the roundhouse) and take a two sided approach using my favorite two sided prototyping boards.

Node Prototype 2

Node Prototype 2

As I was planning to record the block occupancy demo, I decided I needed more signals on the test loop to show the block occupancy system in action. I still had four available outputs on the board running the two Tomar signals– except those could not help me with a signal on the other side of the layout [the signals all have short lengths of thin magnet wire].

The HC595 can connect to another shift register serially, but I had not provisioned that on the boards built so far. It takes three connections to link to the next shift register: the two shared timing lines and the data output from the shift register.

Time to build board #3.

Node Prototype 3

Node Prototype 3

The board works fine. But creating these boards with prototyping materials is painful because of the number of jumpers to route and connections to make. As useful as these were going to be, it was going to take a long time to churn out a lot of them accurately. On the L&NC I expect to be controlling hundreds of lights and other devices around the layout. There had to be a better way.

Duino Nodes, Type A, Version 1

I was using fritzing, my favorite circuit design tool, to work on the circuit design for the next board and it became obvious that what I really needed to do was have a printed circuit board produced to my specs. Since I would need several boards for the test loop alone, and I was only just getting going, a small trial run of boards made sense.

I’m glad I did.  Here is the first version of what I call a Type A Duino Node.

Duino Node Type A

Duino Node Type A

These are double sided pc boards, pre-drilled and ready for components, with copper ground fill on both sides for emf control. It takes about 10 minutes to assemble a board for use. The prototypes took over an hour each to build, so the practical time savings for the dozens I’ll need on the L&NC is substantial.

They are 88 mm x 52mm; about 30% bigger than the smallest prototype I built. There are a couple of reasons for that: first, the board has Arduino-style mounting holes arranged to facilitate board stacking. Second, since these boards will run lights and other devices with varying current limits. generous space is available to mount an appropriate resistor for each cathode. A jumper can be used if a resistor is not needed, as might be the case when running a relay, motor or solenoid through a position.

On the right side are three control connectors: power, serial in and and serial out. When stacked, only short three wire jumpers are needed to chain from one board to the next. A terminal block is mounted on the opposite, output side of the board. There are nine positions: the common anode (power) plus eight switchable cathodes.

Deployment

There are four boards deployed on the test loop. One is dedicated to the two Tomar signals above.

Another board runs the dual signals below. The top searchlight is three aspect (red, yellow, green) and the bottom is two aspect (red, green), requiring a total of 5 outputs.

Dual Searchlight Signals, Scratch Made with BLMA Signal Heads.

Dual Searchlight Signals, Scratch Made with BLMA Signal Heads.

The last two Duino Nodes are used together for the station / signal complex.

The Station, and Signal #5

The Station, and Signal #5

The signal is three aspect (red, green, yellow). The station has a total of 8 individually switchable LEDS for internal lighting.  You may notice that the two sections of the depot have distinctly different lighting: the passenger station side has warmer, incandescent lighting (achieved with a mix of led colors); and the freight side has a cooler fluorescent lighting style (cool white LEDS).

One node is for the station signal that connects via four strands of magnet wire.

Duino Node controlling Station Signal

Duino Node controlling Station Signal

The second node mounts on top of the first, and it controls the Station internal lighting. The bottom node receives the incoming serial connection from elsewhere; then a cable connects the bottom serial out with the top serial in. There is no limit to the number of boards that can be chained and/or stacked together.

The Duino node for station lighting is stacked on top another node that runs the signal.

The Duino node for station lighting is stacked on top another node that runs the signal.

Here is a view of the test loop from below with all the Duino nodes in place.

Test loop from below.

Test loop from below.

It may be hard to tell, but the overall effect of using the Duino nodes is to simplify and compartmentalize wiring.

Using the Nodes

The real advantage of this system comes from adopting a uniform addressing system that makes it easy to randomly access and change any element on any node at any time.  I’ll go into that in the next post.


 

12 thoughts on “Adding Signals to the Test Loop”

  1. Hi.
    I am super impressed with your method for detection of dc layouts! Well done. Bow may i ask on how you scratch built the signals? They are just as impressive, the ones with the blm heads. Cheer. Peter NSW Australia

    • Hi Peter,

      Thanks. I’ve never done a blog post on how I build the signals …. you are right, I really should! I just did a few and photographed most of the process, so I’ll do that.

      The short answer, to be fully explained in a post, is this:

      I take an SMD RGY LED [a surface mount, compound LED with Red, Green and Yellow elements] and connect magnet wire (#38) to each of the 4 contact pads. I gently twist the wire bundle at the LED, then dip the assembly into a product called “Gallery Glass” in the “clear” color. This creates an insulating coating over the assembly and stabilizes the wire connections — the connections break easily without this step. Also, when you dip the LED, lightly shake it then let it dry with the LED face down (hanging by the wires)— creates a simple lens that enhances the effects.

      The first ones I did I used 3 individual SMD LEDS instead of a single compound LED (which did not exist back then) — that was painful and subject to a lot trial and error. The compound LED really helps. You can also use an RGB compound LED and synthesize yellow.

      From there I assemble a BLM head, poke a hole in the back where the wire bundle has to emerge, thread the wires and pull the LED into the housing. I fill the cavity with more clear Gallery Glass. I’ve learned the hard way that you have to take multiple steps to stabilize and protect the magnet wire connections.

      At this point the head is completely stable and easy to work with. I’ve made a signal bridge with 5 heads and many pole mounted signals using brass or styrene tube. Just work carefully with the magnet wire to avoid snags and breaks.

      Best, Rob

  2. Rob

    As with many others I have come across your site in 2020 searching for model railroading uses for Arduinos. I am building a test n scale track for industrial switching to test various
    “modern” control systems (DCC++, JMRI, LCC, Open MRN, etc.). I have plans to transfer these to a larger modular rr in the future. I have order the parts for your signal controllers and block occupancy using ACS712 chip and CT sensors to experiment with. Big question is would you share your fritzing file for this PCB board? I am working on trying this out myself, to learn how, but having a go-by to compare to is alwyas helpful.

    I would also like to be part of your beta testing group if possible. I am an earth scientist by trade but have experience with programming and beta testing of software as well as documentation and proof reading.

    Thanks for this excellent series of blog posts.

    Randy

    • Hi Randy,

      Thanks for stopping by!

      Let me see if I can dig up the fritzing file. I’m happy to share it. I’ll email it directly when I find it.

      I will add you to the LCOS Beta group! I’m nearing the end of the Alpha phase (its been painful at times — like everything in 2020) and will be starting in on the next phase within a month. I will be in touch on that soon.

      Rob

  3. Hi Robin,
    Thank you so much for documenting the development of your DC/DCC block sensing system with Arduinos! I am working in Z scale, where there are limited options for DCC, and I stumbled onto your video demos on YouTube while searching for possible DC Automation solutions for a simple model railroad layout using Arduinos or similar. Brilliant!

    In the future, I may do something modular that can be expanded one IKEA tabletop at a time, but for now, my layout concepts are coffee-table-sized. All I really want to do is run multiple trains at once on an automated chasing block system with signals, but the Marklin relays and contact switch tracks are clunky and unreliable.

    I like the idea of your Node boards used to control each signal or lighting device. It seems that is the most elegant solution for signal wiring that you have documented here and I think it would make sense for my layout (which would only be slightly more complex than your test loop).

    Do you have the Node board layout and/or do you have additional copies of your PCB boards to sell? I think someone else may have asked above about the design file – that would be fine, too. I can figure out how to get some custom PCBs made from there, I think

    Also, while I have limited programming experience, I would definitely be willing to beta-test toward this “play and play” solution you are working with to help simplify and understand the process for less-programming-savvy users.

    • Hi Steve,

      Appreciate the compliments! I’ve seen some pretty cool z scale layouts — its pretty amazing what you can do at that scale on or in a coffee table.

      I wear my commercial hat on a different site, Lew’s Duino Gear. I have the duinoNode I/O boards available in assembled and kit forms, with quantity discounts if you buy multiple units.

      You can also find out about LCOS (the Layout Control Operating System) products that are coming soon for a complete layout control solution. I’m at the end of the testing period, but I will offer special discounts for early adopters who reserve before launch [launch is looking like mid-October, but may slip to Nov 1]. If you are interested, let me know: use the contact form on that site or email sales@beaglebay.com

      Best,
      Rob

  4. Follow-up: Do you have a layout wiring diagram for your test loop that you can share? Please point me to a link if I missed in on a previous or following post in this series!

    Thanks!

  5. Hi, one way to reduce wiring and Complexity for lighting and signals is to use ws2812 addressable rgb leds. The just require 5v, gnd, data in and then daisy chain data out to next led etc. Use the fastled library. Only require one output pin from arduino to drive a string of leds.

    • True. However, they are relatively large because each unit is an RGB LED + a control chip. In N scale, they are way to big to use as a direct light source, such as with a signal.

Leave a Reply

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