ESP32 Command Station

Atani Dec 10, 2017

  1. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    I couldn't reproduce this specific case but I was able to reproduce a similar problem on the development branch. I'll be digging into it further today using an ESP32 DevKitC board (no motor shield or track needed for this so far) I'll have some sort of fix in a short bit hopefully for the development branch.
     
  2. JoshMurrah

    JoshMurrah TrainBoard Member

    54
    20
    4
    OK I'm gonna try out your Arduino build right now... thanks!

    In general, what's the ESP doing for DCC++ other than built in wifi and browser? Is there more under the hood?
     
  3. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    The ESP32 serves the same purpose as the Arduino does and then some. With the ESP32 there is more memory and CPU cycles to do a lot more.
     
  4. JoshMurrah

    JoshMurrah TrainBoard Member

    54
    20
    4
    FYI your Arduino build doesn't seem to work "out of the box" anymore for an Uno. Is there a quick config change I'm missing somewhere?

    Platformio and Arduino IDE both have the same error after changing the src/config.h to use serial and changing platformio's project file to 'uno'

    I'm trying to find where else I'm missing a config setting. It's a little confusing there's two folders, the base folder and the sub folder with some of the same files in each.

    src\CurrentMonitor.cpp:90:120: error: too many initializers for 'MotorBoard* [6]'
    MotorBoard *MotorBoardManager::boards[MAX_MOTOR_BOARDS] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
    ^
     
  5. JoshMurrah

    JoshMurrah TrainBoard Member

    54
    20
    4
    I should be able to fully operate the ESP32 and JMRI without the shield right? I need to revisit. Maybe the project file has something in it that I need to adjust.

    Seems that there aren't a lot of motor control breakout boards out there... I need to run two districts and a program. I It would seem it'd be most cost effective if I operated two shields jumpered rather than stacked right? It'd look "tidy-est" if I was able to run three MC33926 single drivers, but there's no knockoffs available and it's a bit expensive to buy them straight from Pololu. Most of the other cheap drivers don't have current sense.
     
  6. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    change this line to:
    Code:
    MotorBoard *MotorBoardManager::boards[MAX_MOTOR_BOARDS] = { NULL, NULL, NULL, NULL, NULL, NULL };
    
    I'll push a commit shortly to fix this.

    Some sort of shield or motor board is required. But yes, just the ESP32, JMRI and motor boards should be sufficient to run the entire layout.

    Cost wise, I would suggest the Pololu devices. There are a couple options that should work flawlessly:
    https://www.pololu.com/product/2997 (single)
    https://www.pololu.com/product/2520 (dual)
    Both of these are pin compatible and should be fine to run as either standalone or as a shield. Pin mappings (untested):
    GND -> GND
    VCC -> 5V
    MOTORBOARD_ENABLE_PIN_MAIN / GPIO 25 -> EN
    MOTORBOARD_ENABLE_PIN_MAIN / GPIO 25 -> NPN + PNP -> PWM1/PWM2
    DCC_SIGNAL_PIN_OPERATIONS / GPIO 19 -> NPN + PNP (for signal split)
    MOTORBOARD_CURRENT_SENSE_MAIN / GPIO 36 (SVP) -> OCM
    OUT1/OUT2 -> TRACK

    That is solvable *IF* the board uses the right chip. It usually will require just a resistor and a bit of wire to create a jumper. There are a few examples here.
     
  7. JoshMurrah

    JoshMurrah TrainBoard Member

    54
    20
    4
    Yeah I see what you mean, the chip itself has it but the pinout isn't there.

    I really dig that Pololu TB9051 single/dual driver, looks like it has a resetting over-current duty as a failsafe... am I understanding it correctly that the two PWM pins handle direction as well? Makes the wire/jumpering easy.

    I'm gonna go try the mod to get the uno working. I'm on a learning curve here, it sounds like the Uno could handle three timers / three drivers max?
     
  8. JoshMurrah

    JoshMurrah TrainBoard Member

    54
    20
    4
    PlatformIO still borks the UNO... I get a good upload, but the serial outputs a few garbage characters and doesn't respond otherwise.

    I'm gonna see if I have a spare Mega to flash.
     
  9. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    Check serial baud rate. Sounds like it is not right

    Sent from my ONEPLUS A5010 using Tapatalk
     
  10. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    You don't need more timers to support more districts. The operations signal is generated once and shared across all districts (except prog).

    To add extra districts you just need an analog sense line and an enable pin. The signal is common.

    The two PWM pins on the TB9051 board controls the two output pins. The direction pin on the arduino base station simply directs which of the PWM pins on that board the PWM pin on the arduino should connect to. You would need to use a transistor to split the signal so that based on direction you connect the enable (same as PWM) to the two PWM inputs.

    Sent from my ONEPLUS A5010 using Tapatalk
     
  11. JoshMurrah

    JoshMurrah TrainBoard Member

    54
    20
    4
    OK, that makes sense on the districts... don't need to generate again.

    I'll have to ponder on the Pololu more. I'm not there yet anyway, I am still trying to get one of your builds up and running.

    On the Uno upload, the terminal is at 9600 but I don't know what the upload is happening at I couldn't find a setting for it.

    I'm trying the ESP32 again right now.
     
  12. JoshMurrah

    JoshMurrah TrainBoard Member

    54
    20
    4
    Still same thing on the development branch I get the cpu panic and reboots. the master still has that index.html_h error.

    The only build that may still work for me is a mega, I haven't found a workable one (I'm bad about burning the power management on mine, 3D printers, don't ask).
     
  13. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    I'm able to reproduce the odd crash and it seems tied to something in the WiFiClient code for the esp32. I haven't figured it out fully yet but I have narrowed it down to that area and I have been trying a few things to see if I can find a suitable workaround. So far no luck in getting it sorted out other than it appearing to be a bug in arduino-esp32 code.

    As far as master, the index html piece requires a fix still, I'll need to pull the latest and test again and merge a fix of some sort. You can grab the index html l file from GitHub under the release list and drop that in your source tree and that should be fine. But you may hit the see issue that we both see on the development branch. If you skip using jmri it may work for a bit though.

    Sent from my ONEPLUS A5010 using Tapatalk
     
  14. JoshMurrah

    JoshMurrah TrainBoard Member

    54
    20
    4
    the mega had similar results. As a safety check, I did go to Arduino IDE using Gregg's old build and it did fine.

    I think the base-station issues I'm having this may more come down to platformio or visual studio code issues because I'm no good with it.

    I'll see if I can use the esp master with the imported file, gonna try that next.
     
    Atani likes this.
  15. JoshMurrah

    JoshMurrah TrainBoard Member

    54
    20
    4
    OK, I did get the master built and uploaded, but the serial output is garbled, and was later not able to get the html interface to operate right.
     
    Atani likes this.
  16. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    Output on serial being broken is the baud rate being wrong. Set it to 115200 and it may work.

    Sent from my ONEPLUS A5010 using Tapatalk
     
  17. JoshMurrah

    JoshMurrah TrainBoard Member

    54
    20
    4
    Where in Visual Studio Code do I set that? I tried finding it but failed. The terminal task defaults to 9600.
     
  18. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    I'm not sure myself. I'm just trying it out there day for the first time.

    Sent from my ONEPLUS A5010 using Tapatalk
     
  19. JoshMurrah

    JoshMurrah TrainBoard Member

    54
    20
    4
    I found it, it's set in the .ini file... all it did was slow my upload haha.

    Here's a sample...

    > Executing task in folder DCCppESP32-master: C:\Users\Joshua\.platformio\penv\Scripts\platformio.exe device monitor <

    --- Miniterm on COM3 9600,8,N,1 ---
    --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
    AS␂g␂5��␓#�␗␙��ӑ/D�D�r���)�̽
    ␂�␘H���␁␜0@���␙�␐��=<��@�␘J���␌�␐���
    ␄=␛@HD
    ␄=␛@H��
    H�L␎9�␌)9L␎9�␌)9��
    H�L␎9�␌)9��
    H�L␎�!J���L␎9�␌)9��
    HB9)␘L�9�␌)9��
    Ȑ��Ȑ�)1�␄��␌␑1��N␘��␎␙���␐�)1���␎�N!␎��!��� ␄�H
    ���L␐�!ߌ!␐�!J␀H␆L�0 �LΜ��1N@Lڐ␀�N�N!�1���Ȉ!���␄=��ތ�␄␌N�N!��N␐�F
    ␀�␁�
     
  20. JoshMurrah

    JoshMurrah TrainBoard Member

    54
    20
    4
    The browser seems to sort of work, I can turn on track power and get DCC base power OK... but I don't see a place to select a locomotive other than the radio buttons with addresses on right, which have about six random sets of numbers (there's only one loco on the track).
     

Share This Page