Giter Club home page Giter Club logo

atanisoft / esp32commandstation Goto Github PK

View Code? Open in Web Editor NEW
90.0 24.0 33.0 46.71 MB

An ESP32 based DCC Command Station with integrated OpenLCB (LCC) --- NOTE: this project is not under active development.

Home Page: https://atanisoft.github.io/ESP32CommandStation/

License: GNU General Public License v3.0

HTML 4.53% C 5.90% C++ 85.91% CMake 1.16% Assembly 0.51% JavaScript 1.74% Dockerfile 0.06% Shell 0.18%
dcc esp32 command-station model-railroad openlcb lcc

esp32commandstation's Introduction

Project Status

This project is currently not under active development and is unlikely to return to active development anytime soon.

What is ESP32 Command Station

ESP32 Command Station is an open-source hardware and software OpenLCB enabled Command Station for the operation of DCC decoder equipped model railroads.

The ESP32 Command Station consists of an ESP32 module with up to two h-bridge devices to generate the DCC signal for the tracks. Note that only one h-bridge will be enabled at any given time, it is not possible to use both OPS and PROG tracks simultaneously. It is also possible to disable either the OPS or PROG track output entirely via configuration settings.

Support for the following add-ons is available:

  1. CAN transceiver (MCP2551 or SN65HVD23X) for LCC CAN connectivity.
  2. OLED or LCD display for command station status.
  3. Addressable RGB LEDs for visual status indicators.

Documentation can be found here.

Build Status Contributors Stars License

-Jan 11, 2024

esp32commandstation's People

Contributors

atanisoft avatar cymen avatar dtworth avatar jrob3rts avatar sarusso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp32commandstation's Issues

mDNS service publish not working

mDNS service publish and discovery appears to not be working as expected:

[WiFi] IP address is 10.0.0.76, starting hub (if enabled) and uplink.
[httpd] Starting HTTP listener on port 80
[mDNS] Advertising _http._tcp:80.
Listening on port 80, fd 48
[HUB] Starting TCP/IP listener on port 12021
Listening on port 12021, fd 49
[mDNS] Advertising _openlcb-can._tcp:12021.
[mDNS] mdns_service_add(_http._tcp:80): ESP_FAIL.
[WiFi] Starting JMRI listener
[mDNS] Advertising _esp32cs._tcp:2560.
[mDNS] Advertising _http._tcp:80.
Listening on port 2560, fd 50
[mDNS] mdns_service_add(_esp32cs._tcp:2560): ESP_OK.
[Nextion] Display of page 2 was not successful.
[mDNS] mdns_service_add(_openlcb-can._tcp:12021): ESP_OK.
[mDNS] mdns_service_add(_http._tcp:80): ESP_OK.

from rPi:

pi@RPi-JMRI:~/openmrn $ avahi-browse -a -t -k
+  wlan0 IPv6 _openlcb-can._tcp                             _openlcb-can._tcp    local
+  wlan0 IPv4 _openlcb-can._tcp                             _openlcb-can._tcp    local
+  wlan0 IPv6 RPI-JMRI                                      _device-info._tcp    local
+  wlan0 IPv4 RPI-JMRI                                      _device-info._tcp    local
+  wlan0 IPv6 RPI-JMRI                                      _smb._tcp            local
+  wlan0 IPv4 RPI-JMRI                                      _smb._tcp            local

Latest master with ESP-IDF v4.1 - ldgen fails to create esp-idf/esp32/ld/esp32.project.ld

Got another error:

[7/32] Generating ld/esp32.project.ld
FAILED: esp-idf/esp32/ld/esp32.project.ld
cd /mnt/r/CODE/ESP32CommandStation/build/esp-idf/esp32 && /home/user/esp/espressif/python_env/idf4.1_py3.7_env/bin/python /home/user/esp/esp-idf/tools/ldgen/ldgen.py --config /mnt/r/CODE/ESP32CommandStation/sdkconfig --fragments /home/user/esp/esp-idf/components/xtensa/linker.lf   /home/user/esp/esp-idf/components/esp_ringbuf/linker.lf /home/user/esp/esp-idf/components/spi_flash/linker.lf     /home/user/esp/esp-idf/components/espcoredump/linker.lf /home/user/esp/esp-idf/components/esp32/linker.lf       /home/user/esp/esp-idf/components/esp32/ld/esp32_fragments.lf     /home/user/esp/esp-idf/components/soc/linker.lf /home/user/esp/esp-idf/components/esp_event/linker.lf   /home/user/esp/esp-idf/components/esp_wifi/linker.lf      /home/user/esp/esp-idf/components/lwip/linker.lf        /home/user/esp/esp-idf/components/log/linker.lf /home/user/esp/esp-idf/components/heap/linker.lf  /home/user/esp/esp-idf/components/freertos/linker.lf    /home/user/esp/esp-idf/components/newlib/newlib.lf      /home/user/esp/esp-idf/components/app_trace/linker.lf     /home/user/esp/esp-idf/components/esp_gdbstub/linker.lf --input /home/user/esp/esp-idf/components/esp32/ld/esp32.project.ld.in --output /mnt/r/CODE/ESP32CommandStation/build/esp-idf/esp32/ld/esp32.project.ld --kconfig /home/user/esp/esp-idf/Kconfig --env-file /mnt/r/CODE/ESP32CommandStation/build/config.env --libraries-file /mnt/r/CODE/ESP32CommandStation/build/ldgen_libraries --objdump /home/user/esp/espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-objdump
Traceback (most recent call last):
  File "/home/user/esp/esp-idf/tools/ldgen/ldgen.py", line 158, in <module>
    main()

  File "/home/user/esp/esp-idf/tools/ldgen/ldgen.py", line 134, in main
    mapping_rules = generation_model.generate_rules(sections_infos)

  File "/home/user/esp/esp-idf/tools/ldgen/generation.py", line 352, in generate_rules
    self._create_exclusions(mapping_rules, default_rules, sections_infos)

  File "/home/user/esp/esp-idf/tools/ldgen/generation.py", line 451, in _create_exclusions
    general_rule.add_exclusion(specific_rule, sections_info)

  File "/home/user/esp/esp-idf/tools/ldgen/generation.py", line 100, in add_exclusion
    expansions = do_section_expansion(self, section)

  File "/home/user/esp/esp-idf/tools/ldgen/generation.py", line 84, in do_section_expansion
    expansions = fnmatch.filter(sections_in_obj, section)

  File "/usr/lib/python3.7/fnmatch.py", line 55, in filter
    for name in names:

