ESP32 Command Station

Atani Dec 10, 2017

  1. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    I'm having a hard time figuring out what is causing this 'off' issue. I let the train run for 20 minutes without showing any signs of a problem, but then when I hit the emergency stop button it shows power off on the screen even after I used the throttle to bring the train back up to speed again. So I shut it all down and reset so the screen is showing power on, gave the train some speed and hit the emergency stop again, and now it continues to show power is on (which is correct) and I can't get it to fail again. Nothing weird showed on the serial console either, just the standard throttle commands. I'll keep playing with it, maybe it has to do with hitting the emergency stop after a period of time?
     
    Scott Eric Catalano likes this.
  2. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    Ok that sounds like maybe a stop is being sent on top of the stop loco commands. Will check this area as it could be missing an update on the web interface.

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

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Well here's one interesting thing that happened while I was outside... I left the loco running at low speed. Came back in and see on the serial console that the ESP has crashed and restarted itself, but the train is still running and the OLED still shows power is on. How did THAT happen??? I opened up the web interface and changed the speed of the loco, and it briefly sped up then I saw the OLED display reset and all power was cut.

    In case it is of any use to you, here's the crash log from where it restarted while I was outside...
    Code:
    CORRUPT HEAP: Bad head at 0x3ffe6b18. Expected 0xabba1234 got 0x00000000
    
    assertion "head != NULL" failed: file "/Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/heap/./multi_heap_poisoning.c", line 199, function: multi_heap_free
    
    abort() was called at PC 0x400e7aeb on core 1
    
    
    
    Backtrace: 0x40087e74:0x3ffe2140 0x40087f73:0x3ffe2160 0x400e7aeb:0x3ffe2180 0x40087b85:0x3ffe21b0 0x40083cde:0x3ffe21d0 0x40084261:0x3ffe21f0 0x4000bec7:0x3ffe2210 0x401220c5:0x3ffe2230 0x400d8c28:0x3ffe2250 0x401391eb:0x3ffe2270 0x400d9773:0x3ffe2290 0x400d9d53:0x3ffe22b0 0x400d9da8:0x3ffe22d0 0x400d9eec:0x3ffe22f0 0x400d9f2a:0x3ffe2330 0x400d9f39:0x3ffe2350 0x400ded72:0x3ffe2370 0x400defe9:0x3ffe23a0 0x400df113:0x3ffe23d0
    
    
    
    Rebooting...
     
    Scott Eric Catalano likes this.
  4. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    The backtrace you posted above would need to be decoded to be more useful. But, what it does show is that there was a heap exhaustion type of issue. Possibly a buffer overflow that overwrote something in the esp kernel.

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

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Hey Atani, I had a thought today... What about designating a pin for a physical emergency stop button? Make it so the feature is only active if you #define the pin number, and otherwise treat it the same as the button on the web interface. Tie the button to either ground or Vcc with a large resistor and call it good. I'm just thinking about it because I was looking at boxes to wrap everything up in and thought this could be really happen during actual operations.

    I'm also drawing out a schematic for using the Lolin OLED and BTS boards since there have been questions about pinouts and how to hook up the transistor to mirror the PWM signals. Were you ever able to get current sensing working on one of the L298N boards? I'd love to add that for a programming track, but I also have this separate current sense board that we talked about before which might be better for folks looking for a plug&play solution.
     
    Scott Eric Catalano likes this.
  6. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    This sounds like a great idea, something that could be done through a toggle switch like RUN / STOP or even a momentary button press to toggle it. It shouldn't be too difficult to trigger the power-off/on cycle when the pin changes either. If you can log this on github so it doesn't get lost.

    Great! This will be very helpful to include in the Wiki as well, if you can send it to me I will put it up there.

    I haven't had a chance to experiment with it yet, things have been quite busy lately and the board has not been a top priority yet. I do want to get it tested and figure out what modifications are needed for it to expose the CS pins that are present on the chip.

    An external board may be the best option and can be done using a few approaches really. The ACS712 board would work if you put it on the incoming current to the motor shield likely since it is pure DC power at that point. The CT boards would work on the DCC output lines but would require a bit of code to interpret the values.
     
    Scott Eric Catalano likes this.
  7. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Here's a preview of the schematic. I'm just laying it out by hand in gimp, need to confirm this matches my actual setup as I drew it out by memory yesterday, but it should be right. I want to include the panel meter as well, and I have a nice little module to convert the 16V source down to 5V @ 5A which will have its own panel meter. That will be handy for running other arduinos around the layout as DCC accessories. Once it is all laid out I'll tighten up the dimensions.
     
    Scott Eric Catalano and Atani like this.
  8. Texas Tim

    Texas Tim TrainBoard Member

    53
    52
    9
    @Atani

    Any suggestion what I can do from here? It seems the motor shield requires a 5V instead of the 3.3V.
     
    Scott Eric Catalano likes this.
  9. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    As long as the GND is common between the power supplies that should be fine. From the picture you posted previously there was no common GND for the boards.

    Do you have AREF connected to 1.1v?

    Try swapping SVN and SVP pins.

    It is possible the board is mismarked. Your board is not a devkit board and the pins are in different locations. We may find a few other oddities besides the missing 5v pin that is normally opposite the 3v3 pin where yours has VIN.

    Also capture the serial output as it will give some clues to the current sense issue.



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

    Shdwdrgn TrainBoard Member

    251
    182
    13
    I'm not familiar with the motor shield board, but if it requires a 5v source, will it respond properly to the lower logic signals from the ESP? Some boards are really sensitive about that.
     
    Scott Eric Catalano likes this.
  11. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    I got the current sense to work on my L298N board which looks similar to your ebay one. I lifted the end pins on the 298 chip and inserted two 3W 1.5 ohm resistors (one for each channel), then ran the current sense (A0/A1) connections to the junctions between the resistors and L298N. Has worked faultlessly for almost almost a year now. I only use a couple of N-gauge locos on my layout, so my current limit is set at around 800mA. It reads the CVs and programs the locos without any problems.

    (Please excuse the grim soldering!)
     

    Attached Files:

    Scott Eric Catalano and Atani like this.
  12. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    Yes it should the motor driver chip is listed as supporting the lower logic values. Since the lights come on now it is likely that it is functioning almost correctly.

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

    Texas Tim TrainBoard Member

    53
    52
    9

    Do I keep 1.1v to the AREF or should I increase since I switched from 3.3v to 5v now?
     
    Scott Eric Catalano likes this.
  14. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    Keep it at 1.1v. this is the analog voltage reference used by the chips to feed info back out on the current sense lines. You can try it at 3.3v but I don't know if that will have an effect on other parts.

    You can also try disconnecting the aref connection and try that as well.

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

    Texas Tim TrainBoard Member

    53
    52
    9
    Do I need to provide voltage to the IOREF of the motor shield
     
    Scott Eric Catalano likes this.
  16. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    I just checked both ioref and aref on my board. Ioref read as nearly 5v and aref 4v. So, try supplying 5v to both. My board doesn't feed the full 5v on it's pin due to a junk USB cable.

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

    Cymen TrainBoard Member

    10
    11
    7
    My second decoder arrived and I didn't burn it up yet! I've taken much more care this time to avoid a short. This decoder is a basic one from Digitrax but I have the same problem as before -- if I try to read a CV value, I get 255. The prior decoder was a LaisDCC and it did the same thing. I have the decoder on a Kato 11-103 but I used some jumpers to connect it to the programming track just in case it was due to a flakey connection between the wheels and the decoder. But that didn't make a difference. The first read or two, the locomotive does move forward just a tiny bit so I'm fairly certain the communication is happening -- at least a request is being ack'ed by the DCC decoder. It's just the response doesn't seem to be coming back properly. If I switch my test track to main, I am able to drive the locomotive under id 3 (default id).

    Is there something I might need to tweak to get programming read to work?
     
    Scott Eric Catalano likes this.
  18. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    Which motor shield are you using and how is it connected to the esp32?

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

    Cymen TrainBoard Member

    10
    11
    7
    I am using the Arduino motor shield (DeekRobot) and it's connected per post 156 in this thread. The only odd thing I have is I cut the end off of a USB cord so I could solder on some jumper cables to connect +5 and GND to the Arduino motor shield as well as still plug that USB connection into the ESP32 board (I have the Lolin32 lite which doesn't have 5v pin).
     
  20. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    Hmm, it sounds like the analog reading is not working as expected. The result of 255 is possibly a default value (-1 converted to unsigned). It may also b that the ack is being picked up for every bit (too sensitive) or none at all (not sensitive enough).

    In SignalGenerator.cpp is a method for reading the analog channel, it should be just above void readCV(). I don't remember if there is a logi() call or not but you could add one if there isn't to dump the raw analog return values before the method returns. It is possible there is a bug here but I am not sure.

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

Share This Page