G-Scale Switch Motor Remote Control
revised September 5, 2008

 

This project utilizes small remote control receivers to operate most common types of switch (turnout) motors including those from AristoCraft and LGB.

The units are portable and can easily be placed next to each switch motor.  A small handheld remote control unit toggles the turnout one way or the other.

Power can come from the track (including DCC), batteries or solar recharged batteries.

When battery powered these units are ideal for ad-hoc club layouts at train shows and other venues.

Introduction

The remote control receivers used in this application are single channel units that have the ability to "learn" the channel (button on the transmitter) that you want them to respond to.

Here is an 8 channel transmitter.

... and a four channel transmitter.

<Photo of 4 channel transmitter next to a quarter>

This is a single channel receiver.  The 8 channel remote can control up to 8 of these units and the four channel can control up to four.

In the photo below, the five pin connector at the bottom connects to +12 volts (right terminal), ground (2nd from right).  The other three terminals give access to the relay's SPDT contacts (NO, NC and Common)

The small white button in the lower left is used for programming the unit so that it responds to a particular button on the transmitter.  The black jumper to its left is for setting momentary or toggle operation.  Leave it in the toggle position for now.

Programming the Receiver

To program the receiver follow these steps:

  1. connect the receiver to a 12 volt power source being careful to observe proper polarity
  2. briefly press the learning button
  3. the learning LED will light
  4. press the button on the transmitter that you wish to have the receiver respond to
  5. the LED will flash briefly and go out
  6. Test the programming by pressing the programmed button on the transmitter again.  You should hear the relay respond to the button press.
  7. Note that the setting of the jumper will determine if the relay latches on or off each time the button is pressed or if it just goes on while the button is pressed releasing when the button is no longer pressed.

Connecting to the Relay

If you look carefully in the lower right corner you can see VCC (+12), GND (ground), NO (normally open), NC (normally closed) and COM (common) labels for the 5 connection spins.

Use With Switch Motors

When I first started experimenting with these remote control receivers I was planning on using them to control the switch motors on my turnouts.  I reasoned that a battery operated remote control unit would be an ideal way to avoid installing hundreds of feet of wire to my widespread turnout motors.  Unfortunately I soon discovered that the stock receivers, shown above, came with a SPDT (Single Pole Double Throw) relay.  Most turnouts, including those from Aristo Craft and LGB, require a DPDT (Single Pole Double Throw) relay to change their position.  (Please see a my article "Turnout Motor Control" for a more detailed discussion of turnout motors and how they operate.)

I first considered removing the SPST relay and replacing it with a DPDT.  This would require desoldering and removing the existing relay and drilling new holes in the circuit board to accommodate the new relay's additional pins.  This certainly could be done but drilling holes in an existing board can lead to broken connections and short circuits, something that it is best to avoid!

An Easy Solution for Aristo Turnout Motors

It soon dawned on me that the simplest solution would be to add a second, SPDT relay to the receiver and wire the two relays together to act as a single DPDT relay. I had a number of relays that were identical to those on the receiver board and simply attached one to the existing relay as shown here.

 

The wiring was very straight forward as shown in the schematic below.   

The two leads to the coil on the 2nd relay are wired directly to the terminals on the existing relay using the yellow wires shown below.  The other connections can be seen in red (the + 12 volt lead), black (ground), white (NO contact) and a direct soldered connection to the NC contact trace on the board.  The other smaller wires (orange, red, blue & black) that can be seen in this photo were for testing and need not be included.

This setup works perfectly with Aristo Craft turnout motors as they automatically turn off the power to their motor once the switch has been thrown.  All we need to do to make this a functional system is to connect 12 volts, from a battery or other source, to the VCC and GND terminals.  The NO and NC contacts go directly to the two power screws on the Aristo turnout motor.  Pressing the transmitter button once turns the switch one way and pressing it again throws it the other.  Note that the mode jumper on the receiver needs to be in the "toggle" position for this to work properly.

LGB Turnout Motors Make Things Tougher!

I also wanted the ability to use this convenient system with my LGB turnout motors.  As you may have figured out, there is a major problem with LGB motors and the unit shown here.  Since the Aristo motors effectively turn the power off once the switch is thrown the unit described can continue to send power to the switch motor and no harm will be done.  That is not the case with the LGB turnout motors which must be removed from power after the switch is thrown.  If power continues to flow to the switch motor it will heat up (sometimes to the point of melting!) and a great deal of power will be wasted.  This would rapidly deplete the batteries that I planned on using.