TypeError: 'NoneType' object is not iterable
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

This seems to relate to espressif/esp-idf#5734 but I kinda agree with m-bruck - why compile a driver in, for something that's not being used. ¯\(ツ)

CONFIG_LWIP_IRAM_OPTIMIZATION is enabled for ESP32CS build.

Expose Radio TXpower under WiFi Configuration option to limit the SoftAP range

In most use cases there is no reason to broadcast the SoftAP beyond the limits of one's layout (I really don't need my neighbourhood to see it).

For that purpose, TXpower option of the ESP32's WiFi Radio should be exposed, and be user adjustable, to allow the direct control (in dbM) of the transmitted power, thus limiting the SoftAP range.

Add ability to disable compiling OPS and/or PROG support, to gain more free pins

There are use cases when the station will not be performing OPS and/or PROG e.g. CS on a larger layout where PROG is elsewhere (on the bench); PROG on the bench away from the layout where OPS is not needed, etc.

Disabling one, or both, frees a considerable number of pins that could be used for other purposes, such as sensors or outputs.

DCC MP1 turnouts not working

Hi,
sorry but I am wondering what's needed in order to make turnouts work?

I am using these devices: http://www.fucik.name/masinky/MP1/
but it seems no matter what I do the device doesn't try to switch the motor in the MTB MP1 machine.

I have been successfully using these devices with https://github.com/DccPlusPlus/BaseStation previously but now that I've switched over to ESP32CommandStation this doesn't work.

And it seems to make no difference if I try to switch the switches with the web based version of ESP32CommandStation or through JMRI.

I would appreciate any thought on this, thank you.

Integration of LocoNet

Request
to integrate LocoNet in the system. There are already several LocoNet shields (Arduino footprint) available and also the necessary sketches for operating points and accessories.

DCC signal not symmetric

Dear @atanisoft , you have done a lovely job, but I have ran into a strange issue.
I started off on the master branch of your repo, and notices that my DCC locos only responded to DCC commands when put on the tracks in one direction. This lead me to believe there is some assymetry in the code.

I created a small testing board on an ESP8266 that counts the DCC one and zero bit high and low times, and was surprised to see that the signal is indeed not symmetric. I then set up ESP IDF and compiled your latest development branch, only to see the same thing happen.

Here is the tester code: https://gist.github.com/Beherith/9d090f64437d6ca721a76e70a097a664

The output after jamming into excel looks like the following:
image

The above error happens on every DCC packet.

I have an ESP32 board and an arduino motor shield doing the driving.

Add fallback to SoftAP when SSID connection fails

When the SSID connection fails the CS will default to rebooting after approximately 3 minutes. It would be better if the CS would instead switch to SoftAP mode so the user can correct/test the configuration.

Unable to connect to WiFi AP (203 - ASSOC_FAIL)

I keep getting:
Reason: 203 - ASSOC_FAIL
...and on and on retrying to connect with that error.

My AP is MAC locked, and I did add ESP32's MAC address into it. Does this actually pose a problem or the issue is somewhere else?

It would also be nice if the serial log displayed the MAC address for such occasions. I had to hack it in myself in the DCCppESP32.cpp :)

Cannot build (No module named 'cStringIO')

Hi,

Since an autoupdate of something within PlatformIO, i can no longer build ESP32 Command Station. No matter what version.

The building stops with this error;
ModuleNotFoundError: No module named 'cStringIO':

Downgrading python, c++, platformio or platformio core does not solve the issue.

DCC broken in latest master 53c9bd8 and at least after 3c42798

I spent the whole evening troubleshooting my hardware thinking something I broke in the mean time. Turns out the software is broken.

I went back to 3c42798 (last commit of Aug 30) and DCC is actually working, compiled with ESP-IDF v4.0.1.

The culprit is probably those serial LEDs which need to go and be replaced with simple single colour ones. As-is they take valuable resources on the ESP32, and for what, fancy lights?!

There's really no reason for fancy lights, if the basic functionality suffers. Personally I feel DCC and Railcom+ are more important than colourful lights, so I propose the following:

  1. Use pin 22 for WiFi LED only,
  2. Power LED should come off of the DC input,
  3. OPS and PROG LEDs should come directly off of the OPS and PROG outputs.

Thanks.

Wi-Fi missing BTS7960B wiring and capabilities

Hi,

I've been following this since the last update I posted to the Halted screen. Due to work etc, I never finished the build for my son however I am keen to finish this soon.

I believe the IBT_2 Will handle a greater currently than the standard shield so keen to give that a go but I'm lost without some kind of help connecting this to the ESP32.

Any help would be great.

DCC Signal->OPS->Railcom UART selection is ambiguous

When enabling Railcom, an option is presented to select a Railcom UART: UART1 or UART2.

