Tiny DCC decoder for leds

This tiny DCC decoder has been made to drive 8 leds. Instead of using a more expensive turnout decoder this may be a nice alternative.

The DCC decoders brain is an Atmel Attiny24A microcontroller. The microcontroller samples the DCC track signal and takes action when there is a command with the same address as programmed in the microcontroller.

The outputs have 470 Ohm resistors that allow leds to be connected to the PCB. If a led is too bright you can add more resistance.

Track voltage must be between 15 volts and 25 volts. More volts than 15 and the on-board regulator burns out, less than 15 you will be safe, but the leds do not shine that bright or not at all.

The PCB has been designed so that the leds can be connected with common anode (+) or common cathode (-). In the picture above the PCB is configured for common cathode. (Yes, the silk screen is wrong)

Programming the DCC address is simple. Press the button and the programming led turn on. Next, press any DCC turnout key on you command center. Say green 6. The DCC decoder has now been configured for the DCC addresses 6, 7, 8 and 9. The DCC address does not have to begin on a multiple of 4.

I made a few different firmware versions:

  • Mode A: Signal decoder with 2 aspects.
    Every output pair (R1 and G1) can be switched, only one of the outputs is on. Press the red button to turn on R1, press the green button to turn G1 on.
  • Mode B: Signal decoder with 4 aspects.
    Same as Mode A, but with 2 output pairs (R1, G1, R2 and G2). Use this to make a signal with 4 leds.
  • Mode P: Pair-gate decoder.
    Every single output of the 8 (like R1) can be turned on with the green key and turned off with the red key. All outputs can be at any state.
    Use this to make a complex signal with multiple leds that can have complex patterns. When using Rocrail, you can make signals with unlimited aspects.
    In this mode, the DCC decoder uses 8 addresses.
  • Mode R: RG-led decoder with 4 aspects.
    On every pair (R1, G1) you can connect a RG-led (red green led or RGB led with B disconnected). With this version you can make the RG-led display the colors green, red, off and yellow. Very handy for making a control panel with a view of your track. 8 DCC addresses are used.

Want to build it yourself? You will need these parts (or similar like through-hole or DIP versions):

Qty Value Device Parts
1 Tactile switch S1-PG
2 0805 led LEDPG, LEDPWR
2 0.1uF 0805 capacitor C1, C2
1 220 0805 resistor R9
1 2.2uF 35V SMC size capacitor C3
1 4K7 0805 resistor R10
1 100K 0805 resistor R11
8 220 0805 resistor R1, R2, R3, R4, R5, R6, R7, R8
1 Attiny24A ATtiny24A-SSU (SOIC) IC1
1 AVR-ISP-6 2×3 pin header JP1
1 MB2S Smal diode bridge B1
1 AMS1117-5.0 SOT-223 5V regulator IC2
1 10V 1W Zener diode D1

When you have made the PCB or your prototype on a breadboard or strip board you will need to program a firmware into the microcontroller.
At the moment, only firmwares for common cathode (-) have been made and tested.

Mode Common cathode
A dccdecoder-a-cc.hex
B dccdecoder-b-cc.hex
P dccdecoder-p-cc.hex
R dccdecoder-r-cc.hex

Fuses:
Low: 0xC2
High: 0xDD
Extended: 0xFF

All that is left is to connect the DCC track signal from your command station to the decoder and start switching.

Did you like this post? Please give it a thumbs up by sharing it on your social network. Thanks!

9 thoughts on “Tiny DCC decoder for leds

  1. Kubik

    Hi there,

    do you plan to provide the source code? I would like to have chance to modify if necessary.

    Thanks,
    Jakub

    Reply
      1. Chris

        Hi Marc,

        i would like to use an L293DD to drive Rokuhan turnouts. That’s why i need to modify the code an the PCB.

        Reply

Leave a Reply

Your email address will not be published. Required fields are marked *