Flashing Ditch Lights

Revised 11-26-11

Click here for a detailed article on how these lights work.

Video in MP4 format / AVI format  (note: the AVI is MUCH larger)

This circuit utilizes a microprocessor to simulate the unusual behavior of ditch lights that are installed on some railroads' engines.  To make engines more visible than they would be with ditch lights that stay on steadily, one light brightens as the other dims.  This is not the instantaneous change that would be created if one bulb was turned on as the other was turned off but a gradual dimming / brightening that can be adjusted by a potentiometer on the board.

Click here for a modified schematic that allows for BRIGHT incandescent (halogen) lamps rather than LEDs
 

Click here for photos of the completed unit and more details about its operation.

There are two different circuit boards that are used to give different options with the ditch lights.  Each board & schematic is shown below along with programming and connection options specific to it.

 

This version of the board can be used in several ways:
  • 7 to 24 volts DC are supplied to the positive and negative terminals labeled "dc power - +.  This unit is not designed to operate directly from track power as there is no bridge rectifier.  It can easily be powered by a 9 volt or similar battery, by on-board battery power or by tapping into a constant polarity DC voltage that can be found on many engine's circuit boards.
  • The simplest program for this board has the two LEDs flashing at a rate determined by the potentiometer that is installed at the locations labeled "pot 10 K"
  • It can also be programmed to begin flashing only when a switch closure, connected through the 4n25 optoisolator.  This is usually supplied by a sound card so that the lights flash when a horn or bell sounds.  It could also be triggered by a reed switch mounted under the engine that is closed as it passes over track mounted magnets

The version of the board shown below can also be used in several ways:
  • 7 to 24 volts DC are supplied to the positive and negative terminals labeled "dc power - +. 
  • In addition this unit is designed to operate directly from track power when power is applied to the two pins labeled "TRACK".  Since the power is routed through a bridge rectifier polarity does not matter.
  • No matter how power is supplied, the simplest program for this board has the two LEDs flashing at a rate determined by the potentiometer that is installed at the locations labeled "pot 10 K"
  • It can also be programmed to flash at a rate that is determined by the track voltage.  When the voltage to the motor is low the lights flash rapidly.  As the voltage, and engine speed, increases the lights flash more slowly until they stop flashing and stay steadily on when full speed is reached.  The point where the light stop flashing is set by the potentiometer at the location labeled "pot 10 K"

 

The video below shows  the ditch lights circuit on a smaller, surface mount, circuit board.  The board is based on a board used on the Bike Blinker Plus.

Right click the box below and select PLAY
or click here

 
The blue wires go to a normally open switch.  When the switch is open the two LEDs are on and do not flash.  When the switch is closed the lights go into ditch light mode flashing about once per second. 

The power pins are on the left.  The pin by the edge is negative and one marked "+" is positive.  The LEDs connect via the pins on the right.  The pins can be shortened if needed.

This board has the power plug  inserted.  The red wire is positive and the black is negative.  Proper polarity MUST be observed and no more than 5 volts can be used or the unit will be damaged.

 

This close-up shows that the polarity on the LED connections is reversed on the two sets of pins.  On the outer set of pins the positive is towards the top and on the inner set the positive is towards the bottom.

Two 100 ohm surface mount resistors have been installed on the board in the lower right corner.  If the LEDs are too dim these resistors can be replaced by smaller value resistors or jumpered completely.

In the bottom right are two Mosfets - the one on the left (marked with a "z") is a n-channel and the one on the right (marked "L") is a p-channel

The wiring on the back of the board has been modified to accommodate the ditch light function.  Two traces have been cut (under "tra" in trainelectronics.com. and to the left a few mm from the "B" in Bike Blinker.  The orange wire supplies + voltage and the black ground.

The revised schematic for this version is below.

 
Common Anode Modification
The modification shown here allows you to power common anode LEDs from one output on the microcontroller.  It is based on a circuit that was developed to power incandescent bulbs.  Note that the schematic shows back-to-back LEDs at the far right, incandescent bulbs and common anode LEDs (D2 and D4) in the lower left - although all three sets of lights could be used at the same time only one is likely to be installed at any one time.

In the next two photos the modification was done with through-hole components, a 2N2222 and several 1k / 1/8 watt resistors.  No traces were cut on the top of the board.  The transistor was installed into holes from an unused component.

Changes were made to the back of the board.  Three 1K resistors are shown.  Several traces have been cut - they are marked with arrows.

Two 1500 ohm (1K will do) were installed.  One is on pin 5 of the 12F683 and one goes between the base and emitter of the 2N2222 in the lower right

The yellow wire from the collector of the 2N2222 goes through a hole and connects to the point shown here.  Another 1500 ohm resistor goes to +5.