This is rather ambiguous because UART1 is already reserved to provide optional output on pins 5 and 16 via J3, as per the current ESP32CS schematic.

I believe there should not be an option to select UART (or default to UART2), unless UART1 could be shared somehow between Railcom and the UART1 header J3.

WebUI: Document web endpoints

Currently only a handful of the endpoints have comments in the code to indicate the expected behavior, this needs to be extended to all other endpoints and document the json payloads.

AP creation when not at 'home' network

Request
to let the ESP create her own Access Point when it can't connect to the in config.h defined network after, say, 5 or 10 tries. This seems to me very useful if you want to take the layout to a show/exhibition. The SSID and password should be configurable.

Display motor shield status on InfoScreen

Currently the InfoScreen shows the base station version, IP address, websocket client count, track power status. It would be useful to show the motor shield utilization as well.

GPIO0 does not get saved

It looks like the line "if(sensor->getPin() > 0) {" was added to "SensorManager::store()" . Maybe it should be "if(sensor->getPin() >= 0) {" since GPIO0 is a valid port.

IDF v4.1: CS crashes during init of status LEDs

17:08:48.433 -> ESP32 Command Station v1.5.0 (v1.5.0-alpha3-13-g1e4fb03) starting up...
17:08:48.440 -> Compiled on Sep 3 2020 11:21:47 using IDF v4.1
17:08:48.440 -> Running from: ota_0
17:08:48.487 -> ESP32 Command Station uses the OpenMRN library
17:08:48.487 -> Copyright (c) 2019-2020, OpenMRN
17:08:48.487 -> All rights reserved.
17:08:48.487 -> [NVS] Initializing NVS
17:08:48.487 -> [TimeZone] EST5EDT
17:08:48.487 -> [ADC] Configure 12-bit ADC resolution
17:08:48.535 -> [FS] SD card 'SD32G' mounted, max capacity 29832.00 MB
17:08:48.568 -> [FS] SD FAT usage: 0.34/29820.00 MB
17:08:48.568 -> [FS] SD will be used for persistent storage.
17:08:48.568 -> [FS] Dumping content of filesystem: /cfg
17:08:48.568 -> [FS] /cfg/TEST.TXT (154 bytes) mtime: Sat Jan 1 01:00:00 2000
17:08:48.568 -> [FS] /cfg/ESP32CS/wifi-sta (24 bytes) mtime: Wed Dec 31 19:05:16 1980
17:08:48.568 -> [FS] /cfg/ESP32CS/trains.json (216 bytes) mtime: Wed Dec 31 19:03:00 1980
17:08:48.568 -> [FS] /cfg/ESP32CS/wifi-ap (15 bytes) mtime: Wed Dec 31 19:07:24 1980
17:08:48.615 -> [FS] /cfg/LCC/cdi.xml (5574 bytes) mtime: Wed Dec 31 19:00:06 1980
17:08:48.615 -> [FS] /cfg/LCC/config (450 bytes) mtime: Wed Dec 31 19:06:50 1980
17:08:48.615 -> [FS] /cfg/LCC/train.xml (5406 bytes) mtime: Wed Dec 31 19:00:06 1980
17:08:48.615 -> [FS] /cfg/LCC/tmptrain.xml (2593 bytes) mtime: Wed Dec 31 19:00:06 1980
17:08:48.615 -> [LCC] Initializing Stack (node-id: 50101013900)
17:08:48.615 -> [LCC] Enabling CAN interface (rx: 27, tx: 32)
17:08:48.662 -> [WiFi] Starting WiFiManager
17:08:48.662 -> [Turnout] Initializing DCC Turnout database
17:08:48.662 -> [FS] /cfg/ESP32CS/turnouts.json does not exist, returning blank json object
17:08:48.662 -> [Turnout] Loaded 0 DCC turnout(s)
17:08:48.662 -> [Track] Registering /dev/track VFS interface
17:08:48.662 -> [RailCom] Initializing detector using UART 2
17:08:48.662 -> [RailCom] Configuring hardware timer (0:0)...
17:08:48.662 -> [OPS] Configuring H-Bridge (LMD18200 3000 mA max) using ADC 1:0
17:08:48.662 -> [OPS] Short limit 3686/4096 (2699.71 mA), events (on: 0, off: 0)
17:08:48.708 -> [OPS] Shutdown limit 4080/4096 (2988.28 mA), events (on: 0, off: 0)
17:08:48.708 -> [PROG] Configuring H-Bridge (L298 2000 mA max) using ADC 1:3
17:08:48.708 -> [PROG] Short limit 512/4096 (250.00 mA), events (on: 0, off: 0)
17:08:48.708 -> [PROG] Shutdown limit 1024/4096 (500.00 mA), events (on: 0, off: 0)
17:08:48.708 -> [PROG] Prog ACK: 122/4096 (59.57 mA)
17:08:48.708 -> [Track] Registering LCC EventConsumer for Track Power (On:10000000000fffe, Off:10000000000ffff)
17:08:48.708 -> [OPS] DCC config: zero: 96uS, one: 58uS, preamble-bits: 16, wave: high, low
17:08:48.708 -> [eStop] Registering emergency stop handler (On: 10000000000fffd, Off:10000000000fffc)
17:08:48.754 -> [OPS] signal pin: 17, RMT(ch:0,mem:73[2],clk-div:80,clk-src:APB)
17:08:48.754 -> [Track] Connecting track interface (track:OPS, fd:0)
17:08:48.754 -> [OPS] Starting signal generator
17:08:48.754 -> [Track] Connecting track interface (track:PROG, fd:3)
17:08:48.754 -> [PROG] DCC config: zero: 96uS, one: 58uS, preamble-bits: 22, wave: high, low
17:08:48.754 -> [PROG] signal pin: 19, RMT(ch:3,mem:79[2],clk-div:80,clk-src:APB)
17:08:48.754 -> [CDI] Checking /cfg/LCC/cdi.xml...
17:08:48.754 -> [PROG] Starting signal generator
17:08:48.754 -> [CDI] File /cfg/LCC/cdi.xml appears up-to-date (len 5574 vs 5574)
17:08:48.801 -> [CDI] Registering CDI with stack...
17:08:48.801 -> [LCC] Config file opened using fd:6
17:08:48.801 -> [LCC] Creating automatic fsync(6) calls every 10 seconds.
17:08:48.801 -> [CDI] Checking /cfg/LCC/train.xml...
17:08:48.801 -> [CDI] File /cfg/LCC/train.xml appears up-to-date (len 5406 vs 5406)
17:08:48.801 -> [CDI] Checking /cfg/LCC/tmptrain.xml...
17:08:48.848 -> [CDI] File /cfg/LCC/tmptrain.xml appears up-to-date (len 2593 vs 2593)
17:08:48.848 -> [TrainDB] Initializing...
17:08:48.848 -> [TrainDB] Registering 5903 - 5903 (idle: On, limited: Off)
17:08:48.848 -> [TrainDB] Found 1 persistent roster entries.
17:08:48.848 ->
17:08:48.848 ->
17:08:48.848 -> ESP32 Command Station Startup complete!
17:08:48.848 ->
17:08:48.848 -> [Status] Initializing LEDs (color-mode:RGB, protocol:RMT(6)-APA106, pin: 22, brightness: 128)
17:08:50.641 -> Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0)
17:08:50.641 -> Core 0 register dump:
17:08:50.641 -> PC : 0x40082664 PS : 0x00050034 A0 : 0x401a9dc9 A1 : 0x3ffb0690
17:08:50.688 -> A2 : 0x00000000 A3 : 0x00000040 A4 : 0x00080000 A5 : 0x3ffb0670
17:08:50.688 -> A6 : 0x00000101 A7 : 0x3ff6e000 A8 : 0x00005c84 A9 : 0x40088378
17:08:50.688 -> A10 : 0x00017030 A11 : 0x00000180 A12 : 0x3ffdcf88 A13 : 0x00000000
17:08:50.688 -> A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000001a EXCCAUSE: 0x00000005
17:08:50.688 -> EXCVADDR: 0x00000000 LBEG : 0x40101ced LEND : 0x40101d00 LCOUNT : 0x00000000
17:08:50.688 -> Core 0 was running in ISR context:
17:08:50.688 -> EPC1 : 0x401a9dd2 EPC2 : 0x401a9dc9 EPC3 : 0x00000000 EPC4 : 0x40082664
17:08:50.734 ->
17:08:50.734 -> ELF file SHA256: 733616ca23d49ef5
17:08:50.734 ->
17:08:50.734 -> Backtrace: 0x40082661:0x3ffb0690 0x401a9dc6:0x3ffbf150 0x40138dee:0x3ffbf170 0x40102195:0x3ffbf1c0 0x401023b5:0x3ffbf1f0 0x4011a555:0x3ffbf240 0x4011a361:0x3ffbf270 0x400da209:0x3ffbf2a0 0x400d375b:0x3ffbfc30
17:08:50.734 ->
17:08:50.734 -> Core 1 register dump:
17:08:50.734 -> PC : 0x401aa006 PS : 0x00060534 A0 : 0x800d488c A1 : 0x3ffc0b10
17:08:50.734 -> A2 : 0x00000000 A3 : 0x00000001 A4 : 0x800891a2 A5 : 0x3ffb0c40
17:08:50.734 -> A6 : 0x00000003 A7 : 0x00060623 A8 : 0x800d43da A9 : 0x3ffc0ae0
17:08:50.775 -> A10 : 0x00000000 A11 : 0x00000000 A12 : 0x800f419d A13 : 0x3ffb0bf0
17:08:50.775 -> A14 : 0x00020f01 A15 : 0x00060023 SAR : 0x00000000 EXCCAUSE: 0x00000005
17:08:50.775 -> EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
17:08:50.775 ->
17:08:50.775 -> ELF file SHA256: 733616ca23d49ef5
17:08:50.775 ->
17:08:50.775 -> Backtrace: 0x401aa003:0x3ffc0b10 0x400d4889:0x3ffc0b30 0x4008974c:0x3ffc0b50
17:08:50.775 ->
17:08:50.775 -> Rebooting...

