Details for the schematics of OpenDecoder (V. 1)

  • Schematic:
    My first DIY Decoder was inspired by the proposal on Unfortunately I found some 'issues' with the software at bahn-in-haan, so I decided to do it on my own. This software was written for this hardware. Therefore the pin allocation of the Atmel Attiny2313 in this curciut corresponds to the orginal of So the software will run on both hardware platforms.

    Important note: The processor AT90S2313 requires an external reset generator (TL7705) as well as an external quartz. With the processor ATtiny2313 these parts aren't needed (but you will find them in the diagram as an option). If the quartz is omitted, the Attiny must be set for 8MHz and internal oscillator and the source must be compiled for 8MHz as well. So with the ATtiny2313 you can leave out: C4, C5, C6, C7, R3, R4, IC3 and Q1.
  • Description:
    Voltage supply:
    At X2 the input voltage of the external power pack is fed in (approx. 15V); Polarity and type of current doesn't matter: a transformer for model railways, a plug power pack or the DCC signal itself can be used. The input voltage is rectified and by means of the usual 7805 limited to 5V for the supply of the processor. The idle current amounts to approx. 20mA.
    Note: I stated that some magnetic turnout drives from Roco need up to 15V to operate properly; In this case supply voltage is to be increased by the voltage drops at the rectifiers and output drivers to 16V~ or 18V=.

    DCC input:
    To X1 the DCC signal is attached. This is separated by means of an opto coupler from the voltage supply of the decoder. The opto coupler provides a troublefree operation even on large layouts. Usable as opto coupler is 6N136 or 6N137 or even 4N25. When using the 6N137 the pin 7 (enable) must be connected to pin 8 (this is not in the layout of the pcbs V1.1).
    Hint: If You would like to supervise the DCC input signal, replace flywheeling diode by an LED.
    The 4N25 (or its derivatives) must be equipped in such a way, that pin 1 of the 4N25 coresponds to pin 2 of the layout. The 4N25 is slow, in particular the recovery time is relatively long. Therefore the pullup at the output should be changed to 1k.
    R2 is not fitted when the 6N136 is used.

    Output curcuit:
    This is done by means of ULN2803: this chip can supply 0.5A at each output and is internally equipped with a flywheeling diode for inductive loads. This is sufficient for N gauge, with H0 0.5A may be to less. Some drives may require more current. The outputs are arranged in groups of two with a power supply in the middle. Thus the wiring of the layout is made easier, no need for extra connectors to distribute power.
    If more current is required at the outputs, you may use two ULN2803 in parallel. Simply solder the second one on the back of the first one.
    Driving inductive loads:
    Turnout drives are typically equipped with coils, these are automatically turned off at the end of the travel. This turning off causes an induction voltage, which flows backwards to the output driver and is captured by the integrated flywheeling diode. If the switch for turning off is 'ringing' and turns off and on several times, then it can happen that the flywheeling diode is overloaded before the polyfuse switches off.
    A fast suppressor diode connected directly to the switch coil may help in this case - better exchange the turnout drive.

    Control of motor driven turnouts:
    This can be done either by means of a a bistabile relay or with a transistor stage. Christian Wichmann created a pcb layout for a decoder with these outputs.

    Atmel ATtiny2313 is used as processor. There is an optional reset generator chip (TL7705) in the layout of the pcb. This was necessary with the predecessor AT90S2313, in order to avoid brownout. This is no longer needed, since the the Attiny2313 has a built in reset generator.

    The Atmel ATtiny2313 is delivered with a factory adjusted RC oscillator, which runs at 8 MHz. Therefore the quartz and the condensers can be omitted. However then a hex file for 8 MHz must be loaded. When doing the compilation with a set clock rate (F_CPU) of 8000000, all timing setups are adjusted automatically. HEX files for both 10MHz and 8MHz are contained in the zip file below.
    Note: the clock accuracy is indicated by Atmel as 10%, what is sufficiently exact for this application; however, in a worst case scenario (combining clock deviation, delay time of optocoupler and a DCC input at tolerance edge) the reception of DCC may fail. So consider using a quartz, it is not too expensive.

    Tracer and LED:
    The LED is a 2mA type, thus can be operated directly by the AVR. The tracer is used for starting programming.
  • Layout:
    The PCB is realized as single-sided pcb with the dimensions 80*50mm. Only through-hole components and DIL ICs are used, so DIY is easy. There is enough space for large clamps and mounting holes, so that the final decoder can be easily installed.


    Again: This circuit and layout is free for the private use, a commercial use is forbidden. Eagle files are available only on request.
    Connection diagram V1.2: jpg pdf
    part list
    Layout V1.2: jpg dccdecoder_brd_v12.pdf