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

Gregg Aug 25, 2015

  1. esfeld

    esfeld TrainBoard Member

    402
    368
    13
    Gregg .... I am using the same Enercell 15v power supply you show in the video, plugged into the motor shield ... but am still getting only 5v from an AC meter ....... unless you have another suggestion I think I will try to get hold of another motoer shield and see if that is the problem.
     
    Scott Eric Catalano likes this.
  2. esfeld

    esfeld TrainBoard Member

    402
    368
    13
    Hello Gregg an
    Hello Gregg and Scott ........ my dilemma was a bad motor shield ...... I added an OEM Arduino Motor Shield and everything is working as Gregg has described ...... I am now just awaiting the Java code to enhance the project ....... Thank you both for your patience ..... I am a happy puppy!
     
    Scott Eric Catalano likes this.
  3. DJ79

    DJ79 TrainBoard Member

    36
    25
    10
    Awesome project!

    Now, to make it fully flexible with all kinds of setups, we would need a JRMI plug-in. I, for instance, use JMRI primarily for remote cell phone throttles (WiThrottle) and turnout control, but other people have so many other use cases. It's not the prettiest or easiest software, but it's the most complete system today and as such needs to be supported.

    I'd be willing to do the JMRI plug-in myself, assuming I can figure it out, as I'm not quite familiar with Java development, but perhaps someone else could do it quicker or easier. Any thoughts on this?
     
    Last edited: Oct 31, 2015
    Scott Eric Catalano likes this.
  4. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    Success here in HO Scale! I did add the pinMode and digitalWrite code to the DCCpp_Uno as well as the #define to DCCpp_Uno.h file as the Pololu uses Pin 4 to turn the board on and off.....I also had to change the 11/12 to 7/8 code in the DCCpp_Uno.h file again the Pololu shield uses these as motor directional controls. I also had to change how I hooked up the program track and main track as this is backwards on the Pololu shield as compared to an Arduino motor shield.

    The locomotive works fine....moves backward and forward. Now going to test the commands to see if these work. I will report back soon!

    Update #1: I am having difficulty with sending commands to the sound locomotive. I cannot turn the headlight on or off nor can I turn any of the sound functions on or off like the bell and horn. If i read the commands correct it should be this: <f 1108 128 + F0*16 =1> Correct?
     
    Last edited: Oct 31, 2015
  5. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    Hello DJ79,

    I've successfully created a Perl/Tk dispatchers panel using Win::Serial that communicates directly to the Arduino...I can change the signal aspects as well as the IR Sensors can trigger sections of my Perl/tk program on the desktop....so communicating back and forth is not an issue. What I am waiting for is for Gregg to release the Java train control program so I can then port it to Perl/Tk. The cool thing is I can then make a program like JMRI so I can specifically program my locos etc without having all of the extra bells and whistles that is with JMRI....although a plugin would be nice too....the possibilities are endless!
     
  6. DJ79

    DJ79 TrainBoard Member

    36
    25
    10
    I picked up an inexpensive shield at MicroCenter (http://www.microcenter.com/product/443628/OSEPP_Motor_Driver_for_Arduino), knowing that it doesn't have current sense output, but I thought I could just access the pins on the chip. It turns out that there is nontrivial circuitry that needs to be on the board to use it, so I may need to look for something else (and that's ok, I can reuse this one for some other project). This raises a few questions:

    - What would be the simplest circuit that can just tell me if there is a short? (I don't need to know what the exact current is.)
    - Is it correct to assume that the current readings on the official Arduino shield (is it 1.65V per Amp?) and on other shields like the Pololu would be different, and would need to be accounted for in the software?

    On a separate note, this particular board doesn't have DIR input pin, but controls the output pins independently using IN1 and IN2 pins, so it would require either an inverter chip, or some modifications to the software, so a reason more to look elsewhere.
     
    Scott Eric Catalano likes this.
  7. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    Hello DJ79,

    I had to bypass most all motor shields as I needed something heftier to power HO Scale equipment. I am using a Digitrax Power Supply that has amp meters on it so I do not need software to get my readings....and I do believe Gregg has timers programmed into the software to account for shorts. If not you can always use the commercially available short circuit modules used for DCC.
     
  8. DJ79

    DJ79 TrainBoard Member

    36
    25
    10
    Hey, Scott. That's exactly what I'm talking about. By supporting a system as all-encompassing as JMRI, we make the module attractive to the widest audience. The possibilities are indeed endless.
     
    Scott Eric Catalano likes this.
  9. esfeld

    esfeld TrainBoard Member

    402
    368
    13
    Hello DJ79 ....... as I stated in my earlier post the Motor Shield from Micro Center (with the heat sink) did not work ....... when I replaced it with an OEM Arduino Motor Shield everything works as designed ........ just thought I'd save you some time.
    Steve
     
    Scott Eric Catalano likes this.
  10. Gregg

    Gregg TrainBoard Member

    237
    307
    18
    That's great news! Also, I plan on uploading the Java code later today.
     
    Scott Eric Catalano likes this.
  11. Gregg

    Gregg TrainBoard Member

    237
    307
    18
    Scott, I'm really glad to hear the board is working and the you are able to control the locomotive. Since others may want to use the Pololu as well I've created a one-page diagram showing a combination of jumpers that should minimize the number of traces that need to be cut (just one), the number of soldered joints (just one), and the number of code changes. By connecting pin 4 to VDD you can avoid having to write that line high in the software, though it's probably more flexible to use the software -- either way, as long as pin 4 is high, the board is enabled.

    As for the decoder functions, the format for functions F0-F12 should be <f 1108 N>, where N is a single number derived from the formulas in the spec. The headlight is usually F0, in which case N would be 128+1*16=144. In other words <f 1108 144> turns on the headlight for cab 1108 and <f 1108 128> turns it back off. If you want to control F2 as well, you would need to add 1*2=2 to N as well, giving you four combinations:

    <f 1108 128> - in which F0 and F2 are both off
    <f 1108 130> - in which F0 is off but F2 is on
    <f 1108 144> - in which F0 is on but F2 is off, and
    <f 1108 146> - in which F0 and F2 are both on.

    I know this seems a bit cumbersome but unfortunately the DCC specs use the bits of a single register within the decoder to control the engine functions. If these functions were controlled with a CV instead, it would be possible to simply write and clear any given bit, but I'm not sure that can be done (if anyone knows how to do this, please let me know). Turning on and off all the decoder functions requires remembering which other one's are already on and off. My Java code does exactly that, and I'll be posting shortly.


    DCC++ with Pololu.jpeg
     
  12. Gregg

    Gregg TrainBoard Member

    237
    307
    18
    The way DCC++ works, a single pin controlled by one of the Arduino timers is used to flip the direction of the signal polarity, generating the bi-polar DCC signal. Most H-Bridge driver chips generally have separate IN1 and IN2 inputs as you've described, which allows for 4 combinations. If both IN1 and IN2 are high, that may set the impedance of the output channel low, which acts like a motor "brake." If IN1 and IN2 are both low, that might set the impedance of the output channel high, which means any attached motor simply "coasts." And if one of IN1 or IN2 if high while the other is low, that selects the direction of the output current. In principle it may be possible to have the Arduino trigger two pins at the same time but in opposite states to control IN1 and IN2 in tandem, but as you noted, some of the motor shields have additional circuitry that inverts a single signal from one pin to drive both IN1 and IN2 at the same time. At present DCC++ relies on a motor shield having this circuitry.

    In terms of sensing current, DCC++ uses the Arduino analog inputs not only to check for a short, but also to read CVs from the programming track. DCC decoders enable reading on the programming track using a somewhat convoluted method of having the controller send the decoder a request to check whether a given bit on a specified CV is 1 or 0, and then the controller responds by either turning on the motor for a very brief period, or not. The DCC spec requires the controller to then look for a small change in current that would let the controller know whether or not the motor was briefly turned on which in turn indicates whether the bit of the CV requested matches what you asked. I know this sounds crazy, but it does seem to work, at least for the N-scale decoders I'm using. If you don't need to read CVs from the programming track, then you can probably get away without a current-sensing circuit.
     
  13. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    Thanks for the explanation of the DCC commands.....with a full understanding your Java code and my Perl/Tk will work wonderful together. The wiring diagram is perfect too!

    Update on Sounds: They work!
     
    Last edited: Oct 31, 2015
  14. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    I used a small jumper wire and soldered both ends to the bottom severed hole in section labelled 10 and the second hole under Pin 11
     
  15. Gregg

    Gregg TrainBoard Member

    237
    307
    18
    Friends,

    As promised, I've just uploaded my DCC++ Controller/Interface program to the DCC++ GitHub account: https://github.com/DccPlusPlus?tab=repositories. Note it's designed to operate within the Processing IDE and utilizes some of Processing's drawing routines (boxes, circles, text) as well as its serial connection. You'll need to download the latest copy of Processing from www.processing.org.

    DCC++ Controller it a bit more complex than the DCC++ Base Station software so please feel free to post questions --- I'll do my best to answer them as quickly as possible. Enjoy!

    -Gregg
     
    Scott Eric Catalano likes this.
  16. Gregg

    Gregg TrainBoard Member

    237
    307
    18
    That should do the trick. The Pololu provides a lot of options for where/how to add jumpers.
     
    Scott Eric Catalano likes this.
  17. esfeld

    esfeld TrainBoard Member

    402
    368
    13
    Gregg .... when I hit "run" in the processing IDE I come up with "unexpected token: import" errors .... could you please give some direction on any files needed as well as file locations etc etc ... I am trying this in the Processing Ide not the Arduino IDE ... I hope that is correct. Thank you
    Steve
     
  18. Gregg

    Gregg TrainBoard Member

    237
    307
    18
    I'm not sure if Java is also required, but do you have a version of Java installed as well?
     
  19. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    Java is required...I installed the processing IDE and opened the train controller files and renumbered the throttles to reflect my engine decoders and one error that I did get had to do with the cab.jpg file....so what I did was in the DATA folder I just renamed the jpg files to reflect my decoder number...once I did that and ran the console program everything worked as explained....way to go gregg! Everything works for HO Scale as it does in N Scale...I am very pleased!
     
  20. Gregg

    Gregg TrainBoard Member

    237
    307
    18
    Scott, this is terrific! And sorry about the cab.jpg error. I just updated the code and committed a small change to the imageWindow routine that will check to make sure there is an jpg for each cab. If not, the console will show a warning but the program will not crash when you try to display the cab's image (instead, it will just say "no image file for this cab").

    Also, there seems to be some lingering differences in error handling between Processing 3 (which is very new) and Processing 2. In the previous Processing environment, if a file was not found, the program would not crash but instead return a NULL pointer which could be handled gracefully. I rely on this to see if there is a dccStatus.xml file, and if not, the program creates one. But in Processing 3, it seems the program crashes if it can't find some types of files (such as XML files, but apparently not JPG files). This should not really matter since I uploaded my code with a sample dccStatus.xml file that is automatically updated as needed. But there may be some other lingering issues in Processing 3 that might surface as more people try out DCC++.
     

Share This Page