ESP32 Command Station

Atani Dec 10, 2017

  1. Texas Tim

    Texas Tim TrainBoard Member

    53
    52
    9
    Mm. none of the 4 LEDs on the motor shield is ON when I turn the track power to ON.

    The serial port shows a lot of overcurrent. I have not connected to any track at the moment:

    Code:
    [I][MotorBoard.cpp:92] check(): [MAIN] Overcurrent cleared, 250 ms before re-enable
    [I][MotorBoard.cpp:92] check(): [PROG] Overcurrent cleared, 2750 ms before re-enable
    [I][MotorBoard.cpp:88] check(): [MAIN] Overcurrent cleared, enabling
    [I][MotorBoard.cpp:41] powerOn(): [MAIN] Enabling DCC Signal
    [I][MotorBoard.cpp:92] check(): [PROG] Overcurrent cleared, 2500 ms before re-enable
    [I][MotorBoard.cpp:92] check(): [PROG] Overcurrent cleared, 2250 ms before re-enable[/I][/I][/I][/I][/I][/I]
    
     
    Scott Eric Catalano likes this.
  2. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Sorry I've been away, dealing with a combination of ear and teeth problems, really been out of it but things are better now. I received the second BTS board earlier this week, and initial testing suggests that one current sense channel on the original board is in fact defective. I'm getting a current reading on both sides now so I'm up and running again...

    Once I had the new board in place I tried the light bulb test again. On my panel meter I'm seeing about 2.4A of draw from the automotive turn signal bulb. When using the DCC code the bulb immediately pushes the system into overload, despite being set up for a 5A max, so there could be some scaling differences between boards, however I did see you released an update of the code. I'll try pulling that this weekend and see if I can run the light bulb without tripping the overload. By my calculations (assuming the current sense is linear) a 2.4A load would only read about 289 on the ESP32, so there's not a lot of resolution within the usable scale on this board but it's not like this needs to be precises within a few milliamps.

    In other news, I decided to give up on getting an ATtiny to work with the servo board for now. It will definitely require rewriting some code, and for now I just want *something* working to verify that my base station is also operational. I pulled out another arduino nano board and soldered some header pins to it so I can pop it in a breadboard. Hopefully I'll have better luck here. :)
     
    Scott Eric Catalano likes this.
  3. Atani

    Atani TrainBoard Member

    1,469
    1,757
    37
    Can you post a picture and diagram of your wires? It sounds and looks like there is a short occurring somewhere between the ESP32 and the motor shield.

    That is great and unfortunate that you have a bad current sense on the first one. That explains some of the readings you observed.

    The update is merging the s88 branch to master and a few bug fixes. For the scaling lets try adjusting MotorBoard.cpp from:
    Code:
    adc1_config_channel_atten(_senseChannel, ADC_ATTEN_DB_0);
    
    to:
    Code:
    adc1_config_channel_atten(_senseChannel, ADC_ATTEN_DB_11);
    
    We can also try ADC_ATTEN_DB_6. If this fixes it for your board I will put out a new version with this being passed in as board specific.

    Yeah the math seems about right, the max for ~5A is ~476. It should be close enough to trigger if you go over ~5A at least.
     
    Scott Eric Catalano likes this.
  4. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    OK so if you're merging the two bits of code, can you provide the link for which code base is now the latest? I have a busy weekend scheduled, including a train show tomorrow, but I might be able to pull the code tonight and run a few light bulb tests with the atten values.
     
    Scott Eric Catalano likes this.
  5. Atani

    Atani TrainBoard Member

    1,469
    1,757
    37
    You can grab the latest release code here: https://github.com/atanisoft/DCCppESP32/releases/tag/v1.1.0. Future releases will be available from a similar page.
     
    Scott Eric Catalano likes this.
  6. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Getting the new code compiled now, but I've been meaning to ask you... is there something crazy you're doing with the web page code? I've noticed on my cell phone that it won't render with the default web browser but it does fine under chrome and firefox. I'm trying to set up my old phone to use for the train though and it will not render under firefox 46, and chrome cannot be loaded (the phone has android 2.3.6 on it so I'm rather limited). On the pages that won't load completely, the buttons for connect and track power never appear, nor does the speed dial. It looks like it's not loading the CSS for the page, but certainly firefox 46 ought to be new enough to handle even html5 content, so I don't understand why it's having this problem. Any thoughts?

    Cool, code has finished compiling, time to install and test it.
     
    Scott Eric Catalano likes this.
  7. Atani

    Atani TrainBoard Member

    1,469
    1,757
    37
    It sounds like it is not rendering the jQuery ui correctly on the phone. I have seen that happen but unsure of the cause entirely. I have a plan to rework the web interface a bit for the throttle but not sure yet on what to do.

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.
  8. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Ewwww JQuery! :) OK so that information present another question... is the JQuery base completely self-contained, or is it trying to load a library from the internet? My train network is essentially isolated (not completely, but close), so it likely wouldn't be able to pull any other code. If something else is required, could you point me to the appropriate part of the ESP code and I can store that bit on the raspberry pi for local reference?

    Got some more data... First off yes the light bulb still puts the main track into fault mode. I checked with my other code and the light bulb pulls about 2.35A, which reads around 1280 on the ESP, suggesting that the current sensor is in fact not linear (or at least working on a different scale than anticipated). I tried again with DB_11 and now we're looking much better! This time the panel meter read 2.22A and the ESP screen read 2.14A, so the value is very close and it didn't immediately fault out (I can only hold power on the bulb for 2-3 seconds because it gets hot fast). I'll leave that set for now, but I think that's going to be close enough that we can move on.

    Ah, one more thing I've been meaning to ask you about... What's it take to clear the display during the init? I tried to add oledDisplay.clear() and oledDisplay.display() to InfoScreen::init() right after setting the screen flip, but it didn't clear the screen even though this is exactly what I do in my bridge test code (which does clear the screen after flashing the code). Wouldn't normally be a problem because the screen is obviously cleared when you unplug it from power, but when I'm switching between different codes I end up with a lot of leftover garbage on the screen.
     
    Scott Eric Catalano likes this.
  9. Atani

    Atani TrainBoard Member

    1,469
    1,757
    37
    Yes it uses resources from the internet. That is something I want to fix with the rework. It will involve a few more files embedded in the code but that will solve another problem with SoftAP.

    You can see the required files in the top of index.html as references to css and js files.

    So it sounds like we need to tweak the attenuation for the BTS boards. I will put out an update with that included.

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.
  10. Atani

    Atani TrainBoard Member

    1,469
    1,757
    37
    As for the oled screen, there should be a reset method that might help.

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.
  11. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Hmm ok I'll look for the reset. It's weird because I didn't flip the screen for the bridge test code, so it displays upside-down from the DCC code... but when the DCC code starts up it seems to flip the existing display both vertically and horizontally, resulting in my previous text from the bottom-left being shown at the upper-right, but backwards.
     
    Scott Eric Catalano likes this.
  12. Atani

    Atani TrainBoard Member

    1,469
    1,757
    37
    try this:
    Code:
    oledDisplay.clear();
    oledDisplay.resetDisplay();
    
    That should clear everything on the screen and reset it back to the initial state. If that fails you can always try doing oledDisplay.end() followed by oledDisplay.init().
     
    Scott Eric Catalano likes this.
  13. Texas Tim

    Texas Tim TrainBoard Member

    53
    52
    9
    Here is a picture with my annotation of the wiring.
    esp32-motor-conn.jpeg
     
    Scott Eric Catalano likes this.
  14. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    So far no luck on properly clearing the display. I was playing with displayReset() last night until I noticed that it it already called from the end of init(). When I have more time I'm going to try isolating a demo into its own sketch and see how easily I can reproduce it. It almost seems like there might be a bug between the screen flips, creating fixed content that can't be erased. I'm not too worried about it though, it's just an extreme edge case that obviously won't effect most people after their code is uploaded.

    I grabbed a local copy of all the js and css to the raspberry pi last night and rewrote the URLs with a static IP address. That worked great and I can see the controls on the old phone now (although it still doesn't work within the stock browser) with one oddity... the speed dial now appears down below the throttle slider instead of the the right. If I select to receive the desktop version of the page, I get something in landscape mode where everything is positioned correctly. I see this on both phones, even though previously it showed correctly on the new phone. I used wget from the command line to grab all the files but it makes me wonder if any of hosts were detecting screen size and pulled a desktop version of a css instead of having all versions wrapped together? Well I can see the connect and power buttons on the old phone now so that's all I need to worry about until I get a loco ready to test.
     
    Scott Eric Catalano and Atani like this.
  15. Atani

    Atani TrainBoard Member

    1,469
    1,757
    37
    Your motor board connections are incomplete. I don't see GND, 3v3 or 5V connected. the AREF pin may also need to be connected but I don't see the pin on the esp32 to connect to, so check if this pin reads as zero v after connecting power pins. If so use a 1/3 voltage divider with 3v3 to supply 1.1v to AREF.

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.
  16. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Well this should be exciting... Picked up a SoundTraxx mobile decoder at the train show, going to slap that into an 0-6-0 I have here and give me something to test the base station against. Wish me luck!
     
    Scott Eric Catalano and Atani like this.
  17. Atani

    Atani TrainBoard Member

    1,469
    1,757
    37
    Sounds like a lot of fun! I have three sound decoders, one is sitting on my desk waiting to install still.

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.
  18. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Hmmm... Well it's obvious I know nothing about DCC. The directions say all the CVs are pre-programmed, so from the base web page how do I figure out what the address of this decoder is, and then how do i connect to it from the throttle on the base web page? And thanks for the help :)
     
    Scott Eric Catalano likes this.
  19. Texas Tim

    Texas Tim TrainBoard Member

    53
    52
    9
    I connected the 3.3v / GND from ESP32 to Motor shield and divided 3.3V to get 1.1V to AREF, I do not see the OVERCURRENT any more. However, the 4 LEDs on the motor shield still NOT ON when I turned on the track power.

    Thanks!
     
    Scott Eric Catalano likes this.
  20. Atani

    Atani TrainBoard Member

    1,469
    1,757
    37
    The default address is 3 typically. I don't know which CV off hand has the address but I want to say #1 is for the short address.

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.

Share This Page