Components and supplies
Apps and online services
| ||||
|
About this project
What is different about this system ?
A very simple electronic circuit provide the DCC signal and power for the track, however the App does the real work ! The computer on your phone is utilised to the full by constructing the codes required to form each packet of instructions, thus simplifying the job of the Arduino controller !
Update 16 August 2019: Release of new improved App - with facility to Read / Write CV 1 to 255
This App version costs £5 plus tax and available on the Google Play Store.
Update 18 May 2019: Release of new improved App - up to 28 functions with editable titles, visibility and momentary options. Control up to 4 locos at a timewith speed bars on the screen. This App version costs £3 plus tax and available on the Google Play Store.
Update 17 Feb 2019: You may have to modify the HC-06 Bluetooth module to extend its range of reception.I added a solid copper wire (from mains earth wire) 31.2 mm in length (1/4 of wave length for 2.4 GHz). See attached photo in Step 2.
Update 29 Jan 2019: Addition of momentary option on F2 and F3 for horn sounds Preset max speed for each locoThis 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 App 'LocoMotive' is designed to operate on Android phones running version 4.1 and upwards.No need to purchase any propriety systems, this is a stand alone unit operated by a free App called 'LocoMotive'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. Purchase this PCB on eBay.Get free App LocoMotive on Google Play Store.Features include:
- Control of 1 to 20 locos
- Ideal for small to medium size layouts
- 2 Amps load drives up to 16 of OO/HO locomotives using H-bridge specified
- Add a higher current compatible h-bridge to extend load capacity
- Short circuit protected
- Automatic over current cut-out, adjustable in Arduino code
- Lights and direction
- Functions 1 to 8
- Edit function names, visibility and momentary action
- Turnout / points / accessories operates up to 8 pairs of outputs
- Edit turnout names
- Custom naming of your locos and set max speed for each
- Programming the CV1 loco address
- Read / write CV 1 to 255
- Add your own accessory addresses
- Choose a DC power source to suit scale used (Z/N/OO/HO/O/G) 12v to 20v
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 H-bridge Motor driver delivering 2 Amps.
The overall cost of parts is around £20 with parts purchased from eBay.
Step 1: Arduino SketchThe full sketch is attached. This portion is the loop and data receiver code. 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.
void loop() {if(bluetooth.available() > 0); {inString = bluetooth.readStringUntil('\n');}if (inString.substring(0, 1)== "D") {string();}delay(20);}
The string() void then splits out the data from the text string received and places each instruction into itsappropriate position in the DCC packet.
For example:
A received text string of 'DD, 3, 63, 12, 48, ' translates into a 4 byte Speed packet of 8 bits each :
DD = message IDByte: [1] [2] [3] [4]Decimal: [3] [63] [12] [48] Binary: [0000 0011] [0001 1111] [0000 1100] [0001 1000] Action: [Loco 3] [speed steps] [ loco speed] [ XOR data check]
A received text string of 'DD, 1, 129, 128, ' translates into a 3 byte Function packet of 8 bits each :Decimal: [1] [129] [128] Binary: [0000 0001] [1000 0001] [1000 0000] Action: [Loco 1] [ F1 on] [XOR data check]
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.
Step 2: Fritzing Circuit Diagram
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.
List of parts required:
PCB available on eBay.
1 off Arduino Pro Mini Atmega328P 5V/16M eBay
1 off LMD18200T H-bridge eBay
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
3 off Capacitor 0.1uf eBay
2 off 10kΩ Resistor eBay
1 off Capacitor 10uf 25v; eBay
1 off Capacitor 220uf 16v; eBay
1 off Phoenix Contact MKDS 1/ 2-3, 5 2 Way Screw PCB Terminal Block 13.5A 200V 3.5mm eBay
1 off 4.7kΩ Resistor 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 6 pin 2.54mm PCB Universal Screw Terminal Block eBay
1 off Zener Diode 3.6V; 0.5W 1N4732A eBay
Wire
Power `supply: For OO/HO layouts use a 14v DC power supply (e.g. laptop charger unit from eBay). For example this delivers up to 2.5 Amps. Check the size of panel mounted socket required to fit the DC jack plug on the power supply chosen for this project. https://www.ebay.co.uk/itm/Samsung-AC-DC-Adapter-...
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.Please note - the HC-06 connections are Rx (on PCB) to Rx (on module) and Tx to Tx. Please note, the antenna wire should be covered in sleeving to avoid accidental shorting with other components.
For the use of a LMD18200 h-bridge module (as displayed above this is in module form with heatsink etc), 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 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 >2000){ // 2 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(); } }
Step 3: Android AppDownload the free App from Google Play Store - 'LocoMotive'
Download the full App (£5.99) from Google Play Store - 'LocoMotive DCC'
Instructions are attached for the full version App.