Modifications to Dave Bodnar's DCC++ Nextion Throttle

NormHal Jul 16, 2017

  1. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Firstly, I'd like to thank and compliment both Gregg and Dave for their selfless sharing of their work:). I've battled for many years to get to the point of trying to write some 'C' code, and they managed to finally get me to open the door...

    I really enjoy the DCC++ and Nextion concepts and took them as models to do some constructive experimentation and hopefully share my findings with others.

    My first contribution is a very minor addition to Dave's Nextion based Throttle. I felt it would be 'nice' to restore the function settings of each loco when a different address is selected. This involved a small routine I called 'UpdateBinary' which is called whenever one of the three registered loco addresses is selected.

    Once I had this working, I felt it would be visually helpful to replace the Function Key buttons with animated images - giving an expanded view of which functions were enabled/disabled. This proved to be more tricky, but I finally managed to achieve what I wanted. This is achieved with the addition of a subroutine called 'UpdateButtons' :)

    The attached files represent the current state of development. Please feel free to critique/suggest/comment/question any of my rationale. I'd really welcome some comments regarding the type conversions I had to resort to when building the Nextion command strings.

    Hope this is of some interest:)
     

    Attached Files:

  2. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Ok, so life is full of surprises:-(. I found an omission on my part to clear the function settings when a new address is chosen. In so doing I discovered that I had uploaded an intermediate version of the HMI file which didn't include full compatibility with Dave's original Arduino sketch and my mods - my bad:-(. One of my design goals was to make any modifications to either Dave's Arduino code, or to his original Nextion design, retain full interchangeability - ie. One should be able to use my modified HMI file with Dave's original Arduino sketch, and also be able to use my modified version of Dave's sketch, with his original Nextion HMI file.

    Hopefully this is now corrected and I apologise for my slip-up. The newly updated version should work correctly. I am however still working on the address change 'problem'. What I'm hoping to achieve is that when for example the second DCC address is selected to be changed, returning from 'Page 1' will result in the second address slot still being selected, and its address being updated accordingly, but it's associated functions being reset to zero. the function settings for the first and third possible locos must still reflect their correct settings...

    More to come:)
    Norm
     

    Attached Files:

  3. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Hi all,

    Attached is the latest iteration of my changes to Dave's Nextion based throttle.

    I have managed to achieve what I wanted when returning from selecting to change the DCC address - one is now returned to the same loco slot which was active and the function settings are either restored if 'Abort' was selected, or all reset if returning with a new address.

    Sadly, the trade-off with this current version is that I have had to sacrifice the compatibility with Dave's versions I was hoping to maintain. I have been battling to fully manipulate the 'Dual State' buttons as provided by iTead/Nextion, so to achieve what I wanted I needed to revert to using a more Nextion independent method of placing the code in the Arduino.

    My next step is to both review the compatibility issue, and look at implementing a 'Slider' touch based speed and direction control which will hopefully work in parallel with the rotary encoder. I'd appreciate views as to preferences of Rotary encoders versus a touch based option?

    Just by the way, I was getting confused with my own (lack of) naming convention, so have started to use a version numbering system. This first upload assumes all previous versions fall into the category of Version 0.1:)

    Norm
     

    Attached Files:

  4. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Norm
    Since the rotary encoder knob is one of the main attributes in Daves throttle design, I would think that most would want to keep it ..... the addition of a speed slider (on a non interfering basis) would be a plus for those that prefer that .. as long as it was efficiently integrated to the original throttle design.
    Steve F
     
  5. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Thanks Steve. I plan to place the slider in a similar location to the current progress bar, increasing speed from left to right. At this time I intend to modify the direction arrows to buttons, but retain the "Arrows" as text. The numerical value of the current speed will remain in the center. I'm thinking of removing the binary function from the bottom and possibly using the space for three function group selectors. This will be quite far into the future, as I must get to understand how DCC generates the function settings above 8 :).

    One thing which is concerning me a bit, and is being a distraction, is that I feel Dave's visual effect is very clean, uncluttered, and attractive. Whilst I like animated buttons, I'm concerned that I might be creating an overly cluttered interface, basically spoiling Dave's handywork. It would be interesting to hear other's opinions?

    Currently I'm looking at implementing my modifications whilst keeping Dave's style mostly intact. We'll see how it goes:)

    Best,
    Norm
     
  6. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Awaiting your further developments to see how this turns out. I have also built several of UK Steves throttles and modified his Nextion script to include F1,F2, F8 and F0 on page one to facilitate using the most commonly used Functions without changing to the dedicated Function page.
     

    Attached Files:

    Scott Eric Catalano likes this.
  7. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Hi all,

    Here is my latest progress report... Attached is a cleaned up version of developments so far which seems to be quite complete. I have managed to integrate a touch based system with the rotary encoder - both work together (quite) seamlessly.
    In the interim I removed the scaling routines as well as the accelerated effect for the rotary encoder - but don't panic - I didn't see how the slider could accommodate the concept:) The next version will attempt to accommodate both:)

    BTW, both the Arduino sketch and the Nextion files need to be used together. Nextion TFT file is for a 3.2" Enhanced display, but the HMI file "should" work with the Basic version.

    Any and all feedback welcome:)
    Norm
     

    Attached Files:

    Scott Eric Catalano likes this.
  8. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Norm
    I`m not at my desk right now but I believe that the HMI can be compiled for either basic or enhanced, so just sending an HMI would work. Watching your progress with interest.
     
    Scott Eric Catalano likes this.
  9. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    First thanks everyone for work on this. Truly great stuff that I know is often thankless.

    Norm I uploaded everything used hmi file for the basic (non enhanced) 3.2 inch (NX4024T032_011) and after compiling and uploading works flawlessly. I like the slider a bunch! I also like that you can do anything without the rotary encoder if you want. While its much easier with here are times when I'm playing with it it's nice to be able to test everything on Nextion! Great work.

    Just a suggestion that I'm struggling how to implement would be to have + and - buttons for speed that if held down keep incrementing up until released. In my limited knowledge of Nextion I'm not sure how to implement it (or if it's even feasible) Reason being slider is good but not exactly fine control. On older versions the plus and minuses incremented one step at a time and that lots of button pushes if you want to go fast. Anyway just a thought certainly not taking away from what you've done!
     
    Scott Eric Catalano likes this.
  10. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Thanks for the feedback Keith:)

    When I first started experimenting with Sliders, I was impressed with how accurate they could be. My implementation has not yielded the fine resolution I was hoping for. I intend to play a bit more to see if I can improve its performance. I found that because I want to control the slider's movement from multiple sources, I decided to remove the scaling code as well as the 'acceleration' feature of the rotary encoder. Will take some clear thinking to get it all integrated:-(

    Your idea of a + and - incremental option is interesting. My first idea is to see if the repeat function can be implemented within the Nextion itself, perhaps even achieve an 'acceleration' feature as well... I'll add it to my todo list:)

    Best,
    Norm
     
    Scott Eric Catalano likes this.
  11. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Hi Keith! (and all others interested:))
    Here's the latest version of my experiments. I have added a "+" and "-" to page 2 which will increment or decrement the speed one step at a time. Thanks to Dr. Google, a method of repeating commands while keeping the button pressed has also been implemented.

    Please note that this is very definitely a "work-in-progress" as I am battling with a weird phenomenon of the slider delivering zero or reverse direction commands randomly. I humbly plead for feedback, suggestions or comments:). Needless to say I've put new batteries in my bug-swatter and am happily on the prowl:)
    Best
    Norm
    PS. In spite of Steve's constructive suggestion, I include the .tft file (for the last time, unless any complaints received) for those who simply wish to upload the binary to a 3.2 inch Enhanced Nextion display:)
    PPS. I named this version V0.4 in anticipation of the weird problems being resolved:)
     

    Attached Files:

    Scott Eric Catalano likes this.
  12. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    I like it. I'm going to hook it up and play with it some this weekend to bug test and run for real but I like it. The serial commands look perfect coming through. love the push button + and - button. Its a great add. Thanks so much
     
    Scott Eric Catalano likes this.
  13. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Here is my latest:) All known bugs squished:) Weird problems were caused by data coming from the Nextion - seemed like reading from the Nextion can result in getting data which hasn't been updated internally - I reverted to only using data volunteered by the Nextion:)

    One change I also made was to reset the speed to zero of the loco being controlled when direction changed.
    Enjoy and any critique welcome:)
    Norm
     

    Attached Files:

    Scott Eric Catalano likes this.
  14. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Norm
    Have you thought about an option on the speed reverting to zero ........ those of us that use magnetic uncoupling prefer maintaining speed on reversal. Just a thought.
    Steve F
     
    Scott Eric Catalano likes this.
  15. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Interesting thought Steve, I was thinking of adding a page with configuration options so might pick it up.

    What would you think of having a built in deceleration and acceleration function when direction is changed? In my days of developing mobile decoders I had included that as a configurable option, but my involvement in computerized control made it somewhat redundant.
    Best,
    Norm
     
    Scott Eric Catalano likes this.
  16. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Thinking some more about this Steve, in my days of developing mobile decoders I had a beautiful HAG HO Re460 which stripped its geartrain in less than 1ms because I had an instant direction change implemented:-(

    That being said:-
    1. Would it be an idea to allow instant reversal below a certain speed? What is found most suitable?
    2. What are the thoughts on having a 'soft' reversal process (deceleration then acceleration after direction change), which can be interrupted/overridden by the touch panel or rotary encoder?
    3. I want to change the way Dave's code only sends refresh packets for the currently active loco, to include all three active in the throttle. I would also like to refresh current function settings - comments?
    4. I'd like to avoid configuration options - they seem to cause more trouble than worth, but at the same time I want the throttle to offer as much as possible to cater for everyone's needs - therefore everyone's input is vital to achieving this:)

    All this when I thought I'd reached a state of completeness:)
    Best,
    Norm
     
    Scott Eric Catalano likes this.
  17. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Just to keep you on your toes, here is another release with a constant added (which can be changed at compile time) to set the reversing speed threshold above which the speed will be reset to zero. Works for both the Nextion and Rotary Encoder direction change options.

    Unless there are bugs found, I'm going to give this project a bit of a break. I again thank Dave and Gregg for the superb platforms they've developed, and to Steve and Keith for their contributions as well. I've had an immense amount of fun over the last week or so, and will be continuing to 'play' with the code, first thing will be to re-visit Dave's original user interface and attempt in incorporate my changes whilst keeping his clean and neat style. I certainly am not abandoning 'my' version with the animated buttons, but rather developing an alternative model:)

    One of Dave's features I'm thinking of removing, is the binary display of function settings, instead I'll be using 'Illuminated' buttons to show function state.
    As always, all comments or suggestions are most welcome:)
    Cheers
    Norm
     

    Attached Files:

  18. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    Thanks so much normal. It was good work and a massive improvement in my opinion.

    Just a couple thoughts I think would be useful in the future

    1) A track power on and off button.

    2) a 3rd page with functions 10 through 20.

    I agree with removing the binary. It's good for troubleshooting but not much more honestly and takes real estate.

    Again thanks so much for you contributions. It's much appreciated.
     
    Scott Eric Catalano likes this.
  19. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Norm

    While I feel for your loss of the HAG, other than one grand child who yells “let’s make them crash!”, I’m not sure that any operating uncoupling scenario would include excessive speed.

    1. good idea but more difficult to code
    2. don’t agree due to the short length of uncoupler magnets and variable acc/dec rates in different locos
    3. wouldn’t this cause unwanted changes to the inactive loco?
    4. I agree.
    Enjoy your break … you’ve done some nice work here



    The illuminated button idea (in place of binary data) is a great addition. IMHO

    Steve F
     
    Scott Eric Catalano likes this.
  20. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Well Steve, I'm still at it:) Keith's suggestions were irresistible:..

    In response to your answers,
    1. give the latest build 4.2 a try. The instant reversal below a certain speed is already there, and the code is extremely simple. I compiled (the Arduino code) with a speed of 15, but adjust to suit your preference:)
    2. Also agree, but it was suggested in sympathy to the guys driving real trains:)
    3. I'd consider that would happen with buggy code:) For guys who are controlling only one train at a time, I guess there is no need to keep sending packets to the others when they're sitting doing nothing:). I'm considering the possibility of all three locos being on the go, heading somewhere. The operator would need to swap between locos at required intervals to make sure all were still going to plan. Functions are certainly not as important to refresh as speed and direction stuff.
    4.:)

    The user interface for the next bunch of changes is already nearly done - 'ON' and 'OFF' buttons for power in the top corners, and (currently) three selector buttons along the bottom for 3 function groups (1 to 8, 9 to 16, and 17 to 24. Each group includes the FL function and the C(lear) button. As I mentioned right in the beginning, I have some work to do understanding how the upper functions work, but a brief look at Gregg's code seems like he's done it all for me already:)

    I'll be back,
    Norm
     
    Scott Eric Catalano likes this.

Share This Page