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

Gregg Aug 25, 2015

  1. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Hi Andrew,

    Quick tip, if you tap or click the slider scale roughly where you would drag the handle to set your speed, you'll find it just jumps straight there. Easy on a touch-screen whether horizontal vertical or how about rotary?

    I think this one looks excellent.

    Try it. Here. On a phone or tablet if you can, and just tap on the round scale.

    SliderCapture.JPG

    So to answer the question, the possibilities are only limited by our imagination and a few constraints on Webpage structure.
    As we move on with this (and it should be known I've never written any webpages or Arduino code 'till I started 6 weeks ago) I'd like to develop
    my coding abilities and collaboratively work towards a single and solid 'Server' code but with several 'Front-end' designs incorporating sliders
    like my example above.

    The only reason I went for horizontal sliders is because they are 'stock' and it keeps it easy for me. But sure, will be doing lots of variety going forward.

    The beauty of html is that you can move page objects around in a few minutes while the javascript takes care of the functionality.

    Excited?

    I am :)

    Steve.
     
    Last edited: Mar 17, 2016
  2. conrailandrew

    conrailandrew TrainBoard Member

    18
    29
    11
    Actually, the ability to jump directly to a speed is a bit scary for me, since I typically use almost no momentum while operating on my small switching layout, and would prefer not to have my trains suddenly jumping to a new speed if I accidentally put my thumb in the wrong place. :D

    The round sliders are interesting, but I think I'd still prefer vertical sliders. It's good to know that code isn't too hard to learn. I'll be on break next week, maybe I'll download it and fiddle with it a bit and see what's possible.

    Thanks!
    Andrew
     
    Scott Eric Catalano likes this.
  3. maltux

    maltux TrainBoard Member

    11
    12
    2
    Not sure if this is the correct place to introduce myself but I just got my DCC++ working with JMRI. Got it working with 12 volts then I blew up the shield with 16 Volts. Waiting for a new shield. Does the Power supply need to be DC only or will switching work as well? The 16 Volt was a Bachman AC wall wart.--oops :){). On a more positive note I think I am going back to school for Electrical Engineering at 52 years old. This project really rekindled my interest. Thank you to Greg for the DCC++ YouTube videos - TwinDad for the JMRI interface and all others.
     
    Scott Eric Catalano likes this.
  4. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Welcome, maltux - AC is a definite no-no with the DCC++ system - stick with DC. I have had good luck with re-purposed laptop power supplies. They range in voltage from 12 to 19 volts DC and supply very clean power. They frequently can be had for the asking from friends who are retiring a laptop.

    You may also want to cut the trace on the bottom of the motor shield to isolate the power that goes to the shield from that for the Uno. This is discussed on this forum and on my web page here:

    http://trainelectronics.com/DCC_Arduino/JMRI_DCC++_Setup/index.htm

    and here:

    http://trainelectronics.com/DCC_Arduino/DCC++/

    The trace to cut is circled below. Good luck & enjoy!

    dave

    [​IMG]
     
    Scott Eric Catalano and HVT like this.
  5. maltux

    maltux TrainBoard Member

    11
    12
    2
    Thanks for the welcome Dave! I watched all your videos as well. So many smart people all in one place. I did cut the power trace and it must have saved my Arduino but the motor shield died. It was great having it work with JMRI how-ever briefly. I will start scrounging around for laptop power supplies. Initially I will be running N scale but I have HO and O as well. Are all you guys EE's? I was a boring Controller (no offense meant to others) in an earlier life.
     
    Scott Eric Catalano likes this.
  6. rniefert

    rniefert TrainBoard Member

    15
    14
    3
    I seem to be having an issue using a Raspberry Pi to upload the sketch. Im not sure if it has to do with the way it vies the hardware. Here is the error


    In file included from DCCpp_Uno.ino:171:0:
    DCCpp_Uno.h:51:4: error: #error CANNOT COMPILE - DCC++ ONLY WORKS WITH AN ARDUINO UNO OR AN ARDUINO MEGA 1280/2560
    #error CANNOT COMPILE - DCC++ ONLY WORKS WITH AN ARDUINO UNO OR AN ARDUINO MEGA 1280/2560
    ^
    DCCpp_Uno.ino: In function ‘void setup()’:
    DCCpp_Uno.ino:238:16: error: ‘ARDUINO_TYPE’ was not declared in this scope
    DCCpp_Uno.ino:287:11: error: ‘DCC_SIGNAL_PIN_MAIN’ was not declared in this scope
    DCCpp_Uno.ino:366:11: error: ‘DCC_SIGNAL_PIN_PROG’ was not declared in this scope
    In file included from PacketRegister.h:13:0,
    from DCCpp_Uno.ino:172:
    DCCpp_Uno.ino:368:10: error: ‘TCCR3A’ was not declared in this scope
    /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:84:30: note: in definition of macro ‘bitSet’
    #define bitSet(value, bit) ((value) |= (1UL << (bit)))
    ^
    DCCpp_Uno.ino:368:17: error: ‘WGM30’ was not declared in this scope
    /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:84:49: note: in definition of macro ‘bitSet’
    #define bitSet(value, bit) ((value) |= (1UL << (bit)))
    ^
    DCCpp_Uno.ino:369:17: error: ‘WGM31’ was not declared in this scope
    /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:84:49: note: in definition of macro ‘bitSet’
    #define bitSet(value, bit) ((value) |= (1UL << (bit)))
    ^
    DCCpp_Uno.ino:370:10: error: ‘TCCR3B’ was not declared in this scope
    /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:84:30: note: in definition of macro ‘bitSet’
    #define bitSet(value, bit) ((value) |= (1UL << (bit)))
    ^
    DCCpp_Uno.ino:370:17: error: ‘WGM32’ was not declared in this scope
    /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:84:49: note: in definition of macro ‘bitSet’
    #define bitSet(value, bit) ((value) |= (1UL << (bit)))
    ^
    DCCpp_Uno.ino:371:17: error: ‘WGM33’ was not declared in this scope
    /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:84:49: note: in definition of macro ‘bitSet’
    #define bitSet(value, bit) ((value) |= (1UL << (bit)))
    ^
    DCCpp_Uno.ino:373:17: error: ‘COM3B1’ was not declared in this scope
    /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:84:49: note: in definition of macro ‘bitSet’
    #define bitSet(value, bit) ((value) |= (1UL << (bit)))
    ^
    DCCpp_Uno.ino:374:17: error: ‘COM3B0’ was not declared in this scope
    /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:84:49: note: in definition of macro ‘bitSet’
    #define bitSet(value, bit) ((value) |= (1UL << (bit)))
    ^
    DCCpp_Uno.ino:376:19: error: ‘CS32’ was not declared in this scope
    /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:85:52: note: in definition of macro ‘bitClear’
    #define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
    ^
    DCCpp_Uno.ino:377:19: error: ‘CS31’ was not declared in this scope
    /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:85:52: note: in definition of macro ‘bitClear’
    #define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
    ^
    DCCpp_Uno.ino:378:17: error: ‘CS30’ was not declared in this scope
    /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:84:49: note: in definition of macro ‘bitSet’
    #define bitSet(value, bit) ((value) |= (1UL << (bit)))
    ^
    DCCpp_Uno.ino:380:3: error: ‘OCR3A’ was not declared in this scope
    DCCpp_Uno.ino:381:3: error: ‘OCR3B’ was not declared in this scope
    In file included from PacketRegister.h:13:0,
    from DCCpp_Uno.ino:172:
    DCCpp_Uno.ino:387:10: error: ‘TIMSK3’ was not declared in this scope
    /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:84:30: note: in definition of macro ‘bitSet’
    #define bitSet(value, bit) ((value) |= (1UL << (bit)))
    ^
    DCCpp_Uno.ino:387:17: error: ‘OCIE3B’ was not declared in this scope
    /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:84:49: note: in definition of macro ‘bitSet’
    #define bitSet(value, bit) ((value) |= (1UL << (bit)))
    ^
    DCCpp_Uno.ino: In function ‘void TIMER3_COMPB_vect()’:
    DCCpp_Uno.ino:444:5: error: ‘OCR3A’ was not declared in this scope
    DCCpp_Uno.ino:470:3: note: in expansion of macro ‘DCC_SIGNAL’
    DCCpp_Uno.ino:445:5: error: ‘OCR3B’ was not declared in this scope
    DCCpp_Uno.ino:470:3: note: in expansion of macro ‘DCC_SIGNAL’
    DCCpp_Uno.ino:447:5: error: ‘OCR3A’ was not declared in this scope
    DCCpp_Uno.ino:470:3: note: in expansion of macro ‘DCC_SIGNAL’
    DCCpp_Uno.ino:448:5: error: ‘OCR3B’ was not declared in this scope
    DCCpp_Uno.ino:470:3: note: in expansion of macro ‘DCC_SIGNAL’
    DCCpp_Uno.ino: In function ‘void showConfiguration()’:
    DCCpp_Uno.ino:494:16: error: ‘ARDUINO_TYPE’ was not declared in this scope
    DCCpp_Uno.ino:500:16: error: ‘DCC_SIGNAL_PIN_MAIN’ was not declared in this scope
    DCCpp_Uno.ino:509:16: error: ‘DCC_SIGNAL_PIN_PROG’ was not declared in this scope
     
    Scott Eric Catalano likes this.
  7. w8one

    w8one TrainBoard Member

    89
    109
    5
    A Raspberry Pi is not the same as a Arduino uno or mega. DCC++ is meant for Arduino Uno or Megs boards, you can use the Raspberry Pi to run JMRI from my understanding.
    Here is the main website for you to look through. https://sites.google.com/site/dccppsite/
     
    Scott Eric Catalano likes this.
  8. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Can you tell us more about the setup you are using on the Raspberry Pi? (Pi version, Arduino version, hardware & software setup, have you disabled serial login, etc)

    I have experience with both the Pi and the Arduino but have never tried to program from the Pi (I use Windows for programming)

    From what I have read it can be done but I have seen no reference to how one deals with libraries and such - perhaps just the same as in Windows.

    If you have access to a Windows computer that might be the best option!

    dave
     
    Scott Eric Catalano likes this.
  9. HVT

    HVT TrainBoard Member

    74
    93
    15
    UK Steve and Dave Bodnar,

    Can an Arduino Mega serve as a DCC++ Base Station; and
    - Connect via USB to a Raspberry Pi3 running JMRI; and
    - Connect via RS485 to 'client' Megas; and
    - Control an Arduino motor shield for program track and BTS7960 H-Bridge for main power; and
    - Connect via RX & TX to an ESP8266; and
    - Still handle 2 servos, 2 push switches, 12 LEDs and 10 detection coils?

    The USB/JMRI and RS485 are pretty much mandatory, and the ESP8266 is optional. The RPi3 can serve as a WiFi access point but the ESP8266 might be handy for guest operators. Still planning on throttles connected via RS485 and eventually wireless.

    Thanks,
    Dave
     
    Last edited: Mar 21, 2016
    Scott Eric Catalano likes this.
  10. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Dave - I don't have too much personal experience with what you ask but I can give you what info I have.

    Yes, the Mega is fully supported by DCC++
    I have worked with the Pi 3 and it should have no trouble running JMRI (FYI, I run an APRS repeater for ham radio on a Pi 2 and it works like a charm - the Pi 3 is much more capable)
    Not sure about the RS485
    The BTS7960 should work as well as it does on the Uno
    You will have to use software serial if you want to talk to two devices with RX/TX - should not be an issue
    Shouldn't have any trouble with servos, switches, LEDs and detection coils on the Mega

    Good luck with your project!

    dave
     
    Scott Eric Catalano and HVT like this.
  11. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Dave, Dave B,

    As Dave B points, out most of your wishlist is do-able already. Both you guys might be interested in my latest developments regarding serial comms over the weekend.
    My controller app obviously works in the TX direction, but for enhanced operation I wanted bi-directional support, if only to give a reassurance of the wifi connection holding up.
    So after more research and the addition of a small amount of code to the esp8266 server sketch, I came up with a working solution.

    From a novelty point of view this is a really cool breakthrough. An html serial monitor in your browser !
    And we can do that standalone on another computer or phone or table in multiple instances if you desire.

    Now all the Base Station replies and server comm's can be seen on screen verifying all is working as it should. The aim is to put a small window in the Controller page containing this live info.
    Thoughts?

    Steve.
     
  12. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Steve - good work! Feedback is good as it goes a long way in helping to debug things and, when in operation, it gives us confidence that the unit is actually working!

    dave
     
    Scott Eric Catalano and HVT like this.
  13. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Dave,

    If I have time today, I'll draft up a separate demo webpage for you to try. Your server code will need an update and the TX line from Arduino to ESP will need connecting as I outlined previously.

    Steve.
     
    Scott Eric Catalano likes this.
  14. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    No hurry, Steve - I am in the middle of getting ready for a 2 hour presentation at a big train show later in the week so I have minimal discretionary time this week!

    thanks
    dave
     
    Scott Eric Catalano likes this.
  15. HVT

    HVT TrainBoard Member

    74
    93
    15
    Dave B,
    I guess this is really the crux of my question. Do I recall correctly that Gregg stated that the DCC++ Base Station can only have one serial connection at a time, ie. either JMRI or the serial monitor or a WiFi shield? Have you been using the serial monitor while using the ESP8266? Does the ESP8266 connect to pins 0 & 1?

    BTW JMRI worked great on an RPi2 on my last layout with the Digitrax Zephyr so the new RPi3 should be fine with DCC++. I have run JMRI tests from the laptop to DCC++ with some test track. I expect to have some powered track with detection coils on the new layout this weekend. Awaiting the RS485 converter boards to experiment with the client Mega.

    Thanks,
    Dave Merrill
     
    Last edited: Mar 21, 2016
    Scott Eric Catalano likes this.
  16. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Dave,

    Guess you missed the post above. The ESP8266 does plug in to pins 0 & 1. There is no need to do any software serial programming. And a nice touch of an esp WiFi serial connection is that you can have several instances at the same time.
    The usual limitation of a single hardware USB connection is not there. Just one caveat, you have to go with a raw TCP (PC app/JMRI) or Websocket (Html) system. Can't have both to my knowledge at the same time on the ESP8266.
    However I'll look into the technicalities of getting a normal PC app to connect and run over a websocket. Might be possible, who knows? A browser does it just by renaming the connection to ws://"IP Address":"Port/ with a bit of code to do hand shake, encode/decode.

    Steve.
     
    Last edited: Mar 21, 2016
    Scott Eric Catalano likes this.
  17. HVT

    HVT TrainBoard Member

    74
    93
    15
    Sorry, Steve. The whole Websocket thing is way over my head. My understanding was that it had to do with how the handheld devices interacted with the ESP8266, and the ESP used a serial connection to the DCC++ Base Station with no changes to the Base Station.
    Dave
     
    Scott Eric Catalano likes this.
  18. rniefert

    rniefert TrainBoard Member

    15
    14
    3
    The Raspberry Pi 3 runs JMRI really well and makes a great benchtop programmer with DCC++. I installed the Arduino that came included in Raspbian Jessie via sudo apt-git install arduino. this version is not the latest version and I assume that is where the problem lies. I am making a few DCC++ setups for friends and was looking to program them on my bench. Ill just program them on my windows machine and test JMRI on my becnh.
     
    Scott Eric Catalano likes this.
  19. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Short answer yes.
    JMRI includes websocket connection for some elements, although I'll leave that for others to work out (I really can't get my head around even starting with that software !).
    So obviously javascript libraries exist and they could be added to give Gregg's Controller app a websocket connection. There is one for Processing. (I might go there if I'm so inclined one day)

    Edit; I've also found a proxy bridge to try out, seems promising https://github.com/kanaka/websockify

    Steve.
     
    Last edited: Mar 22, 2016
    Scott Eric Catalano likes this.
  20. maltux

    maltux TrainBoard Member

    11
    12
    2
    I have an 15 volt Toshiba laptop AC adapter 15 volts rated at 5 Amps. Is this too many amps for the Arduino motor shield? I do not want to blow up another shield. Dave B has been really helpful and hate interrupting your web sockets conversation.
     
    Last edited: Mar 22, 2016
    Scott Eric Catalano likes this.

Share This Page