/DCC-Lokdecoder

DCC locomotive decoder

Primary LanguageC++Creative Commons Zero v1.0 UniversalCC0-1.0

DCC-Lokdecoder

Description

DCC multifunction decoder for H0 locomotives

Features

  • 1 motor H-bridge output
    • 3.6 A peak current
    • PWM frequency configurable (1-40 kHz)
    • overcurrent and temperature protected
  • 10 function outputs
    • 115 mA per output
    • F0f, F0r, AUX1 and AUX2 are dimmable todo
    • mappable to F0-F12 function keys
  • DCC asymmetry can be detected (for automatic brake control) todo

Hardware

  • 4-layer PCB esigned in KiCAD
  • fairly standard components (available from Digi-Key, Farnell, Mouser, etc...)
  • hand solderable (I did it too)
  • 4 debug LEDs (red, yellow, green and blue)
top bottom
top side bottom side

Firmware

  • Arduino compatible programming (behaves like an UNO)
  • DCC decoding by NmraDcc library

JMRI integration

basic motor basic_speed speed_table function_map advanced
Basic Motor Basic speed control Speed table Function map Advanced

Install guide

  1. Get the PCB (e.g. JLCPCB) and the components (e.g. mouser, digikey)
  2. Solder the components. The SOIC with exposed pad is a bit tricky, it can be soldered from the other side with a big tip and a lot of flux.
  3. Install the Arduino bootloader using the pads 5V, GND, SCK, MISO, MOSI, RST and an Arduino. Arduino as ISP
  4. Uncomment the line #define RESET_FACTORY_DEFAULTS to fill the EEPROM with the default CV values
  5. Upload the code using the pads 5V, GND, RX, TX, DTR and a USB TTL UART cable like this
  6. Re-comment the line #define RESET_FACTORY_DEFAULTS to avoid resetting to factory defaults every time.
  7. Upload the code again.
  8. Add the decoder XML file to JMRI. In DecoderPro select "File-> Import Decoder File..." and browse to the decoder XML. It will take some time, then adds the decoder definition to the database.
  9. Connect the T1 and T2 pads to the programming track of your DCC system.
  10. Add new locomotive with the "New Loco" button and then "Read type from decoder". It should detect the correct type: add
  11. If everything is fine, you can install the decoder into your locomotive!

Pinout

Pad Function
M1 Motor 1
M2 Motor 2
T1 Track 1
T2 Track 2
V+ Positive common for function outputs (keep-alive capacitor positive)
F0f F0 function output forward (open drain)
F0r F0 function output reverse (open drain)
1-8 AUX function output n (open drain)
5V internal microcontroller +5V supply
GND ground (keep alive capacitor negative)
SCK ISP programming clock (connect to ISP SCK)
MISO ISP programming read (connect to ISP MISO)
MOSI ISP programming write (connect to ISP MOSI)
RST ISP programming reset (connect to ISP reset output)
RX serial programming receive (connect to TTL UART TX)
TX serial programming transmit (connect to TTL UART RX)
DTR serial programming reset through a 100 nF capacitor (connect to TTL UART DTR)

Todo list

  • CV15, CV16 decoder locking
  • CV65 kick start
  • CV67-94 speed table
  • CV27 automatic brake control
  • function output dimming
  • motor fault check