OpenDCC - Command Station for DCC

    Note: Besides using the precompiled version a open source system offers the possibility to optimize the system for own purposes. Here You will find a description of the necessary tools.
    Besides changing default settings and configuration (most often constants defined in config.h or config.c) it is possible to change more things - however, knowledge in C and the protocols around model railways is really useful :-)

Getting Started

  • Collect Informations about the AVR Microcontroller range of devices. See the Atmel AVR site and also the AVRFreaks web site or Mikrocontroller.net is another good place to start. On these sites you will find good application notes, sample code, data sheets, information about software, hardware and development system tools etc. They have a specific GCC page that has several tutorials and other useful information.
    Besides there is a lot of open source in the web, e.g. a USB end point, Open Source RTOS or a Webring.
  • Software
    The AVR port of the popular GNU Compiler Collection (GCC) is called AVR-GCC. For those developing on MS Windows, there is a single Win32 install package WinAVR that now contains everything needed to get started quickly with AVR-GCC. It includes the complete GCC Compiler and Bin Utils, the Programmers Notepad which can now execute external programs like GNU make, the AVRDude Programming software and many other useful tools and utilities. For other OS's there is quite a bit of information at the OpenAVR site

    A good simulation environment ist AVR Studio from Atmel. WinAVR can be integrated in AVR Studio, thus resulting in a complete IDE.
    Note:
    The GCC compiler 3.4.5 has a bug, which is detremental for function calls to locomotives. This was fixed in version 4.1.1 (20070122). This compiler requires AVRstudio 4.13. And this requires the new Windows Installer 3.1. So proceed as follows:
    1. install Microsoft Windows Installer 3.1.4000.2435 Redistributable.
    2. install WinAVR 20070122
    3. install AVRstudio 4.13 (bei http://www.atmel.no/beta_ware/)
  • Hardware
    Besides the target hardware (I use OpenDCC, of course) You will need a flash programmer for the first programming. I'm using ponyprog, the needed connectors are on the PCB, but I recommend the use of an externalAdapter; Or you can buy a Atmel AVRISP programmer.
    Once a bootloader is loaded, the flash programmer is not longer needed. This is adapted version (from appnote AVR911) for opendcc: bootloader.zip
  • Start up:
    In general: first create a new project in AVR Studio, processor is ATmega32 running at 16MHz. Please use the following settings for Project -> Configuration Options:
    General settings
    Set the optimize level to -Os, the speed of the cpu according to the project: for OpenDCC 16MHz, for decoders 8 or 10MHz.

    Memory
    Thus additional memory areas for eeprom are defined to bind EEPROM Variablen to fixed an predefined addresses. Currently these settings are not forwarded correctly to WinAVR, therefore the content of eeproms is defined in one structure - esp. for decoders. OpenDCC_XP uses an external Makefile 'Makefile_EECV' to control the allocation in EEPROM.

    Now unzip the software files to the working directory and use "add existing source files" to add all header and c files. Now the system should compile with BUILD (=Taste F7).
    All important settings are located in config.h
    Notes:
    A easier way: just open the contained OpenDCC.APS with 'Project - Open', all setups will be loaded correctly.
    The file dccout_without_feedback.c is only a backup of dccout.c and should not be included.
  • Fuses:
    http://palmavr.sourceforge.net or http://www.engbedded.com/ is an excellent tool to calculate the fuses.
 

© Wolfgang Kufer 09.11.2006, update 22.11.2007