ESP32 DCC++ questions

Peter Buelow Dec 20, 2017

  1. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Say, is there a way to set up one of these controllers as a booster or maybe some kind of repeater? The plans for my layout allow for it to be sectioned for transport and I'd like each section to have its own power source and such, but from what little I've picked up about DCC it seems like it would be bad to have multiple controllers on the same layout? Since we're also using wifi here it seems like it would be a simple matter for a booster to simply repeat the same commands to the track, but I don't know how it would work if the track sections were not electrically isolated?
     
    Scott Eric Catalano likes this.
  2. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    Well you don't need anything DCC++ to make a booster, several commercial ones available. Digitrax, NCE, MRC, Tam Valley, etc.

    You can build your own with a MERG kit. https://gregstrainyard.com/2017/12/12/merg-booster/

    or Dave Bodnar's DIY booster. http://www.trainelectronics.com/DCC_Arduino/DCC_Booster/index.htm

    All wlll work with whatever system because as you suggest they are just taking the signal and boosting power, not actually creating or issuing signals.

    A booster could work on to power the track in a separate place but the most common uses are for districts. But certainly if you just want to give the whole track a boost and not divide into electrical districts hook a booster up to the base station then run to the track.

    For what you want though you'll need to electrically isolated. Electrically isolated does not mean totally separate. Typically you would run the DCC to each (using boosters if you want) and then have a circuit breaker of some type (most boosters have them built in) for each power district. This way some signal to everyon but if one section shorts or you turn off or whatever you can still run the rest.
     
    Scott Eric Catalano likes this.
  3. AndyH

    AndyH TrainBoard Member

    77
    9
    6
    I've seen a few suggestions here and on (shhh) other train forums that there is value in having your accessories (eg points motors) on a different DCC circuit, so that if the train circuit shorts, you can still operate the points if necessary. I've seen it on the context of using a commercially available circuit killer between the layout and the signal generator.

    I want to use the above booster because I'm on DCC++ using an arduino motor shield, and don't want to cook the shield. Could I split the DCC generation signal at pin 3 (think, Arduino Mega, not at my proper computer, but know which pin is the right one) and take one feed to the signal booster and the other to the motor shield voltage control terminal? I could then use the signal being sent through the shield to control accessories, and the signal from the booster for the rails? Thanks.
     
    Last edited: Mar 6, 2018
    Scott Eric Catalano likes this.
  4. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    You could but it would be easier to have the base station itself manage the shield. You would just need to define another motor board as the accessories bus and set a current limit.

    My original setup with the Arduino base station was using an Arduino motor shield for programming and my helix and then a pair of the bts7960 boards for the upper and lower decks of the layout. Since then though I have torn down the layout and am preparing to build a new one, I will be using a similar setup except having a bts7960 for staging and helix. I am thinking along the same lines as you and use the Arduino shield to provide an accessories bus.

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

    AndyH TrainBoard Member

    77
    9
    6
    How do you do that? Pretend I'm thick, which shouldn't be that hard in this context - I'm an accountant not a programmer (to illustrate, it took me a good few hours to work out that the board wasn't diagnosing properly in serial monitor because I had the Baud rate wrong, and I just had to change the baud rate until the writing made sense).

    I've currently got the standard DCC++ base station layout of arduino mega plus motor shield, programming track done Pin 12 to pin 21 (i.e. no connector), main track done pin 2 (3?) jumpered to pin 13, taking both main and programming track from the motor shield.

    I had thought that to connect up Dave's booster setup, I would disconnect the jumper and take the feed to the board from pin 2(3?), meaning that I would have no main output from the motor shield, but instead the output would be coming from the H Bridge booster, but I'd need no change in programming.

    If I am hearing you correctly, what you seem to be suggesting is adding in programming to control a third timer and PWM output on the arduino, and then taking a third resulting DCC signal for track/accessories? Have I missed something?

    Thanks.
     
    Scott Eric Catalano likes this.
  6. Cymen

    Cymen TrainBoard Member

    10
    11
    7
    [I realized this should go in a new thread or somewhere else -- too far off topic for this thread]
     
    Last edited: Mar 6, 2018
    Scott Eric Catalano likes this.
  7. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    For a Mega you should only have one jumper, pin 2 to pin 13. No other jumpers are required.

    For Dave's booster you would connect it to the motor shield pins for motor A. You would not use the Mega pins/jumpers as they are not the DCC signal. The pins on the Mega side are the enable and direction control only. It is a combination of these two that the motor shield translates into the actual DCC signal.

    Somewhat. You don't need a third timer or PWM signal. What you would do is connect the new motor board to the base station via a couple pins:
    DIRA (pin 12) -> DIR-A on motor board/shield.
    A2 -> A0 on motor board/shield (or current sense A)
    Pin 4 -> PWM-A on motor board/shield

    For the BTS7960 you would need a few extra parts to convert the above connections to the BTS7960 eight pin connector. @Shdwdrgn has created a great diagram for the ESP32 base station to connect the BTS7960 here: http://www.trainboard.com/highball/...sp32-base-station.112634/page-13#post-1047918 The connections on the ESP32 are as follows: SVP = current sense, 25 = PWM-A/ENABLE, 26 = DIR-A. You can use these mappings to convert it to the Mega pins listed above.

    For the Mega base station code you would need to add a new current monitor for A2 to monitor the current draw on the new motor shield. Depending on which base station code you are using this can be easy or it can be challenging. If you are using my fork of the base station (https://github.com/atanisoft/BaseStation) you can add another line here: https://github.com/atanisoft/BaseStation/blob/master/DCCpp_Uno/src/DCCpp.cpp#L247 like this:
    Code:
    MotorBoardManager::registerBoard(A2, 4, MOTOR_BOARD_TYPE::BTS7960B_5A, "ACC");
    
    What this does is registers the board as a 5A current limit with a name of "ACC" using A2 as current sense and pin 4 as the PWM/enable pin.

    For the original base station code you would need to add a few more modifications to support the third analog pin and set a current limit for the BTS7960 board.
     
    Scott Eric Catalano likes this.
  8. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Just for future reference, the Lolin32 OLED board that I'm using will not support adding a third channel without some soldering. The ESP32 has two channels of analog inputs, ADC1 and ADC2. ADC2 cannot be used at the same time as wifi (although I have seen talk of some software hacks that may get around this), which means that we are only interested in using ADC1 pins for current sensing. Unfortunately on the Lolin32 OLED board they only exposed TWO of those pins on the board (SVP and SVN). So if anyone is using this board and wants to add a third channel, you must solder a wire directly to the ESP32 chip on pin 6, 7, 8, or 9.
     
    Scott Eric Catalano and Atani like this.
  9. AndyH

    AndyH TrainBoard Member

    77
    9
    6
    Yep, got that.

    So connect to Pin 2 on the shield? That was what I thought, or do you mean still have the 2 to 13 jumper, and take the signal from the actual track output (green screw terminals) on the shield?

    If I'm reading this right, you're permitting Pin 12 to operate the original motor shield, but also taking a feed from it to the high power H Bridge?

    I've been looking at these two pages:

    http://trainelectronics.com/DCC_Arduino/DCC++/#Power_Tests

    http://www.trainelectronics.com/DCC_Arduino/DCC_Booster/index.htm

    From a combination of them, what I read as happening is the following:

    RPWN/LPWM on the 7960 are being fed from Pin 12 on the Mega/shield combination, but through the additional circuit which creates two PWM signals as the BTS7960 wants two PWM feeds.
    R_IS/L_IS on the 7960 are the current sensing feeds, which go back to pin A0 on the motor shield? From what you seem to be saying, it goes to A2 on the arduino, and you put a new current sensor into the programming?
    GND on the 7960 to any available ground on the Mega/Motorshield
    VCC/REN/LEN on the 7960 to Pin 4 on the motor shield? The two pages above seem to be suggesting Pin 3, but I notice that on the pictures I can find of the shield I have, Pin 4 is labelled up PWMA.

    So if I read this right, you are piggy-backing on the feeds for Motor A on the Mega/Shield, so that you are driving the 7960 with exactly the same feed as the Motor A output, so you get two identical track feeds? So you can use the 7960 to drive your track, but the Mega/Shield combination to drive the accessories? You then use a separate analog input (A2) as a current monitor for the 7960 with a max of 5A before it cuts, and the code below adds the current monitoring?

    So all this does is register the board for a current monitor/limiter?

    Would I not need to place this code after line 241, in the IF line relating to Type 0 motor shield? I'm guessing that I won't be changing the type of motor shield that I am telling the base station that I have? Or will I? Do I now have to set it to Type 2, and add the code in after line 247?

    Writing code is not my forte. Reading it I do OK with.
     
    Scott Eric Catalano likes this.
  10. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    leave the jumper AS IS. Connect your "booster" to the green screw terminals labeled as "MOTOR A", this is the MAIN track signal output.

    That is exactly right. We are leveraging the existing MAIN track signal generator (really just direction pin) to generate the signal on the high power bridge. The "PWM" signal is constantly HIGH when the track power is ON so there is no true PWM signal being generated there. So we connect any other available pin as the ENABLE pin (which is what the PWM pin is really being used for on PROG/MAIN today).

    Yes, the BTS7960 treats the left and right outputs individually whereas the L298 chip used in the Arduino shield controls them together. The "extra" circuitry creates an inverted signal from the single direction pin on the Arduino side to have Left be HIGH and Right be LOW, or the inverse. They should never be the same state.

    Something like that, you would wire R_IS and L_IS together and connect to the Arduino on A2 (A0 and A1 are in use for MAIN and PROG respectively). You need to ensure this is wired to an analog pin that is not already in use.

    Yes, the reason for the pages referencing pin 3 or similar is due to it not being the base station. Those pages describe a standalone booster which is not necessary when connecting to the base station itself.

    Which motor shield exactly do you have? Every Arduino shield that I have seen and that I know is supported has PWM-A on pin 3, which is also required by DCC++.

    Only partially piggybacking. We are leveraging only the DIR-A pin and using a dedicated ENABLE and ANALOG pin for the BTS7960. You can use either the BTS7960 or the Arduino Shield to drive MAIN/Accessories. The Arduino shield by default is the only one that you can use for PROG though.

    Yes, it adds a third motor shield output to the base station monitoring code.

    I would recommend placing it on line 249, a blank line after the #endif. You will still stick with type 0 in Config.h as you are still using the Arduino shield to power two outputs (PROG, MAIN/ACC)

    No worries, the fewer modifications that are needed to get up and running the better for most people!
     
    Scott Eric Catalano likes this.
  11. Mariano

    Mariano New Member

    1
    0
    3
    Peter have you done any coding in the particle photon? I'm new on DCC++ and I'm trying to convert Atani ESP32 code into this board.
     
  12. dompondaco

    dompondaco TrainBoard Member

    47
    6
    6
    gentlemen, I just found this forum and wondering if this is the best place to ask questions regarding the DCC++ ESP32 Basestation hardware and software. I have been trying to get a ESP 32 basestation working for quite a while now , but still have issues and not sure what to do next. I this the best place, or just stick to the DCC++ ESP32 Basestation forum?
     
    Atani likes this.
  13. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    Atani likes this.
  14. dompondaco

    dompondaco TrainBoard Member

    47
    6
    6
     
  15. dompondaco

    dompondaco TrainBoard Member

    47
    6
    6
    Just got the serial monitor on PIO to work and can see sort of whats going on . Issue seems to be the system thinks there is a overload on main and prog tracks. This explains why the A and B outputs blink when track power is applied. Issue now is that there is nothing connected to either A or B outputs on the motor controller. Only connection is Vin to a ATX switching power supply supplying 12volts dc to the motorboard. Could the ATX switching supply be causing this problem? Possibly the lack of anything connected to the A and B outputs ?
     
  16. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    It sounds like one of the following may be at play:
    1) noise on analog lines
    2) no common GND
    3) motor shield is not powered correctly
    4) wrong motor shield selected in Config.h
    5) a short from +5VDC (or 3.3VDC) to the analog pins

    Most likely it is a connection issue as you should see the analog current sense being near zero when there is no load placed on the DCC output pins from the motor shield.

    Sent from my ONEPLUS A5010 using Tapatalk
     
  17. Shdwdrgn

    Shdwdrgn TrainBoard Member

    251
    182
    13
    If I'm reading this correctly, you do NOT actually have your motor controller connected to any track yet? What about the analog current sense input on the ESP32, do you have that line connected to the motor controller, or did you leave it floating? If you left the analog line floating, then yes it is quite common to see an overload reading (this is something I ran into early in my own testing). The solution to THAT scenario is to hook the analog sense pin directly to ground while you are doing your testing. Just remember to hook it to the current sense line on the motor controller later on when you do start hooking up the track.
     
  18. dompondaco

    dompondaco TrainBoard Member

    47
    6
    6
    Correct, the motor controller is not connected to and tracks or input voltage. Not sure about the analog current sense input on ESP32, only EPS32 pins connected are GIPO25,GPIO36, GPIO18, GPIO19, GPIO23, GPIO39 and 5v and ground. Which pin is the analog sense input??
     
  19. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Pins 36 and 39 are analog inputs.

    Sent from my ONEPLUS A5010 using Tapatalk
     
  20. dompondaco

    dompondaco TrainBoard Member

    47
    6
    6
    seems like there is a different problem every day. most current issue is compile software (V1.1.1), load the target everyting fine, start the serial monitor to watch whats happening and gets as far as opening powershell sees device on comm port and has correct settings then it just hangs up in the mini term program. Used to breeze right through and run the software. Question is the Arduino version of the system any more reliable?? I am about to give up Atom/PIO
     

Share This Page