Central Station

Aus Digital Modellbahn

Eigenbau | Zentrale Z21PG | Z21 mobile | XpressNet | LocoNet | Booster

Arduino UNO Version | Arduino MEGA Version | ESP8266 (WeMos D1 mini) Version | ESP32 Version | Sanguino Version

Sprachen:
Deutsch • ‎English
Z21 logo.png
Dcc logo.jpgRailcom logo.gif

XpressNet logo.jpgLoconet logo.jpgS88-N logo.jpg

Basics

Central Station in a Eurobox
DCC Central with network, S88, XpressNet and LocoNet connection
Connections of the central station

A very good but also very expensive model railway control ROCO Z21 and the XpressNet gave me the idea to develop a own central station. My intention was to reduce the hardware or/and replace it with software. The self-construction central station should also have a network interface for APP and PC control, XpressNet, S88 and LocoNet so it will be equal or even more powerful then the original ROCO Z21.
Here I will describe the build up of the Z21 DCC Central Station on the base platform of the Arduino (Arduino MEGA buy it on AliExpress for about 8,- Euro) to control the model railway via the Z21 LAN protocol. The basic version need for the network connection a Ethernet Shield with a W5100 chip (at AliExpress for about 5,- Euro). With the ethernet shield you can include the central station into a already used home network with WiFi to control over smartphone hand device or other software for example Rocrail your model railroad. With extensions you can add for example even a WiFi AP or Client (with ESP6288) to the central station.

Functions

  • control 29 function (light, F0, F1 to F28),
  • control up to 2048 switch,
  • extern booster connection for ROCO 10761/10764 Digitalamplifier
  • internal DCC booster (TLE5205 driver with 5A)
  • NEW: RailCom® Cutout for internal booster (supported from version v4.70)
  • NEU: CV read and write (with optional programming track) (supported from version v4.75)
  • POM (programming on the main)
  • NEW: support for F9 up to F28 for Intellibox (supported from version v4.72)
  • LocoNet-Client Mode (Slot-Server can be switched off) for connection to Uhlenbrock Intellibox
  • programming of LocoNet LNCV (configuration variable) with the Z21 mobile APP (supported from version v4.52)

Advice

More informations you can find on the german Stummis Modellbahnforum.

known Bugs

This project is private and just developed by myself. It doesn't have a 100% support for the used protocols. Here is a list of known problems:

  • (solved, from v4.89) no status of LocoNet occupy detectors on mobile Z21-App.
  • (solved, from v4.88) not correct init of EEPROM-Values when upload the sketch the first time.
  • (solved, from v4.86) crash when open the switch panel on mobile Z21-App. (Stellpult Bug)
  • (solved, from XpressNetMaster Libary v2.9.0) when reading CVs from a ROCO Multimaus the Multimaus blocks.

I am pleased to receive suggestions and unknown problems by: Email or they can also discussed on Stummis Modellbahnforum.

Hardware

The Arduino Z21 DCC Central Station generates the DCC signal by using my own DCCInterface Library and Timer1/Timer2 (selectable). The central station support different protocols and it's own hardware interface. To select your own used protocols and hardware you have to (de)activate the interfaces inside the Arduino sketch (with "//" infront of #define or #include you can deactivate the unused protocol!).


Ethernet Interface

The Ethernet-Interface can be activated inside the sketch with "#define LAN". It provides the communication with the Z21 protocol library for cable devices connected to the Arduino W5100 Ethernet Shield. The used IP-Address is by default 192.168.0.111/24 and can be changed only over it's website (you need to activate the website by #define HTTPCONF"). You can also activate DHCP to receive a IP. To reset the IP to default you need to hold the power on/off switch while power plug in.

If you use the Arduino UNO with WiFi over Software Serial, you can't activate the Ethernet-Interface!

Wenn nach dem Einschalten der Zentrale keine Verbindung über die Ethernet-Schnittstelle (W5100) möglich ist und diese nach dem Drücken von RESET auf dem LAN Interface sich aufbaut, dann muss ein 1uF Kondensator, C- nach GND 0V, C+ nach RESET auf dem Shield installiert werden. Das LAN W5100 Board ist dann immer direkt nach Power on (ohne Betätigung der Reset Taste) erreichbar.

DCC Input Interface

Attention: This is obsolete and will be not updated! With the DCC-Input of a "foreign central station" you can integrate this DCC information on the rails. You will have no feedback between the central stations because there is no reverse communication. You can use this connection for example to use a PIKO Fern / Digi 1 (55019). The DCC decoding use no timer and will work on each provided micro controller. You need to active the interface with #define DECODER inside of the sketch.

