Introducing DCC++ ---a complete open-source DCC station and interface

Gregg Aug 25, 2015

  1. KE4NYV

    KE4NYV TrainBoard Member

    219
    281
    17
    There are some RS485 sheilds out there and I can only assume libraries to go with them. I'm integrating the RS485 transceiver directly into the HHT I'm designing. You bring up a good point, we need to make sure there is a viable source of shields for those who want to "build onto" their already present stack. Luckily, with RS485, it's a matter of feeding the TTL serial lines in and the transceiver takes care of the rest.

    One option:

    [​IMG]
     
    Last edited: Jan 20, 2016
    Scott Eric Catalano likes this.
  2. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    ISCOLD, I'm going to need to know the rest of that information to help me diagnose...

    Which version of JMRI are you using?

    Are you using a PC, Mac, or Linux box?

    Are you trying to connect your base station via USB or Ethernet?
     
    ISCOLD and Scott Eric Catalano like this.
  3. ISCOLD

    ISCOLD TrainBoard Member

    36
    38
    3
    I am using JMRI version 4.3.2-R2 edd195
    I am using a PC 64 bits Windows 7
    I am connecting my base station via USB
    The Java version in my laptop is 8 uppdate96.
     
    Scott Eric Catalano likes this.
  4. mikegillow

    mikegillow TrainBoard Member

    116
    117
    13
    When you start JMRI for the first time it should take you to a screen to define a Connection. Did it do that? Or can you not get in the first time to even set up the Connection?
    Please note that if you have defined a connection for DCC++ on a serial port and try to start JMRI without the Base Station connected to the USB port (or if the COM port number for the Arduino changes), it will throw an error message and then when you click OK, it will just sit there with the small JMRI window and never pop up the rest of the JMRI program (at least that is what happens to me).
    Also, do you have the Arduino IDE running and the Serial Monitor open? If so, you must close it. Same applies if you have Gregg's Controller program running. Only one application can be connected to the Arduino over the USB port at a time.
     
    ISCOLD and Scott Eric Catalano like this.
  5. dcsun

    dcsun TrainBoard Member

    23
    16
    2
    SOLVED! The jumper wire on the motor shield was no good! It worked okay enough to do the troubleshooting with the LEDs but not enough to carry signals for the tracks.

    I am still curious if there's a "read" command for the main track, though, if anyone knows the answer to that. I don't see one in the commands list on the GitHub site.

    Dave
     
    Scott Eric Catalano and ISCOLD like this.
  6. Gregg

    Gregg TrainBoard Member

    237
    311
    18
    That great news! Glad everything is working.

    As for your question - There is no read command on the main track. It's not a limitation of DCC++. The DCC standard does not support reading on the main. If you notice when you read from the programming track, the engine should pulse a bit. It's this pulsing on an otherwise quiet track that the base station senses to "read" the CV. This would not be possible on the main track since other trains are presumably operating. Reading CVs in DCC is very "clunky."

    -Gregg
     
    Scott Eric Catalano and ISCOLD like this.
  7. dcsun

    dcsun TrainBoard Member

    23
    16
    2
    Thanks, good to know. Ya I could definitely hear a few pulses when reading and writing to/from the decoder.

    Random question for you or anyone else, what speed setting is usually required to get a loco moving on an HO track? I've put decoders in two locos now and they seem to need to be at 40+ before they move. Is that normal or do I maybe have power issues?


    Dave
     
    Scott Eric Catalano and ISCOLD like this.
  8. Gregg

    Gregg TrainBoard Member

    237
    311
    18
    That's likely due to your 15v supply. 18v is more typical for HO and you'd see a lower starting throttle. But there's nothing wrong with operating at 15v.
     
    Scott Eric Catalano and ISCOLD like this.
  9. dcsun

    dcsun TrainBoard Member

    23
    16
    2
    Okay good to know. I switched my power supply to 18V (one of those replacement laptop ones with a bunch of settings), it's reading 18.24V going into the motor shield but still needs 40 something to get moving. I'll keep playing with things and see what happens.

    Thanks for the replies :)

    Dave
     
    Scott Eric Catalano and ISCOLD like this.
  10. ISCOLD

    ISCOLD TrainBoard Member

    36
    38
    3
    Dave,
    In my case, using an UNO MEGA , a Polulo Motor Shield and a Laptop power soucer 125W 15V output, the engine start at 002 of master control. Very fine control.
     
    dcsun and Scott Eric Catalano like this.
  11. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    I use a Digitrax power supply and it depends on the brand of decoder....also make sure decoders are set on speed step 128....my older decoders move at 10 while others move at 1 or 2
     
    dcsun and ISCOLD like this.
  12. mikegillow

    mikegillow TrainBoard Member

    116
    117
    13
    I've looked for an existing Arduino-based DCC booster and although I found code for one on Github (by CustardCat) it didn't cover any of the hardware details.
    I barely know enough about the component side of this to be dangerous so I won't take offense if (when) someone corrects me on this.
    If I take the optocoupler piece from Geoff Bunza's decoder design and feed it the Main output from my Base Station, wouldn't the resulting output from it be the same as DCC_SIGNAL_PIN_MAIN on my Base Station? If so, then a Booster Station would need to have a way to know when signal was present (still have to think about that piece) so that it would turn its own Enable output(s) on, plus have a modified version of the short circuit protection that would automatically turn itself back on after a short delay, but the signal that would normally be fed into the M1DIR of the motor shield would come directly from the optocoupler output. Or do I have this all wrong?
     
    Scott Eric Catalano likes this.
  13. DwayneG

    DwayneG New Member

    8
    12
    5
    When would you need a dcc booster is it based on the size of the layout or number of trains you run?
     
    Scott Eric Catalano likes this.
  14. mikegillow

    mikegillow TrainBoard Member

    116
    117
    13
    Mainly based on scale and number of trains, which often is based on size of the layout. In my particular case, since I run HO, I opted to build a DCC++ Base Station using the Pololu motor shield to get the higher max current output. Its built-in short circuit protection reacts faster than an EB1 or an AR1, which means no power districts and manual auto-reversing for a turntable or reverse loop/wye. The Arduino motor shield doesn't have the built-in short circuit protection like the Pololu. I intend to build a Booster that uses the Arduino motor shield to service a section of my layout that will have a turntable and use an AR1. I could use the Tam Valley booster but I'd like to build my own. I like the challenge (plus I'll save around 75%). The Arduino shield doesn't have the same power output capacity as the Tam Valley booster but it will suffice for this application. The Booster design in my head also lets it service two 2A power districts so I'll add a second booster down the road as I build out my layout and have it divided into 5 power districts.
     
    Scott Eric Catalano likes this.
  15. ISCOLD

    ISCOLD TrainBoard Member

    36
    38
    3
    Many thanks Mikegillow, now I can run JMRI.
    There are a lot to learn about this complete software.
     
    Scott Eric Catalano likes this.
  16. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Hi Mike,

    I've been thinking of solutions to similar problems like yours.

    A booster is basically an H Bridge circuit which amplifies the logic level signal to something we can use to drive the trains. Similar to how an audio amp boosts a low level signal to something that will drive a speaker.

    So the Arduino Motor Shield is a dual H Bridge driver circuit, a fully fledged booster, albeit limited to 2 Amps per channel.

    I got to thinking that if you don't need to drive any power district higher than the 2 Amp, then 2 such shields stacked and configured correctly would provide 1 x Programming and 3 x Main outputs.
    A separate power supply to each shield would probably be best. Then there is also the issue of current monitoring, though Pins A2 and A3 are free. So this could maybe added to the software if Gregg sees this as feasible.
    Trouble there is, if a circuit triggers 'short' then the whole layout gets shut down. That could also be a good thing though !

    Would need confirmation from the experts on this, namely whether the Main logic level outputs of the Arduino can drive 3 H Bridge channels simultaneously. Alternatively can the 'Main' logic be mirrored to some spare pins on Arduino?

    Another scheme could use an array of the L298N driver boards, which are a very cheap substitute non-shield device. Again subject to parallel connection being possible, and if not a simple multi-way connection circuit could be employed.
    Optocoupler or transistor arrays for example.

    Thoughts Anyone?

    Steve.

    PS. On a side note. This would appear to be an all singing WiFi solution for those interested.
    Yes it does AP !!! http://www.dragino.com/products/yunshield.html
     
    Last edited: Jan 21, 2016
    esfeld and Scott Eric Catalano like this.
  17. KE4NYV

    KE4NYV TrainBoard Member

    219
    281
    17
    If you're actively following this thread, you should head over to the Support forum and "like" mikegillow's request to create a DCC++ sub-forum. I'm hoping the likes will be identified as votes for the idea.
     
  18. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Steve - you may be interested in some tests that I did today with the Arduino Motor shield and one of the eBay clones of it - each uses an L298 motor controller IC. I found that you can only count on getting about 1 amp from these boards and that is when you add a heat sink and small fan to keep them cool.

    My notes are here: http://trainelectronics.com/DCC_Arduino/DCC++/#Shield_Power_and_Thermal_Tests__

    On that same page you will also find a 5 amp H-Bridge that I tested - it doesn't give its rated power either but will run reliably at 3 amps with the addition of a small fan. Here is a direct link: http://trainelectronics.com/DCC_Arduino/DCC++/#A_5_Amp_Controller - Please note that this device does not provide a programming track output and needs a simple 1 transistor circuit to connect to the DCC+ Arduino.

    I have ordered a number of other H-Bridge units for additional experimentation. Stay tuned!

    dave
     
  19. Gregg

    Gregg TrainBoard Member

    237
    311
    18
    Mike, I think you have this exactly right. You could use an opto-coupler tied to the tracks to reproduce the original DCC logic signal. This signal could be brought directly into the DIR pin of another motor shield to create a separate DCC source.

    You can also take the logic signal directly from the original board as HVT demonstrated. However, one concern with that is whether this signal will degrade or get noisy over appreciable distances. Another potential issue is whether it can drive multiple other motor shields.

    As noted by Steve above, you can stack multiple shields on top of each other which would ensure the DCC signal gets to the pins of each shield, but then you lose individual control of the enables and current monitoring.

    I've being reviewing the RS485 spec over the last few days and think that the small $3.00 add-on boards that utilize the MAX485 TTL-RS485 converter chip might be a very good solution for how we can broadly distribute a single DCC logic signal from a main board to many other boards.

    There are three ways we can have the "booster" base stations process the signal. The first is to not process it at all and just feed it into the second motor shield as HVT demonstrated. Carrying the signal over RS485 would solve the problem of distributing it over long cables and to multiple other shields. The Arduino running those other shields would have full enable/disable control as well as the ability to monitor current. Of course we still need a method of having the master Arduino communicate some set of commands to the remote Arduinos but that's a separate issue (see below).

    The second way that the booster Arduino can process a master DCC signal is to use it as an interrupt trigger on one of the Arduino pins. The code triggered by the interrupt would simply echo the signal back on the DIR pin of the motor shield. The downside to this is that it introduces a very slight delay, which I don't think would be an issue but must be tested. But there is a big upside to this: As an alternative to simply echoing the DCC signal, the interrupt could echo the inverse of the signal, effectively reversing the polarity of the Motor shield output. What this means is we have a generic booster that can be used to operate a power district OR be configured as an autoreverser. Could just be an option in the software.

    A third method would be to run the master DCC signal into one of the inputs of a logical XOR chip near the booster Arduino. The output of this gate would then be fed into the motor shield DIR pin. The second input to the XOR would be fed by an Arduino pin. When that pin is LOW, the DCC signal is simply passed through the XOR chip. When that pin is HIGH, the DCC signal is inverted. The advantage of this method over using an interrupt within the software is that you avoid the need for the Arduino to handle the inverting in software. The disadvantage is the need for a separate XOR chip.

    Of final note, we still need a way to have the master Arduino communicate with the boosters. I'm going to play with the TWI/I2C this weekend but this likely will not scale to any appreciable distance.

    Using an RS485 will help here, but it is not a full replacement. RS485 is just a spec for the transmission of a digital signal. We would need to create or utilize a communication protocol to transmit actual data. You can always simply connect the RS485 to the serial pins on the Arduino, and this works fine. But this mechanism does not inherently support addressing multiple boards at the same time. However, I think we could add a few simple commands to the DCC++ command set that could be used to address other boards.

    In sum... It may be possible to create a "generic" DCC++ auxiliary station using an Arduino and a Motor Shield. This auxiliary station could be used as a booster to operate separate power districts, each with its own enable/disable control and short-circuit protection. It could also be used as an autoreverser, which is basically just a power district in which a short-circuit does not disable the power, but rather flips the polarity of the signal. And thirdly, it can be used to extend the sensor pins and output pins so you control more switches and servos.

    Of course all of this is in theory. Now I need to order some max485s!

    -Gregg
     
    KE4NYV, dcsun, KC Smith and 2 others like this.
  20. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Thank You Dave,

    Interesting findings indeed.

    Kinda makes you think these devices should be rated in Watts.
     
    Last edited: Jan 21, 2016
    Scott Eric Catalano likes this.

Share This Page