ESP32 Command Station

Atani Dec 10, 2017

  1. ghruei

    ghruei TrainBoard Member

    33
    6
    2
    #700 ok well that is now clear to me thanks.
    So I have now set up a separate 5v supply to the motor board and the ESP32 is supplied via its usb interface. Once again no luck.
    When power is turned on for either the main or prog only one LED comes on. Then if I connect a decoder/motor to the prog it suddenly runs up to full speed for 2seconds, cuts out, all LED's on the Motorboard go out, then after about 10seconds or so, it lights up and the motor runs for another 2 seconds at full speed and again cuts out. Interestingly even after using the web interface to switch the power off this continues.

    So either the ESP32 is not outputting the correct signals to the motorboard or the deek-robot motor shield is slightly different to a genuine
    Arduino Motor shield and not handling the ESP32 output as expected. I am thinking of getting a Pololu MC33926 Motor Driver and seeing if that works. If it does we know that it is the other type of motorsheild, if it doesn't then it it is the ESP32 board.

    I swapped the motorshield back to the original Arduino setup and it functions fine so I know it is still in working order.
     
  2. Les B49

    Les B49 TrainBoard Member

    37
    3
    7
    ***Bear in mind I'm no expert here (an ex-programmer from the 70s, and a novice with electronics), so Jimbo or Atani may well correct me***

    The cutting out and restarting sounds similar to a problem I had when first trying the standard DCC++ setup out some months back. The problem occurred when I was driving the Motor Board through the 5V supply from the Arduino Mega (not an ESP32), which in turn came over a USB cable from the iMac it was linked to. The serial Monitor showed I was getting power Brown Outs (during which time the motor would stop). When the power supply went back to normal, the motor restarted. My issue was that the 5v through the USB cable from the iMac wasn't giving a clean enough supply. Putting a cleaner and higher voltage input into the motor board resolved this - I need a bigger psu since I'm using G gauge locos.

    Is it possible that your separate 5v PSU into the motor board is giving brownouts? Check on the Serial Monitor.

    If so and you manage to correct it, I would guess you'll still (like me) simply get back to the issue of only 1 light on each motor output from the motor board and no control over the constant speed of an attached loco - and we still have to find the solution to that!

    Hope I've not simply muddied the waters more for you!

    As an aside, I've just spent the whole afternoon looking at the four You Tube videos which explain why and how the hardware needs to be set up for the original DCC++ systems (Arduino Uno or Mega2560 plus Arduino Motor Shield) - see . I now think I understand that, so will now try to work through various posts from Atani to see if I can confirm or find equivalent wiring to link my particular ESP32 to the Motor Board. If it all works, I'll certainly update the thread - and also be quite amazed that I managed to work it all out!!

    Regards and thanks to all who are helping us with this.
    Les
     
  3. ghruei

    ghruei TrainBoard Member

    33
    6
    2
    I had brownout issues right at the beginning as my old hub could not supply enough power when the ESP32 starts up as it requires a fair bit of power when it initially sets up due to the wifi. I thought I had solved this with a new hub, but it still could be causing it to reset as I assumed it was working because it you could talk to it. So I will see if the serial logs show anything.
     
  4. Les B49

    Les B49 TrainBoard Member

    37
    3
    7
    So I've tried my best to correlate my understanding from the DCC++ videos and the settings in Config_MotorBoard.h of DCC++ ESP32 to confirm that the wiring suggested to me by Atani in post 690 checks out. (I didn't doubt it would - I was just trying to understand things in my own mind.) The only query I have here is that the schematic for my ESP chip has SVP marked as ADC0 (or GPIO36) and SVN as ADC3 (or GPIO39) - are these valid equivalents of ADC1_CHANNEL_0 and ADC1_CHANNEL_3 in the config file or do I need to alter something?

    So I wired things up once again and got the same result - only one LED light per Motor Output when the relevant motor's power is turned on. (I didn't have the motor shield outputs connected to my decoder & loco engine block this time, following Jimbo's advice in post 694, but I would guess I would have got the same problem of the motor continuously running and not controllable from the web page - I may prove this later...) If I put a voltmeter across the 3 sets of terminals on the Motor Shield I get a steady 17v going in and either the same going out when the Ops or Main outputs are switched on and 0v when off. Is this normal?

    I've also just tried the same setup with a new ESP32 (same HiLetGo chip) with the same effect, so don't think the chips are obviously blown in any way.

    So I'm at a loss as to what to do next, other than order a Uno-form ESP32 from AliExpress (20-30 days?) and hope that works.

    Any suggestions, anybody?

    JIMBO: What might you suggest to try to get the single LED issue sorted out? Are there any simple tests I can run with a different sketch?

    Regards,
    Les

    PS If anyone thinks it would help, I can upload the document I've written for myself as an my understanding of how DCC works, how the Arduino Uno and Motorshield set-up can support DCC, and what the equivalent pin settings are for Uno, Mega2560 and ESP32. I can also upload the pin schematic for the HiLetGo ESP32.
     
  5. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    Hi Les,
    The fact that only 1 led is switching on for each track suggests that the enable pin mapping on the shield is probably set correctly. However to get both LEDs to light for a track there needs to be a signal on the associated 'dir' pin. This you don't appear to have.

    A question; have you cut the 'brake disable' a & b traces on your shield? Please don't alter them - I'm trying to establish what your current setup is.
     
  6. ghruei

    ghruei TrainBoard Member

    33
    6
    2
    Les B69 on my esp32 the ADC1_CHANNEL_0/3 are marked as VN and VP, and on the pin out diagram they are shown as 36 / 39 they are also mentioned as ADC Channels so I would assume it is similar with your board. I am having the same issues as you with 1 LED only lit. So we are using different ESP32 boards but having the same result which I am sure means were both having the identical problem. So I do not believe getting another board will help as the issue will occur with that?

    I have checked the serial console and everything is good here no errors / brownout warnings.

    Jimbo20 is saying this is related DCC_SIGNAL_PIN_OPERATIONS which are pins 18/19 the default in config_Motorboard.h and on my ESP32 I have these connected to the DIR on the motorboard. I have a photo of my setup attached to one of my earlier posts. So for some reason the ESP32 is not outputting a suitable signal to the motorboard and hence on 1 LED is lit and nothing works correctly.

    I am going to experiment some more tomorrow with the changing the Signal pins to different ones. Just in case it helps Jimbo20 on my set up I definitely have the traces cut.
     
  7. Les B49

    Les B49 TrainBoard Member

    37
    3
    7
    <<Dumb question now, I'm sure... What are the 'dir' pins?>> EDIT: Ignore that dumb question. I've now spotted that on the Motorboard, pins 12 & 13 are also labelled Dir A and Dir B respectively. With the ESP setup, these pins are connected to pin 19 (DCC Signal Pin Ops) and pin 18 (DCC Signal Pin Prog) - on the Arduino Uno original DCC++ system, they would be connected to Pins 10 and 5 respectively. As far as my understanding goes from my work today, these pins from the ESP (or Uno) are providing the DCC signals to the motherboard as a PWM pattern. So, in theory, I think my board is still wired was Atani recommends and it ties in with his code. (As an aside, I'm confused as to why M/B pins 12 & 13 are labelled Dir A and Dir B - don't m/b pins 3 & 11 effectively switch the polarity of Outputs A & B and thereby change the direction in which a normally attached motor would run?)

    Does it look then as if:
    - either the underlying DCC PWM signal (0 or 5v) is not getting sent correctly from ESP pins 18 & 19 to the motherboard;
    - or those signals are being sent, but the conversion on the motherboard to a full bi-polar DCC signal (-17v or +17v in my case) is not happening and no signal is being pushed out of pins 12 & 13?
    (The latter seems less likely to me - with my admittedly flakey knowledge - since the motorboard works ok when linked to my Arduino 2560 using standard DCC++.)
    How can I test for signals at the correct places? I have a reasonable Multimeter, but don't know what to look for at this level...

    Originally, I didn't have the Brake traces cut, since I thought when I was doing my original trials of DCC++, it said somewhere it didn't really matter since the Brake feature (whatever that is...) wasn't being used. However, a day or two back, I decided to cut them, just in case it did make a difference - but it didn't!

    So, yes, now they are cut.
     
    Last edited: Apr 27, 2019
  8. Les B49

    Les B49 TrainBoard Member

    37
    3
    7
    Agreed. I think different boards just use similar, but slightly confusing terms. Your VN & VP are my SVN & SVP.
    Maybe. I was just considering the ESP board that Atani says he's had more success with - but not necessarily absolute success.

    Good - I think!

    Agreed - see my response to Jimbo's last message.

    I look forward to your findings! Good luck!
     
  9. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    Hi, the reason I ask about the cut traces is just an idea I have that might be the cause of the problem, though I'm not certain.

    (Les: there are dira and dirb pins 12 & 13 on the shield which you have connected as per Atani's instructions.)

    My thought regarding the disable brake traces is a bit technical, but I'll try to explain.

    The two pins brake a and brake b (8 & 9) are not used by dcc++ and it is normally suggested that their traces are cut, this disconnects the pins from the arduino (assuming it is plugged in to an arduino) which then allows those aduino pins to be used for sensors or whatever.

    Les, have you tried your shield on the arduino with DCC++ since you cut the brake traces? If not I think you should and confirm it still works ok.

    If it doesn't work with the traces cut, I think you should re-make the cut brake traces, then ground pins 8 & 9 on the shield and try that with the esp.
     
  10. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    To explain a bit more, the brake a & b lines on the motor sheild 8 & 9 should normally be held at 0 volts otherwise the motor drive outputs wont work. If the sheild is plugged onto an arduino running dcc++ the software is set for the arduino to hold those pins at 0v. As you dont have the sheild plugged into an arduino those lines may be floating high causing your problem. There should be pull down resistors to prevent this but I wonder if they are missing on your shield. So if that is the case for it to work you would need to re-make the cut traces, then (if not plugged onto an arduino) connect 8 & 9 to ground.
     
  11. ghruei

    ghruei TrainBoard Member

    33
    6
    2
    Jimbo20 thanks for the explanations this really helps as it is giving me a much better understanding on what is going on.
    Anyway I have now recompiled this several times using different pin combinations. The result is the same each time. So next I put everything back to the defaults. I have then rejoined my brake traces and tied these down to gnd. No difference.

    However I did not realise Atani had been using an ESP32 in UNO format as LES B49 mentions so I think actually his idea of getting one in this format is the next step. I can get one of these from the great river website by tomorrow (as I cannot wait 30days from china!). If it works out of the box then it clearly establishes that ESP32 in UNO format provides something extra to the MotorShield that just running jumpers to it from any other ESP32 board does not.

    I have made the assumption the dcc PWM signal is correct. I have no way of testing this as I have no oscilloscope and I am not to sure if the signal can be slowed down to use an led as an indicator instead.

    With what Jimbo20 has said now I do think though it is a pin connection issue between the boards both LES B49 and I are using which are not providing all the connections the motorshield needs to function correctly.
     
    Jimbo20 likes this.
  12. Les B49

    Les B49 TrainBoard Member

    37
    3
    7
    It still works with the Mega 256.

    I'll try re-making the traces and explicitly grounding. May not get around to it today - going to see our daughter & grandson. All the work is for him to play choo choos of course - that's my excuse...

    Thanks for all your input.

    Les
     
  13. Les B49

    Les B49 TrainBoard Member

    37
    3
    7
    That sounds good!

    What’s the web address for Great River? Google search doesn’t find anything that seems useful. (If your test works, I could order one for my son to collect at his offices in Boston when he’s there the week after next.)



    Sent from my iPhone using Tapatalk
     
  14. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    Les, If it still works with the traces cut on the Mega then I suspect that this (grounding of brake pins) is not the problem.

    Looking briefly over the schematics, the only other thing that springs to mind is that I notice that on at least one ESP32 in the arduino form factor (the Unopuino32s) there appears to be pull down resistors on the GPIO pins. Could this be the issue?
    Do you need pull down resistors (to grnd) of say 4.7K on the signal (Dir) pins 12 & 13 of the motor shield, because you're not using an arduino form factor esp32? Or, I don't know if there is a pin config in the code that needs setting to enable the internal pull up/downs on those pins?

    http://esp32.net
     

    Attached Files:

  15. ghruei

    ghruei TrainBoard Member

    33
    6
    2
    Great River == AMAZON. More expensive then using aliexpress but worth it for the time saving.
     
    Jimbo20 likes this.
  16. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    Sorry, but I just had a fleeting vision of Les's son paddling down the Amazon with an ESP32 held in his teeth! :)
     
  17. Les B49

    Les B49 TrainBoard Member

    37
    3
    7
    Thank heavens you can’t see. my embarrassment from across the pond!


    Sent from my iPhone using Tapatalk
     
  18. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    The problem is a bit more complex than that. The SIGNAL pin should be connected to the DIR pin on the motor shield and the ENABLE pin to the PWM pin on the motor shield. Neither the Arduino DCC++ or the ESP32 CS code generate a true PWM signal, both simply set ENABLE to HIGH when the signal should be ON and uses the SIGNAL pin to control the output of the signal to the left/right rails via polarity flip. In both cases if you connect the SIGNAL pin to a scope with a reference to GND it will show you a square wave with roughly 58uS/98uS HIGH/LOW pulses.

    In this case with your motor shield only showing one LED as ON that means either the ENABLE or SIGNAL pin is not being correctly used by the h-bridge on the motor shield to flip polarity of the left/right outputs. Until that is resolved it is not going to generate a suitable DCC signal under any circumstances.

    You might connect the 3v3 pin from the esp32 to the motor shield and see if that helps. Outside of that I'm unsure.
     
  19. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    I haven't seen any pull-down resistors on any standard boards, this would be an odd one to have this by default. I'd be curious if it helps at all but it shouldn't really make much difference.

    The only way to test this would be with a scope. You would connect the SIGNAL pin to the scope and check that it is generating a square wave pattern of 58/98uS (roughly).

    These markings are standard to all ESP32 boards, some mark them with the S and others without. The naming/mapping of these come straight from the ESP32 datasheets themselves which declare the functions and mappings to the analog inputs.

    I haven't seen any issues with the Deek-Robot motor shields (I've used them successfully for the Arduino DCC++ and the ESP32 CS, in fact my layout is currently powered with one!)

    As for motor shields that work, the wiki has a list of supported/tested motor shields and how to use them, some information still needs to be updated on the Wiki and is available here instead (I'll move it over to the wiki soon).

    I'd be interested in seeing this document, if you can send it to me over email I'd appreciate it. There are a number of real differences between how the hardware works in the Arduino side vs ESP32 but the core functionality of how the signal is generated is fundamentally the same (ENABLE goes HIGH when signal is ON, SIGNAL/DIR gets used to flip polarity of the signal based on 0/1 bit time).

    This sounds like the motor shield is signaling a short condition. Is the motor pulling more than 1.75Amp? Is there a short being introduced when connecting? Do you have a way to monitor the serial console of the esp32 when it is all connected?

    The signal can be slowed down but it is not very straightforward to do so. Modify this constant from 80 to say 800 or even 1600. This will result in a 10x or 20x slow down of the signal and you might be able to use a bi-color LED on the SIGNAL pin to see the polarity swap. There is no guarantee that this would slow it enough though.
     
  20. ghruei

    ghruei TrainBoard Member

    33
    6
    2
    Well I got the replacement board today from Amazon (The web shop NOT the river just so everyone is clear!) Stuck the motor sheild on top. Uploaded the code. Switched on and...... exactly the same response as before. With either the brakes cut or joined. Once again the serial monitor reports all is good.

    I am just going to have a good read through what Atani has wrote and see what to do next.
     

Share This Page