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. Es ist auch möglich Lokdekoder über CV zu programmieren. Die Library nutzt außerdem automatisch ab Adresse 100 - lange Adressen für die Ansteuerung von Loks.

Hinweis: Das Steuern von langen Adressen unter 100 ist nicht möglich.

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 und Funktionen

#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); Rückgabe Gleisspannungszustand
(OFF, ON, ESTOP, SERVICE)
void eStop(void); Halt für alle Lokomotiven
Gleisspannungszustand = ESTOP
Loksteuerung
bool setSpeed14(uint16_t address, uint8_t speed); Lok mit 14 Fahrstufen steuern
speed = DSSS SSSS (D = Dir; S = Geschw.)
bool setSpeed28(uint16_t address, uint8_t speed); Lok mit 28 Fahrstufen steuern
speed = DSSS SSSS (D = Dir; S = Geschw.)
bool setSpeed128(uint16_t address, uint8_t speed); Lok mit 128 Fahrstufen steuern
speed = DSSS SSSS (D = Dir; S = Geschw.)
void getLocoStateFull(uint16_t adr, bool bc); Abfrage aller Daten zur gewählten Adresse
Antwort: notifyLokAll()
byte getLocoDir(uint16_t adr); Abfrage der Fahrtrichtung
Antwort: true/false
byte getLocoSpeed(uint16_t adr); Abfrage der Geschwindigkeit mit Fahrtrichtung
Antwort: DSSS SSSS
Lok Funktionen (F0 bis F28)
void setLocoFunc(uint16_t address, uint8_t type, uint8_t fkt); Schalten einer Lokfunktion
type => 0 = AUS; 1 = EIN; 2 = UM;
fkt => 0..28
bool setFunctions0to4(uint16_t address, uint8_t functions); Schalten der Lokfunktionen F0 bis F4
functions = 0 0 0 F0 F4 F3 F2 F1
bool setFunctions5to8(uint16_t address, uint8_t functions); Schalten der Lokfunktionen F5 bis F8
functions = 0 0 0 0 F8 F7 F6 F5
bool setFunctions9to12(uint16_t address, uint8_t functions); Schalten der Lokfunktionen F9 bis F12
functions = 0 0 0 0 F12 F11 F10 F9
bool setFunctions13to20(uint16_t address, uint8_t functions); Schalten der Lokfunktionen F13 bis F20
functions = F20 F19 F18 F17 F16 F15 F14 F13
bool setFunctions21to28(uint16_t address, uint8_t functions); Schalten der Lokfunktionen F21 bis F28
functions = F28 F27 F26 F25 F24 F23 F22 F21
byte getFunktion0to4(uint16_t address); Abfrage Funktionszustand F0 bis F4
Antwort: 0 0 0 F0 F4 F3 F2 F1
byte getFunktion5to8(uint16_t address); Abfrage Funktionszustand F5 bis F8
Antwort: 0 0 0 0 F8 F7 F6 F5
byte getFunktion9to12(uint16_t address); Abfrage Funktionszustand F9 bis F12
Antwort: 0 0 0 0 F12 F11 F10 F9
byte getFunktion13to20(uint16_t address); Abfrage Funktionszustand F13 bis F20
Antwort: F20 F19 F18 F17 F16 F15 F14 F13
byte getFunktion21to28(uint16_t address); Abfrage Funktionszustand F21 bis F28
Antwort: F28 F27 F26 F25 F24 F23 F22 F21
Basic Accessory (Zubehör Befehle)
bool setBasicAccessoryPos(uint16_t address, bool state); Schalten einer Weiche
state => true = abzweig; false = gerade;
bool setBasicAccessoryPos(uint16_t address, bool state, bool activ); Schalten einer Weiche mit Spulenzustand
state => true = abzweig; false = gerade;
Drücken: activ = true;
Loslassen: activ = false
bool getBasicAccessoryInfo(uint16_t address); Abfrage Weichenzustand
Antwort: true = abzweig; false = gerade;
CV Programmierung
bool opsProgDirectCV(uint16_t CV, uint8_t CV_data); CV-Programmierung im "Direct-Mode"
bool opsProgramCV(uint16_t address, uint16_t CV, uint8_t CV_data); POM-CV-Programmierung
Hinweis: Nicht getestet!
bool opsDecoderReset(void); Sendet Reset Paket zu allen Dekodern
Automatisch bei opsProgCirectCV() und opsProgramCV()


C++ call back functions
void notifyLokAll(uint16_t Adr, uint8_t Steps, uint8_t Speed, uint8_t F0, uint8_t F1, uint8_t F2, uint8_t F3, bool bc) Antwort auf Nachfrage getLocoStateFull()
void notifyTrnt(uint16_t Adr, bool State) Aufruf bei Änderung des Weichenzustand
void notifyPowerOFF() Information über Abschaltung der Gleisspannung nach erfolgter Programmierung.