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

Gregg Aug 25, 2015

  1. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Steve - update: Just went through the whole thing again, figured out the Git syntax, had to get around Windows not allowing me to write to the Arduino directory, installed Python, ran the Python script from DOS (again had Windows permission issues) and it still does not work - very frustrating - we (you?) need to find a better sequence to go through to get the ESP8266 programmed or very, very few are going to attempt it.

    Are you running Windows? Is your Arduino directory in "Program Files (x86)"?

    thanks!
    dave
     
    Scott Eric Catalano likes this.
  2. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Hi Dave,

    Baffled me too, but if you can use the CMD prompt it will take just a few minutes.

    First get python 2.7 and install. (you'll be needing that soon anyway as it is now hooked up with Arduino, some astonishing stuff to see there) its a great time to be alive !

    You've installed Git so that step done.

    Fire up a CMD prompt (I usually right click Run as Administrator) copy and paste the following prompts, hit the return key where stated

    cd C:\Program Files (x86)\Arduino\hardware ------------->hit return

    mkdir esp8266com ---------------------> hit return

    cd esp8266com ---------------------------->hit return

    git clone https://github.com/esp8266/Arduino.git esp8266 ----->hit return

    the clone operation will run - then go>

    cd esp8266/tools ---------------------------->hit return

    python get.py ---------------------------->hit return

    exit ----------------------------------->hit return

    All done, it really is the best way.
     
    Last edited: Mar 10, 2016
    Scott Eric Catalano likes this.
  3. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    That should help, Steve - I am retrying the procedure from scratch on another computer - this is really a royal pain!

    dave
     
    Scott Eric Catalano likes this.
  4. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Funny thing is, when you're all done cursing the computer screen.

    It's just as easy as programming arduino.

    I can mod a sketch, compile, upload and have it reconnected to the WLAN in under 5 mins. I hopefully jumped through all the hoops so you guys don't have to.

    And it is very rewarding once you get to the other side. My head is spinning at this amazing new world. Lasers, CNC machines, 3d printing, remote control, robots......wow.
     
    Scott Eric Catalano likes this.
  5. David Taylor

    David Taylor New Member

    7
    8
    1
    I have just found DCC++ and it is exactly what I wanted to do a few years ago, except I couldn't figure out the logic signal -> bipolar signal part. Great idea to use the motor shield.

    In fact, awesome project all around! I've ordered clone versions of the mega, ethernet shield, and L298 driver shield and am looking forward to hooking them all up.

    Beautiful job on this guys.

    Regards,
    David.
     
    Scott Eric Catalano likes this.
  6. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Welcome David,

    Great to have you aboard. If you have any problems don't hesitate to ask however trivial.

    Regards

    Steve

    Just a thought, but are most model railroaders called Dave or Steve? Hmmm.
     
    Scott Eric Catalano likes this.
  7. DJ79

    DJ79 TrainBoard Member

    36
    25
    14
    Interesting stuff going on.

    The Photon thing is powerful, but a bit too easy for my notion -- you can program it with a cell phone -- probably aimed at middle school kids, but then again, I'm old school. It's crazy that every train motion, horn blow, turnout switch, or signal should go to through some corporate data center. Imagine all the data mining and privacy invasion possible with this! On the other hand, using DMA is the right approach for DCC signal generation. Did you know that ESP-8266 supports DMA? It's only on a single pin, but I guess a simple PIC can easily demultiplex that if you need more. I've got to try it next.

    Good work with the web interface, it looks promising. Using the ESP-8266 as an Arduino is a quick way to get started, and probably sufficient for many projects, but you don't nearly use the full potential of the chip. I'd encourage you to you check out native programming, although it's not easy to set up, as you've already discovered -- I spent days trying to set it up with Visual Studio. Speaking of which, Visual Studio has built-in graphical GitHub support, and it also has a component (NuGet) for Arduino with full code completion, debugging, and everything else. If you're using Windows, download the free Community edition -- it has pretty much everything. If you're on a Mac, use Parallels.

    Also, using WebSockets is a quick and easy solution, but then the ESP has a limited number of simultaneous TCP connections (four?). A solution using UDP wouldn't have this limitation, but to my knowledge, you can't use UDP from within a web browser without resorting to extensions, so to have more connections one would need a native client, with it's own issues. Which brings us again to Photon... And privacy issues... And latency, too... Gotta go now...
     
    Scott Eric Catalano likes this.
  8. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Steve - No luck - I tried again, on two different PCs. I found that I had to reinstall GIT to add its path to Windows so that it would run from the Windows command prompt.

    The error I get when I try to compile the program is below - Should I see somewhere in the Arduino/library or hardware/library folder a file called WebSocketsServer.h ? I cannot see it on either PC.

    Any help / suggestions are appreciated.

    thanks!

    dave


    Arduino: 1.6.7 (Windows 10), Board: "Generic ESP8266 Module, Serial, 80 MHz, 80MHz, DIO, 115200, 512K (64K SPIFFS), ck"

    C:\Shared_stuff\Dropbox\Arduino\DCC++\WiFiThrottle\ESP8266Throttle_v0-1\ESP8266Throttle_v0-1.ino:24:30: fatal error: WebSocketsServer.h: No such file or directory

    #include <WebSocketsServer.h>

    ^

    compilation terminated.

    exit status 1
    Error compiling.
     
    Scott Eric Catalano likes this.
  9. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Steve - update - found the library here: https://github.com/Links2004/arduinoWebSockets
    Put the files in the Arduino/library folder and got past the error above - now the error is

    C:\Program Files (x86)\Arduino\libraries\WebSockets\src\WebSockets.cpp:28:35: fatal error: core_esp8266_features.h: No such file or directory

    #include <core_esp8266_features.h>

    ^

    compilation terminated.


    It looks like I need to spend some time finding and installing more libraries!

    dave
     
    Scott Eric Catalano likes this.
  10. lnxlnx

    lnxlnx TrainBoard Member

    24
    20
    7
  11. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Thanks for the link, but, no, it is not the issue - I have the proper chip option installed and selected. The problem is getting the right set of libraries installed in the Arduino environment. This is not an unusual issue to run into - I am still stuck trying to find the right library to get past the error in my prior email - I think I'll put this aside for a few hours and revisit it later on.

    thanks again!

    dave
     
    Scott Eric Catalano likes this.
  12. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Hi Dave,

    Your going down the same rabbit holes as I did.

    You just think it's all good when you find and install the next library that was not found, compile and it wants something more.
    There are so many dependencies, you can soon burn hours of your time. And to make it worse some of the libraries are broken outside of the core package.
    I messed up my main Windows machine so much, that I had to abandon that idea and get the CMD prompt method done properly on another machine.

    So I slept on it for day or so.

    Fresh head and following the prompts to the letter, it worked like a charm, done in a few minutes, it was hard to believe what all the fuss was about !

    The reward is worth it.

    I would uninstall the the whole Arduino IDE and start fresh. Please persevere. A whole world of esp projects are available once you have this done.

    Regards

    Steve.
     
  13. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Steve - I started over with a clean Windows 10 computer and have some promising results so far - I'll see if I can carve out some time later in the day to finish up - thanks for the help and encouragement -
    I'll do my best to document every step if it all works!
    dave
     
    Scott Eric Catalano likes this.
  14. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Hi Dave

    Using cut and paste from the post above #942 on that same messed up Win 8.1 machine here is the record in the prompt window.
    Run as admin Make sure you start C:\Windows\system32



    CMDCapture.JPG



    And success it compiles first time


    ArduinoCapture.JPG
     
    Scott Eric Catalano likes this.
  15. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Steve - I think I have things working properly - I was able to compile and upload the file to the ESP8266 module -

    Is there anythings special I should look for to test the software? All I see in the terminal is a few hundred random characters (at 115200 baud) - I haven't had time to test with the DCC++ unit or the web interface.

    I also wrote up my notes - please look them over and see what I may have missed or done incorrectly.

    see: http://trainelectronics.com/WiFi-esp8266/Setup/

    thanks again!

    dave
     
    Scott Eric Catalano likes this.
  16. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Dave.

    Ooops a small caveat. When you mentioned that Git was not recognised in Cmd Prompt, I realised I had missed that step for getting the Python tools bit to work.

    Although that should not stop the sketch compiling.

    So using the same procedure navigate to the Environment Variables (Control Panel > System > Advanced System Settings > advanced tab > environment variables )
    Select "Path" in the lower pane. click Edit and at the end of the string add ;C:\Python27 click OK.

    Back in cmd prompt, copy and paste this----------> cd C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\tools ------------->return
    then type -----------> python get.py --------------->return
    The package should then install. Sorry about that.

    Steve.

    Edit; Think we cross posted. Just checked your website, excellent job. Can't think of anything make sure the baud is set 115200. If using Chrome on the desktop, start the 'Webpage' right click on the window, select 'inspect element' click the 'console' tab then you can debug the html wireless side in there. A series of messages will appear once you have a successful connection and start operating the buttons. You did remember to put your WLAN details into the sketch I presume. See your router webpage to make sure the device is online and note it's IP.

    It would be awesome if you could do a video for other users, once you have it all worked out.

    Thanks

    Steve.
     
    Last edited: Mar 11, 2016
    Scott Eric Catalano likes this.
  17. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Hi All,

    While some of you are out there testing DCC++ WebSocket interface. I thought I might share my plan for the next version.

    It's obviously a pain putting files onto mobile devices and having to deal with connection issues.

    So after a look around I came upon this project http://adityatannu.com/blog/post/2016/01/24/ESP8266-Websockets-demo-using-NeoPixels.html

    What Ady has done there is combine the best ideas into a single package. The webpage is loaded into the esp8266 SPIFFS memory, then when a client logs with an
    ordinary browser the page is 'served' to the client device. A websocket connection is established and client takes control. Server to client messages are implemented and
    even Html page updates can be done via browser. Connection data can be hard coded as the system will be self-contained AP server. Self-contained in software as everything will be on the ESP.

    For a bit of fun how about driving your train with your phones Gyros ???
    https://www.instagram.com/p/-ii54rEdew/

    Steve.
     
    Last edited: Mar 11, 2016
    Scott Eric Catalano likes this.
  18. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Hi, Steve - I have the ESP8266 getting an IP address (192.168.1.17 is reported in terminal) and I can ping that address from my PC.
    I have that address entered into the web page. When I toggle buttons or use the slider the console shows that I have done stuff but nothing shows on the Arduino terminal - I gather from the code that I should see DCC++ commands (ie <1>)

    I put a screen shot of Chrome on the web page AT THE VERY BOTTOM: http://trainelectronics.com/WiFi-esp8266/Setup/

    Any thoughts?

    dave
     
  19. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Hi Dave,

    You forgot to add the port number at the end 192.168.1.17:81<<<eighty one. So the socket was not open in your case.
    There will be only one RED comment at the start once the connection is open.

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

    David Bodnar TrainBoard Member

    264
    481
    13
    Bingo! Its alive --- hope to have time to connect it up to the DCC++ unit tomorrow. Great work, Steve

    Thanks for your patience!

    dave
     
    Scott Eric Catalano likes this.

Share This Page