Software

Source files

The software for this variant (2.2) of the OpenDCC decoder can be found in the the download section.

Relation to OpenDecoder2

The software is based on OpenDecoder2 Version 0.12 (from 14.09.2010).

The main software changes are:

  1. Supports the new Printed Circuit Board.
  2. Supports RS-bus feedback.
  3. Supports different processors: Atmega8535, 16A or 32A, as well as the newer 164, 324 & 644. Note that usage of the 644-20PU leads to relatively frequent brown-out resets, even when using the lowest possible BODLEVEL (lowest brown-out voltage) supported by the AVR. The AVR 16A-PU did not suffer from these problems, and therefore runs more reliable.

Note: these AVRs do include ADC, which are needed for subsequent occupancy detection boards

Note: although there are many code changes, there are no functional improvements for the existing (8515 / 162 based) hardware. Upgrading is therefore not recommend.

File changes

Compared to the OpenDecoder2 Version 0.12 software, the following files have been changed:

  • dcc_receiver.c
    • No functional changes were made.
    • In the beginning of the file many aliases were added to make the code less hardware specific and also capable to run on the newly designed PCB for hardware 2.2.
    • Since AVRs 164, 324 & 644 use timers in a different way, the pre-compiler directive "ENHANCED_PROCESSOR" is used for conditional code segments.
  • dcc_decode.c
    • In "analyze_message / Basic Accessory handling" a new test is included to correct "errors" made by LENZ LZV100 master stations. This test is controlled by a new CV.
    • Although this correction will not be needed if the decoder is used in the traditional way (controlling four switches via four subsequent addresses, no RS-bus feedback), it will improve operation if it is used together with LENZ LZV100 master stations.
  • config.h
    • Includes #define OPENDECODER22 22
    • Removed #define TARGET_HARDWARE, since this is moved to the Makefile
  • main.c
    • Added hardware initialization for OPENDECODER22
    • init_RS() and send_RS() have been added (as conditional code)
    • Some minor changes in the comments are made.
  • port_engine.c
    • In the beginning of the file many aliases were added to make the code less hardware specific and also capable to run on the newly designed PCB for hardware 2.2.
    • Since AVRs 164, 324 & 644 use timers in a different way, the pre-compiler directive "ENHANCED_PROCESSOR" is used for conditional code segments.
    • A new "SkipEven" CV has been introduced to "skip even addresses". The motivation is that the RS-Bus, like several other feedback buses (including XPressnet) have fundamental problems if the position of multiple switches is signaled via a single message.
  • cv_define.h
    • Three new CVs have been added (see also above): RSRetry, LenzCor and SkipEven.
    • Note that "reserved CVs" have been (mis)used for this purpose.
  • cv_data_port.h
    • Initial values have been included for these new CVs.
    • CV546 supports a new feedback method: RS-bus
  • Makefile
    • Several changes to support OPENDECODER22
    • Like XTAL and MCU, the TARGET_HARDWARE (PROJECT) is now defined in the Makefile

New files

The following files have been added to provide RS-bus feedback:

  • rs_bus_hardware.h
  • rs_bus_hardware.c
  • rs_bus_port.h
  • rs_bus_port.c

Finally, for debugging purposes, some files are included to allow debugging via an LCD (lcd_ap.c, lcd_ap.h, lcd.c, lcd.h). Note that these files are written by Peter Fleury.

Program sizes