A couple DCC++EX questions....

Sumner Aug 15, 2020

  1. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    Conductors and many Tinkerers will prefer to follow these steps to install the DCC-EX Command Station. There is more information at the end for advanced Tinkerers or Engineers who want to see the software and perhaps help with the development or make changes for themselves. Links to the GitHub repositories are there.

    You will not need any Jumpers with an Arduino Motor Controller and your Mega. If you use a WiFi shield, you will need a jumper from the Tx pin of the shield to Serial1 Rx on the Mega, and one from the Rx pin of the shield to Serial1 Tx on the Mega.

    **** Conductors and Tinkerers ****

    1. Make sure you download and install the Arduino IDE if you don't already have it. NOTE: This is a 192Mb download.

    https://www.arduino.cc/en/main/software

    2. Download the CommandStation-EX sketch here:

    https://github.com/DCC-EX/CommandStation-EX/archive/master.zip

    3. Unzip the zip file to your Arduino sketch folder

    4. Run the Arduino IDE Application and from the library manager (tools -> manage libraries), install the "DIO2" library.

    5. Click "File -> Open" and open the "CommandStation-EX.ino" file

    6. If you have an Arduino Mega, Arduino Motor Controller, and either no WiFi board or want to use Access Point mode (AP mode) from a compatible ESP8266 Shield or ESP0-01 to connect from your WiThrottle compatible throttle (ie. Engine Driver) directly to the Command Station, you are done and can upload the sketch to your Arduino

    7. If you have WiFi and want to use Client mode (you want to have the CS connect to your router and your throttle finds the CS by its IP address on your network), you are going to need to click on the CommandStation-EX.ino file tab in the editor for your IDE and enter your network SSID name and logon password where you see the instructions and then save the file. You can save the file and then opload the sketch.

    9. Use the Serial Monitor that comes with the Arduino IDE to look at logging information. If you are using WiFi Client mode, you will see the CS connect to your network.

    10. Use JMRI or our exWebThrottle to test your setup.

    11. If you are using WiFi, download Engine Driver or another WiThrottle device. To use AP mode, find the CS AP from your network list and connect to it. Then connect to the IP address of the AP from Engine Driver. Use port 3532.

    We are updating our installer program to automate this process for this new version and that should be available soon.

    Our website is https://www.dcc-ex.com

    **** For the Engineers ****

    Browse the code or use these links to clone the DCC-EX Command Station files. Create repositories:

    The main Command Station Sketch:
    https://github.com/DCC-EX/CommandStation-EX.git#master

    To clone, use GitHub Desktop or Git Bash. In git bash, navigate to where you want to clone the repository and from the "$" prompt, type:

    git clone https://github.com/DCC-EX/CommandStation-EX.git

    You can use whatever development environment you like, however we use Visual Studio Code with the PlatformIO Plugin
     
    KC Smith likes this.
  2. S t e f a n

    S t e f a n TrainBoard Member

    167
    93
    6
    Thanks a lot, Flightrisk! So in the new DC++EX the DCC++ Basestation has been renamed to Commandstation, not to be confused with the 'controller' in the old DCC++... of course that at first confused me.

    Is there a particular thread you want feedback in (assuming you want feedback)?
    Anyways, here are my first observations:
    The sketch works on my Arduino Uno (clone, i.e. real Uno, as far as i can tell, but not sold by arduino.cc) with real Arduino motor shield R3 (sold by arduino.cc) and old jumpers (5 - 13 and 10-12) in place. It seems to use 95% of available program memory on the Uno.

    After installing the DIO2 library, I could compile and load, but initially only the command station function in the JMRI decoderpro defaults tab was linked to DCC++; this might have been a leftover from what I was doing before uploading the new sketch. After fixing that, power control did not work until I selected one of the locomotives in decoderpro. This might be consistent with how it was before under the old DCC++? As you might be able to tell, both JMRI and DCC++ are completely new to me.
    Programming track and main track power still seem to be linked? Maybe this is a JMRI limitation.

    As far as looking at the code goes, this really looks quite different. Config.h seems gone. I left my shield jumpers in place, because as far as I could tell from the code, that is indeed still required for the Uno, and it didn't seem to have any negative effects.
    At first glance I did not see any mention of Railcom.

    Functionality I would be interested in:
    o - Railcom (not just blanking out the gap, but receiving and relaying to JMRI)
    o - a code version that turns the command station into a smart booster (with two districts, or a single higher power district)

    Functionality that already seems to be there in the code, but might not be accessible from JMRI (or I still have to discover it there):
    o - separate power control for programming and main
    o - ability to have the program track become a separate main power district (mirroring main, but with separate current monitoring)
     
  3. S t e f a n

    S t e f a n TrainBoard Member

    167
    93
    6
    I forgot the most important part: The lowest level CommandStation-EX-Master folder (with the code) had to be renamed CommandStation-EX for the Arduino IDE to accept the sketch. It apparently expects XYZ.ino in a folder named 'XYZ'.
     
    Erik84750 likes this.
  4. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    You do NOT need any jumpers, remove them. It won't hurt anything, but they aren't doing anything and tie up pins :)

    You must have gotten the version that was only up there for a short time where I forgot to rename the .ino file ;) Glad you spotted that.

    Yes, power is turned on in JMRI only after you acquire the loco. This is up to the software like JMRI and Engine Driver. In you or software sent a <1> command, power would turn on without a loco. Since it is a new command, nothing supports it yet. We are adding that to JMRI. It does turn on and off autmatically on the service track.

    We had a discussion about config.h and will probably be adding it back.

    We do have a feature to switch main and prog to both be main ;) https://github.com/DCC-EX/CommandStation-EX/wiki/DCC-EX-Command-Reference#track-power-commands That is not in JMRI yet, but you can send that command.

    Thank you for all your comments!
     
    Erik84750 and mijnmodelbaan like this.
  5. S t e f a n

    S t e f a n TrainBoard Member

    167
    93
    6
    Thanks for the reply! The jumpers are back in the jumper & power supply drawer (it's amazing how organized one can get after retirement...).

    Is there a diagram or sketch with a high level overview of how the different pieces of code inside DCC++EX work together? It would make reading the code easier. If not, then I guess I have to make one for myself.;)

    I think I have to work on my layout first though, before getting deeper into any code or electrics. Now that the shells are seated correctly, my 13" radius turning loop is derailing my E9 A unit: it seems the front steps are limiting the front truck movement.
     
  6. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    If you have the time to help us document the code, that would be great! There was talk of different ways, but an organized person working with the right people and getting the to either explain to you or write something you could expand, that works.
     
  7. mijnmodelbaan

    mijnmodelbaan New Member

    7
    5
    4
    As this post started with some questions, I have another one: with this new software set-up (building blocks), is it possible to add another motor shield to the Arduino and get the correct current readings of both shields (4 channels)? With not too much of a hassle, I mean?

    I've been tinkering with Dcc++ (the original one), Arduino's and ESP's on and off for some years now and found this Dcc++-EX thingy just yesterday and got exited as it seems to work better and there seems to be more structure in the software. As I want to have several power districts on my layout, I'm playing with the idea of building a board with four L298's, so I can have eight districts, or seven and one PROG. Hence my question.

    Willem.
     
  8. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    Well, we designed the system to be fairly flexible, though some things may require code rather than a configuration switch. Are you talking about the "BaseStation-EX" version? I hope we didn't confuse things, but here is the evolutionary process:

    1. Gregg created DCC++
    2. We expanded on that, made some fixes, renamed things the way Gregg intended and called that "DCC++ Classic"
    3. With that as a base, we added and changed a lot of things. A different way to handle communication to serial ports, Wifi, etc., display support, new way to manage "motorboards". This is DCC++ EX's "BaseStation-EX"
    4. After an idea from Chris, UKBloke, we started from scratch. We completely rewrote everything from the ground up, pulling in some code as we went from the BaseStation-EX repository code. I am not sure this is what you are seeing. This version we put in a repo named "CommandStation-EX" because DCC++ was the only thing calling it a "Base Station" ;)

    So it can be confusing if someone looks at the repository instead of the website or the installer because we kept 2 versions of DCC++ EX, the one in the BS-EX repository and the one in the CS-EX repository. We didn't want to get rid of any of the versions in case someone needed a feature we didn't have in the latest version. All work for DCC-EX is in the CommandStation-EX repository. And it is very different from anything anyone has seen in the other versions. But it is a good thing. We can have custom .ino files, the main program file, that use a new API (application programming interface) to do things that go beyond a simple config file option. For example, we have DCC::Begin(ARDUINO_MOTOR_SHIELD) as a main function in the .ino file. You just add another one with settings to list different pins and you have control of another motor board. Since we added a new set of DCC commands for power and track:

    <1 MAIN> // power on main
    <1 PROG> // power on prog
    <1 JOIN> // join MAIN and PROG as one main track with 2 power districts

    So this feature lets you have a siding that can be operational, but then switch to a programming track when you need it. But it does give you 2 power districts as a side benefit. This is on the same motorboard, so you have twice as much power, but have to remember the overall limit of one board. An arduino board with 1amp or more on 2 channels would need cooling.

    As for 7 power districts and a programming track, that requires some cogitatin' as one of my instructors used to say ;) We can do it fairly easily, but I would have to run through the logistics. Many would argue you need boosters. But since this is one signal, we would just need to add code to set pins for power and current sense if you wanted to control all that from the main CS. The brainpower would come in thinking about power requirements. You would probably need a separate 7-9V supply for all the Arduinos involved so you were pulling 5V for all of them from the voltage regulator on the CS and we might need a pullup (or not) for 7 boards being driven from one pin on the Arduino. All the ground would need to be tied together to prevent ground loops.

    I ran this by Chris and of course that led to, "we could add a new power routine like <1 DISTRICT1> <1 DISTRICT2> and then add code for handling current sense and auto power shutoff to just one shorted district, and what if we...etc." LOL. So there is a lot we can do if you want more than what I mentioned and you can join the team to help with that even if it is just helping decide how the feature would work and testing it.
     
    Last edited: Sep 23, 2020
    KC Smith likes this.
  9. mijnmodelbaan

    mijnmodelbaan New Member

    7
    5
    4
    I went to https://dcc-ex.com/download/dccex-downloads and from there followed the link to the DCC++ EX GitHub Repository and cloned it in VSC. I think this is the correct (newest) version because I see this 'DCC::begin(STANDARD_MOTOR_SHIELD);' command.

    First I tried the uno setup and got some warnings about a missing include directory. After solving this the build went fine. I didn't upload the file to an Arduino as I assume that'll work (and I didn't have one at hand). I'll try some more things later on.

    But I'll clarify some more as I think we misunderstand each other. What I'm thinking about is a system consisting of one ATmega328P chip and four L298N chips (and some additional hardware). The ATmega is sending the Dcc waveforms to all four L298's. The user (while building the pcb or later) can decide if he wants some channels of the L298's connected to the MAIN and some to the PROG waveform lines. With the <1 JOIN> etc. commands the user then will be able to use one or more channels of the L298's as MAIN or PROG (switchable). The only issue I see at this moment is the need for more Analog inputs, two per L298, but this can be solved by using the ATmega328P-AU, which has eight of them.

    So the only thing needed for this is the possibility to use more Analog inputs for the current measurement, while only using the two standard waveform pins.

    I hope it's a bit more clear now. If not, please ask.
     
    FlightRisk likes this.
  10. S t e f a n

    S t e f a n TrainBoard Member

    167
    93
    6
    Willem, that's a very interesting idea, and potentially simpler (fewer code changes) than relaying the DCC signal from the CommandStation Arduino to several booster Arduino+shield combinations, which is what I thought a future expansion could be.

    Flightrisk, if one wanted independent short protection, does the Arduino Uno have enough pins (and routing flexibility) to put the four DCC signals for each shield onto different pins, or would one need to use a Mega for that? On my Uno I count 12 pins left for motor control in total, so 6 power districts or three shields; but I'm very new to this Arduino business.
     
  11. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    Looks like Willem wants to use discrete Atmega chips to make his solution. Using an Uno, you have 6 Analog inputs. You have 16 on a mega 2560. So you could use multiple shields and get current sense. We would need to add some code to handle that separately. Easy to do as a separate routine, but we could add an internal routine like "AddPowerDistrict()" so we know with board tripped overcurrent protection and handle turning it on and off. If you jumper them with wires, that eliminates having to bend pins out of the way if you stack them, but either way will work. If you want to turn them all on and all off (other than the programming track) at the same time, then we don't need code changes for that. It is something we would probably add soon. We are not adding any new features for the next few weeks as we try to get to a release. If there are no major bugs or issues after that is released, we start on the next one. The schedule is Nov1 release and then another "holiday release", so around Christmas/New Year
     
  12. Sumner

    Sumner TrainBoard Member

    2,798
    5,837
    63
    I've been a little confused by the three different versions, specifically BaseStation-EX and CommandStation-EX. I have a better idea after looking at your post up the page but do you have the differences explained more clearly on the new web site you guys have up? I did look a week or so ago there. It sounds like those have a lot of features for someone that is into working with code and Arduino's and such but for a lot of us the lingo associated with all of that makes it look like they aren't an option for us.

    I know that you don't need to know much to setup a DCC++ system as I managed to do it a year ago. I'd suggest really emphasizing, to what I believe is a large group out there, that it can be very simple if you just want to run trains and program decoders. Separated instructions for that group out and have a basic set of steps for them to follow. Buy these parts (Arduino and motor shield), connect the Arduino to your computer like this, run Dex's installer like this, connect the motor shield to the Arduino, connect the track wires to the Arduino and a power supply and you are running trains. No electronics or programming skills needed. No talk about serial monitors, repositories, code rather than a configuration switches, libraries, etc.. Keep the language simple for some of us on this option so we aren't scared away. It can be not much different than buying a plug'n'play system except for putting the sketch on the Arduino.

    You guys have done some great work. Let's get people that just want to have a basic DCC layout going and take advantage of what you guys have accomplished in a short period of time.

    Later some of those who got into DCC with just the basic setup will start to explore more options with it that you guys have been working on and some will just treat it like the commercial option that most have used up to this point. Both groups are out there,

    Sumner
     
    KC Smith likes this.
  13. mijnmodelbaan

    mijnmodelbaan New Member

    7
    5
    4
    @ Stefan glad you like the idea. Made a little drawing so it might get even more clear. The idea is to create a pcb with 1 to 4 L298's. It can be used as a booster (1), then the ATMega part is not needed, OR it can be used as a DCC++ system and then one can use a LocoNet connection (2) OR a DCC connection (3) but not simultaneous (it's 2 OR 3) and a serial connection (4).

    @ FlightRisk I thought about using an Uno or Mega, but I'm not overly happy using jumper wires to connect all kinds of stuff. It's nice to do some prototyping with it, but if it has to work reliable for some time one might get problems with oxidized contacts, loose wires etc. Not what I want. I'll start doing some testing with the sketch as it is and see if I can add a second motor shield.
     
    FlightRisk likes this.
  14. S t e f a n

    S t e f a n TrainBoard Member

    167
    93
    6
    Sumner, I might have prompted the confusion with my question about where the development version is. I think the web page is pretty safe, since as far as I could tell it does NOT contain a pointer to the CommandStation code (=development version).

    I am also in favor of a bit more detail on the hardware recommendations for the default setup. For example mentioning that current sense is needed on the motor shield, if one deviates from buying the standard Arduino Rev 3 shield. I initially bought a clone with different pinout and more importantly without current sense, thinking I could make it work with a few changed pin assignments in the code...

    Willem, if you want active current monitoring and overcurrent protection(*) for the additional L298s, then either dedicated hardware or an Arduino needs to be involved that can monitor the current for each power district and turn the DCC signals off for the district that has the short. That could either be the commandstation Arduino (which is what I thought you wanted), or the Arduino on your booster PCB; but you either need to feed back the L298 current sense lines to the command station, or you'd need to route the DDC signals from the commandstation through the Arduino on your PCB, and feed the current sense lines back to it from the L298s.

    (*): beyond the built-in the L298 over temperature shutoff; interesting link: https://www.rugged-circuits.com/the-motor-driver-myth
     
  15. Sumner

    Sumner TrainBoard Member

    2,798
    5,837
    63
    If you run the installer I believe all three versions are options to pick from. Not sure if the installer is working currently,

    Sumner
     
  16. S t e f a n

    S t e f a n TrainBoard Member

    167
    93
    6
    Geez, it already changed after I looked at it. Flightrisk said I caught it at a bad time, or something...
     
  17. mijnmodelbaan

    mijnmodelbaan New Member

    7
    5
    4
    Indeed I want as much protection as possible, but with the 'standard' Uno or ATmega it won't work, not enough analog pins. That's why I looked into using the ATmega328P-AU which has 32 pins and 2 of those extra 4 pins are analog pins, exactly what I need to make 8 analog pins. Have to check if there will be enough pins left for the other things needed, but there might be just enough pins.

    Well, it might look interesting, but they just want to sell their motor shields. If you ask STMicro to write such an article featuring the L298, the outcome will be just the opposite. That's how advertising works. Maybe we could organise a poll, asking the users of motor shields about their experiences, could be interesting to know how the various shields hold up in practice.
     
  18. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    I agree it is an interesting link and I also agree with @mijnmodelbaan that it looks more like an ad than a neutral review of the two items.
    That said though, the DRV880x is a superior h-bridge IC overall due to it's built-in capabilities. The DRV880x is capable of providing up to 2.8Amp, most usages will limit to around 2.5A by adding a 0.2Ohm R on the SENSE pin to GND. One downside to the DRV880x is that you would need two of them to have the two output pairs you get from the L298, but I don't see this as a major downside since you can control the output voltage of each individually whereas the L298 has only one voltage source pin.

    I think this has been done and virtually everyone uses the L298 due to the built-in support for it *BUT* they all complain about the very low cut-off (~980mA). @FlightRisk did adjust things a bit to increase the cut-off work in DCC++EX which is helpful.

    My fork of the DCC++ code which was used for DCC++EX originally had exactly this support. However, it required the signal (DIR) pin to have a jumper from the MAIN track output. However, I wouldn't recommend adding it back in if it was removed! I'd highly recommend instead switch to exposing the power-station interface and recommend externally controlled boosters for the extra outputs. This is more inline with how all commercial offerings are handled, and it offers the extension of receiving RailCom feedback from boosters if/when DCC++EX supports that. Note that both ESP32 CS and FireBox support the power-station interface with RailCom feedback (@David Cutting please correct if needed), similarly the upcoming TCS CS will support the same (and when they release it the TCS booster)
     
  19. S t e f a n

    S t e f a n TrainBoard Member

    167
    93
    6
    Atani, could you explain what you mean by that? Is it a switch in the code? Just using the DCC pins without current monitoring feedback is not that useful, if you want to actually control (including being able to reset) external boosters.
     
  20. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    NMRA standard S-9.1.2. There is a draft update to the specification here and the tech note here. There is also an extension to this draft specification here which adds RailCom feedback support. These drafts are currently in the review comment phase and will be presented to the NMRA body for adoption in the coming months. I've been working with the author of these drafts on implementation of these within ESP32 CS (@David Cutting has done similarly in FireBox)

    Very few commercially available boosters will interface at the track voltage or report their state via the track, they comply with the spec linked above. This shifts the responsibility of monitoring the booster outputs from the CS to the booster.

    I'd suggest draft an extension to the DCC specs to define that use case as it is not standardized across manufacturers.
     

Share This Page