document building with Arduino IDE

Currently the code is only built and tested using the Platform IO IDE. Instructions will need to be provided for using Arduino IDE as an option for users.

IDF master: crash due to task_wdt (unknown cause)

This backtrace has been observed at least once and needs further debugging

[mDNS] Advertising _esp32cs._tcp:2560.
E (6414) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
Core  0 register dump:
PC      : 0x4008aa29  PS      : 0x00060033  A0      : 0x80159361  A1      : 0x3ffb0800  
A2      : 0xff4c03da  A3      : 0x00000068  A4      : 0x0000000c  A5      : 0xffffffff  
A6      : 0x00000000  A7      : 0xfffffff7  A8      : 0x8000814b  A9      : 0x3ffb0770  
A10     : 0xff4c03da  A11     : 0x3f45110a  A12     : 0x3ffb073f  A13     : 0x00000034  
A14     : 0x00000000  A15     : 0x3ffb0745  SAR     : 0x00000004  EXCCAUSE: 0x0000001c  
EXCVADDR: 0xff4c0422  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  

Backtrace:0x4008aa26:0x3ffb0800 0x4015935e:0x3ffb0820 0x400828c1:0x3ffb0840 0x401ab92f:0x3ffc0640 0x400d8641:0x3ffc0660 0x40089acc:0x3ffc0680
0x4008aa26: xTaskGetAffinity at esp-idf-master/components/freertos/tasks.c:3702 (discriminator 1)
0x4015935e: task_wdt_isr at esp-idf-master/components/esp_common/src/task_wdt.c:166
0x400828c1: _xt_lowint1 at esp-idf-master/components/freertos/xtensa/xtensa_vectors.S:1105
0x401ab92f: esp_pm_impl_waiti at esp-idf-master/components/esp32/pm_esp32.c:484
0x400d8641: esp_vApplicationIdleHook at esp-idf-master/components/esp_common/src/freertos_hooks.c:63
0x40089acc: prvIdleTask at esp-idf-master/components/freertos/tasks.c:3385

