Villy’s Electronics for Model Railroads



          Pictures served up from my VAX – which isn’t always up:

                   Astronomy, Simh and Aircraft Photos can be found here.

Pictures from the Alberta Railway museum can be found here Train pictures

Pictures from Coalspur and Parkhill Junction in the Alberta Coal Branch


A Franklin Railway Supply Co add from 1932 featuring a TH&B 2-8-4 a colour jpg or b&w tif,  the other side.  A colour tif served up by my virtual vax – which is not always up.


Lighthouse (updated 25 Jun 2007) :  The kids bought me a lighthouse for the garden last year – nice but the light was constantly on.  When the water wrecked the electronics, I built a flashing (with fade in and out) unit with power saving features around an ATMEL microcontroller.  Also a version without the battery save stuff, making it more suitable for a train layout…



$$$ and More $$$.  If you see costs quoted anywhere, it is my estimate of what it will cost you to acquire the parts required from a reasonably priced supplier.  I do all my mail order buying from DigiKey and my local purchasing from Active Components (I live near a major Canadian city).


Coded Infrared car detector

This page contains all of the information that you will need to build the Car Sensor. The software has been updated to reduce the probability of a spike at power up putting it into calibrate mode by mistake


Auto Reverse Controller (aka Shuttle Controller)

This page contains some of the information for the Shuttle Controller  (auto reverse controller).  This project is pretty well ready for prime time.


Lighthouse (updated 25 Jun 2007)

Two versions – a power miser one for battery operation and one this uses a little more power…


Diagram  (jpg)  for using leds to light up my passenger cars – correction to diagram.  Also note – ground symbols do not indicate a connection to the car chassis.  They only indicate the common ground for the lighting system in the car.


Diagram  (jpg) and software for the single led firebox flicker…- note this software currently drives all of PB0 through PB4.  Each pin is driven by a LSF (Linear Feedback Shift Register) with a different maximal length – anywhere from 4 million to 4 billion bits in length.  The assembler version only drives a single port (PB4) with a 4 billion bit sequence/



Ongoing Project – Semaphore Controller

Slow motion controllers for turnouts, semaphores etc, with electronically settable end points that you can build for less than $20.  I am building this to work with the car detector,  a still to be build block occupied controller, rc servos (which are available for less than $10) and a semaphore built from an article by Jim Atkinson

I started this project with a ATtiny45 and after many hours of fiddling trying to get a nice slow and smooth motion on the rc servo, realized that I didn’t have enough IO pins (only 5 usable) on that microcontroller to do everything that I wanted. Part of the problem was that I didn’t want to use filters for the searchlight.  I wanted to use a 2 wire red/green led (which makes a reasonable orange if the polarity is switched fast enough).  The in-the-field calibration would need at least a couple more pins so..

                        -        2 pins for the search light

                        -        1 pin for the servo

                        -        2 pins for the block occupied signals

                        -        2 pins (or maybe more) for the in-field calibration….


I am currently re-writing the code to work with the ATMega88 chip.  This is tremendous overkill (it has 23 usable IO pins), but it was in the parts box.  Once I get it working the way that I want it to and the budget allows, I will migrate it to something a little more reasonable – like an ATtiny24 (14 pins – 11 usable).



Future Projects

Block occupied controller.  Since the car detector can only tell if a car is passing over, something additional is going to be needed to make a block occupancy detector.  The method that detects current drain in a block has a certain appeal (and is the only way that I can think of that should always work) – but the thought of adding resistors to the wheel sets of all of the cars doesn’t.  I haven’t decided how I am going to do it yet, but a thought is to use a modified car detector with two IR Receivers – that will allow me to determine direction.  One of these at each end of the block and a controller to keep track would work – most of the time.  It won’t detect a dropped car for instance and it won’t always identify blocks that are occupied at power up.

Controller for search light type block control signals (driven by the Car Detector – or any other sort of detector that can provide an active low signal)

A very complicated (from a functional perspective) DC throttle with the following features:

Stored configuration data for multiple locomotives (8 sounds like a good number)

Settable min/max throttle & pulse settings for each locomotive (so they all start at the same throttle setting and reach their maximum scale speed at the same throttle setting

Train size setting (variable momentum control)

Air brake functionality – waste you air & you have a runaway – (with an EMERGENCY as distinct from an Emergency brake)

Bar code read out for power setting, speed, air pressure etc.



If you have any questions or ideas, drop me a note at