DCC

Aus Digital Modellbahn

Eigenbau | Allgemein | Railcom | DCC-Dekoder | Servo-Dekoder | Spezialdekoder

Dcc logo.jpg

DCC-Protokoll

Software

Die Software ist für die Arduino IDE geschrieben. Mit dieser Software wird ein NMRA konformes DCC-Signal erzeugt. Die Wiederholungsanzahl und die maximale Anzahl an Loks lassen sich in der Library für verschiedene MCUs (UNO, MEGA, etc.) einstellen. Aufbauend auf der Railstars CmdrArduino Library (kein wiederholendes Senden von Lok-DCC-Daten wie im NMRA-Standard gefordert!) wurde eine leistungsstarke DCC Interface Library entwickelt.

Arduino DCC Library

Die Arduino DCC Interface Library ist in C++ geschrieben und kann mit verschiedenen Arduino's verwendet werden. Die Library unterstützt, je nach verfügbaren RAM und Architektur des Mikrocontroller, eine variable Einstellung der Lok- und Weichenanzahl, sowie die Auswahl des Timer1 oder Timer2 für die Signalerzeugung sind möglich. Die Steuerung erfolgt ausschließlich im DCC Format und erfolgt mit 14, 28 oder 128 Fahrstufen. Unterstützt wird das Schalten von 29 Funktionen (F0 bis F28) und maximal 2048 Weichen. Die Library nutzt außerdem automatisch ab Adresse 100 - lange Adressen für die Ansteuerung von Loks. Es ist auch möglich Lokdekoder über CV zu programmieren

Download

DCC Interface Dokumentation

Änderungen: DCC Waveform Generator v2.3

  • add a store for active loco, so you can request the actual state
  • add a store for BasicAccessory states
  • add a repeat queue for Speed and Function packets
  • add Function support F13-F20 and F21-F28
  • add POM CV Programming
  • add BasicAccessory increment 4x (Intellibox - ROCO)
  • add request for state of Loco funktion F0 - F28
  • add notify of BasicAccessory even when power is off

Konfiguration

DCCHardware_config.h
schnelle DCC Signalausgabe auf festem PIN (je MCU) ON: #define DCC_USE_TRUE_C
OFF: #undef DCC_USE_TRUE_C
Auswahl des Timer1 (sonst Timer2) ON: #define DCC_USE_TIMER1
OFF: #undef DCC_USE_TIMER1
DCCPacketScheduler.h
Anzahl steuerbarer Weichen (je MCU) ATmega1284p: #define AccessoryMax 2048
ATmega1280p: #define AccessoryMax 1024
ATmega644p: #define AccessoryMax 512
andere: #define AccessoryMax 128
Speichergröße für Lokdaten (je MCU) - max. steuerbare Loks ATmega1284p: #define SlotMax 128
ATmega1280p: #define SlotMax 64
ATmega644p: #define SlotMax 36
andere: #define SlotMax 16
Speichergröße für Datenpakete (je MCU) ATmega1284p: #define PERIODIC_REFRESH_QUEUE_SIZE 180
ATmega1280p: #define PERIODIC_REFRESH_QUEUE_SIZE 100
ATmega644p: #define PERIODIC_REFRESH_QUEUE_SIZE 80
andere: #define PERIODIC_REFRESH_QUEUE_SIZE 50
Zubehör Adressverschiebung (increment) #define ROCO 0 //Roco/Fleischmann
#define IB 4 //IntelliBox
DCCPacket.h
Senden von langen Adressen #define MAX_DCC_SHORT_ADDRESS 99

Anwendung

#include <DCCPacketScheduler.h> Einbinden der Library
DCCPacketScheduler dcc; Erzeugen der Klasse
void setup()
dcc.setup(uint8_t pin = 6, uint8_t format = ROCO); Initialisierung der Library
optional: Ausgabe PIN und Zubehör Adressverschiebung
dcc.setpower(bool state); Zustand der Gleisspannung (ON/OFF)
Grundzustand ist OFF!
void loop()
dcc.update(); Gleisdaten verarbeiten
Kein delay verwenden!
other public functions
byte getpower(void);
void eStop(void);
Loksteuerung
bool setSpeed14(uint16_t address, uint8_t speed);
bool setSpeed28(uint16_t address, uint8_t speed);
bool setSpeed128(uint16_t address, uint8_t speed);
void getLocoStateFull(uint16_t adr, bool bc);
byte getLocoDir(uint16_t adr);
byte getLocoSpeed(uint16_t adr);
void setLocoFunc(uint16_t address, uint8_t type, uint8_t fkt);
Lok Funktionen (F0 bis F28)
bool setFunctions0to4(uint16_t address, uint8_t functions);
bool setFunctions5to8(uint16_t address, uint8_t functions);
bool setFunctions9to12(uint16_t address, uint8_t functions);
bool setFunctions13to20(uint16_t address, uint8_t functions);
bool setFunctions21to28(uint16_t address, uint8_t functions);
byte getFunktion0to4(uint16_t address);
byte getFunktion5to8(uint16_t address);
byte getFunktion9to12(uint16_t address);
byte getFunktion13to20(uint16_t address);
byte getFunktion21to28(uint16_t address);
Basic Accessory (Zubehör Befehle)
bool setBasicAccessoryPos(uint16_t address, bool state);
bool setBasicAccessoryPos(uint16_t address, bool state, bool activ);
bool getBasicAccessoryInfo(uint16_t address);
CV Programmierung
bool opsProgDirectCV(uint16_t CV, uint8_t CV_data);
bool opsProgramCV(uint16_t address, uint16_t CV, uint8_t CV_data);
bool opsDecoderReset(void);