WebUI: Upload of loco images

Feature request to allow users to upload pictures of their locos for the web interface. The image would be used in addition to custom names to help identify which locomotive the throttle is currently attached to.

Problem to compile.

Hello
What is the used Version of ESPAsyncWebServer ?
Cause compiler Errors

Thanks

Left/Right pins instead of Enable/Direction pins

I'm using an H bridge motor controller: https://www.robotshop.com/en/l298-dual-h-bridge-dc-motor-controller.html

I am currently controlling it with an ESP32, and I'm just doing old school (DC?) PWM output on the left track or the right.

The motor controller I have doesn't have enable/direction though, it has 4 pins, two for each track, one pin for each side. It looks like in signalGeneratorPulseTimer and signalGeneratorDirectionTimer, you are digitalWrite'ing to the directionPin, and in MotorBoard, you're setting the enable pin.

What do you think about abstracting that functionality to be compatible with other motor controllers like mine? I'm hoping to avoid #ifdefs. Maybe I should just start with a branch, finding the edits I need first, and then we can work on abstraction.

Add pictures of supported motor shields to webpage

Currently the webpage only lists supported motor shields but without pictures, in the case of the L298 boards there are multiple variants available and not usable without modifications (red PCB with vertical L298 lacks current sense)

Pololu MC33926

Is there any information on connecting the Pololu MC33926 to the ESP32 for DCC++?

Thank you in advance.

Loco Function are not working

When trying to activate decoder functions in either the web interface or JMRI; nothing happens.
No response from decoder, no activity in serial monitor.
JMRI DCC++ traffic monitor shows correct command when function button is pressed.

Tested with: arduino motor shield, ESP32 devkit1, 15V psu, ESU loksound 4

Config_MotorBoard.h configured like this:
`// MAIN TRACK MOTORBOARD NAME
#define MOTORBOARD_NAME_OPS "OPS"
// MAIN TRACK NOTORBOARD ENABLED PIN
#define MOTORBOARD_ENABLE_PIN_OPS 27
// MAIN TRACK MOTORBOARD CURRENT SENSE ADC PIN
#define MOTORBOARD_CURRENT_SENSE_OPS ADC1_CHANNEL_5
// MAIN TRACK MOTORBOARD MOTOR_BOARD_TYPE
#define MOTORBOARD_TYPE_OPS ARDUINO_SHIELD

// PROG TRACK MOTORBOARD NAME
#define MOTORBOARD_NAME_PROG "PROG"
// PROG TRACK NOTORBOARD ENABLED PIN
#define MOTORBOARD_ENABLE_PIN_PROG 25
// PROG TRACK MOTORBOARD CURRENT SENSE ADC PIN
#define MOTORBOARD_CURRENT_SENSE_PROG ADC1_CHANNEL_4
// PROG TRACK MOTORBOARD MOTOR_BOARD_TYPE
#define MOTORBOARD_TYPE_PROG ARDUINO_SHIELD

/////////////////////////////////////////////////////////////////////////////////////
//
// DEFINE WHICH PINS ARE USED FOR DCC SIGNAL GENERATION
//
// OPERATIONS TRACK DCC SIGNAL PIN
#define DCC_SIGNAL_PIN_OPERATIONS 14

// PROGRAMMING TRACK DCC SIGNAL PIN
#define DCC_SIGNAL_PIN_PROGRAMMING 26

/////////////////////////////////////////////////////////////////////////////////////
//
// DEFINE THE CURRENT SENSE ATTENUATION. THIS IS USED BY THE ADC SYSTEM TO SCALE
// THE CURRENT SENSE VALUES BASED ON THE MOTOR SHIELD.
//
// SUPPORTED VALUES: ADC_ATTEN_DB_11, ADC_ATTEN_DB_6, ADC_ATTEN_DB_2_5, ADC_ATTEN_DB_0
//
// IF LEFT UNDEFINED ADC_ATTEN_DB_11 WILL BE USED.

#define ADC_CURRENT_ATTENUATION ADC_ATTEN_DB_6

/////////////////////////////////////////////////////////////////////////////////////`

Intermittent errno=128 from TCP/IP connections

Incoming connection from 10.0.0.221, fd 53.
Incoming connection from 10.0.0.221, fd 53.
[WS 10.0.0.221/53] Connected
[WebSocket fd:53] read-error (128: Socket is not connected), disconnecting (recv)
[WS 10.0.0.221/53] Disconnected

It is not clear why the socket ends up in this state even though the browser indicates that it is still connected and reconnects a second time and remains connected.

Crash when powering on track

ESP32CommandStation crashes when powering on the track. No train is on the track.
ESP32 Uno board with aliexpress arduino motorboard shield