End of Support!

XpressNet Interface with external booster support

Arduino XpressNet Booster Interface (Eagle)

If you have a less expensive ROCO 10761, 10764 or Fleischmann Digitalbooster 680801 it can be used as an external 3,5A booster with the central station. Also without XpressNet support (no MAX 485) you can use this external booster. The necessary short detection is already inside the software. You need just to activate this function with:
#define BOOSTER_EXT
#define BOOSTER_EXT_ON HIGH
#define BOOSTER_EXT_OFF LOW

To communicate with a ROCO LokMaus2 or MultiMaus you need the XpressNet driver MAX485. The Z21 Central Station provide then the master function for the LokMaus2 or/and MultiMaus. You can connect up to 31 slave devices (clients) to the XpressNet.

To activate the XpressNet-Interface you need to have this lines in the sketch:
#define XPRESSNET
#include <XpressNetMaster.h>

The picture on the right shows the schematic for the connection of the ROCO Boosters 10761 and the hardware you need to build up the XpressNet-Interface. For the data lines A and B you my need an additional pull up/down and/or a bus close ending. (see XpressNet hardware).

Das XpressNet Interface untersützt die automatische Umschaltung zwischen Master und Slave Betrieb. Daher ist es möglich eine Koppelung über XpressNet mit einer vorhanden Zentrale herzustellen um die Z21 Funktionalitäten per Ethernet oder WLAN an dieser nutzen zu können.

LocoNet

Arduino LocoNet Master und S88N Interface (Eagle)

With the integration of the LocoNet-Interface it is possible to connect the Arduino Z21 Central with a Uhlenbrock Intellibox, feedback/switch modules or with throttle devices like Fred. To use a Fred you must activate the LocoNet slot server. Note a connection to a Intellibox is only possible with a deactivated slot server, because the Intellibox provide it's own server! The LocoNet Library uses to create the signal the timer 1 and on the Arduino MEGA timer 5. To activate the LocoNet-Interface:
#define LOCONET
#include <LocoNet.h>

The Slot-Server can activated by #define LnSLOTSRV . If it is necessary you can send all loco informations with #define TXAllLokInfoOnLN true . This can be useful if you use a client software that communicates with the Z21 oder LocoNet.
Note: The LocoNet-Interface now support functions up to F28!

LocoNet-B

Arduino LocoNet-B Anschluss

Zum Anschluss eines LocoNet-Booster (Uhlenbrock 63240 Power 4 oder ähnliches) wird am LocoNet-Bus auf den Leitungen 1 und 6 (Raildata) ein DCC-Signal benötigt. Für die Erzeugung des Signals mit einem 12 Volt Pegel wird ein kleiner 1A H-Brückentreiber IXYS IXDF604PI in 8-Pin PDIP Bauform genutzt. Dieser wird angesteuert vom DCC-Signal (PIN 6) oder beim Arduino MEGA über den seperaten PIN 11, wo ein konstantes DCC-Signal ausgegeben wird. Dies kann direkt an IN A und IN B des IXYS angelegt werden. Die Signalisierung für das An- und Abschalten oder bei Kurzschuss des Booster erfolgt mittels LocoNet-Befehlen an die Zentrale.

Hinweis: Eine Unterstützung erfolgt ab Software v4.83!

S88N

Arduino S88 singel Master schematic

Feedback messages can received with the S88N-Interface and send to the control software. The S88 connector support up to 62 modules with eight inputs. To manage the number of modules that are permament requested you have to open the web configuration on the LAN or WiFi IP-Address. To activate the interface you need to uncomment:
#define S88N
Advice: With more then 5 modules you should use a driver 74HC244 for your S88 system.

Da durch den Aufbau des S88-Bus eine "Verkettung" erzeugt wird, nimmt die Geschwindigkeit des Auslesens der Zustände ab, umso mehr Module genutzt werden. Da nicht immer eine komplette Kette mit 62 Rückmeldemodulen angeschlossen ist, sollte die Anzahl der maximal abzufragenden Module in der Software begrenzt werden. Dies erfolgt über das vom LAN- oder WiFi-Interface bereitgestellt Webinterface (Webseite).

internal Booster

TLE5205-2g Booster3 (Not in use! - see TLE Booster3R with RailCom)

A cheap Booster (for example: H-Brücke TLE5205) to provide a DCC-Signal for programming and main track. A second short circuit detection for the internal booster with a seperate RailCom-Signal. To activate the interface you need to uncomment:
#define BOOSTER_INT
#define BOOSTER_INT_ON LOW
#define BOOSTER_INT_OFF HIGH

