DCC++ EX Hardware Thread

David Cutting Apr 8, 2020

  1. David Cutting

    David Cutting TrainBoard Member

    62
    29
    3
    Okay so dumb question... why can't we just use the current sensing capabilities baked into the motor driver chips instead of adding in extra circuitry? @haba are you able to test this on your setup?

    Here's another schematic that uses one of the DCC rails as GND... https://www.opendcc.de/elektronik/gbmboost/BiDiB_GBM_Boost_1.9.1_sch.pdf ... I'm not a huge fan of this at all.

    I'm now looking at using the DRV8874 or DRV8876 motor drivers on my board. The produce an sensing output current proportional to the driver's output current, and they feature automatic current limiting. The best part is that they are pin-compatible and one is rated for 3.5A and the other 6A, so a shield could have one programming track and one main track, or two main tracks.
     
    Last edited: Apr 19, 2020
  2. haba

    haba TrainBoard Member

    78
    32
    10
    I have not wrapped my head yet around if this is possible. I think reading from the DAC is slow, maybe too slow.

    Regards,
    Harald.
     
  3. Jasenk

    Jasenk New Member

    3
    2
    1
    I did a search for the display with PCF8574 chip and really couldn't confirm any of the displays actually had this chip. What displays can you recommend and what Arduino Mega Pins are set for I2C communication?

    Also I am using DCC++ and have verified almost all usable I/O that aren't tied up with Ethernet Shield or The Motor Driver. Does anyone have a list of open pins for I/Os with DCC-EX or is it the same as DCC++? Either way I haven't seen a published list. I have an excel spread sheet I use to understand all the pinouts thus far. Maybe I can contribute with that and make some modification to allow for the various hardware configurations if some hasn't already.
     
  4. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    You can search "I2C PCF8574" and find a lot of displays. They need 2 parts, the display and the control board. You can get them at digikey, amazon, banggood, aliexpress, etc.. You need the SDA and SCL pins. A4 and A5 on the Uno, 20 and 21 on the Mega. You could use any display if you changed the code, but we are using the LiquidCrystal_PCF8574 library. You can search for information on that. It also requires the Wire library.

    Here is a graphic on the used/available pins. Obviously, the Mega has many more that are not under the motorboard

    https://dcc-ex.github.io/assets/Motor Shield Pin Mappings.pdf

    We will add to this list since we keep using pins ;) Haba added a trigger pin so we can start a scope or analyzer capture. If you use Ethernet, that requires pins. That won't work on the Uno because there aren't enough. I'll have to check and see what the esp9266 networking interface requires.
     
  5. Jasenk

    Jasenk New Member

    3
    2
    1
    Thank you for the quick reply. I’m sure I have some displays that will work. What all is displayed by DCC-EX?

    -Jasen
     
  6. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    Here is a display. Zoom in and you can see the chip name on the backpack module:

    https://www.amazon.com/dp/B019K5X53...d-us000-pcomp-feature-scomp-wm-5&ref=aa_scomp

    and here:

    https://www.aliexpress.com/item/330...earchweb0_0,searchweb201602_,searchweb201603_

    You need to make sure you are ordering a set with both items or order them separately. Some people have ordered and got just one or the other ;) There are different colors, different and different number of lines. You could use a display with more lines to get more information.

    DCC++ and DCC++ EX are based pretty much on the same code. We may add a command or add an item in the response to the command. We change or replace code, but it does the same thing, just (hopefully) better. We did add an optional pin as I mentioned above, but most people won't use it so they could use that pin for something else.

    It is easy to display whatever you want, but right now it displays startup information, networking info if you add networking, and power status. We will probably add a warning for overcurrent. It will be interesting to see how people want to use it. It really isn't necessary for operation. You have the serial monitor or JMRI to give you a lot of information. I just looks cool ;) Keep in mind that everything you add reduces memory. On the UNO, we have to be very careful to make sure it all works. We recommend a Mega or Mega clone.
     
  7. David Cutting

    David Cutting TrainBoard Member

    62
    29
    3
    Okay - I've been quiet for a while, had to wait for my oscilloscope to come in the mail. But it's finally here and things are working! Well, mostly. I'm not getting any feedback on the programming track (ACKs), and there doesn't seem to be an RailCom data coming through. Here's my O-scope printout:
    SDS00001.png
    What do I have to do to get a railcom decoder to talk during the cutout? I'm running a new LokPilot v4.0, which comes with Railcom turned on by default.

    As for the ACKs, maybe there's too much noise or the threshold is wrong. More to come...
     
  8. Quax

    Quax TrainBoard Member

    27
    5
    8
    With my Arduino Due based setup I get a RailCom response from the decoder after moving the throttle in JMRI. So I guess that a „throttle command“ (maybe even v=0) is needed to let the decoder send out RailCom data.
     
  9. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Most locos will not respond to RailCom unless they are being addressed...
     
  10. Quax

    Quax TrainBoard Member

    27
    5
    8
    Okay, so if we like to detect all locos that are put on the track at some time (I think that this is the RailCom plus feature) we need to send out some command to all possible decoder addresses?
     
  11. David Cutting

    David Cutting TrainBoard Member

    62
    29
    3
    Solved! I have railcom data coming through on my H-bridge current sense line (blue), and it is being cleaned up by an LM393 (green). I'm using the DAC on my SAMD21 to generate an 18mV voltage for the LM393, so the only other component needed is a pullup resistor. The pink and yellow lines are the DCC bus voltage. You can even see the serial decode feature picking up the railcom data - maybe not very accurately, but it's there. Exciting!
     

    Attached Files:

    Atani likes this.
  12. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Not necessarily, the decoders can be configured to always respond for ch1 (occupancy) or ch2 (POM response, etc). The occupancy data is not very useful when more than one loco is in a detection block as they can try to transmit concurrently which will corrupt the data.

    A pull-up should be added anyway for the UART data (that is what the RailCom data actually is).

    It looks like you have captured both CH 1 and CH 2, but they may be corrupted. Try attaching UART decode to the green line with a pull-up on the line to see if you get a different value. There should be up to two bytes (12 bits) for ch1 and up to four bytes (up to 36 bits) in ch2. The 0x2E that you captured for ch1 first byte looks like it might map out to 0x37, is the decoder using address 55 or 56?
     
  13. David Cutting

    David Cutting TrainBoard Member

    62
    29
    3
    Looks like it was just a problem with my O-scope decode settings. I changed the idle level and fine-tuned the baud rate, and I'm getting the following:

    CH1:
    10100011 -> 0x04
    10101100 -> 0x00

    CH2 (6 bytes according to the spec):
    00001111 -> NACK
    00001111 -> NACK
    00001111 -> NACK
    00001111 -> NACK
    00001111 -> NACK
    00001111 -> NACK

    How do I know which locomotive this is referring to? I am currently commanding a decoder on address 3.
     
  14. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    You will need to decode the ch 1 data further to a 12 bit value, which would be:
    0000.0000.0010 = 0x002 (If I decoded it correctly, entirely possible I did it incorrectly...).

    But, that 12-bit address 0x002 is the "on-the-wire" DCC decoder address for decoder #3.

    The fact that channel 2 came up as all NACK is not entirely unexpected, if you send a POM command you should get back something a bit more interesting in channel 2...

    Also of interest is detecting the direction of travel of the locomotive based on which rail the signal was received on which can be detected in hardware if you have the right setup...
     
    David Cutting likes this.
  15. David Cutting

    David Cutting TrainBoard Member

    62
    29
    3
    I just ordered PCBs from seeed studio for the SAMD21 base station. I managed to get all the functionality I wanted into a ~60x60mm footprint. Here's a quick render of the board...

    SAMCommandStation.png
    I've included the following features:
    • Railcom detection on both main and programming tracks with software-adjustable detection threshold.
    • Expansion headers with external interrupts that allow different expansion modules to be added:
      • Booster station add-on turns the board into a booster that repeats the signals coming from loconet or another block
      • LCC/LocoNet/CMRI/S88/etc. add-ons allow control of a layout bus.
      • Direction-sensing railcom
    • 6A peak current on main track and 3.5A peak current on programming track. By populating different chips, I can have two channels running at 6A peak current.
    • Dual I2C expansion headers, compatible with Sparkfun Qwiic system of sensors and screens.
    • I2C based EEPROM (SAMD21 doesn't have internal EEPROM so this is needed)
    • ESP8266 module (ESP-WROOM-02D) pre-integrated on the board for wifi connection.
    Boards should get here in less than a week, and hopefully it'll work!
     
    Last edited: May 15, 2020
    KC Smith and Atani like this.
  16. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    Can't wait to see it. Are you having them soldered or are you going to have to solder the SDMs on there? If so, did you have a stencil made up so you can just use solder paste and a squeegee on it?
     
  17. David Cutting

    David Cutting TrainBoard Member

    62
    29
    3
    For prototype boards, I always do the soldering myself. I've made ten or twenty boards of different designs by now. I've even done a small signal decoder production run by hand. My procedure is to squeegee the paste on using a stencil and credit card, then populate the components by hand and finally bake the board in an electric skillet until the solder all melts. I rarely get solder bridges even on the tiny leads, and those are easily fixed with solder wick.

    Cost on these boards is hard to say because of the low quantity of prototype boards, but I think most will be happy with the price once I run a batch. I expect it'll come out to less than a Arduino mega and motor shield setup with wifi - and all while packing a couple more horses than an Arduino Mega.

    David
     
    Atani likes this.
  18. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    prototype runs are always more expensive... My ESP32 CS PCBs with shipping from JLCPCB run a bit over $2 USD IIRC when ordered in batches up to around 20, going higher will cut the cost a down (which I will be doing very soon!).

    Your PCB looks good, one thing to caution though... PROG track *MUST* be limited to 250mA per spec, I have a section of the schematic to do just this on my PCB.

    For the RailCom on MAIN and PROG, are you sharing a single circuit and alternating between the two or dedicated circuit? Also on the topic of RailCom, with LCC there is a proposal to support RailCom feedback via the LCC bus via the DCC pins in the CAN connector (pins 4, 5). I haven't figure out how to deal with the feedback on that just yet but will need to consider a slight redesign of the PCB to handle this feedback.
     
  19. haba

    haba TrainBoard Member

    78
    32
    10
    Yes, I agree, PROG track must be possible to limit to 250mA. But the limit does not need to be in hardware?! It's easier to make the limit in software as one wants to make this configurable. There are this (sound) decoders that otherwise trigger the limit.

    Regards,
    Harald.
     
  20. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    That is true, it is easier to detect and react in code but a hardware limit is very easy to do as well. *BUT* the problem is most h-bridge chips have only one power input even if they have multiple power outputs (L298 has two, Pololu MC33926 has two, etc) so you may run into problems implementing a hardware only solution.

    In the case of OPS and PROG each having a dedicated h-bridge it is very easy to add a current limiter to the PCB to ensure that it is compliant with NMRA specs.

    Most of those likely being older generations that were likely not NMRA compliant to begin with (S-9.2.3 section B item #2 - lines 13-15). However, the next piece of the spec says that it should be limited to 250mA, possibly via current limit resistor.

    Another spec to refer to that is more up-to-date is RCN-216 (more). The Rail Community group has been working extensively on improving many of the standards and these are being used as part of the NMRA spec refresh which is already underway one being S-9.1.2 (spec, tech note).

    @David Cutting please review this thread as it may require some minor tweaks to your PCB (relates to S-9.1.2 and RailCom over LCC).
     

Share This Page