stack:

0x4014e4e9: sys_sem_signal at C:\Users\....\.platformio\packages\framework-espidf\components\lwip\port\esp32\freertos/sys_arch.c:203
0x40150b46: lwip_netconn_do_getaddr at C:\Users\...\.platformio\packages\framework-espidf\components\lwip\lwip\src\api/api_msg.c:1925 (discriminator 6)     
0x40141812: tcpip_thread at C:\Users\....\.platformio\packages\framework-espidf\components\lwip\lwip\src\api/tcpip.c:483
0x4008c2e9: vPortTaskWrapper at C:\Users\...\.platformio\packages\framework-espidf\components\freertos/port.c:403

RailCom Detector alloc failure

Observed once, needs further investigation. Possibly shift from alloc on-demand to alloc from limited pool.

Backtrace: 0x401280ab:0x3ffb0b40 0x400f936e:0x3ffb0b70 0x400f93e7:0x3ffb0b90 0x400faf32:0x3ffb0bc0 0x400faf3d:0x3ffb0bf0 0x400f684a:0x3ffb0c10 0x40083765:0x3ffb0c30 0x40081c39:0x3ffb0c70 0x40082b3d:0x3ffb0c90 0x401a5a47:0x3ffc0dd0 0x400d4a55:0x3ffc0df0 0x40097acc:0x3ffc0e10
0x401280ab: DynamicPool::alloc_untyped(unsigned int, Executable*) at ESP32CommandStation/build/../components/OpenMRNLite/src/utils/Buffer.cpp:112

0x400f936e: void Pool::alloc<HubContainer<StructContainer<dcc::Feedback> > >(Buffer<HubContainer<StructContainer<dcc::Feedback> > >**, Executable*) at ESP32CommandStation/build/../components/OpenMRNLite/src/utils/Buffer.hxx:295
0x400f93e7: esp32cs::Esp32RailComDriver<esp32cs::RailComHW>::set_feedback_key(unsigned int) at ESP32CommandStation/build/../components/OpenMRNLite/src/executor/StateFlow.hxx:1139
 (inlined by) esp32cs::Esp32RailComDriver<esp32cs::RailComHW>::set_feedback_key(unsigned int) at ESP32CommandStation/build/../components/DCCSignalGenerator/private_include/Esp32RailComDriver.h:159
0x400faf32: esp32cs::RMTTrackDevice::encode_next_packet() at ESP32CommandStation/build/../components/DCCSignalGenerator/RMTTrackDevice.cpp:445
0x400faf3d: esp32cs::RMTTrackDevice::rmt_transmit_complete() at ESP32CommandStation/build/../components/DCCSignalGenerator/RMTTrackDevice.cpp:348
0x400f684a: esp32cs::rmt_tx_callback(rmt_channel_t, void*) at ESP32CommandStation/build/../components/DCCSignalGenerator/DCCSignalVFS.cpp:327
0x40083765: rmt_driver_isr_default at esp-idf/components/driver/rmt.c:588
0x40081c39: shared_intr_isr at esp-idf/components/esp32/intr_alloc.c:505
0x40082b3d: _xt_lowint1 at esp-idf/components/freertos/xtensa_vectors.S:1153
0x401a5a47: esp_pm_impl_waiti at esp-idf/components/esp32/pm_esp32.c:484
0x400d4a55: esp_vApplicationIdleHook at esp-idf/components/esp_common/src/freertos_hooks.c:63
0x40097acc: prvIdleTask at esp-idf/components/freertos/tasks.c:3382

Disabling legacy DCC++ support throws an error

I thought I could disable the legacy DCC++ support, but I got this error:

../components/JmriInterface/JmriInterface.cpp: In lambda function:
../components/JmriInterface/JmriInterface.cpp:37:28: error: 'CONFIG_JMRI_LISTENER_PORT' was not declared in this scope
         new SocketListener(CONFIG_JMRI_LISTENER_PORT,
                            ^~~~~~~~~~~~~~~~~~~~~~~~~
../components/JmriInterface/JmriInterface.cpp:37:28: note: suggested alternative: 'CONFIG_FMB_TIMER_GROUP'
         new SocketListener(CONFIG_JMRI_LISTENER_PORT,
                            ^~~~~~~~~~~~~~~~~~~~~~~~~
                            CONFIG_FMB_TIMER_GROUP
../components/JmriInterface/JmriInterface.cpp:50:9: error: 'CONFIG_JMRI_MDNS_SERVICE_NAME' was not declared in this scope
         CONFIG_JMRI_MDNS_SERVICE_NAME, CONFIG_JMRI_LISTENER_PORT);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../components/JmriInterface/JmriInterface.cpp:50:9: note: suggested alternative: 'CONFIG_MDNS_MAX_SERVICES'
         CONFIG_JMRI_MDNS_SERVICE_NAME, CONFIG_JMRI_LISTENER_PORT);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         CONFIG_MDNS_MAX_SERVICES
../components/JmriInterface/JmriInterface.cpp: In lambda function:
../components/JmriInterface/JmriInterface.cpp:59:9: error: 'CONFIG_JMRI_MDNS_SERVICE_NAME' was not declared in this scope
         CONFIG_JMRI_MDNS_SERVICE_NAME);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../components/JmriInterface/JmriInterface.cpp:59:9: note: suggested alternative: 'CONFIG_MDNS_MAX_SERVICES'
         CONFIG_JMRI_MDNS_SERVICE_NAME);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         CONFIG_MDNS_MAX_SERVICES
[34/112] Building CXX object esp-idf/main/CMakeFiles/__idf_main.dir/ESP32CommandStation.cpp.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