You can use a H-Bridge driver TLE5205 or equal like TLE5206-2. They can provide up to 5A. A discription you can find under Booster3. For the RailCom Output you must use the hardware of Booster3R.

Attention: The logic table of the Datasheet from the TLE5205 is different then the TLE5206!

internal Booster with Railcom

Soll eine Kurzschlusserkennung über den Messwiderstand (SENCE) erfolgen muss dies 'aktiviert' werden:
#BOOSTER_INT_CURRENT_SHORT_DETECT
Zur Anzeige der Stromaufnahme zum Beispiel in Rocrail über einen Messwiderstand (SENCE) muss im Sketch #define BOOSTER_INT_MAINCURRENT aktiviert werden.

Damit ist nun auch künftig möglich ist eine H-Brücke mit Kurzschlussdetection (zum Beispiel TLE5206-2 mit 5A) weiter zu nutzen kann der "SHORT2" über im Sketch mittels #define BOOSTER_INT_TLE5206 aktiviert werden. Im anderen Fall kann der "SHORT2" auch für die Kurzschlusserkennung eines externen CDE-Booster genutzt werden, dies ist mittels #define BOOSTER_EXT_CDE zu aktivieren.

Bei der Verwendung von einem Booster ohne Kurzschlusserkennung

(z.B. L6203 / L298n), muss diese mittels SENCE Widerstand erfolgen 
und im Sketch auch aktiviert sein!


Am Ausgang des Booster3R kann ein allgemeiner Railcom Detector angeschlossen werden. Über diesen können beim Programmieren mittels POM die CV-Daten von Dekodern auf dem Hauptgleis ausgelesen werden. Der RailCom Detector muss zwischen TLE Ausgang RAIL_1/RAIL_2 und dem Prog. Relais installiert werden. Bei der MEGA Variante wird "RAILCOM_RX" mit dem Serial3 Port verbunden. Ein Pull-Up von 100k kann für eine bessere RailCom Erkennung optional am Ausgang des UND installiert werden.

WiFi (WLAN Add-On)

ESP Arduino WiFi Modul
ESP Serial Anschluss (Eagle)

Für die WiFi-Kommunikation wird das ESP82660-01 Modul eingesetzt. Das ESP-Modul benötigt ein eigenes Sketch, welches im Downloadbereich heruntergeladen werden kann. Das ESP-Modul verbindet sich mittels Serial mit der Zentralen-MCU. Anschluss ESP8266 WLAN-Modul:

  • Arduino UNO = Serial (0,1) [oder über Software Serial (13,12)]
  • Arduino MEGA = Serial2 (16,17)
  • andere = Serial (0,1)

