Model Rail DCC Command Station With App
by BillC35 in Circuits > Arduino
9069 Views, 14 Favorites, 0 Comments
Model Rail DCC Command Station With App
Updated 30 Jan 2023 - add option of using the L6203 h-bridge
To purchase ready built DCC Controllers or build your own, go to website
----------------------------------------
Updated 26th Feb 2022 - add option of using the DRV8871 module
See Step 4 for details of build
----------------------------------------
This is the most efficient DCC command station possible to build.
No other system can do so much with so few components.
An easy to assemble fully functioning DCC Command station with PCB available on eBay plus requiring only a few parts.
The Apps are designed to operate on Android phones running version 8.0 and upwards.
No need to purchase any propriety systems, this is a stand alone unit operated by a free App called
'LocoMotive Cab'
Works with NMRA compliant decoders. This system compiles the operating DCC packets within the App which are sent to the Arduino interface to combine with the DCC clock signals.
Get free App LocoMotive Cab on Google Play Store or full version 'LocoMotive DCC'
New release of 'LocoMotive DCC 2' with 4 digit address, program on the main and consist control.
System Features include:
Roster list allowing multiple engines with short or long address
Ideal for small to medium size layouts
2 Amps load drives up to 10 of OO/HO locomotives using H-bridge specified
Short circuit protected
Automatic over current cut-out, adjustable in the code
Lights and directionFunctions 1 to 8 (1 to 32 on full App)
Turnout / points / accessories 8 pairs of outputs (16+ on full App)
Custom naming of your locos
Programming the CV1 loco address
Full App has read / write CV's 1 to 1024
Add your own accessory addresses
Free App - Change function buttons F1 to F8 from momentary to on/off switches
Full App has editable titles, visibility and momentary options on 32 function buttons
Full App has 4 on-screen speed bars for control of 4 locos at a time
Add max speed for each locoLong Address (Locomotive DCC 2 App)
Program on the main (Locomotive DCC 2 App)
Form a consist (Locomotive DCC 2 App)
Further to previous work on DCC wireless systems, I have developed a Bluetooth Command Station linked to a receiver Arduino based circuit with a HC-06 BT module and a LMD18200 or L6203 H-bridge Motor driver delivering 2.5 Amps.
The overall cost of parts is around £20 with parts purchased from eBay.
Arduino Sketch
Updated 21 Feb 2024 - For LMD18200T use sketch 'locomotive_dcc_lmd_2.5amp_v4.ino'
Updated 21 Feb 2024 - For L6203 use sketch 'locomotive_dcc_L6203_2.5amp_v3.ino'
------------------------
To load a sketch on to the Arduino Pro Mini you need a USB- TTL adapter such as the CH340 available on eBay or here on Hobby Components website :
https://hobbycomponents.com/usb-interface/586-ch34...
The Android App sends a complete packet to the receiver and is decoded here into an array of data. Depending on whether 3 or 4 bytes are received the code will generate the correct DCC packet format for the train track.
For more information on the NMRA packet standard refer to:
https://www.nmra.org/sites/default/files/s-9.2.1_2...
The LMD requires the DCC signal on the DIR pin and the PWM pin held HIGH.
This latest version includes the Read Write of CV's facility. The sketch has additional code to create the required packet formats to enable reading and writing of CV values.
Using PCB With LMD18200t IC On-board
The Arduino Pro Mini receives the Bluetooth data via the HC-06 module. The Arduino generates the NMRA standard clock cycles of data in packet format. The received data interrupts the sequence when new data is received and the DCC packet is updated to send instructions to the train tracks.
Note: The Arduino must be a Pro Mini ATmega 328 16MHz 5v version
List of parts required:
This PCB - contact me for availability
1 off Arduino Pro Mini Atmega328P 5V/16M eBay
1 off LMD18200T H-bridge IC
(beware of sellers who supply faulty parts)
1 off HC-06 Bluetooth module eBay
1 off 0.1 ohm 2W Metal Film Resistor 0.1R 2 Watt (11.5 mm x 4.5 mm) eBay
8 off Capacitor 0.1uf eBay
1 off 10kΩ Resistor
1 off 4.7kΩ Resistor
1 off 470Ω Resistor (use in place of 10kΩ resistor next to 0.1 ohm)
2 off 180Ω Resistors
1 off Capacitor 10uf 25v; eBay
1 off Capacitor 470uf 25v or 35v ; ebay
1 off L7805 CV Positive Voltage Regulator IC eBay
1 off 4-pin Female Header Edge Pins Strip 0.1" 2.54mm eBay
2 off 12-pin Female Header Edge Pins Strip 0.1" 2.54mm eBay
1 off Zener Diode (any value between 3.0 and 4.7v) e.g. BZX79C3V6. 3.6V; 0.5 W eBay
2 off 2-pin PCB mount screw terminal 10 amp 5mm spacing
1 off Aluminium heat sink for TO220 (as designed for L298N)
Wire
Power `supply:
Do NOT use a DC train controller as these do not provide a true DC voltage.
Ensure correct polarity of output plug before connecting.
Power supply: voltage of 14 to 18 volts DC
Ensure correct polarity of output plug before connecting.
Connect a 15v 2 amp power supply with a 2.1mm/2.5mm x 5.5 mm plug , for example search for eBay item # 401871382681
or, Connect a 15v 3 amp power supply similar to PowerPax item SW4323B with a 2.1mm/2.5mm x 5.5 mm plug, available from cpc.farnell.com
or, Connect a Multibao 15v 3A adapter with a 2.1mm/2.5mm x 5.5 mm plug, search for in Amazon
or, Connect a Photonic Universe 16v 3A adapter with a 2.1mm x 5.5 mm plug, search for in Amazon
To extend the range of the HC-06 Bt module, solder a wire onto the end of the antenna on the module. I used a solid copper wire (from mains earth wire) 31.2 mm in length (1/4 of wave length for 2.4 GHz). See photo above.
This wire should be covered in sleeving to avoid accidental shorting to other components.
Please note - the HC-06 connections are Rx (on PCB) to Rx (on module) and Tx to Tx
For the use of a LMD18200 h-bridge IC, I have added current sense components to provide protection from short circuit or overload issues on the train track, The updated circuit diagram and Arduino code now includes the current sense function. The code limits the max current to 2.5 Amps when reached, the LMD18200 h-bridge is shut down by applying a HIGH signal from D13 on the Arduino to the 'Brake' input on the h-bridge. The use of a 0.1 ohm current sense resistor gives an analog input range of 0 to 200 mv on Arduino sensor pin A0 for up to 2 Amps load. For approx 5mv per analog step input (1023 total steps or divisions) gives 0 to 40 divisions or 2 Amps / 40 = 50mA per division. The measured current precision is 50 mA however we are protecting the h-bridge when 2 Amps is reached. The LMD18200 also has in-built over temperature protection as a back up.
if(C >2500){ // 2.5 amps
Serial.println("Over Current");
digitalWrite(13, HIGH); }
The value of the current drawn is sent to the Android App via Bluetooth every second.
void send_c(){
t = millis() - lastmillis;
if (t >= interval){
bluetooth.write(sensorValue);
bluetooth.write('c');
lastmillis = millis();
} }
Android App
Download the FREE version of the App from Google Play Store - 'LocoMotive Cab'
Download the FULL version (£5.99) of the App from Google Play Store - 'LocoMotive DCC'
Instructions attached for full version with enhanced features including read/write of CVs, full function control 1-28, 4 off speed control sliders, buttons with fine control of speed steps up and down.
Download the 4 digit address version (£8.49) of the App from Google Play Store - 'LocoMotive DCC 2'
Instructions attached for DCC 2 version with enhanced features including read/write of CVs, full function control 1-32, 4 off speed control sliders, buttons with fine control of speed steps up and down, 4 digit loco addressing, program on the main and consist control.
Using the DRV8871 Module
Updated 26 Feb 2022 - added DRV8871 option:
This PCB - contact me for availability
The Arduino Pro Mini receives the Bluetooth data via the HC-06 module. The Arduino generates the NMRA standard clock cycles of data in packet format. The received data interrupts the sequence when new data is received and the DCC packet is updated to send instructions to the train tracks.
Note: The Arduino must be a Pro Mini ATmega 328 16MHz 5v version
List of parts required:
1 x Arduino Pro Mini Atmega328P 5V/16M eBay
1 x DRV8871 module available from Aliexpress or Adafruit / Pimoroni
Note: Attach a heatsink (one with self adhesive tape) to the underside of the module behind the DRV8871 IC
(Similar to RS Components type here )
1 x HC-06 Bluetooth module eBay
1 x 0.1 ohm 2W Metal Film Resistor 0.1R 2 Watt (11.5 mm x 4.5 mm)
3 x Capacitor 0.1uf
1 x 10kΩ Resistor
1 x 4.7kΩ Resistor
1 x 470Ω Resistor (use in place of 10kΩ resistor next to 0.1 ohm)
1 x Capacitor 10uf 25v
1 x L7805 CV Positive Voltage Regulator IC
1 x 4-pin Female Header Edge Pins Strip 0.1" 2.54mm
2 x 12-pin Female Header Edge Pins Strip 0.1" 2.54mm
1 x Zener Diode (any value between 3.0 and 4.7v) e.g. BZX79C3V6. 3.6V; 0.5 W
Wire
Power `supply:
Do NOT use a DC train controller as these do not provide a true DC voltage.
Power `supply: voltage of 14 to 16 volts DC
Ensure correct polarity of output plug before connecting.
15V 2 Amp version with a 2.1/2.5 x 5.5 mm plug, search for eBay item # 401871382681
Wiring of the module:
Unsolder the resistor Rlim on the DRV8871 module next to the can capacitor - this is a 32k surface mount resistor and replace with a 15k 1/4 watt axial lead resistor.
Connect a wire from In1 on PCB to IN1 on DRV8871 module
Connect a wire from In2 on PCB to IN2 on DRV8871 module
Connect a wire from Vcc on the PCB to Power + on the DRV8871
Connect a wire from Gnd on PCB to Power _- on the DRV8871
Arduino sketch : Use the attached file 'locomotive_dcc_2_tle5206_v15.ino'
Using the L6203 H-bridge IC on Board
The Arduino Pro Mini receives the Bluetooth data via the HC-06 module. The Arduino generates the NMRA standard clock cycles of data in packet format. The received data interrupts the sequence when new data is received and the DCC packet is updated to send instructions to the train tracks.
Note: The Arduino must be a Pro Mini ATmega 328 16MHz 5v version
List of parts required:
This PCB - contact me for availability
1 off Arduino Pro Mini Atmega 328P 5V/16M
1 off HC-06 Bluetooth module
1 x 0.1Ω Resistor tolerance ±5%; pin spacing 400 mil; package THT; power 2W;
2 x 10kΩ Resistor, tolerance ±5%; pin spacing 400 mil; package THT; power 0.25;
1 x 4.7kΩ Resistor, tolerance ±5%; pin spacing 400 mil; package THT; power 0.25;
1 x 470Ω Resistor, tolerance ±5%;pin spacing 400 mil; package THT; power 0.25;
2 x 180Ω Resistor, tolerance ±5%; pin spacing 400 mil; package THT; power 0.25; resistance 180Ω
2 x 15nf Ceramic Capacitor, package 100 mil [THT, multilayer]; voltage 35V
1 x 10uf 25v elctrolytic Capacitor
5 x Capacitor ceramic 0.1 uf 35v
1 x Capacitor ceramic 220 nf 35v
1 x 220uf Electrolytic Capacitor, 16v
1 x 10uf Electrolytic Capacitor, 25v
1 x 470uf 35v Electrolytic Capacitor
1 x Voltage Regulator, variant sink; chip 78005; package to220-igo; voltage 5V
2 x Generic female header - 12 pins, row single; female; hole size 1.0mm,0.508mm; pin spacing 0.1in (2.54mm);
1 x Generic female header - 4 pins, row single; female; hole size 1.0mm,0.508mm; pin spacing 0.1in (2.54mm);
2 x Rectifier Diode, UF4007, type Fast Rectifier; package 300 mil [THT];
2 x Screw terminal - pins 2; hole size 1.1mm,0.508mm; pin spacing 0.197in (5.0mm)
1 x L6203 package to-220-11 lead
1 x Heatsink TO220 Cooler 23*16*40MM With 2 Pins
1 x Zener Diode, breakdown voltage 3.6V or 3.2 or 4.2; package 300 mil [THT]; power dissipation 0.5W;
Wire
Power `supply:
Do NOT use a DC train controller as these do not provide a true DC voltage.
Ensure correct polarity of output plug before connecting.
Power supply: voltage of 14 to 18 volts DC
Ensure correct polarity of output plug before connecting.
Connect a 15v 2 amp power supply with a 2.1mm/2.5mm x 5.5 mm plug , for example search for eBay item # 401871382681
or, Connect a 15v 3 amp power supply similar to PowerPax item SW4323B with a 2.1mm/2.5mm x 5.5 mm plug, available from cpc.farnell.com
or, Connect a Multibao 15v 3A adapter with a 2.1mm/2.5mm x 5.5 mm plug, search for in Amazon
or, Connect a Photonic Universe 16v 3A adapter with a 2.1mm x 5.5 mm plug, search for in Amazon
To extend the range of the HC-06 Bt module, solder a wire onto the end of the antenna on the module. I used a solid copper wire (from mains earth wire) 31.2 mm in length (1/4 of wave length for 2.4 GHz). See photo above.
This wire should be covered in sleeving to avoid accidental shorting to other components.
Please note - the HC-06 connections are Rx (on PCB) to Rx (on module) and Tx to Tx