The solution was to add a third relay that would close for only a short time when the receiver changed the polarity by activating the new DPDT relay.  There are any number of ways to accomplish this and I settled on using a PIC microcontroller.  Some might think this is overkill but using it easily allowed me to add a potentiometer that can be used to adjust the amount of time that power flows to the turnout motor.  (Please note that this is not a PICAXE, but its big brother the PIC 12F683 - programming these chips requires that one purchase a programmer and a software package for programming.  The PICAXE could be used as well)

In this photo you can see the PIC processer (lower right) and the small potentiometer just above it.  I did not create or use a circuit board and just glued the IC socket to the side of the relay.

These photos are from the prototype and will be replaced by clearer, step-by-step pictures.

 

'd. bodnar revised 7-28-08
' Time delay for switch motor control from RC relay
'Note2: GPIO.3 can't be connected to IR sensor while using ICSP
 @ DEVICE  MCLR_OFF
ansel = 0          'all inputs digital
cmcon0 = 7          
INCLUDE "modedefs.bas"
DEFINE ADC_BITS 12
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
ADCON0=0    'analog

Event       VAR gpio.0     'pin 7
Pot1 	    VAR gpio.1     'pin 6
Relay       VAR gpio.2     'pin 5 - use HPWM 2, ...
NotUsed3    VAR gpio.3		'pin 4
NotUsed4    VAR gpio.4		'pin 3
Serial      VAR gpio.5		'pin 2
Temp        VAR WORD
Temp2       VAR WORD
EventFlag   VAR BIT
gpio = %00000011        '1, 2, 3 inputs other outputs
EventFlag=0