Die Kommunikation mit dem ESP erfolgt nicht mittels AT-Befehlen, sondern über ein modifiziertes Z21 LAN Protokoll mit Client-Erkennung (Sketch für ESP im Downloadbereich). Da das ESP-Modul mit 3,3Volt (ca. 200mA) arbeitet ist ein extra Spannungsregler und Pegelwandler auf dem WLAN-Interface zu installieren. Die zwei Taster auf dem Adapter im Bild, sind für das aufspielen des Sketch (Firmware-Update) und Reset beim ersten installieren des ESP-Moduls nötig. Programmiert wird das ESP wie ein Arduino, aus einer angepassten Arduino IDE heraus.
Für den Anschluss an der Zentrale können die auf dem Adapter installierten Taster und LED entfallen! Diese sind nur für die einmalige Programmierung notwendig. Um WLAN in der Zentrale zu aktivieren muss folgende Zeile einkommentiert werden: #define WIFI
Das ESP8266 stellt einen AcessPoint (AP) bereit. Über diesen kann mithilfe eines Webbrowser (http://192.168.0.111) die Standard-Einstellungen (SSID "Z21_ESP" und Passwort "12345678") und der WLAN Client-Betrieb (Client-Mode) an einem vorhandenen WLAN-Router konfiguriert werden. Wenn das S88-Interface genutzt wird, kann über das Webinterface auch die Modulanzahl angepasst werden.

Optional kann auch ein "WeMos D1 mini ESP8266" als fertiges Board für das WiFi-Interface genutzt werden.

Debugging (optional)

Um im Bedarfsfall interne Daten über den Serial Monitor überwachen zu können, gibt es dafür eine Debug-Ausgabe. Diese muss beim Arduino UNO und aktivem XpressNet oder WLAN komplett deaktiviert sein!
Aktiviert wird das Debugging mittels: #define Debug Serial
#define DebugBaud 115200 muss auch aktiviert werden und legt die Geschwindigekeit fest.
Einstellung welche Daten/Protokolle ausgegeben werden sollen:
#define DEBUG Ausgabe von Einstellungen und Softwareversion
#define REPORT Ausgabe der Zustände von S88 Rückmelder
#define LnDEB Ausgabe LocoNet Kommunikation
#define XnDEG Ausgabe XpressNet Kommunikation
#define Z21DEBUG Ausgabe Z21 Protokoll Kommunikation
#define Z21DATADEBUG Ausgabe RAW Daten des Z21 Protokoll
#define Z21SYSTEMDATADEBUG Regelmäßige Ausgabe der Systemwerte
#define DEBUG_WLAN_CONFIG Konfiguration des ESP8266 Interface mit IP-Adressen, SSID, Passwort, etc.
#define RCDEB RailCom RAW Daten werden ausgegeben.

Software

Die Software ist mit der Arduino IDE geschrieben.

Arduino Plug-In: Anpassung der Arduino IDE für die Funktion mit Sanguino oder ESP-Modul sind unter Arduino#Hardware beschrieben.

Das Sketch kann universal für den Arduino UNO [eingeschränkt], Arduino MEGA oder für den Sanguino Mikroprozessor ATmega1284p (ab Sw. v31) eingesetzt werden. (Übersicht Arduino Mikroprozessoren)
In dem Sketch ab der Softwareversion 3x sind alle Protokolle variable aktivierbar/deaktivierbar. Bitte nutzt die Sketch Version 4 oder höher, hier wurden viele Fehler beseitigt! Bitte ladet euch auch die jeweils letzte Version der Bibliotheken herunter, denn nur so ist die Software lauffähig!

Z21 WLAN Add-On Sketch

Diese Software ist für das WLAN Add-On basierend auf dem ESP8266 für die Arduino Z21 DCC Zentrale (Arduino NANO/UNO/MEGA version) notwendig. Sie muss in das ESP8266, mit Hilfe der Arduino IDE, hochgeladen werden. Die Software beinhaltet einen AJAX Webserver zur Konfiguration und die Option die S88-Modulanzahl zu ändern. Außerdem ist ein Reset Fall-back (Timeout) des Daten-Buffer für die Serial-Kommunikation zur Arduino Z21 DCC Zentrale implementiert. Zu beachten ist, dass es sich hierbei nur um das Sketch handelt welches für das WLAN-Modul notwendig ist, dies ist keine eigenständige Zentrale.
Info: Bei Konfigurationsänderungen am AccessPoint (AP) wird dieser beim Speichern automatisch neu gestartet - es erfolgt dadurch keine Rückmeldung oder Bestätigung des Speichervorgangs! Eine freie Kanalauswahl (1-13) für den AP ist nur möglich, wenn keine Client Verbindung besteht.

  • NEU v32: Übertragung des Client-IP-Hash zur Identifizierung der angemeldeten Clients
  • Fix v32: leere/falsche Darstellung der SSID und Passwort, wenn keine Daten im EEPROM vorhanden sind.
  • Fix v27: Akzeptiert jetzt auch eine SSID mit nur einem Zeichen.

Arduino Z21 DCC Zentrale Sketch

Änderungen:

  • v4.90: NEU: Temperatursensor mit DS18B20 möglich
  • v4.90: Fix: DCC RailCom Cutout Länge.
  • v4.90: NEU: Seriennummer ist die geladene Arduino Z21 Versionsnummer
  • v4.90: NEU: EEPROM wird beim Starten geprüft und beim RESET mit default Werten initialisiert.
  • v4.90: Fix Kommunikation mit WDP
  • v4.90: Fix Übertragung LocoNet Belegmerderdaten zur Z21-APP (09.04.2021)
  • v4.91: Fix LocoNet Daten Verarbeitung
  • v4.91: NEU Unterstützung ESP32 Plattform


Ältere Versionen können über Sourceforge heruntergeladen werden:

necessary libraries

Hier sind die notwendigen Bibliotheken aufgeführt. Nur damit ist das Sketch der DCC Zentrale lauffähig. Informationen wie ihr Bibliotheken installiert, findet ihr auf der Arduino Webseite (engl.).


Remedy

Note:
The software, circuits and layouts presented on this website can be used free for the private use,
commercial exploitation requires a written approval.
  1. The motorola format (MM) is not supported!
  2. S88N support up to 64 S88 device with 8 ports and raildata (DCC-signal) .
  3. up to 31 clients (Roco LokMaus2, Roco MultiMaus) can be connceted over XpressNet.
  4. support F0 to F8