Modifications to Dave Bodnar's DCC++ Nextion Throttle

NormHal Jul 16, 2017

  1. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    One thing we've taken for granted is that we are all using the same development environment... As a checkpoint, I am using the latest Nextion Editor V0.47, Arduino IDE 1.8.3, The Arduino Nextion library linked to from Dave's site - https://github.com/bborncr/nextion, running on Windows 10. A tip I picked up from one of UK Steve's posts is that one should specify the Nextion baud rate in the pre-initialization event of page 0 (bauds=9600 in my case). I haven't (yet) done this, but have suggested to Steve (esfeld) that this is worth checking.

    In answer to you Keith, I have NOT tried running the Nextion to Arduino interface at greater than 9600. I am going to experiment with some faster options, but feel that trying to run the Software Serial code too fast may be problematic. I will advise my findings too.

    That's all for now:)
    Norm
     
  2. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    From my side, everything is working well with the enhanced 3.2" Nextion. I am currently running trains with the comms between the Nextion and its Arduino, and the Base Station Arduino, all running at 115200 baud:). I have connected the setup to a small double loop test track and have been running two trains via the throttle. It's the first time I've been able to listen to the internal sounds on functions 9 upwards too!:)

    The practical use of the throttle has tempted me to experiment with some two way communication with the throttle. I find when the Base Station shuts down (from a short) it would be really cool if the "Off" button on the throttle would come on. Also, it's probably a pipe dream, but it would be Super Cool to be able to run the computer based control software in tandem with the throttle. Not sure if anyone has attempted to have two serial connections working on the Base Station? Either a Software Serial port, or using an Arduino Mega? I might still be able to achieve an original goal of having a full Command Station in a matchbox:). The small Pololu motor drivers have already been acquired and I sourced some mini Arduino Megas on eBay - so much to do, so little time:)

    Unfortunately, my testing this morning has got me nowhere on the road to solve Steve and Keith's problems:-(

    Best,
    Norm
     
    Scott Eric Catalano likes this.
  3. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    OK success except for one bug. I updated to latest arduino compiler 1.8.3 and redid everything and all good now.

    Unfortunately the jitter "revert to zero" problem is very evident in 4.5. especially if holding down the plus or minus. I can hold for 10 or 20 roughy speed steps then reverts to zero most of the time. Sliding I don't notice it as much.

    4.0 has no such issues and I can hold the + - down smooth with no issues.
     
    Scott Eric Catalano likes this.
  4. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Hi Keith, thanks for the feedback! I had been doing all my testing at 9600 baud - yesterday was the first attempt at 115200. I too observe the resetting to zero at the higher baud rate:-(

    By making some minor mods to the timing of the repeat function (repeat rate is faster) and dropping the baud rate to 57600 I have not been able to make the zero speed occur. Me thinks this is going to take some serious head-scratching to determine the exact cause at 115600. I'm going to try to swop the two serial port usages in an attempt to determine the source. Again any thoughts or suggestions are welcome:)

    Just because it's becoming a habit, attached is the latest V0.46 - .ino and .hmi set to 57600 baud. Another fix is that the throttle speed is updated as the slider is moved. Again, both .ino and .hmi go together:)

    In the meantime, I've been playing with ideas for version 0.5... "Major" addition is to be able to control turnouts from a page 3. My idea is to have a bunch
    of predefined left or right turnouts (about 30) with (customizable addresses and orientation (left or right) via compile). Also to include an "On-Fly" facility to change any turnout address to "Thrown" or "Closed". We're running out of Desktop space on the 3.2" Nextion, so I'll have to drop Dave's background (it's getting obliterated anyway:-(. Another thought is a further page for signals, but I'd like thoughts as to how relevant this is for a handheld throttle?

    All the Best,
    Norm
     

    Attached Files:

    Scott Eric Catalano likes this.
  5. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    Well, at the risk of stating the overly obvious, the simple solution is to drop back to 9600 baud which should be plenty fast anyway. I'll make just that switch and test and confirm but honestly from my side I think it's fine just to tell folks don't run over 9600 baud or whatever number your comfortable with.

    I think turnout control is a great and interesting idea. Certainly not a must have in my book but nice (though I am keeping DCC traffic limited to the train functions personally).

    I think the best way display wise might be to just have a button currently where the highest function button is that goes to a menu. That menu page then has options 1) the high functions 2) turnouts 3) signals etc. that go to their own unique pages (it would need a "throttle screen" link on each to return to the throttle screen) That way there is plenty of room for expansion. I guess really the main limit will be when you start getting close the the memory of the basic but I see no harm in having these as options without taking up additional real estate on the main page.

    Once again I can't say thanks enough for all your work on this. You have truly taken it to the next level and folks like me are the beneficiaries!!
     
    Scott Eric Catalano and esfeld like this.
  6. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Thanks for your kind words Keith - I must say I am selfishly having tremendous fun with DCC++ - all credit must go to the concept (and implementation) by Gregg, and Dave's creative contribution. I'm merely trying to put my own brand of polish on a fine piece of work, and am delighted that others find it of some use:)

    I suspect there are bandwidth/timing constraints we're running into. I personally am building a housing without the rotary encoder, and (so far) am finding the 57600 baud setting to be flawless, however Steve (esfeld) has found problems at this speed with the Rotary encoder. Perhaps it's going to be a case of configure to suit your preferences. I cannot so far establish what is causing the return to zero issue - I can only conclude the arduino is requesting data from the Nextion at an inconvenient time:)

    Very soon I'll post my initial concept for the turnout option - signals received a little thought and I fear that will come much later, if at all. I haven't yet been able to conceptualize how to control 3 and 4 aspect signals in an easy touch based manner...

    But I'll be back (soon:))
    Norm
     
    Scott Eric Catalano and esfeld like this.
  7. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Norm/Keith ...The RE issue I encountered was a bad RE ....... now everything seems to be working reliably except the return to zero problem. Norm, I agree that it may be a timing issue as it seems to occur when making the RE direction change closely to another ...... as in testing!! :)
    Again, nice work ..... thoroughly enjoying the project.
    Steve
     
    Scott Eric Catalano likes this.
  8. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Thanks too to you Steve, your constructive comments have been great:)...

    In terms of the return to zero problem, are you sure you're not referring to speeds above 15 (as per the arduino .ino)? Below the "ReverseThreshold" (line 43) constant value, the speed does not get reset when changing direction - above "ReverseThreshold" the speed WILL be reset to zero on a RE button push:)

    Told you I'd be back:)
    Norm
     
    Scott Eric Catalano likes this.
  9. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Thank you forgot all about that …. I will adjust accordingly. As an aside what was the rational for that ….switching below 15 I imagine, but why a stop above that .. why not just a reverse and let accell/decell apply?
    Steve
     
    Scott Eric Catalano likes this.
  10. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Remember the stripped HAG gears? Some decoders respond instantly to direction changes, and some not. While playing with a BLI PA1 on my test layout, I noticed that it gracefully slowed and changed direction in spite of my precaution. Bottom line is, if it's not important to you, change the "ReverseThreshold" value to 126 and all will be forgiven:)

    Norm
     
    Scott Eric Catalano likes this.
  11. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Thought I'd quickly post a "proof of concept" version for comment:)

    Basically it's the same as Version 0.46, but with the addition of the Nextion mock-up of turnout pages. Turnout 20 (Address 21) uses a pic for the image so won't respond to any touch. All the other turnouts use Dual State buttons for now purely for visual effect. My goal is to make the orientation (Left or Right) and Address of each turnout definable in the Arduino code at this stage. Perhaps later look at having a Nextion based configurator - we'll see:)

    Comments are as always most welcome:)

    All the best
    Norm
     

    Attached Files:

    Scott Eric Catalano likes this.
  12. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Thought I'd post little more than a status update:-(
    Attached is the current status of developments for your investigation/comments/critique. I seem to have hit an Arduino problem where lack of available memory causes "weird" effects...

    This version provides support for 50 turnouts (as well as everything previous:), but is buggy:-(. Feel free to test and report your findings...

    Over the last few days I spent time (trying to) re-write much of the structure which has evolved, but shelved my efforts for the time being. I initially mentioned my difficulties getting to grips with C data type conversions, and this challenge still afflicts my efforts. I'm hoping that what I've learned over the last day or so will enable me to re-visit the code I re-wrote in an attempt to simplify what has become quite a patch-work project:-(

    Please feel free to pass any comments you wish:)
    Norm
     

    Attached Files:

    Scott Eric Catalano and esfeld like this.
  13. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    As happens all too often, last night saw a too hasty change to some code and I messed up the accessory data generation - offset the address by one:-( The attached zip has fixed it:) I also re-instated the 57600 baud communication for both the Nextion and Arduino comms.

    Note one quirk with the method I have used to store turnout details - multiple instances of the same turnout address are possible - this could be handy for convenient 'groups' of turnouts - for eg. possible future routes. The downside is that each instance is insular and does not update the visual state of any other turnout pictures with the same address... I will keep this in mind as I progress...

    Norm
     

    Attached Files:

    Scott Eric Catalano and esfeld like this.
  14. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Just to give you something to play with over the weekend, here is build V0.60. A page has been added with access to routes predefined in the Nextion. You will notice that I have only added 7 buttons for routes, but there is the capacity on one page to have up to 21. I chose larger buttons so that minor customization of the button text is possible. Each route can have "unlimited" turnouts associated with it. Nested routes should be possible by using the Nextion capability to activate buttons from a command - I haven't tested this.

    All in all, it's amazing how much can be done with no more than a Nextion and an Arduino Nano/Pro Micro/Micro/Uno. Again, kudos to Gregg and Dave for creating such an incredible project!

    Enjoy!
    Norm
     

    Attached Files:

    Scott Eric Catalano likes this.
  15. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Well guys, for me this has really been a fun project - managed for the first time to write some code in C. I have now reached the point where I can humbly say 'Mission Accomplished' :). I have checked everything as thoroughly as possible, and decided to make a final version number change to V4.00, to keep with Dave's numbering convention. This 'final' version saw the correction of some minor inconsistencies, an update to the "Stop" button, and I decided to fill Page 5 of the Nextion with more "route" buttons - now 21 in total:). As always, any comments or suggestions, and of course bug reports, are most welcome!

    All the Best,
    Norm
     

    Attached Files:

    Scott Eric Catalano likes this.
  16. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    One last upload...
    Some minor mods:)
    1. Revisited the Rotary encoder 'Speed-up' code and made the speed-up rate easily modifyable - it's a #define incAmount on Arduino Line 206
    2. Added delays between the route commands in the Nextion - look at the "Press events" for each "Route" button
    3. A little more tidying up:)

    Keith, if you're still following developments, I'd like to hear your findings with the Rotary Encoder? I suspect the changes I implemented may have fixed it:)

    Enjoy!
    Norm
     

    Attached Files:

    Scott Eric Catalano likes this.
  17. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    Sorry been out of the country so limited time to read/post. I'll catch up on things this week and try to do some testing, etc and report back!

    Been playing with the DCC++ booster as well and getting some wacky results dependent on the motor shield so lots to play with. Hopefully I can find some time this week.
     
    Scott Eric Catalano likes this.
  18. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    And now for something new...
    I really wanted to do the 3D type of "animated buttons" but I felt it lost Dave's clean design...
    So here is my latest iteration - Same underlying code hence the same version number, but a revised interface.

    Best
    Norm
     

    Attached Files:

    Scott Eric Catalano likes this.
  19. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Keith
    Did you build the booster using Daves printed circuit board or your own design? I am presently building one using Daves printed circuit board and have some questions for you if you did used it or perhaps some photos of your build.
    Steve F
     
    Scott Eric Catalano likes this.
  20. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    Have done both but gotten the flaky issues repeated on both which I'm hoping is due to the actual motor drivers but I'll have to find some time to test it
     
    Scott Eric Catalano likes this.

Share This Page