b891c124000526b3fc8106bbf628f500c2d1f86c
HW 364A ESP8266 DCC Command Station with XpressNet
This is a minimal HW 364A ESP8266 project for a DCC Command Station using the LM18200 motor driver, now with XpressNet support for communication with throttles and other XpressNet devices.
Structure
src/main.cpp: Main application entry pointsrc/DCC.cpp/src/DCC.h: DCC signal generation and handlingsrc/XpressNet.cpp/src/XpressNet.h: XpressNet protocol interface (stubs)src/WiFiManagerHelper.cpp/src/WiFiManagerHelper.h: WiFiManager-based configuration
Getting Started
- Open the project in PlatformIO or Arduino IDE.
- Select the HW 364A ESP8266 as your target board.
- Connect the LM18200 and XpressNet bus to the HW 364A ESP8266 as per your hardware setup.
- Build and upload to your HW 364A ESP8266 board.
- On first boot, connect to the WiFi AP named
DCC-CommandStationto configure your WiFi credentials using the captive portal.
Notes
- Wire the LM18200 motor driver to the ESP32 according to your motor control and DCC output requirements. Refer to the LM18200 datasheet for correct pinout and power handling.
- Use of included display
- This is a minimal template. You must implement the DCC signal generation logic for your hardware.
- XpressNet protocol functions are provided as stubs for further development.
- WiFiManager is used for easy WiFi configuration by the user.
Hardware Compatibility: HW 364A ESP8266
This project is designed for the HW 364A ESP8266 board. Ensure you select this board in PlatformIO or Arduino IDE for correct pin mapping and features.
Connecting the LM18200 Motor Driver
The LM18200 is used to drive the DCC signal to the track. For RailCom cutout, you must implement a hardware or software cut-off during the RailCom window.
Basic Wiring:
- IN1/IN2: Connect to ESP8266 GPIOs for DCC signal generation (e.g., GPIO 5 and GPIO 4).
- PWM: Connect to a PWM-capable GPIO if needed for DCC modulation.
- VCC/GND: Connect to your power supply and ground.
- OUT1/OUT2: Connect to the track.
- RailCom Cutout:
- To implement RailCom cutout, use a MOSFET or relay to disconnect the track output during the RailCom window. Control the MOSFET/relay from an ESP8266 GPIO.
- Alternatively, use a dedicated circuit to blank the DCC signal during the cutout period.
Example RailCom Cutout Circuit:
ESP8266 GPIO ----> MOSFET Gate
MOSFET Drain ----> Track Output
MOSFET Source ---> GND
- Set the GPIO HIGH to enable track power, LOW to cut off for RailCom.
XpressNet Bus
- Connect the XpressNet bus (RS485 or TTL UART) to the ESP8266 UART pins.
- Use a level shifter if required for voltage compatibility.
Display
- Use an I2C OLED display (e.g., SSD1306).
- Connect SDA to GPIO 14 (D6), SCL to GPIO 12 (D5) as per sample code.
Software Features
- DCC signal generation (implement in DCC.cpp)
- RailCom cutout support (add cutout logic in DCC routines)
- XpressNet protocol (see xpressnet.md for commands and custom extensions)
- WiFi configuration via captive portal
- Optional XpressNet over IP (WebSocket)
References
- LM18200 Datasheet
- HW 364A ESP8266 Pinout
- RailCom Protocol Overview
- XpressNet Protocol
For further details, see xpressnet.md and source files.
Description
Languages
HTML
50.9%
C++
29.8%
JavaScript
11.9%
C
6.2%
CSS
1.2%