This is version 2 of my original DCC Command Station Instructable.
I have learned a number of things from the original experience about the Arduino Nano, the h-bridge LMD18200t and the TFT LCD display.
1. The analog pins on the Nano may be used for serial communications e.g. A3/A4 for Rx/Tx. The original used D0 and D1 making serial monitoring impossible. I have also used A2 and A5 as a digital outputs to control the on/off of the bridge output in event of over-current. Note: A6 and A7 cannot be used as digital output pins on the Nano.
2. The LMD18200t current sense pins on the actual IC package, do not work well and in some cases not at all. Therefore, I have added a 0.1 ohm 5 watt resistor to monitor current through the bridge. This is sensitive to within 50mA which is ok for the purpose of detecting overloads/shorts.
3. The TFT LCD display requires lower values on the voltage divider inputs (was 4k7 and 10k ohm), 1k0 and 1k5 ohm values work fine. The TFT is slow in response compared to response of turning the speed pot and recording on the display. The time lag gives incorrect values. I have included a special void in the Arduino sketch to transmit speed data only and change one line on the display instead of refreshing the whole display.
4. The DCC command signal timing has been improved by switching state of the output using binary register coding instead of digitalWrite(D10, High) e.g. DDRB = B00000100; // register B for digital pin 8 to 13, pin 10 as an OUTPUTPORTB = B00000100; // using register control to speed up switching speed pin 10 switched HIGH (DIR)PORTB = B00000000; // pin 10 switched LOW (DIR)
5. The input keys on the membrane key pad are selected in void get_key() I have improved the response time taken in the void by using ‘case’ and ‘return’ rather than ‘if’ statements.
6. The NMRA standard requires a continuous flow of DCC data every 30 ms. This has been added to the sketch for speed and direction on all running locos (not for function controls which are only sent when keypad is pressed).
7. The DCC Command packet for 128 speed steps is 4 bytes long whereas the function Commands are 3 bytes long. I have included a means to assemble 4 or 3 byte packets by altering the length of the Message array: void amend_len4 (struct Message & x) { x.len = 4; z = 4; }void amend_len3 (struct Message & x) { x.len = 3; z = 3; }
8. On review of the power requirements of the Nano and LCD and the H-bridge voltage (12v to 14v) I have used a 9v regulator to supply the Vin pins of the Nanos and the input of the 3.3v regulator for the LCD. This gives optimum power dissipation on the regulators. The Arduino Nanos should not be relied upon to supply enough current to the LCD display from their 3v outputs.
9. A PCB design from Fritzing and manufacturing in China has enabled me to provide bare PCB’s of the circuit included here. If you are interested purchasing one, please search e-bay for ‘DCC Command Station PCB’ (should be available during August 2018)”