Exposure of LCC fast-clock

This is a future request to make the LCC fast-clock available as a JSON output. Once that is enabled we can show syncronized layout time from the web UI on multiple devices.

Enabling Railcom without increasing Preamble Bits > 11 throws an error during menuconfig re-entry

I'm setup using WSL2 (Debian) with ESP-IDF environment, in Win10. Right now I'm just playing with it...

When I do idf.py menuconfig most of the time I can get into the menu and change settings.

The first time I loaded the menuconfig, I enabled the Railcom and set the RAILCOM-EN pin to 12, as per the ESP32CS schematics.

I did not change OPS PREAMBLE BITS, so they stayed at 11 (didn't know about that/missed the config).

I tried to build and I got an error about Preamble Bits needing to be at least 16.

I thought sure, I'll go back to menuconfig and fix it. Turns out, menuconfig won't load because it checks for the Preamble Bits and Railcom Enabled, and triggers an error. So, it's a Catch-22, a circular error.

I edited the sdkconfig manually and changed CONFIG_OPS_DCC_PREAMBLE_BITS=16 then went back to try and build.

This time build failed with on RAILCOM-EN pin

Make Error at CMakeLists.txt:259 (message):
  OPS RailCom enable pin should not use GPIO 0-3, 5, 12, 15.  These are reserved pins.

Obviously something's not right, because the schematic says it's pin 12, so either the reserved pins need to be updated, or the schematic needs to.

Building and installing with Visual Studio

Hi Mike, I'm getting back into this after a long break. I think this is the right repository now, I see that others have been obsoleted. However, I see the documentation, and a how to build, but it doesn't actually tell how to actually do this with with VSCode. I use VSCode for Particle, but for the ESP32, I seem to be striking out. I was wondering if you might update the git pages sections to indicate how to build and how to flash using VSCode. I'll keep working on it myself in the meantime, but it would be nice to round out that portion of the documentation.

Intermittent crash when "node reboot" is received from JMRI

abort() was called at PC 0x40198f4f on core 1
Backtrace:0x40088b4e:0x3ffeb970 0x400891e5:0x3ffeb990 0x4008fd39:0x3ffeb9b0 0x40198f4f:0x3ffeba30 0x4011d6f5:0x3ffeba60 0x4011d74d:0x3ffeba80 0x400f7a55:0x3ffebab0 0x400ebce3:0x3ffebae0 0x401287b7:0x3ffebb00
0x40088b4e: panic_abort at esp-idf-master/components/esp_system/panic.c:360
0x400891e5: esp_system_abort at esp-idf-master/components/esp_system/system_api.c:104
0x4008fd39: abort at esp-idf-master/components/newlib/abort.c:46
0x40198f4f: __assert_func at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/stdlib/assert.c:62 (discriminator 8)
0x4011d6f5: ActiveTimers::remove_locked(Timer*) at ESP32CommandStation/build/../components/OpenMRNLite/src/executor/Timer.cpp:168
0x4011d74d: ActiveTimers::update_timer(Timer*) at ESP32CommandStation/build/../components/OpenMRNLite/src/executor/Timer.cpp:177
0x400f7a55: esp32cs::shutdown_dcc_vfs() at ESP32CommandStation/build/../components/OpenMRNLite/src/executor/Timer.hxx:236
 (inlined by) ?? at ESP32CommandStation/build/../components/OpenMRNLite/src/executor/Timer.hxx:242
 (inlined by) ?? at ESP32CommandStation/build/../components/OpenMRNLite/src/openlcb/RefreshLoop.hxx:79
 (inlined by) esp32cs::shutdown_dcc_vfs() at ESP32CommandStation/build/../components/DCCSignalGenerator/DCCSignalVFS.cpp:478
0x400ebce3: node_reboot at ESP32CommandStation/build/../main/OpenMRNEsp32Overrides.cpp:38
0x401287b7: os_thread_start at ESP32CommandStation/build/../components/OpenMRNLite/src/os/os.c:391

Compile failed with CONFIG_OPS_RAILCOM_BRAKE_PIN undeclared

[929/992] Building CXX object esp-idf/DCCSignalGenerator/CMakeFiles/__idf_DCCSignalGenerator.dir/DCCSignalVFS.cpp.obj FAILED: esp-idf/DCCSignalGenerator/CMakeFiles/__idf_DCCSignalGenerator.dir/DCCSignalVFS.cpp.obj /home/user/esp/espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++ -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -Iconfig <SNIPPED LONG SECTION> -I/home/user/esp/esp-idf/components/sdmmc/include -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -nostdlib -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Os -freorder-blocks -fstack-protector -std=c++14 -D_GNU_SOURCE -DIDF_VER=\"v4.0.1-412-g820621687\" -DGCC_NOT_5_2_0 -DESP_PLATFORM -D_GLIBCXX_USE_C99 -DESP32 -DLOCKED_LOGGING -Wno-ignored-qualifiers -MD -MT esp-idf/DCCSignalGenerator/CMakeFiles/__idf_DCCSignalGenerator.dir/DCCSignalVFS.cpp.obj -MF esp-idf/DCCSignalGenerator/CMakeFiles/__idf_DCCSignalGenerator.dir/DCCSignalVFS.cpp.obj.d -o esp-idf/DCCSignalGenerator/CMakeFiles/__idf_DCCSignalGenerator.dir/DCCSignalVFS.cpp.obj -c ../components/DCCSignalGenerator/DCCSignalVFS.cpp In file included from ../components/DCCSignalGenerator/DCCSignalVFS.cpp:32: ../components/DCCSignalGenerator/DCCSignalVFS.cpp:66:49: error: 'CONFIG_OPS_RAILCOM_BRAKE_PIN' was not declared in this scope GPIO_PIN(OPS_HBRIDGE_BRAKE, GpioOutputSafeHigh, CONFIG_OPS_RAILCOM_BRAKE_PIN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../components/OpenMRNLite/src/freertos_drivers/esp32/Esp32Gpio.hxx:413:55: note: in definition of macro 'GPIO_PIN' static const gpio_num_t PIN_NUM = (gpio_num_t)NUM; \ ^~~ ../components/DCCSignalGenerator/DCCSignalVFS.cpp:66:49: note: suggested alternative: 'CONFIG_OPS_RAILCOM_ENABLE_PIN' GPIO_PIN(OPS_HBRIDGE_BRAKE, GpioOutputSafeHigh, CONFIG_OPS_RAILCOM_BRAKE_PIN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../components/OpenMRNLite/src/freertos_drivers/esp32/Esp32Gpio.hxx:413:55: note: in definition of macro 'GPIO_PIN' static const gpio_num_t PIN_NUM = (gpio_num_t)NUM; \ ^~~ In file included from ../components/DCCSignalGenerator/DCCSignalVFS.cpp:32: ../components/OpenMRNLite/src/freertos_drivers/esp32/Esp32Gpio.hxx: In instantiation of 'struct GpioOutputPin<esp32cs::OPS_HBRIDGE_BRAKEDefs, true, false>': ../components/OpenMRNLite/src/freertos_drivers/esp32/Esp32Gpio.hxx:241:8: required from 'struct GpioOutputSafeHigh<esp32cs::OPS_HBRIDGE_BRAKEDefs>' ../components/DCCSignalGenerator/DCCSignalVFS.cpp:101:13: required from here ../components/OpenMRNLite/src/freertos_drivers/esp32/Esp32Gpio.hxx:163:27: error: non-constant condition for static assertion static_assert(PIN_NUM < 34, "Pins 34 and above can not be used as output."); ~~~~~~~~^~~~

There is no OPS_RAILCOM_BRAKE pin - this should be OPS_BRAKE (pin 26 in ESP32CS schematic) and only when using LMD18200T for OPS output. In all other cases, this pin should be free for other uses as it is only used by LMD18200T.

IDF v4.2/v4.3: SD card fails to mount using SPI

[TimeZone] UTC0
[ADC] Configure 12-bit ADC resolution
E (749) vfs_fat_sdmmc: slot init failed (0x103).
[FS] SD Card not present or mounting failed, using SPIFFS
[FS] SPIFFS usage: 18.63/757.66 KiB
[FS] SPIFFS will be used for persistent storage.

Bogus currents values reported (dived by 1000)

First of all I would thank you for this great project, it's really a nice way to learn an play with DCC and the ESP32.

I'm however facing an issue with current readings/reportings.

Setup

  • WeMos D1 R32
  • Deek-Robot Motorshield (L298P, Arduino clone), A0 to A4 and A1 to A5, brake and VIN pins cut
  • IDF 4.1
  • Commit c52c483
  • Pretty standard setup:
    • GPIO input and sensors disabled (CONFIG_GPIO_OUTPUTS and CONFIG_GPIO_SENSORS), I'm not using them
    • SSID mode
    • SNTP enabled and TZ to Europe/Rome
    • No LEDs, nothing else
  • Power comes from a 16V 5 Amps laptop power adapter (so it's pretty stable)

Issues

OPS is working fine, I can command my DCC engines (H0n3, H0n30 and 0n30), however I always get [OPS] 0 mA / 2000 mA even when there's a load (engine on track running); shortages are properly spotted: [OPS] Shutdown threshold breached 2.00 mA (raw: 4095 / 4080), but only 2.00 mA are reported instead of 2000 mA.

Digging into the code I've found the following:

float getUsage()
{
if (state_ != STATE_OFF)
{
return ((lastReading_ * maxMilliAmps_) / 4096.0f);
}
return 0.0f;
}

That formula actually returns a value that looks reasonable for mA, i.e. ((50 * 2000) / 4096 = 24)

However, when getUsage() is called, the value returned is dived by 1000, like if it was returning Amps and not mA, i.e.:

lastReport_ = esp_timer_get_time();
LOG(INFO, "[%s] %6.0f mA / %d mA", name_.c_str(), getUsage() / 1000.0f
, maxMilliAmps_);

As a quick and dirty test I've changed getUsage() to return A and not mA (multiplying by 1000, so I can change only one point in the code) and now returned values do make sense:

return ((lastReading_ * maxMilliAmps_) / 4096.0f * 1000.0f);

I get back

[OPS]      7 mA / 2000 mA     # (15 * 2000 / 4096=      7) 
[OPS] Shutdown threshold breached 1999.51 mA (raw: 4095 / 4080)

Is this a bug or it's a peculiarity of my setup (maybe the L298)? I'm also unable to read CV on PROG, not sure if this could be related or it's a different issue.

As a reference the same Shield works fine (readings too) with an Arduino Uno R3 and the BaseStation-EX (via JMRI).

Reconfigure wifi

Hi there, I'm trying to get this built and running for the first time. I configured the wrong wifi SSN (the 5.8 ghz one instead of the 2.4 ghz one) and flashed it to my device. I figure this out quickly, and I've reconfigured it, but it continues to try to connect the 5.8 ghz SSN. That is, the changes to the wifi configuration don't seem to be taking effect. I've done a idf.py fullclean, etc., but nothing seems to be taking effect.

Any suggestions? I'm brand new to ESP32, so it's certainly possible I'm doing it wrong. Thanks for any suggestions!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.