ESP32 Command Station

Atani Dec 10, 2017

  1. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    Sounds like something else is missing. When you setup the shield, did you cut the VIN trace on the back side?

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

    Cymen TrainBoard Member

    10
    11
    7
    Are you definitely connected in the web client (as in, the connected toggle shows connected -- it's not just being on the web page)? I was confused yesterday when I was trying to turn the track off and on after rebooting the ESP32 but it wouldn't turn on the lights. Then I realized I could toggle the track on/off without actually being connected in the web ui to the ESP32 web server. So go back to the main tab and make sure you're connected. It would be great if the toggle for powering on the track was disabled if the web client is in the not connected state. I'd be happy to contribute to the web client if that is of interest (my day job is basically frontend JavaScript web application development).

    If that was obvious, my apologies but I found it confusing.

    3 minutes later, I did something stupid and burned up my first DCC decoder (a short, nothing to do with this project) so now I'm waiting for another one (well, two as I learnt that lesson). I'm glad the basic questions are coming up here as I have the same ones. This project is my first experience with DCC :). Very happy so far!
     
    Last edited: Feb 18, 2018
    Scott Eric Catalano and Atani like this.
  3. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    Cymen, feel free to take a pass at the web UI. I am open to contributions for all areas.

    Also clicking the track power should toggle the connect if not connected today. At least it used to unless I broke it.

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano and Cymen like this.
  4. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    @Atani -- So is there something I should be able to do from the web interface? For example I know there's the radio buttons down below for 123, 456, etc. I tried clicking 123 and setting the throttle but nothing happened. I did verify with my meter that the DCC decoder is receiving track voltage but there is no DC output present on the two motor pins of the board. I thought I had seen something at one point which would tell me what addresses had registered themselves with the base station, but now I can't seem to find that bit of info. Would that help me here at all? Sorry, like I said, really clueless about DCC.

    @Texas Tim -- You didn't mention it, but did you use the web interface to connect and then turn on track power? Do you have an multimeter that will read AC voltages? When I measure across my track outputs I see around 3VAC (because my meter is cheap and doesn't measure true AC), but it's enough to tell me that the voltage is getting sent out. Also check to make you do NOT have a DC voltage present across your rails. If you don't have a meter for AC, you could also place a diode bridge across the rails and see if that provides you with a DC output. This will probably be around 1.5V less than your power supply. With my setup, my power supply is providing about 16.4V, and after the diode bridge I am measuring 15V. That will tell you for certain that the full voltage is being applied to the rails.
     
    Scott Eric Catalano likes this.
  5. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    From the web interface you can go to the base station tab and then to the programmer to read CVs from the decoder to confirm behaviors etc. You can also check that it is set to a certain address.

    Also you can double click the locomotive numbers on the throttle to enter a new number.

    I had planned to setup a roster system on the base station and have the loco pull numbers from there instead of the current hard code.

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

    Shdwdrgn TrainBoard Member

    251
    182
    13
    IT'S ALIVE! I found the page on DCC++ commands and telneted into the base. Played around with a few things and then found the command to directly set the throttle. After entering <t 1 03 64 1> the loco is successfully making circles! So that proves the new decoder is actually receiving from the base station (and I hooked it up right), now to figure out why it doesn't work from the html throttle.
     
    Scott Eric Catalano and Atani like this.
  7. Texas Tim

    Texas Tim TrainBoard Member

    53
    52
    9
    yes. the web page show "connected", the OLED display showed WS Clients: 01, and TRACK POWER: ON. and MAIN: NORMAL / PROG: NORMAL.

    Serial port monitor showed:
    Code:
    [I][MotorBoard.cpp:41] powerOn(): [MAIN] Enabling DCC Signal
    [I][MotorBoard.cpp:41] powerOn(): [PROG] Enabling DCC Signal
    

     
    Scott Eric Catalano likes this.
  8. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    And even more progress... Now that I have a tiny clue of what I'm doing, I was watching the commands being sent from the web interface and noticed the throttle commands were calling for loco numbers 123, 456, etc. I found the line in the web interface where the numbers are defined and changed the first one to 03, and now it works from my cell phone. This has definitely been a progressive evening!
     
    Scott Eric Catalano and Atani like this.
  9. Texas Tim

    Texas Tim TrainBoard Member

    53
    52
    9
    yeap. click on track power will toggle the connect. I normally, clicked on connect first prior to turn on track power.
     
    Scott Eric Catalano and Atani like this.
  10. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Hey Atani, got a bug for you! I noticed that after running the train around for awhile, the display on the ESP tells me that track power is off, and both MAIN and PROG are also off... which is funny because the train is still going around in circles and responding to throttle changes.
     
    Scott Eric Catalano likes this.
  11. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    Most likely it is just wrong loco number in the web UI. Double click (tap?) one of the loco slots and it should bring up a dialog to enter a new loco number. If that fails edit the html and reflash to have it default with a new loco.

    The new design I was going to implement was to add a new button for "select loco" to add a new one to the list and send an idle packet to the base station to allocate it upon selection. I would also have a "release loco" button to drop the loco from the up and send a shutdown packet of some sort to the base station so it would send a stop packet and discard references to it for updates until selected again. Kinda similar to LocoNet approach.

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

    Atani TrainBoard Member

    1,469
    1,756
    37
    If you can capture the serial console I can review it and see if I can figure out why it is doing that. If the display says power is off the enable pin should be off as well. The dcc signal is still sent out on the pins so it is possible the enable pin logic is not right for the BTS7960 connections.

    Are you using the enable pin to power the BTS or is it connected to it at all?

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

    Atani TrainBoard Member

    1,469
    1,756
    37
    Great, I thought it was still working but wasn't 100%. Thanks for checking and letting me know!

    Ok yeah we need to make this a bit more intuitive for sure. @Cymen if you have any ideas on this let me know, see my post above for the acquire/release direction I was going to head as well.

    Ok that is some good progress towards solving this. Lets do some debugging...
    1) Check your VIN terminal (track power supply) to make sure it is ON and supplying the correct voltage.
    2) Check motor A terminal and motor terminal B to confirm there is some amount of voltage when track power is ON.
    3) Use an LED tester to power the motor shield LEDs individually with no connections to the ESP32 or external power source (or have it OFF).
    4) Check PWM-A and PWM-B to confirm that with track power ON these read as +3.3v or +5v. With track power off these should read 0v. This value should not fluctuate.
    5) If you have a scope, connect it to the DIR-A or DIR-B pins, this should show up as a square wave with either 58uS or 98uS HIGH and LOW. Track power does not matter for these pins as the signal is always present.
    6) Double check that BRAKE-A and BRAKE-B traces have been cut on the back side of the shield, we don't use this feature and it could interfere if left in its default state. This would also impact the shield for usage on an Uno/Mega.
    7) Double check the VIN trace on the back side of the shield to confirm it has been cut, if you supply more than ~7v on the VIN terminal it could fry the motor shield and/or connected devices (ESP32, Uno/Mega, etc).

    For #2, if you have a meter that can measure AC use that setting, it should be around 1v lower than your power supply connected to the VIN terminal. If you see a value considerably lower then that means your meter is not using RMS to measure the power.
     
    Scott Eric Catalano likes this.
  14. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    If you send "<t 1 3 0 0>" this should start the sound decoder in an idle state and keep it going until you send a speed/direction. This should survive track power off/on cycles, when track power is ON it should start up again.
     
    Scott Eric Catalano likes this.
  15. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    @Atani -- I will grab some serial output later this afternoon and send that to you, and hopefully see how long the train runs before the displayed power state changes to off. Not sure why it's happening, but it did happen every time I left the train running for a few minutes.

    Regarding the enable pin... yes I use that both for enabling the BTS channels and for power to the board, so if the enable pin were shut down then power to the track would definitely drop out immediately.

    I did say this was a *cheap* decoder board. :) There's no sound here, it just has the outputs for the motor and four functions, nothing else. But it's already served its purpose in that I now understand how to talk to DCC decoders and I was able to verify that everything is actually working.
     
    Scott Eric Catalano and Atani like this.
  16. Texas Tim

    Texas Tim TrainBoard Member

    53
    52
    9
    THANK YOU FOR HELPING ME...

    yes. I have 15V coming in. This is the same power supply I used when the motor shield was connected to Uno

    No power here at A nor B

    do not currently have a LED tester
    yes. 3.3v when ON, 0v when OFF
    No scope :(

    indeed, this has been cut on the back side of the shield

    yes. this has been cut as well. Hence the motor shield has no problem with the UNO

    No power here.
     
    Scott Eric Catalano likes this.
  17. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    ok yeah it should drop off immediately if you turn track power off. You might want to confirm that since it sounds like it is not.

    If you send an idle packet to the decoder most will turn on the headlight (either direction) by default. You may just toggle F0 (light) to ON and then it should flip to one end or the other by switching locomotive direction in the idle packet: <t 1 3 0 0> vs <t 1 3 0 1>

    No problem, it is what we are all here for, to help others learn and enjoy the hobby :)


    Ok this means we may have an issue with PWM-A/B connections. Lets check the L298P chip on the motor shield to make sure signals are reaching it.

    Pin 8 and 14 on the L298P should read 3.3V when track power is ON, 0V when OFF.
    Pin 7 and 9 should read 3.3V/0V as DIR-A pin flips state (one pin HIGH other LOW).
    Pin 13 and 15 should read 3.3V/0V as DIR-B pin flips state (one pin HIGH other LOW).

    The LEDs for Motor A are connected to pins 4 and 5 (one for each polarity), this will be ~15V AC with track ON.
    The LEDs for Motor B are connected to pins 16 and 17 (one for each polarity), this will be ~15V AC with track ON.

    If these do not check out, double check that the shield works with the Uno still.
     
    Scott Eric Catalano likes this.
  18. Texas Tim

    Texas Tim TrainBoard Member

    53
    52
    9
    1 step closer, I have to connect a 5V (NOT 3.3v) to the motor shield. Now, the 4 LEDs are on when TRACK POWER is ON. Verified the track and detect voltage. I do not see a 5V on ESP32, so I added an external 5v.

    However, still unable to move LOCO, nor READ CVs.
     
    Scott Eric Catalano likes this.
  19. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Yes when using the web interface, if I intend to turn power off and click the toggle, power does indeed go off to the tracks. Everything still seems to work as it should *except* the OLED display after a time shows that power is off when in fact the train is still making loops.

    I did find that F0 is pre-programmed to run the headlight, however I left that connected to the tracks when I put in the decoder yesterday. It's not much of a bulb though, doesn't even light up the track in a dark room. When I'm ready to pull it apart again I'll drop in an LED (I have a bag of warm whites that put out a great color) but I expect there's not much reason for it since I already know it will work. Eventually this decoder board will be replaced with an ESP32 anyway, and then I'll hook up all the lights. What I really need to do with this decoder now is learn how to reprogram the CVs to give it the correct engine number and add in some inertia settings. The default allows the train to go immediately from 0 to 127 and steamers just love to spin their wheels when you do that.
     
    Scott Eric Catalano likes this.
  20. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    Take a look at jmri to set the speed table and other features. It will take some time to tweak it to your needs.

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

Share This Page