Accessory Decoder: a software for OpenDecoder (Var. 1)

    This accessory decoder is the first version of my DCC decoders. This software operates either as decoder for switches (pulse) or for signals (permanent outputs). This software runs on OpenDecoder 1, based on the ATtiny2313.
    A simple accessory decoders is implemented, only the basic packets are evaluated, neither the DCC reset packet nor the broadcast packet will be considered. The setting of the operating modes and the address is made by simply pressing the programming tracer and sending an accessory command.
    (Hint: for OpenDecoder 2 there is a fully featured accessory decoder with CV programming and true feedback of turnout positions)

    There are the following modes:
      ModeFunction
      0 Turnout decoder for magnetic drives, pulse duration 0,25 sec
      1 Turnout decoder for magnetic drives, pulse duration 0,5 sec
      2 Turnout decoder for magnetic drives, pulse duration 1 sec
      3 Turnout decoder for magnetic drives, pulse duration 2 sec
      4 Decoder for light signals, 4 signals with two aspects
      5 Decoder for light signals, 2 signals with three aspects, one signale with two aspects
      6 Decoder for light signals, 2 signals with four aspects
      7 Decoder for traffic lights

Programming

    The setting of the operating mode and of the address is made by simply pressing the programming tracer and sending an accessory command. The contents of the first received command will determine mode and address.
    1. Press the program tracer for at least 100ms, the LED is turned on. This indicates that the decoder is waiting for an accessory command.
    2. Now send an accessory command. The decoder dtermines his base address from this command, according to the following rule:

          Base address = (received address - 1) / 4. (the reminder is ignored)

      The decoder is now programmed to the following addresses: base address * 4 + 1 up to base address * 4 + 4

      The above "reminder" will be combined with the "coil" (red or green) is used to set the operating mode:
        Selected Operation Mode
        0 2 4 6
               
        turnout 1 turnout 2 turnout 3 turnout 4
               
        1 3 5 7
    For example, sending the switch command for turnout 18 will set the base address to 4. The decoder now reacts on turnout commands 17 to 20 and operates in mode 2.

The operating modes

    Generally, OpenDecoder doesn't need a pause between individual commands. However, if several magnetic drives are switched simultaneously, so that the power consumption of the outputs is too large, the fuse may interrupt the current. consequence: switching takes not place. In this case, a short break is recommend between the execution of multiple turnout commands.
  • Mode 0, 1, 2, 3
    These operating modes are suitable for magnetic coils of conventional double-coil drives for switches or signals. Usually, these drives have 3 connectors, which are wired as follows:

    In mode 0, the pulse time is 0.25sec, in mode 1 the pulse time is 0.5sec, in mode 2 the pulse time is 1sec and in mode 3 the pulse time is 2sec.
    If motor controlled turnout are to be operated, a bistable relay or a transistor curcuit must be used. Mode 5 is not appropriate for this.
    The outputs (up to 500mA each) can be activated simultaneously, but the total should not exceed a current of 1A. Therefore, it is recommended to add a small break after switching.
    The decoder evaluates only the "switch on" commands. "switch off" commands are ignored and replaced with the programmed pulse duration. There are some command stations (like Intellibox®) which do not a switch off command at all.
  • Mode 4
    In this mode, four light signals are operated.

    If a jumper is fitted to JP1, the last state will be stored in EEPROM (for operating modes 4 to 7)
  • Mode 5
    In this mode, two light signals with three aspects and one signal with two aspects can be operated. Each signal aspect (Hp0, Hp1, Hp2) or (Vr0, Vr1, Vr2) is assigned to one output. An aspect can be displayed by several lamps connected to this output. (Sum max. 500mA).

      active outputs [76543210]
      xxxxx001 xxxxx100 xx010xxx 01xxxxxx
      Signal1: Vr0 Signal1: Vr2 Signal2: Vr1 Signal3: Hp0
      1 2 3 4
      Signal1: Vr1 Signal2: Vr0 Signal2: Vr2 Signal3: Hp1
      xxxxx010 xx001xxx xx100xxx 10xxxxxx
    The outputs are mapped to the commands in accordance with the above table. Each accessory command turns on exactly one output. For signals with three aspects the outputs mutually turn off each other.

    If a single LED is contained in different aspects, a diode matrix must be used to connect this LED.
    Example:
      In the announcing signal of the DB, there are two green and two yellow lights, these are turned on acordingly to the desired aspect:

      The lower yellow light is turned on with aspects Vr0 and Vr2, the upper green light is turned on with aspects Vr1 and Vr2. Therefore these LEDs are wired with a diode to both outputs. The diodes are needed for decoupling. (At this point, I would like to mention the signal decoder software, which works without diodes and uses dimming techniques.)


      Connecting the signal.

    You will find a good overview on different aspects at: Christoph Schmitz, animated signals
  • Mode 6
    In this mode, two signals with four aspects can be operated, the control is similar to mode 5.
      active outputs [76543210]
      xxxx0001 xxxx0100 0001xxxx 0100xxxx
      Signal1: Hp0 Signal1: Hp2 Signal2: Hp0 Signal2: Hp2
      1 2 3 4
      Signal1: Hp1 Signal1: Sh1 Signal2: Hp1 Signal2: Sh1
      xxxx0010 xxxx1000 0010xxxx 1000xxxx
    The outputs are mapped to the commands in accordance with the above table. Each accessory command turns on exactly one output, four outputs mutually turn off each other.
  • Mode 7
    In this mode, two traffic lights can be operated. Both traffic lights act independant and can be switched to following states::
      Command Result
      1 traffic light 1 turns yellow, then red and stays red.
      The magnet for stopping a faller car will be turned on in the middle of the yellow phase.
      2 traffic light 1 turns red+yellow, then green (and stays green).
      The magnet for stopping a faller car will be turned off some time after 'green'.
      3 traffic light 1 turns off completely.
      The magnet for stopping a faller car is turned off
      4 traffic light 1 flashes yellow.
      The magnet for stopping a faller car is turned off
      5 traffic light 2 turns yellow, then red and stays red.
      The magnet for stopping a faller car will be turned on in the middle of the yellow phase.
      6 traffic light 2 turns red+yellow, then green (and stays green).
      The magnet for stopping a faller car will be turned off some time after 'green'.
      7 traffic light 2 turns off completely.
      The magnet for stopping a faller car is turned off
      8 traffic light 2 flashes yellow.
      The magnet for stopping a faller car is turned off
    The transition from red over red-yellow to green and the corresponding control of the magnet for stopping a car (and vice versa) id performed through a single command. A computer program only needs to issue 'go' on one road and 'stop' on the other road.

    Connecting the traffic lights and stop magnet.

Download/documents:

    The software is available under gnu public license. If someone should build a new decoder with this software, I would appreciate it publishing here. And money and/or material donations are welcome; -)

    Download Hexfile and Source Code (contains both 10MHz and 8MHz precompiled version).
    If links are broken: please ask by mail.