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

Gregg Aug 25, 2015

  1. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    @ Steve F (esfeld),

    Great news Steve, I've at long last managed to have a play around with my Wang Tongze shield (does that sound rude?) and got it all running with the server code first time out.

    My stack is finally free of the breadboard, Woo-hoo.

    Switch positions work as you described, shout if you need any help.

    In other news, I'm making rapid progress with the new throttle code, should be getting to a proof of concept this weekend.

    Steve.

    Update: I've brought together the WebSocket Client code with the Rotary Encoder and a basic Command String assembly function, in a test rig. It's all running beautifully, effectively this means a brand new WiFi WebSocket Throttle is born.
    More work is needed on polishing up the handling features, but the ideas are proven in my Javascript code and will be just porting from that work.
    Then get to grips with a basic display input/output interface on the new Nextion device.

    Serial Capture of Boot, Connect and a fast crank of the Encoder

    CaptureT.JPG
     
    Last edited: Jul 2, 2016
  2. Curn

    Curn TrainBoard Member

    752
    500
    32
    I just came across this thread and learned about DCC++ last night. Really great work you guys have been doing. Just ordered an Uno and a motor shield. Open source is the way to go! Time to see if I can get the controller to run in Ubuntu. Keep up the good work.
     
    Scott Eric Catalano and sboyer2 like this.
  3. sboyer2

    sboyer2 TrainBoard Member

    35
    41
    6
    no problems with Linux, works great, JMRI and DCC++ are perfect under Linux.

    Steph!
     
    Scott Eric Catalano likes this.
  4. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    All,

    Having had some time to put the new Wang Tongze shield through some heavy testing, it could arguably be the best in DCC++ WiFi solutions to date.
    At around $10US and loaded with my server code (just a few seconds once you have the prerequisites for Arduino IDE), it truly is a little plug and play diamond.

    I set up an instance of JMRI and instantly connected, then plugged in Engine Driver on my cellphone for good measure, and ran an instance of Mobile Controller from the same phone.
    And threw a WiFi Serial Monitor Webpage also on the PC. All running simultaneously.

    IT DOESN'T BREAK.

    $_57.jpg

    Steve.
     
    HVT, KC Smith, Curn and 2 others like this.
  5. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    All,

    While we've all been playing around with low res poor quality Rotary Encoders, I got to thinking "There has to be a Better way".

    Personally I think the cheap encoders are not fit for purpose in a throttle application, hence I upgraded to one that is.

    However for those of us on a budget here's another solution for you to play around with.

    Have a look on ebay for something like this - and it can be any type of switch, rocker, rotary as long as its push to make only on one state at a time.

    100098_C.jpg

    With this 4 way joystick toggle you could do Throttle up/down forward/reverse just using your thumb.

    Then hook up an Arduino with this sketch, I think you can fill in the rest.



    /*

    In this program, we use 2 switches to make a count increment
    and decrement

    */
    // swtich 1 connected at Pin 8 and other end to GND
    // switch 2 connected at Pin 9 and other end to GND
    //

    int sw1 = 8; // Connect pin 8 to SW1
    int sw2 = 9; // Connect pin 9 to SW2
    int count = 0;


    void setup()
    {
    Serial.begin (115200);
    Serial.print("Up-Down Counter");
    // Declare Switches as INPUT to Arduino
    pinMode(sw1,INPUT);
    pinMode(sw2,INPUT);
    digitalWrite(sw1,HIGH);
    digitalWrite(sw2,HIGH);
    }

    void loop()
    {
    if(digitalRead(sw1) == LOW && digitalRead(sw2) == HIGH)
    {
    count++; // Increment Count by 1
    if(count > 126){
    count = 126;
    return;
    }else{
    Serial.println(count);
    delay(50);
    }
    }
    if(digitalRead(sw2) == LOW && digitalRead(sw1) == HIGH)
    {
    count--; // Decrement Count by 1
    if(count < 0){
    count = 0;
    return;
    }else{
    Serial.println(count);
    delay(50);
    }
    }
    }
     
    Last edited: Jul 4, 2016
  6. Curn

    Curn TrainBoard Member

    752
    500
    32
    My Arduino Uno and motor shield (both Arduino.org) came in today. I had some trouble getting things to work in Ubuntu. Jumped to Windows 10 and everything worked super easy using Arduino.cc IDE and JMRI. The only problem I had was reading the CVs. I'm using a 12v power supply and was using a MTL Z scale GP9 to test. Since CVs are read by the current draw and Z scale motors draw little current, I retested it with an N scale engine and everything worked fine. Had to play with the ACK_SAMPLE_THRESHOLD in PacketRegester.h to get it to read the Z engine. I currently have it set to 15 from the default of 30.

    Knowing how its supposed to work, I went back and got Ubuntu working. Basically nothing is ever super easy in Linux. Installed Arduino IDE from the repositories. Added myself to the Dialout group. Downloaded JMRI. Make launcher for JMRI but it wouldn't run in OpenJRE. Removed OpenJRE. Installed real Java, which is kind of a pain, but there is a good 8 step tutorial out there. JMRI would launch. chmod some serial ports. Removing OpenJRE killed the dependencies for Arduino IDE. Downloaded Arduino IDE form Arduino.cc. Made Arduino launcher. That launched, and I was able to compile and upload to the Uno after manually setting the port it was on. Opened Decoder Pro. Linux version doesn't have a wizard. Go into preferences. Setup the DCC++ system under connections... Still wont work. Go into preferences, under defaults, checked Service Programmer and Ops Mode Programmer for the DCC++ system. Then it all worked as it should.

    Still need to download the Processing IDE and play with the controller.

    I didn't know about the .cc / .org rift when I ordered my boards. Wish I had gotten one of the adafruit made Unos. I'll probably order a Mega from them when its time to upgrade.

    Matt
     
  7. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Hi Matt,

    I'm impressed with your persistent and methodical approach to getting your Linux system up to speed, well done !
    Many folks would have opened multiple threads by now seeking help on hard to diagnose problems, it's refreshing to see someone with the determination to get the job done.

    On the Arduino boards, many of us have had great success using the cheap Chinese clones you might see on the auction sites.
    As the Arduino project is Open Source there is nothing ethically wrong with using such alternatives, but with the caveat that they might not work as expected.
    I do feel it is right to purchase the genuine article from time to time though, in order to support the project.

    If you would like to spin off on setting up a WiFi solution, I've done some considerable research on the ESP8266.
    Just recently a cheap plug and play shield has come to market that I've found to be very good.
    See my earlier posts on the last few pages.

    Welcome to DCC++.

    Steve.
     
    Scott Eric Catalano likes this.
  8. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    Being a hardcore linux user myself (red hat, mandrake, suse, solaris) I am very impressed with your determination to get things working....oh the many hours I have spent trouble shooting things just to get them to work...I am a command line user myself and when I was able to get a graphical interface to finally work on a linux box I could of thrown a huge party!
     
  9. Paul Maiorana

    Paul Maiorana New Member

    1
    1
    1
    Does DCC++ support Digitrax DS64 Quad Stationary Decoder?

    DCC++ sends the <T command to change or throw a switch, the Digitrax DS64 Quad stationary decoder uses the <a command. Can the DCC++ Controller be modified to support the DS64?
     
    Scott Eric Catalano likes this.
  10. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    Has anyone addressed the possibility of using more MD boards to have multiple power districts?

    It would primarily require adding multiple current monitors (at least) and ancillary stuff to support the multiple MD boards.

    I've looked at Greg's code, and it's so far beyond my programming ability that I can't do it.

    Anyone up to it???
     
    Scott Eric Catalano likes this.
  11. lnxlnx

    lnxlnx TrainBoard Member

    24
    20
    7
    Have a look at Dave Bodnar's DCC Power Booster http://www.trainelectronics.com/DCC_Arduino/DCC_Booster/index.htm for another approach
     
    Scott Eric Catalano likes this.
  12. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    You're missing the point.....I already am using multiple MD boards, one is the 43A unit for the main track that Dave found, and another for the program track that uses 2 L298 chips (like the standard board, but not exactly the same), and both required some minor mods to work.

    I want more/multiple MD boards controlled by the one DCC++ Arduino for multiple power districts (not difficult to electrically connect), but want DCC++ to monitor the current from ALL the boards, and if possible, JUST shut down the MD board that's drawing to much power. I want one for the program track, and multiple other MD boards for the power districts, all with current monitoring.



    Gregs remote 'slave' DCC++ Arduino would work (but it's not close to being done), but I don't think it's really needed for this configuration......the MD boards will be physically local to the DCC++ Arduino.
     
    Scott Eric Catalano likes this.
  13. dimonic

    dimonic TrainBoard Member

    23
    15
    2
    Cheers Greg! I am using DCC+ and your wonderful Arduino code. I actually found it through here, so I joined to thank you.

    I also want to have sound, and in n-scale civil war era, that is very tricky - until I stumbled upon SurroundTraxx. Great idea, big money, and it seems to rely heavily on Digitrax. Hmm. At those prices, I thought, I could make my own. I did some research. I can make transponders using RFID tags, and an NFC reader per section. I found a reader at less than $30, and tags can be gotten for a couple of bucks each. The readers use I2c, so I can hang them off the arduino, or directly off the Raspberry Pi I am using as my PC.

    Coupled with the location data, I can use Mustajuuri, an open source API that will mix sound in a multi-channel setup to position the source on the sound stage. Basically, I can position my loco sound in real time, based on its block location on my layout - just like SurroundTraxx does. I can use a cheapo USB 7.1 surround card and a bunch of powered speakers for actual sound.

    I would like to contribute my code efforts and documentation to the project, once I get things working more or less.
     
  14. dimonic

    dimonic TrainBoard Member

    23
    15
    2
    I should add that I am an embedded software developer by day job, so I should be able to accomplish this. Now having said that of course I am doomed to struggle mightily.

    I think the most challenging thing for me will be to loop the sample sounds properly and link them to speed data. I could just use an existing sound decoder as a sound signal generator, and link that directly into a line in as a source to begin with.
     
    Scott Eric Catalano and UK Steve like this.
  15. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Scott Eric Catalano likes this.
  16. dimonic

    dimonic TrainBoard Member

    23
    15
    2
    That is pretty neat - however, I will be doing the sound processing on a Raspberry Pi - I think the Arduino lacks the horsepower to do real time sound mixing for 5+ channels. I will attach a USB 7.1 capable "sound card" to the Pi, and send the Mustajuuri muxed sound signal to the card. What I was referring to earlier was the clever stuff like adjusting the "chuff" frequency without changing its pitch, all controlled by the velocity of the loco. Although I am sure I could figure it out, I can take a short cut while getting the other loose stuff sorted out, by using a "real" sound decoder.
     
    Scott Eric Catalano and UK Steve like this.
  17. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Hi Dimonic,

    Welcome to the DCC++ area.

    What a superb project you have planned. I was secretly hoping someone would take up the challenge on just such a system.
    High quality sound decoders and their libraries are an expensive item here in the UK. I could always see the benefit of going down a diy "SurroundSound" route.
    Well done Sir in taking this on.

    In my own little niche contribution, I have been experimenting with the ESP8266 WiFi module. While I don't have the benefit of being able to call myself a software developer,
    I've been able to produce a few Web-app throttle pages and server code that can run up to 10 locos from a cellphone or tablet, without the need to run via a PC application.

    Currently, I'm working on a handheld WiFi throttle device using similar technology. The Client code has just been completed, just leaving the control/display interface to do.
    I'm using a Nextion touch screen device for this. Another world first in DCC++ throttle options !
    http://wiki.iteadstudio.com/Nextion_HMI_Solution#Nextion_Instruction_Set
    http://wiki.iteadstudio.com/Nextion_Instruction_Set

    Regards

    Steve L.
     
  18. dimonic

    dimonic TrainBoard Member

    23
    15
    2
    Thanks, Steve,
    The WiFi sounds like the next logical thing to go head to head with the commercial products.

    For what I have in mind, the sound processing would need more horsepower than the Arduino has, so a Raspberry Pi model 3 seems like the way to go. Since it includes WiFi, and has the guts to run the DCC+ Java app, with the nice 7" display available it would sit beautifully on the layout, control the Arduino as "the PC", and can run web server apps (my blog runs on a Pi), at $35 including WiFi it seems like an easy choice. Running throttles from a cellphone would be more than doable with this.
     
    UK Steve and Scott Eric Catalano like this.
  19. KC Smith

    KC Smith TrainBoard Member

    109
    111
    12
    Hi Dimonic,

    Great Project Idea, Looking forward to your design and build efforts. Perhaps you could start a Separate thread under "DCC++ Sound Board interfaces" for us to follow along.

    Have you seen Bruce Kingsley's Ultimate DCC Throttle project were he's using a Arduino Mega and a RR-CirKits Locobuffer USB rev-n card to interface Digitrax to a DYI Sound System?
    Part 1
    4:00 min into the video are the components
    6:00 min the Sound boards
    7:45 the Locobuffer USB card

    There are 13 parts to his videos, Part 10 talks about his Telemetry and Camera train with wireless communications and fiber occupancy detection trip sensors for local exterior sound effects.


    Perhaps it may have some of your requirements already coded or at least a person to clarify issues and provide possible solutions for your project.

    In Addition perhaps this TF MP3 sound decoder board could be a good inexpensive ($1.69) Stationary Local area sound effects card if it could be triggered by and Arduino or Raspberry Pi. I've found it to have excellent sound reproduction when used with a DZ383 4ohm 3watt Speaker.

    http://www.ebay.com/itm/191543512579?_trksid=p2057872.m2749.l2649&ssPageName=STRK:MEBIDX:IT

    http://www.ebay.com/itm/131319663194?_trksid=p2057872.m2749.l2649&ssPageName=STRK:MEBIDX:IT

    Hope this is helpful.

    Regards,
    Kevin
     
    Scott Eric Catalano likes this.
  20. KC Smith

    KC Smith TrainBoard Member

    109
    111
    12
    Hi UK Steve,

    Great News on your heavy testing of the shield.

    I order one of these ESP82266 ESP-12E Wireless Shields this week and it's on a sloooow boat from China. Looking forward to using your ESP wifi code soon.

    When you feel like you have it as a completed project could you post your project and code links on the "Links for DCC++ " project thread?
    It makes it a little easier to find and make sure we're all using the same up to date configuration and code version.

    Thanks in advance.
    Cheers,
    Kevin
     
    Scott Eric Catalano likes this.

Share This Page