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

Gregg Aug 25, 2015

  1. Ivan Strom

    Ivan Strom New Member

    8
    9
    1
    Hi Gregg -

    First, thanks for writing excellent, fast, well commented code.

    I'm looking to add a feature for controlling reversing loops to the code (which I'll send to you once I have it debugged on my layout). I use two on my layout sharing a common auto-reverse unit (its possible, but very unlikely, that metal wheels will cross multiple start/end junctions at the same time). I'd like to instead have this processed by the Arduino. I have two possible solutions - the first requires relays, the second requires an additional motor shield. I've thought the first one through - need your help on a couple of items for the second.
    1. Run the main track output to 2 switches on a relay board or shield (using them as a DPDT switch) and from there to the reversing loop. Define pin RELAY_PIN_REVERSINGLOOP to be a pin on an Arduino UnO or Mega that controls the DPDT switch. When current is exceeded and the pin is defined, the overload loop then toggles the pin and, after waiting for several cycles (I'm assuming the relays take about 40ms to switch) retests the current to determine if it should disable the motor shield channels or not. (I already wrote this code and hopefully will test it later today - if that doesn't work I can move on to solution 2).
    2. Am I correct that each timer circuit puts its outputs on both its A and B pins? If I'm reading your code correctly (I've not used PWM before) it looks like both outputs are the same, but one isn't used. If B is the one currently going to the tracks, my thought is then to use code similar to solution 1 to manage the COM1A0 bit, inverting the output to change polarity as needed, with the output of the A channel then going to an additional motor shield which would feed the reversing loops. Does that work, or am I misunderstanding your code?
    BTW - my existing reversing unit (MRC AD520) buzzes (the relay oscillates) when fed by DCC++ (this doesn't happen with my existing controller, an MRC2000). Any idea why that might be the case?
     
    Scott Eric Catalano likes this.
  2. ronp849

    ronp849 New Member

    9
    2
    2
    Hi Ivan

    I have been thinking along similar lines but instead of using a second shield, I was thinking of using the programming output instead. (The hardware is so cheap, I would have a completely separate system for programming).

    Ron
     
    Scott Eric Catalano likes this.
  3. Ivan Strom

    Ivan Strom New Member

    8
    9
    1
    I have my code working and tested - I'll post it shortly to the board.

    But I had one question - the current monitoring code checks the main track and the programming track against CURRENT_SAMPLE_MAX, which is a value of 300. But if the Arduino Motor Shield is giving out 1.65 volts/amp, and the analog input pin is scaling 0-5 volts to 0-1023, doesn't that mean that both channels will "short" if the current exceeds .888 Amps (.888 amps * 1.65 volt/amp * 1024/5volts = 300). That seems too high for the programming track (NMRA standards limit current to .25 Amps), and too low for multiple HO engines on a main layout. Is there scaling going on elsewhere in the code?
     
    Scott Eric Catalano likes this.
  4. Atani

    Atani TrainBoard Member

    1,466
    1,736
    37
    The Arduino Motor Shield only provides 2A total between both PROG and MAIN. The code is configured for ~90% capacity of that. This value is not ideal for all motor boards and has been extended by others. Also note that a short on PROG OR MAIN will cut power to BOTH! A few of us have altered the code to only cut the power to the channel that is overloaded.
     
    Scott Eric Catalano likes this.
  5. Ethan

    Ethan New Member

    1
    2
    1
    Hey Guys

    I have been reading up on the DCC++ for a while now and just finished converting a Z scale steam engine to DCC++ using a ZIMO Mx648. I have never done anything model train wise but really wanted this addition as I am building my scene. I have everything working with the base station and controller except the F Function keys! It's driving me crazy that I can't seem to figure out in any writing about DCC++ how to get the keys to show up and work! Do I need to get into the code and write it out, if so where? I have CAB 2004 set to my address but the Function keys are still just Headlight and taillight, neither of which do anything at all. I am at my wits end here... Thank you so much for a great resource and I am sure it is something super simple but I need help!
     
    Scott Eric Catalano and sboyer2 like this.
  6. John W Zerbe

    John W Zerbe TrainBoard Member

    96
    59
    7
    Hello all.
    I'm just getting into dcc++ and dcc in general. I have already jumped in with buying an arduino mega 2560, the arduino motor shield and have that hooked via usb to a Raspberry Pi 3 where I have the arduino software installed as well as JMRI. I've been in the IT business for over 30 years and know my way around programming and some level of electronics. I had an interesting thought on a modified application of this hardware/software combo. I have a few older DC trains that just cannot be converted to DCC. My thought was that since the motor shield is actually designed from the start to drive dc motors, why not do a mod that allows a uno/motor shield pair to drive the dc voltage to an older isolated track for these engines? Possibly drive a trolley that trips sensors that the ardunio can read and relay to jmri that allow the software to pause the dc driven trolley at stations, stop and "end of line" and change direction, etc. From JMRI's perspective it could be simply cab control commands for a hard coded train id. ie only throttle and direction.

    I've looked at the code and frankly it doesn't look like that bad of an addition. JRMI could drive both the current DCC++ controller/shield combo as well as one that is configured to just drive the dc voltage for potentially two tracks.

    Granted, one would have to be really careful about which locos you put on which tracks or else you could "let the smoke out". (Its generally known that electronics actually run on smoke. If you ever let the smoke out, they stop working.)
     
    Scott Eric Catalano and sboyer2 like this.
  7. ObiJay

    ObiJay New Member

    5
    6
    9
    How would I control switches with this? I am running JMRI Headless on a RaspberryPi 3, hooked to the DCC++ command station via USB. I use WiThrottle to control the trains. This layout will have 11 switches on it.Great project!!! Thanks, Jay
     
  8. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    Hi,

    I have successfully built a DCC servo decoder based on an Arduino Nano and use it to operate 4 points, (though many flavours of Arduino should work) I have used the design on Rudys Model Railway site. Although I believe the design only supports a maximum of 6 servos per Arduino, the hardware is cheap enough to build two decoders which would suit your requirement for eleven switches. Rudy's site does also have designs to suit solenoid operated points.

    The design works well for my small layout, though there is no feedback from the points.

    https://rudysmodelrailway.wordpress.com/software/

    and

    https://rudysmodelrailway.wordpress...uino-dcc-servo-and-function-decoder-software/

    Jim
     
  9. dottney

    dottney TrainBoard Member

    118
    19
    20
    I just found this thread and the DCC++ web site and am fascinated with the project. I have seen arduino projects but haven't jumped in on one yet as I found the programming and ancillary hardware a bit daunting. The explanations in the videos on the DCC++ site are great. I'd like to give this project a try as the hardware and software stuff seems to be all taken care of.
    I have a lot of experience with JMRI and use it on my large N scale layout and a shelf HO switching layout. Both run from Mint Linux machines through NCE systems and use Android & IOS devices as throttles. I'd like to experiment with DCC++ on my test/programming track loop.
    Am I correct in assuming that what I would need is the Arduino Uno, Motor Shield, 12-15v power supply, computer with USB cable connected to the Arduino and the Base Station software? Then would I be able to run JMRI on the computer through the DCC++ Base Station to my test/programming track loop?
    I'm off to read about how to install the Base Station software on an Arduino ( I assume its done via the USB cable connection) and more of this thread (81 pages-yikes).
    Thanks for any answers and suggestions.
    Dave
     
    Scott Eric Catalano likes this.
  10. dottney

    dottney TrainBoard Member

    118
    19
    20
    I forgot to put this my original post. Are all Uno boards the same? I found this one for $4.39! http://www.gearbest.com/development-boards/pp_62975.html
    Newegg has a couple for under $10 and then there's Ebay.
    Plowing through the thread I see that you have to be mindful of the Motor Shield you buy (early posts showed this).
    Thanks
    Dave
     
    Scott Eric Catalano likes this.
  11. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    There's two basic ways to control switches with DCC++, with a couple of variants on one of them.

    (1) You can use a standard DCC stationary decoder hooked to your track bus (e.g. a Digitrax DS44 or DS51K1 or an NCE Switch-IT or similar).

    There are two variants of this, depending on how you configure JMRI. One, you directly send commands to the stationary decoder, using the DCC++ base station as just a "pass through" of sorts. Two, you can configure a "look up table" in the Base Station so that the Base Station keeps track of the decoder addresses, and JMRI just has Turnout Index number to send the commands to.

    (2) You can use one of the Base Station's GPIO pins to drive ... something else ... that triggers a turnout control. There's too many variations on the wiring of this to go into detail here, but think of the Base Station GPIO as being a JMRI controlled fascia pushbutton triggering whatever device actually throws the points. In this case, there is a lookup table in the Base Station so JMRI uses an Output Index to send the command.

    There are somewhat-improved instructions on both these methods in the JMRI Help pages

    The other option you have if JMRI is in the picture is to use a separate interface for turnout control, and use DCC++ solely as train control. You can, for example, hook up a Lenz XpressNet or Digitrax LocoNet, or directly drive things using the Raspberry Pi's GPIO pins, or whatever you like. This is not hard to do, but is probably outside the scope of the DCC++ forum.
     
    Scott Eric Catalano likes this.
  12. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    I'm proto testing a board that will control turnouts and it is specifically designed to work with an arduino and provides feedback and you can put leds on it...I will show video soon. It does not use servos...it is for snap switches...atlas, bachmann lifelike etc
     
    VaBEast likes this.
  13. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    Ooh! That sounds nice...
     
    Scott Eric Catalano likes this.
  14. Ivan Strom

    Ivan Strom New Member

    8
    9
    1
    I've been thinking of doing this as well, using automation. The idea would be to use automation and blocks. DC (or preferably pulsed DC, which I found is better at getting over dirt on track) would be supplied to a block with has a DC cab. As the cab approaches the next block, the software would determine if the block was occupied - if so the DC train would stop and wait - if not the next block would be toggled to DC (using relays for each block). That would permit a DC train (maybe even more than one) to run over the entire layout.

    Until I get around to that (I'm making other changes before then) I do have one section where I use DC. What I decided to do was power that section off the main track via a decoder (i.e. the decoder feeds the block of track rather than the cab). That then treats the entire system as though it were DCC (e.g. I can use JMRI throttles).
     
    Scott Eric Catalano likes this.
  15. Ivan Strom

    Ivan Strom New Member

    8
    9
    1
    Hi Scott -

    I've been doing something similar - my solution is based on a 16 relay board (about $14 on Ebay). What I did was modify Accessories.c, which assumes that subaddresses range from 0-3. What I did was add code that if the subaddress is in the range 4-254, the software assumes that the address/subaddress pair refer to Arduino output pins used to close or throw a turnout. When a <T ID THROW> command is received and the stored subaddress is in the 4-254 range, the activates the pin associated with address or subaddress, then sets an EggTimer to turn off the current after .2 seconds. This has been tested and seems to work well - I can share the code with you if you like.

    I'm looking to possibly replace the relays with high current triacs, such as the BTA24-600B, which can handle switching A/C current for snap switches. That would cost even less than the relays, provide silent operation at the panel, and could fit into a smaller footprint. I'll let you know if this succeeds or (literally) goes up in smoke.
     
    Scott Eric Catalano likes this.
  16. dottney

    dottney TrainBoard Member

    118
    19
    20
    If I wanted to add a wifi or Ethernet shield to the setup, would I put it between the uno and motor shield or on top of the motor shield and then put the two jumpers that go on the motor shield on to the wifi or Ethernet shield.
    Dave
     
    Scott Eric Catalano likes this.
  17. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    @dottney

    The choice is yours, the jumpers apply in either configuration.
     
    Scott Eric Catalano likes this.
  18. dottney

    dottney TrainBoard Member

    118
    19
    20
    Thanks Steve.
     
    Scott Eric Catalano likes this.
  19. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    I try to keep the motor shield on top where practical, so the driver gets maximum cooling from ambient air.

    I haven't tested having a wifi card underneath the motor from a "can I still get good reception?" perspective, though.
     
    Scott Eric Catalano likes this.
  20. dottney

    dottney TrainBoard Member

    118
    19
    20
    Thanks twindad I didn't realize there might be a heat issue with motor shields. I'm waiting for the motor shield to arrive. Once I get a base station up and running by placing a laptop close by and running wth a USB cable then I'll consider putting the base station on my "railroad" network (wireless router not connected to outside world) with an Ethernet cable or wifi shields so I won't have to keep the laptop right next to the base station
    This has really sparked my interest. I'm reading about raspberry Pi now too!
    Dave
     
    Last edited: Mar 20, 2017
    Scott Eric Catalano likes this.

Share This Page