Start:
SEROUT Serial,n9600,["Event / Flag = ",#Event, " ",#EventFlag,10,13]
IF Event <> EventFlag THEN
    HIGH Relay
    GOSUB GetPot
    Temp=Temp/10
      SEROUT Serial,n9600,["temp pause = ",#Temp,10,13]
    PAUSE Temp
    LOW Relay
    EventFlag=NOT(EventFlag)
ENDIF    
GOTO Start

GetPot:
  ADCIN 1, Temp          ' PIN 6
  SEROUT Serial,n9600,["  ADCIN 1= ",#Temp, " ",#Event,10,13]
RETURN

 

Yet Another Bicycle Epiphany!

The day after completing and testing the above circuit I was on a fairly long bicycle ride when it occurred to me that I might be able to accomplish the same objective, that of controlling an LGB turnout motor, with only one additional relay, a DPDT, rather than the two SPDTs shown above.

That would make things a little more efficient and a bit easier to wire.  I reasoned that I could change the receiver from 'toggle' mode to 'momentary' mode and use its existing SPDT relay to activate the relay only when the transmitter button was held down.  The new relay, a DPDT, would be used to change the polarity of the DC connection going to the switch motor.

The same PIC processor would be employed to react to the receiver detecting the proper button signal.  Just some minor changes to the wiring and some software modifications would do it!

Notice the "X" in the bottom left area of the receiver board.  That indicated a place on the circuit board were a trace needs to be cut.  It can be seem more clearly in the photos below.  This cut allows the PIC 12F683 to control both the DPDT and the SPDT relays.

You will note that the power to the DPDT relay's coil goes through the NO contacts on the board's relay.  This assures that power only goes to the DPDT when the button on the transmitter is being pressed.  The polarity of the power going through the relay is controlled by the PIC processor through its pin 5. 

Construction

What follows is a series of step-by-step photos that show how the DPDT relay and PIC processer are added to the remote control module.  We will be modifying the original board and soldering wires to it so it is a good idea to test it before beginning. 

Note that the relay that I added is actually a 4PDT.  Since it has 4 poles and I only needed two I wired adjacent sets of connection pins together.

Here is the back of the board before starting.  The first step is to disconnect the on-board relay from the board's microcontroller.  The microcontroller is in the lower right.  The transistor that operates the coil on the relay is marked "Q1" and is at top, just left of center.  We need to cut through the wire, called a trace, that connects pin 2 of the microcontroller with the resistor (R2) just below the transistor.

Notice the cut trace in the center of the circle.  The cut was made with a razor blade, you can also use a Dremel or other cutting tool.  Just make sure to cut completely through the trace.  Once the cut is made test the receiver again.  The relay should not click and the LED should not light.  If it still works properly cut through the trace again.

The new relay is held to the existing relay with a piece of foam tape.  Remember that this relay has twice as many pins in its contact area since it is a 4PDT.

The first wires connect the board to 12 volts DC through the red and black wires.  The diode is across the relay's coil contacts.  The anode end of the diode (with a silver band) goes to what will be the positive connection of the coil.  Note that the lead also connects to the two terminals above it.  The green and white wires will go to the turnout motor.  They cross with the green wire going high and the white going low.

This photo gives a better idea of how they cross over each other without touching.

The negative terminal from the main board goes to the contacts just above the diode.

The transistor that activates the coil on the relay is an NPN, 2N2222.  It just fits between the contacts shown here.  The emitter goes to ground, the collector goes to the coil's negative terminal and the center lead, the base, will go to the PIC microcontroller that we will add next.

The positive wiring goes from the VCC terminal on the main board to the NO terminal (small yellow jumper) then from the COM terminal to the positive lead on the new relay.

This PIC processor is in an 8 pin socket that has its pins bent to the side.  A red wire goes to pin 1 and will supply +5 volts.  A black wire goes to pin 8 for ground.  Three 1/8th watt, 1000 ohm resistors go to pins 3, 5 and 7.  After this wiring is done the socket will be glued to the on-board relay.

The program below couldn't be simpler.  Everything before "Start" is for initialization and pin configuration - the program itself is between "Start" and "GOTO Start".

'd. bodnar revised 7-30-08
'uses DPDT relay to change switch motor polarity
@ DEVICE MCLR_OFF
ansel = 0 'all inputs digital
cmcon0 = 7
Include "modedefs.bas"
define ADC_BITS 12
define ADC_CLOCK 3
define ADC_SAMPLEUS 50
ADCON0=0 'analog

RelaySPDT var gpio.0 'pin 7
Pot1 var gpio.1 'pin 6
RelayDPDT var gpio.2 'pin 5 - use HPWM 2, ...
NotUsed3 var gpio.3 'pin 4
Event var gpio.4 'pin 3
Serial var gpio.5 'pin 2
Temp var word
Temp2 var word

gpio = %00010000 '1, 2, 3 inputs other outputs

Start:
serout Serial,n9600,["Event / Flag = ",#event,10,13]
if event=1 then
    toggle relayDPDT
    high relaySPDT
    WaitTillRelease:
    if event=1 then
        goto WaitTillRelease:
    endif
    pause 300
    low relaySPDT
endif
goto start:
 

Use a Transistor, Save a Relay!

One final revision to the circuit gets it to the same functionality of the circuit just discussed but without a need to add anything more than one SPDT relay and a simple power transistor.  It seems that every time I ride my bike the circuit gets better!

 

 

'd. bodnar revised 9-05-08
'uses DPDT relay to change switch motor polarity
 @ DEVICE  MCLR_OFF
ansel = 0          'all inputs digital
cmcon0 = 7          
INCLUDE "modedefs.bas"
DEFINE ADC_BITS 12
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
ADCON0=0    'analog

RelayDPDT   VAR gpio.0     'pin 7     'drives both relays (board + add-on)
LED 	    VAR gpio.1     'pin 6     'lights when power active
TIP101      VAR gpio.2     'pin 5     'drives TIP 101 power transistor
NotUsed3    VAR gpio.3	   'pin 4     'not used
Event       VAR gpio.4	   'pin 3     'detects button push from transmitter
Serial      VAR gpio.5	   'pin 2     'used for testing only
Temp        VAR WORD
Temp2       VAR WORD
RelayFlag   VAR BIT         'keeps tack of state of relay
RelayFlag=0                 'not in
gpio = %00010000            '4 is input - others are outputs

Start:
SEROUT Serial,n9600,["Event / Flag = ",#Event," ",#RelayFlag,10,13]
IF Event=1 THEN
    RelayFlag=NOT(RelayFlag)
    IF RelayFlag=0 THEN 
        LOW TIP101
        LOW LED
    ELSE
        HIGH TIP101
        HIGH LED
    ENDIF
    HIGH RelayDPDT
    WaitTillRelease:
    IF Event=1 THEN
        GOTO WaitTillRelease:
    ENDIF    
    PAUSE 300
    LOW RelayDPDT   'relax relay
    LOW TIP101      'power off
ENDIF
GOTO Start:


With the mode jumper set to "momentary" the two relays change the polarity of the power to the switch motor each time the button is pressed.  The TIP 101 transistor only applies power to the motor until the button is released.  The relays are relaxed after power is removed to further lower the standby power consumption, significantly increasing battery life.