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 Steve,

    Has anything changed? Have you 'upgraded' to the Dev versions on page 55?
    For me that is normally pointing to a misconfiguration of the ws:// address in the Html
    The hard coded address is ws://192.168.101.101:81. You'll need to change to suit your own if necessary.
    Here's the error when I reproduce that fault.

    CaptureClosed.JPG

    First click on Connect brings Disconnected in the Serial Display then a retry gets the message box.

    Steve
     
    Scott Eric Catalano likes this.
  2. Gregg

    Gregg TrainBoard Member

    237
    311
    18
    Current sensing is used for two purposes -- the first is to protect against current overflow (presumably due to a short-circuit but could be for any other reason, such as too much load). The second is for detecting acknowledgments when reading a CV from the programming track. The logic and parameters for these two uses are completely separate in the code so you can change one without worry about the other.

    The current-sensing logic is in CurrentMonitor.cpp and the parameters are in CurrentMonitor.h. CURRENT_SAMPLE_MAX is the parameter that should be changed depending on the motor shield board. Within CurrentMonitor.cpp you'll see the method CurrentMonitor::check(). This is called twice within DCCpp_Uno - once for the programming track, and once for the main track. It would be relatively straightforward to add a single parameter to the check() method that passes distinct versions of CURRENT_SAMPLE_MAX (one for the programming track, and one for the main track). This would allow you to create two different scaling factors for use with two different motor shields.

    The logic for reading/writing CVs is in PacketRegister.cpp and the parameters are in PacketRegister.h. I've tried to create a set of logic that can robustly detect current spikes (which is how decoders acknowledge reading a CV) but there is one parameter that likely would need to change if you use a motor shield for the programming track with a very high current threshold -- the greater the threshold, the lower the output voltage for a very small current spike. If you find you are having problems reading CVs try lowering the parameter ACK_SAMPLE_THRESHOLD in PacketRegister.h.

    Hope this helps.

    -Gregg
     
    KC Smith, Scott Eric Catalano and HVT like this.
  3. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    Yes, that's the answer I was looking for.....THANKS.

    One other thing comes to mind. If multiple power districts are desired, I assume that as long as the motor shields are the same as far as current sense, the multiple motor drivers should be able to use some of the unused analog lines for current sensing.....is the current sense code flexible or modular enough for multiple current sense pins?

    I guess I'll have to dig deeper into you code to see how it can be expanded in this area.
     
    Scott Eric Catalano likes this.
  4. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Steve
    Thanks, Didn't upgrade to the Dev version ( using set up 2) but it seems to by pass the error and connect. I was just curious about the cause. Other than that I am still marveling at your development of the interface. Wondering where we go from here. :D
    Steve F
     
    Scott Eric Catalano likes this.
  5. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    I was just throwing around some new ideas actually and trying new code.

    The next iteration will have a nice animated 'Speedometer' as a visual reference in the centre of the page. To the left will be a single Throttle slider
    much the same as now. An over on the right will be your customised Roster in the form of a 10 button column. You will be able to just pick a loco
    from your list, its throttle status will update instantly, adjust as you like and move to the next. Any order, up to 10 throttles running at the same time.
    Though I wouldn't recommend you try that !
    We can change left and right positions if people have a preference.
    All in a similar format of the throttle section on Gregg's Controller app.

    I'm hoping to have a mock up page assembled shortly. Watch this space.

    The Base Station command codes will all be compiled and sent from the html/javascript with automated session backup on the fly, using an XML document.
    And the ESP code will be ultra simplified just passing serial to and from the websocket connection.

    In the current version a lot of work is done by the ESP and I went down that route because most of the 'community' examples did the same.
    Now I've learnt a thing or two, the webpage can do the majority of the work like a true app. Then I can write a standard server code which will rarely need updates.
     
    Scott Eric Catalano, HVT and esfeld like this.
  6. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Steve
    Sounds more than exciting, can't wait. I, for one, like having more than one active throttle, for ease in operating two (or more) locos without switching back and forth on a single throttle ....... perhaps thinner throttles would allow for this on the left side.
    Steve F
     
    Scott Eric Catalano and HVT like this.
  7. Kevin Whitham

    Kevin Whitham New Member

    4
    5
    7
    I'm also risking disdain for not knowing where to look on this board for what is probably an easy answer to a question I'm stumped on:

    I am developing a layout based on Gregg's excellent DCC++ system, some 40 years after I sold my old Triang-Hornby layout. I have jumped in at the deep and and designed a 2 track double-loop layout with 52 turnouts, a turntable, 3 yards, etc. I want to use Controller and Base Station to control routes on this layout, and I have defined all my tracks, turnouts and routes in controllerConfig. BUT, I cannot get any of the turnouts to switch states, except for the very LAST one defined under the tButtonxx = new TrackButton(); command. (Under Emulator control - the physical layout isn't finished yet). I've even successfully hooked up a Mega and Base Station, and defined all 52 Turnouts with the <T> commands through the serial port, but - nothing switches state on the monitor. If I comment out the last turnout, (#52) then only #51 will switch when mouse-clicked.

    Eventually I plan to control the turnouts and the turntable using 4 Nanos and 4 16-relay boards
    (each Nano would operate 16 turnouts, because I've figured a way to have each relay board operate 16 torti).

    Help ?
     
    Scott Eric Catalano likes this.
  8. Gregg

    Gregg TrainBoard Member

    237
    311
    18
    Can you post a snippet of your Processing code where you define some of the turnouts. If only the last one is operating it sounds like each one defined is overwriting the prior one.
     
    Scott Eric Catalano likes this.
  9. Kevin Whitham

    Kevin Whitham New Member

    4
    5
    7
    Here's the last 5 Turnouts:


    tButton48 = new TrackButton(20,20,1); // 48
    tButton48.addTrack(TopLoopB3,1);
    tButton48.addTrack(InnerA2,0);

    tButton49 = new TrackButton(20,20,1); // 49
    tButton49.addTrack(TopLoopA1,1);
    tButton49.addTrack(InnerI2,0);

    tButton50 = new TrackButton(20,20,1); // 50
    tButton50.addTrack(TurnF,0);
    tButton50.addTrack(TurnG,1);

    tButton51 = new TrackButton(20,20,1); // 51
    tButton51.addTrack(SouthYd21,1);
    tButton51.addTrack(SouthYd22,0);

    tButton52 = new TrackButton(20,20,1); // 52
    tButton52.addTrack(SouthYdP,1);
    tButton52.addTrack(SouthYdQ,0);

    Thanks for the quick reply.
     
    Scott Eric Catalano likes this.
  10. Gregg

    Gregg TrainBoard Member

    237
    311
    18
    Thanks Kevin. The issue is in the TrackButton call. The first two parameters are for the x-size and y-size of the (invisible) button and 20 is a good value for both. However, the last parameter is actually the number of the turnout (its ID). These need to be unique and you have them all defined as 1 (which is why only the last one seems to be working). The names of the track buttons also need to be unique, but only for the purposes of using the autopilot function. Otherwise the names don't actually mean anything and they could be numbers, letters, etc. In my own code I named them with a suffix that matches the numerical ID of the turnout simply for convenience. If you change the last parameter in each TrackButton call to 50, 51, 52, etc. I think that will do the trick.
     
    Scott Eric Catalano likes this.
  11. Kevin Whitham

    Kevin Whitham New Member

    4
    5
    7
    Aha !

    Thanks a 10^6

    I'll get to that pesky code later today
     
    Scott Eric Catalano likes this.
  12. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    All.

    As some of you know I've recently decided to rework parts of my Mobile Controller project.

    Part of that work was to revisit the possibility of storing the Front end page on the ESP in the SPI Flash File System (SPIFFS). Throughout my adventures with the ESP8266
    I have relied heavily on the knowledge and dedication of the 'ESP Community'. Most notably Markus Satler (links2004) for bringing us the WebSockets library for ESP on the Arduino IDE.

    I've played around with a Spiffs implementation a few times, but have been disappointed with the results. It was either too slow or failed because my 'App' is large by ESP standards
    and has a lot of dependency files, which modern browsers tend to call in multiple simultaneous requests causing the ESP to crash.

    However the main contributors Links2004, Me No Dev and others have come good once again with something called ESPAsync TCP. This very recent development brings together the very best
    in http tcp, websockets and spiffs firmware code. Perfect for my project, I can't thank them enough.

    I've done a few tests and here's the Chrome console results serving 307KB of page and dependencies. Great stuff.

    CaptureM.JPG

    If these results are reliable, and I've every reason to believe they are. Then the whole project can be flashed to the ESP. And you can do OTA (Over The Air) updates as well.
    Under 3 seconds for a running App is excellent, oh and we should be able to call session info and auto connect the Websocket all at page load simplifying everything.

    I guess I'm going to be busy getting to know this new stuff and recoding everything but it should be awesome when I'm done.

    If there are any adventurous ESP enthusiasts wanting to test Spiffs just let me know.

    Steve.
     
    Last edited: Apr 27, 2016
  13. KC Smith

    KC Smith TrainBoard Member

    109
    111
    12
    UK Steve,

    Great work Steve we all appreciate all the work you've put into the esp these past few months.

    Apparentley the Arduino Uno Wifi board with the imbeded ESP8266 is now available fro $33euro,appx $38us.

    http://46.140.176.33/gitarduino/products/boards/arduino-uno-wifi#
    world.arduino.org/en/new-products/arduino-uno-pro.html
    [​IMG]

    Would this make DCC++ Server Basestation idea with a DCC++ browser Throttle a little easier?
    Would it take much code modification to use this as our Primary DCC++ Base Station with a Motor Shield or Polo Shield on top and your web Throttle as is?

    Regards,
    Kevin
     
    HVT and Scott Eric Catalano like this.
  14. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    Didn't this board just come out not to long ago?
     
  15. KC Smith

    KC Smith TrainBoard Member

    109
    111
    12
    Yes, this was the Uno Wifi board Jason saw in Hackaday magazine article with the Frederico Musto interview on Jan 4th. post #506
    http://hackaday.com/2016/01/04/new-...interview-with-federico-musto-of-arduino-srl/

    I've just been waiting for its public release. I don't think the Schematics are available yet so clone boards maybe not be available for quite a while. Data sheet attached

    Reseller Alsrobot: http://www.alsrobot.com/index.php?route=product/product&product_id=935

    K
     

    Attached Files:

    Last edited: Apr 28, 2016
    Scott Eric Catalano and HVT like this.
  16. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Hi Kevin, All

    Yes I remember the Hackaday article, and here we are with some product at last.
    For sure it will give access for hobbyists who are a little less inclined with a soldering iron to try some different options.
    I hope we see the usual price falls and I would buy one myself.

    As for code modification, I would think everything stays pretty much the same, in that one would program each chip separately.
    So yes it makes for a compact easy solution.

    Steve.
     
    sboyer2 and Scott Eric Catalano like this.
  17. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    All,

    As promised, I've been busy recoding the Mobile Controller app. I think it's fair to say the app now works in harmony with Gregg's fine logic on Base Station and DCC++ Controller.

    If I've got the coding right, you will now be able to run the app on any device with a browser and wifi. You can jump in mid session, in theory with multiple instances. Take over a session
    that was started on DCC++ Controller. Exit a running session and then come back to it etc. The only caveat is that you set up the Cab numbers to match the throttle numbers on Gregg's app and the Mobile app.
    I've thrown in as many features as I can think of, no doubt you might be able to come up with more.
    I can do a few custom pages for anyone interested, over to you guys.

    Steve.


    CaptureN.JPG
     
    KC Smith, esfeld, FStop8 and 5 others like this.
  18. sboyer2

    sboyer2 TrainBoard Member

    35
    41
    6

    i cannot get the current meter to work in JMRI ( both 4.3.4 and 4.3.5 haven't tested earlier versions) the window does't even popup, i have to select it in the window list menu, and when it shows up, it is blank.

    not a problem on the DCC++ Hardware, as i can get readings with commands in the serial window of Arduino IDE(1.6.8).

    also i'm in Linux,if this makes a difference.
     
    Scott Eric Catalano likes this.
  19. sboyer2

    sboyer2 TrainBoard Member

    35
    41
    6
    just to add here's le console log from JMRI if it helps

    2016-05-03 01:23:54,777 util.Log4JUtil INFO - ****** JMRI log ******* [main]
    2016-05-03 01:23:54,854 util.Log4JUtil INFO - This log is appended to file: /home/sboyer2/.jmri/log/messages.log [main]
    2016-05-03 01:23:54,855 util.Log4JUtil INFO - This log is stored in file: /home/sboyer2/.jmri/log/session.log [main]
    2016-05-03 01:23:54,864 apps.AppsBase INFO - DecoderPro version 4.3.5-R305598e starts under Java 1.8.0_91 at Tue May 03 01:23:54 EDT 2016 [main]
    2016-05-03 01:23:57,074 gui3.Apps3 INFO - Starting with profile SBoyer2NRail.3ea12415 [main]
    2016-05-03 01:23:57,139 node.NodeIdentity INFO - Using jmri-0010C6B0CAB5-3ea12415 as the JMRI Node identity [main]
    2016-05-03 01:23:57,480 serial.DCCppAdapter INFO - /dev/ttyUSB0 port opened at 115200 baud with DTR: true RTS: true DSR: false CTS: false CD: false [main]
    2016-05-03 01:24:00,577 util.FileUtilSupport INFO - File path program: is /home/sboyer2/Desktop/JMRI/ [main]
    2016-05-03 01:24:00,577 util.FileUtilSupport INFO - File path preference: is /home/sboyer2/.jmri/SBoyer2NRail/ [main]
    2016-05-03 01:24:00,578 util.FileUtilSupport INFO - File path profile: is /home/sboyer2/.jmri/SBoyer2NRail/ [main]
    2016-05-03 01:24:00,578 util.FileUtilSupport INFO - File path settings: is /home/sboyer2/.jmri/ [main]
    2016-05-03 01:24:00,579 util.FileUtilSupport INFO - File path home: is /home/sboyer2/ [main]
    2016-05-03 01:24:00,579 util.FileUtilSupport INFO - File path scripts: is /home/sboyer2/Desktop/JMRI/jython/ [main]
    2016-05-03 01:24:07,749 withrottle.UserInterface INFO - Creating new WiThrottle DeviceServer(socket) on port 12090, waiting for incoming connection... [WiThrottleGUIServer]
    2016-05-03 01:24:24,278 ptionhandler.UncaughtExceptionHandler ERROR - Uncaught Exception caught by jmri.util.exceptionhandler.UncaughtExceptionHandler [AWT-EventQueue-0]
    java.lang.NullPointerException
    at javax.swing.ImageIcon.<init>(ImageIcon.java:217)
    at jmri.jmrit.catalog.NamedIcon.<init>(NamedIcon.java:70)
    at jmri.jmrit.ampmeter.AmpMeterFrame.<init>(AmpMeterFrame.java:66)
    at jmri.jmrit.ampmeter.AmpMeterAction.actionPerformed(AmpMeterAction.java:30)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
    at java.awt.Component.processMouseEvent(Component.java:6535)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6300)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4891)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4713)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
    at java.awt.Container.dispatchEventImpl(Container.java:2280)
    at java.awt.Window.dispatchEventImpl(Window.java:2750)
    at java.awt.Component.dispatchEvent(Component.java:4713)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
     
    Scott Eric Catalano likes this.
  20. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Hi Steve
    Can we have the IP field come up blank (like the Cab # field) so we don't have to delete and enter our IP but just enter the IP ..... just a suggestion.
    Regards
    Steve F
     
    Scott Eric Catalano likes this.

Share This Page