So we decided to make a new module with two independent tracks and an independent command station so we can read, program and test locomotives. This module will be in the operator's side, connected to the "T" module that we use to enter or extract compositions to the main tracks.
We took profit of the fantastic DCC++ project, and just changed it to add a display, keypad and slider so we don't need the PC to perform any of the above operations before running a train in the main layout.
Disclaimer
Before continue reading, please consider the following typical disclaimer for DIY projects that applies to all this blog:
DIY projects are purely “at your own risk”. As with any DIY project, unfamiliarity with the tools and process can be dangerous. Posts should be construed as theoretical advice only. I’m not a professional, but only a hobbiest passing on ideas and tips to other hobbiests. Information and techniques I show here can change, and there can be mistakes in the information I publish, so I’m not responsible if that happens. Please consider my instructions as a guide only.
Shopping List
L298 Motor Shield, 5€
We chose a linear potentiometer, but it can be a regular button potentiometer or any other kind.
20x4 LCD display with I2C controller, 6€
Two power sources, one for Arduiono and an independent one for the motor shield. We recomend a 16Vdc 3Amp power source for the motor shild, as we found with less voltage some decoders do not respond to CV commands, or sound decoders do not work properly.
Connection
Please check first my previous post about how to mount the original DCC++ command station here (http://www.clubncaldes.com/2016/02/build-your-own-dcc-command-station-for-8.html). Motor shield needs some preparation (cutting a pad and making a bridge between pins 2 and 13).
After that you can connect the new elements (keypad, display and slider pot) as shown in the following scheme. Take into account that the keypad of the scheme is not the correct one (we are using the 4x5 keypad, see photo above these lines), but I couldn't find the Fritzing object for the right keypad:
- Display needs 5V, GND and two wires to SDA and SCL pins of Arduino (pins 20 and 21)
- Potentiometer needs 5V and GND in the same way, and the signal is connected to A8
- Keypad is connected using 9 pins (from 22 to 30)
- You will need one power source for Arduino, and an independent 16Vdc power source for the motor shield
Program
You will find always the latest version of the program to upload to the Arduino in the following link, were you can freely download from ClubNCaldes github repository and upload it to the Arduino Mega board:
How it works
I tried to make it as much intuitive as possible, but this are the main keys:
"*" ON, tracks are feeded with current
"#" OFF, no current to tracks
"F1" RUN MODE, this is the mode to run and test trains
"F2" PROG MODE, this is the mode to read and write CV in the programming track
In RUN MODE the left and right arrow are used to set the direction of travel, while the numbers activate or deactivate the functions. Speed is controlled with the slide pot.
In PROG MODE you can see a little help in the last line of the display which tells you the meaning of each CV entered (just for the standard ones like address number, acceleration, break, config...)
I hope you enjoy this simple but useful DCC command station for you own projects.
Hi Guys.
ReplyDeleteI have built this unit, all components are new. The 20 x 4 display only shows two lines of solid blocks and no text. I thought it was a faulty display so bought a new one. Same result. I tried a 16 x 2 display and it worked. I could select and control a loco. Any ideas?
Cheers
Dave
davevendfix@gmail.com
This is really strange... check you have the right code with the initialization of the display:
DeleteLiquidCrystal_I2C lcd(0x27,20,4);
This is a standard library to manage displays, try to use an example or write a simple program just to make sure the display you purchased works.
Hi Dani
DeleteI did as you suggested. It was the I2c interface that have me problems. I bought a display with an older interface and it worked straight away. Great project, thanks for your help.
Well done!!! Good to know!
DeleteYour KeyPadLCD code uses the C++ xxxx.init() style of coding while most LiquidCrystal_I2C libraries use the older plain C xxxx.begin style.
ReplyDeleteThis version works with your code -
https://www.archiduino.com/liquidcrystal_i2c-h-library-arduino-ide-1-6-x
bye.
What is the value of the Potentiometer?
ReplyDeleteIt's a 10K slide pot, you can find it in Aliexpress just searching "Arduino potentiometer".
DeleteHello Dani.
DeleteMy name is Bertil from Sweden.
I have built your version with 1 pot, display.
It works nice.
I want to add some more trottlepots and direction switches.
Do you have any ideas where to inplement this in the code??
Please send me a mail.
bertil.je.hermansson@gmail.com
Hello Dani.
ReplyDeleteMy name is Bertil from Sweden.
I have built your version with 1 pot, display.
It works nice.
I want to add some more trottlepots and direction switches.
Do you have any ideas where to inplement this in the code??
Please send me a mail.
bertil.je.hermansson@gmail.com
Hello Dani.
ReplyDeleteThank you very much. Congratulations for the work.
I have done the assembly and it works correctly. The only problem is that the locomotives go very slowly at maximum speed and the lights do not shine very much. The power supply of the shield is 15v. Any idea?
Thank you very much.
Hello.
ReplyDeleteExcellent work.
I have assembled the mount and it works fine but I am not able to program a decoder.
Is there any more extended explanation of how to do it?
Thank you very much.