A simple question: DCC-EX + ESP8266?

Erik84750 Nov 18, 2023

  1. Erik84750

    Erik84750 TrainBoard Member

    307
    109
    12
    How can DCC-EX be compiled for ESP8266?
     
  2. Sumner

    Sumner TrainBoard Member

    2,585
    4,933
    62
    Don't take this as a definitive answer as I just and found it (HERE ) .......

    'Can you use ESP8266 with Arduino?

    The ESP8266 is a low-cost WiFi module built by Espressif Systems. Its popularity has been growing among the hardware community thanks to it's nice features and stability, to the point that it can be easily programmed using your Arduino IDE.'

    So with that in mind might be possible but I'd check with them on Discord.

    [​IMG]

    I used something similar in building the $50 DCC WiTcontroller throttle above, a LOLIN32 ESP32 Lite. I just followed Peter Akers of EngineDriver fame instructions that I've got posted on my site here...

    https://1fatgmc.com/RailRoad/DCC/WiTcontroller-Index.html

    Sumner
     
    RCMan and sidney like this.
  3. FlightRisk

    FlightRisk TrainBoard Member

    542
    228
    13
    No, but we already ported it to the ESP32. The ESP8266 does not have the hardware to generate the DCC signal correctly. It is also discontinued. It will probably be around for a while since they made so many, but better to use it. You can make a great command station out of an ESPDuino32 board ($3-$8) and a motor shield like our EX-MotorShield8874. We are working on something new, but to use that board, you have to add a resistor and make another change. Start here and read through to the instructions for the ESPDuino if that interests you. We will have this available soon in our store for those wanting it already modded and flashed. https://dcc-ex.com/reference/hardware/microcontrollers/microcontrollers.html#espressif-esp32-series
     
  4. Erik84750

    Erik84750 TrainBoard Member

    307
    109
    12
    And what might those hardware issues be?

    I am interested to know since a simple AVR can do the job of generating DCC signals correctly?

    If I understand this article correctly then a UNO-formfactor board with an ESP32 onboard can be used to compile and download DCC-EX?
     
  5. FlightRisk

    FlightRisk TrainBoard Member

    542
    228
    13
    The DCC-EX team has a pretty frustrating relationship with Expressif. Apparently AI-Thinker, one of their biggest clients, and who writes their own firmware based on the Expressif code (you often see their name in a bootup log or on the chips), feels the same way and have abandoned them to use Bouffalo Labs BL616/618 hardware instead. And no plans for us to look at that yet with the ESP32-WROOM and STM32 Nucleo hardware we already use.

    Among other things, the ESP8266 cannot generate a DCC signal because of the way it handles interrupts. They use soft interrupts which means that when anything they think is a higher priority like handling a WiFi interrupt or doing garbage collection, it completely stops everything else. Even on the ESP32, some of which have 2 cores, both processors are interrupted! So the only way to generate DCC is a trick to use another piece of hardware on some ESP32s called "RMT". It is a remote control transceiver circuit with hardware and firmware designed to be used for infrared transmitters and receivers in remote controlled devices (TVs, remotes, LED lighting, etc.). We can send instructions to that hardware to generate DCC from main processor. ESP8266 boards do not have RMT, ergo, can't generate DCC.

    A "simple AVR" has hardware timers and interrupts, and even though they are a hodge-podge of bit depth and pins they are attached to, we luck out that they are connected to the right pins on a standard motorshield. Additionally, since the processor is so fast relative to the DCC signal frequency, and the AVRs do not block timer interrupts, we can also generate DCC on most of the other pins (there is a bit of jitter so we call using the recommended pins "High Accuracy" mode). Newer processors like the STM32 pretty much let you configure any pin for any function which if freeing!

    Important to note, there are many confusing iterations of ESP32s, all with different hardware features. We only support the ESP32-WROOM. For whatever reason we can't fathom, most of the other versions of the ESP32, like the ESP32-C3, cripple the RMT hardware by reducing the number and configuration of RMT "channels" (memory buffers). Since DCC packets have to be sent as data, rather than just generating pulses as we can do on other processors, the memory of most of the ESP32 RMT devices are too small to handle the larger DCC packets.

    So yes, the ESPDuino32 board with some minor modifications work great. We are working more and more on our own hardware due to the issues with a lot of the cheap hardware from China. Many of you may already know about the "Wangtongze" board that was cloned by someone in China and made with misspelled words and the wrong level shifting transistors. It works, but not without modifications. The same holds for the ESPDuino32 boards. The people who made them incorrectly connected the IORef pin to 5V rather than IORef which would be used by other boards to tell if they are connected to a 5V or 3.3V device. They also have an issue with the voltage on IO0 and you can't use the A0 and A1 pins we normally use because they are taken up by WiFi functions. So there are 3 small, and simple, changes to make to use them with a Motor Shield and make a command station. Those are listed on the website link in the previous post.

    You can't see the ESPDuino32 on the bottom, but this is a 3D printed mount, ESPDuino32, and the EX-MotorShield8874 (in purple since it is the one sold in Australia), along with a small I2C OLED display. You need to bend out a pin if using the Arduino MotorShield or modify a solder pad jumper on the bottom of the EX-MotorShield8874:

    upload_2023-11-22_10-6-24.png
     
    rcmodeler likes this.

Share This Page