loading

Updated 28 April 2016

The points / turnout controller is built and installed into my railway layout.

The finished system controls 16 points and 15 accessories such as lights, sounds, turntable, etc
The circuit is shown inside a pVC enclosure with 15 volt input socket and 2 flying leads to be connected to the track DCC supply.

Step 1: DCC Turnout Control - 16 Points ( Using 2 X Arduino Modules)

The DCC command station has a turnout control facility for up to 16 turnouts.

The basic Arduino circuit to drive 2 turnouts is shown in the Fritzing diagram above.

A 'packet receiver' circuit is required to provide input to the Arduino - see separate diagram.

Step 2: DCC Packet Receiver - Basic Circuit

Updated 23 March 2016:
Added current sense circuit to protect turnout coils and H-bridge devices etc from over current.

int analogPin = 7;
const int Power_shut_off = 19; // A5 as digital
pinMode(Power_shut_off, OUTPUT);
digitalWrite(Power_shut_off, HIGH);


In void loop():

amp = analogRead(analogPin);
   if (amp > 5){     
      Serial.println(amp);   }   
   if (amp > 200   ){   // approx 2 amps     
      digitalWrite(Power_shut_off, LOW);   }


When 2 amps is exceeded, the TIP 120 shuts off the power (12 volt or 15 volt supply) to the turnouts.
_____________________________________________________________________

From an excellent tutorial by Geoff Bunza in the Model Railroad Hobbyist Magazine forum. It described how an Arduino Pro Mini (a low cost Arduino board) could be wired and programmed to respond to function keys on a DCC controller. This opens up a wide world of control options for animations, sound and other options on a DCC equipped model railroad.

I have made use of this circuit to capture DCC packets from my Arduino based Command Station
(see instructable). The Command station has also been amended to allow turnout control (8 turnouts so far).

Basic Accessory decoder packet is :
0 10AAAAAA 0 1AAACDDD 0 EEEEEEEE 1

From analysing the packet used by Lenz (Compact / Atlas) for points control, I have used the following binary packet format for bytes 1 and 2 :
tunAddr = 1
Turnout 1a : 1000 0001 1111 1000 / Turnout 1b : 1000 0001 1111 1001
Turnout 2a : 1000 0001 1111 1010 / Turnout 2b : 1000 0001 1111 1011
Turnout 3a : 1000 0001 1111 1100 / Turnout 3b : 1000 0001 1111 1101
Turnout 4a : 1000 0001 1111 1110 / Turnout 4b : 1000 0001 1111 1111
tunAddr = 2
------------------------------------------------------------------------------------------------------------
Turnout 5a : 1000 0010 1111 1000 / Turnout 5b : 1000 0010 1111 1001
Turnout 6a : 1000 0010 1111 1010 / Turnout 6b : 1000 0010 1111 1011
Turnout 7a : 1000 0010 1111 1100 / Turnout 7b : 1000 0010 1111 1101
Turnout 8a : 1000 0010 1111 1110 / Turnout 8b : 1000 0010 1111 1111
-----------------------------------------------------------------------------------------------------------
Turnout 9a : 1000 0011 1111 1000 / Turnout 9b : 1000 0011 1111 1001
etc .........

By manipulation of the binary packet, we can extract the turnouts required and send a pulse of 350 ms.

E.g.
looking at first byte:

0x80 in HEX = 1000 0000 in Binary

tunAddr = (Msg->Data[0] - 0x80);

looking at second byte:

0x8f8 in HEX = 1111 1000 in Binary, then shift bitwise >>1 to eliminate last bit

f1a on:

if (tunAddr == 1){
   if ((((Msg->Data[1]) - 0xf8>>1) + 1) == 1 && (Msg->Data[1] & 0x01) == 1){ 
digitalWrite(FunctionPin1a, 1);             
delay(350);          
digitalWrite(FunctionPin1a, 0);     }

The diagram shows LED outputs. Replace LEDs with solenoid drivers e.g. TIP120 (2 off required for each turnout) or SN754410 Quad driver (supplies 2 turnouts per IC).
All digital outputs are used in pairs to produce a pulse that fires the turnout solenoids via motor drivers or power darlington transistors. The code may be changed to match the drivers used from a '1' pulse to a '0' pulse.

Download NMRA library here

Download Arduino Code :

Step 3: Turnout Control - Arduino Circuit

2 off Mini Pro Arduino module were chosen for this part of the project. Each provides 8 turnouts and if more are required, you will need to add more modules or use a larger Arduino (Mega perhaps)

<p>Bill, great Instructable! I wondered if you could share which points you're using? I'm using Hornby R8243 surface mounted point motors, and my sn754410s are struggling to supply enough current. Whilst the point motor switches definitely off-load, when under load (i.e. attached to points), whilst there is movement, it just does not seem to meet the instantaneous current requirements needed to be fully switched in either direction. I have even tried piggybacking the sn754410s and even then, switching is only successful in one direction of travel. I had wondered if you are using points with a high resistance/impedance?</p>
<p>Hi Simo, glad you like this Instructable. I used Hornby R8014 points motors (not surface mount) but should operate with same voltage and current. Please check the Vcc2 power supply which must be about 15 volts and capable of supplying peak current of at least 1 amp. Do your point motors operate of the track ok i.e. in free air movement? Please check alignment and freedom of movement of lever to points. You may have to adjust the timing in the Arduino sketch. I have 150 to 250 milliseconds on time <em><strong>delay (250); </strong></em></p>

About This Instructable

4,115views

11favorites

License:

More by BillC35:Arduino - adjustable & smart battery charger  Model Railway DCC Arduino wireless commands on a dead rail system Garden Train - Arduino / Wireless DCC 
Add instructable to: