DCC++ Hardware - Throttles

KE4NYV Jan 25, 2016

  1. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Good day, all - I have been working with a new, updated throttle for the last few weeks.
    It uses the Nextion color LCD display that is also a touchscreen. Thanks to Steve for alerting us to that display!

    Because all of the controls, except for the rotary encoder, are on the screen it is a much easier unit to use and is about 1/2 the size of the first wireless throttle that I built.

    The throttle's operation is very similar to my other throttles. Some of the highlights are:
    + operates from one 3.7 volt cell phone battery
    + the throttle senses how fast you are moving it and increases the speed proportionately
    + three locomotives can be operated - this could be increased
    + functions 1 through 9 are supported - more could be added
    + DCC addresses are stored in non-volatile memory

    FYI, the learning curve for the Nextion display was quite steep - it is not well documented and I spent hours & hours reading and experimenting to get it to do what it is capable of doing.
    I am very pleased with the end result and will continue to refine it. I hope to make a video showing a bit about setting up the Nextion display and the operation of the throttle. The good news is that I have the code working and setting the Nextion with my files is fairly easy.

    My notes and the Arduino code are on my web page here: http://www.trainelectronics.com/DCC_Arduino/Nextion_LCD/index.htm

    Please let me know what you think and if you have any suggestions.

    dave

    [​IMG]
     
    Michel Goyard, esfeld, HVT and 4 others like this.
  2. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Nice job Dave, well done,

    Agreed on the display learning curve, once you 'get it' though it's quite easy I think.
    I have high hopes for the device in general, shame Itead are reluctant to 'open source' their Editor. New developments are not coming fast enough in my
    opinion and for sure the community would run with it much faster if they did.

    I've not seen the library you referenced on Github before, good find.
    I gave up trying to make Itead's work properly for me. However I went away to develop some neat solutions of my own with regards to talking to the display.

    Off to study your code.

    Regards

    Steve.
     
    Scott Eric Catalano likes this.
  3. Atani

    Atani TrainBoard Member

    1,474
    1,781
    37
    @David Bodnar very nice work. I was just looking at your page as I ordered three 3.2" displays to play with. I was going to setup something similar to what you have here. The only difference was going to be to put the speed control into the touch screen side of it.

    One question though, is there a reason why you did not go with the Nextion official library? If it is only due to it supporting HardwareSerial there is a commit up on github that will enable SoftwareSerial.
     
    Scott Eric Catalano likes this.
  4. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    @ Atani,

    The official library, for me anyway, kept throwing errors at compile time. If you look at the repo, it is quite some time since the Itead team did
    anything with it. The whole support project seems under-resourced as borne out in the numerous threads on the official forum from disgruntled customers.

    On the plus side, once you get to grips with the basics, the device is reasonably easy to work with. And a tinkerers dream if you've got some time on your hands.

    I ended up devising my own 'comms' protocol which works just fine, and I'm sure the library Dave used is obviously doing the job.

    Steve.
     
    Scott Eric Catalano and Atani like this.
  5. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    I think you will like the capability of the Nextion displays - not a bad solution.

    I could have used the screen for the throttle but many folks like to have a physical throttle to hold onto so I opted for the rotary encoder.

    As for the library, the official one seemed to be buggy and I got everything I needed to work with the library that I linked to on my web page. Note that the commands I have used may or may not work with Nextion's official library.

    enjoy!
    dave
     
    Atani and Scott Eric Catalano like this.
  6. Atani

    Atani TrainBoard Member

    1,474
    1,781
    37
    Something I have not seen anywhere yet is a step-by-step guide on how to use the editor and upload the HMI file to the device. Can you share some steps on this? That is the main area that I am not sure on yet.

    I am going to give both a try once I have the displays in hand. The library you are using looks like it is a smaller library (not a bad thing!) and may be better in some ways. The official library seems a bit more object oriented in design and may be leading to some of the bugginess in the code. It also may not be being maintained or updated for new versions of the core libraries as well. I will post my results after I have time to tinker with it.
     
    Scott Eric Catalano likes this.
  7. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Nextion tip of the Day

    Instead of trying to parse out a button number from a rather long string received when using Send Component ID.
    Get just the data you need in a format you can work with by entering a print command in the user code pane as below.
    Don't check "Send Component ID"
    And that is all that will be sent over the serial line, easy to catch and easy to parse.
    Here F1 gets sent when you press a button called er.. F1.
    Changing button colours and loads of other stuff can be done at the same time too. No need to load instructions on the arduino.
    The Nextion processor is more that capable of doing those tasks.

    CaptureW.JPG

    Steve.
     
    Scott Eric Catalano and Atani like this.
  8. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Great tip, Steve - I am sure that there are dozens (hundreds?) of such things that are not well documented
    thanks
    dave
     
    Scott Eric Catalano likes this.
  9. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    I hope to make a short video that goes through the basics - I agree that such a thing is sorely needed.
    stay tuned!
    dave
     
    HVT, RossNZ, sboyer2 and 2 others like this.
  10. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    Same goes for Perl/Tk...I made my graphical GUI last year when DCC++ started taking off....can use it on windows and linux etc distros utilizing Perl
     
    sboyer2 likes this.
  11. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Nextion tip of the Day.

    Itead load some great example demo's to their displays at the factory. Your choice of display will determine which demo comes with the device.
    However all the current demo's are available for you to download.
    My 3.5inch Enhanced model came with this https://www.itead.cc/wiki/File:Enhanced_Nextion_3.5_Demo.zip
    If you open the HMI in their free Editor software you'll get an interesting example of a 4 digit PIN code entry screen and a change/store to EEPROM screen.
    Study the code then see how it works by compiling and then running in Debug mode. You don't need to buy a display to do this.
    For budding throttle developers this can give you some ideas of how to program (seems to be basic C code) say a Loco Address and store to the device EEPROM.
    Note EEPROM is only available on the Enhanced versions of these displays.
    So following on from yesterdays tip, you should start to grasp the concept that the display itself incorporates a powerful and user programmable processor, that can do
    a whole lot of stuff and thereby relieving the Arduino (or other mcu) free to complete the main tasks at hand.

    Steve.

    Capture1.JPG Capture2.JPG Capture3.JPG
     
    Last edited: Aug 28, 2016
    Scott Eric Catalano and Atani like this.
  12. esfeld

    esfeld TrainBoard Member

    443
    382
    17
    Well done Dave, as usual ....... just when I sensed a lack of activity on the board I come back from a weekend away and find this! ... Time to order the new LCD ... can't wait to get started.
    Just to double check ...... is the screen that you are using model: NX4024T032_011R
    Steve F
     
    Last edited: Aug 29, 2016
    Scott Eric Catalano likes this.
  13. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
  14. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Nextion tip of the Day.

    How to emulate radio buttons (because the new custom feature doesn't :()

    Open a new project in Nextion Editor

    Drag 3 Dual-State Buttons on to the screen area (you can do lots more if you're feeling adventurous)
    CaptureTip1.JPG
    Load a font to your project. Fill in some loco numbers in the text attribute for each button.

    Carefully copy this simple code into the touch press event user code pane. For each button adjust the IF statement if you have more
    buttons or want to change the font size etc.
    CaptureTip2.JPG
    CaptureTip3.JPG
    CaptureTip4.JPG

    Compile the project and then run it with the Debug feature.

    Clicking the buttons will change the new active button to yellow. And at the same time send a string for you
    to parse the changes back on your remote mcu. Simples.

    Steve.
     
    esfeld and Scott Eric Catalano like this.
  15. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    just thought I would pop in with my idea. feel free to shoot it down. ;)

    I was looking at a RC transmitter tray harness a bit ago, and I thought it would be a great platform for a walk-around controller.
    http://www.ebay.com/itm/SECRAFT-RC-...-DJI-Inspire1-Neck-strap-Double-/152210118225
    this would allow a larger control surface, and still let you wander around.

    I agree that it may be too big for regular operations, but I thought I would toss out the idea just the same.
    BTW, Dave, love your idea. I just thought I would propose my own. even if I am the only person that uses the idea. :)

    ~Travis
     
    Scott Eric Catalano likes this.
  16. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Travis - it might be cool for an outdoor garden railroad layout - for HO and such I would surely opt for something smaller. The latest version I am working on is about 1.5 x the size of a pack of cigarettes - easier to get in your pocket!

    dave
     
    Scott Eric Catalano likes this.
  17. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    I was thinking more of the hands-free approach. no need to worry where you last set down the controls. I guess I can see where the size might be daunting though.

    ~Travis
     
    Scott Eric Catalano likes this.
  18. esfeld

    esfeld TrainBoard Member

    443
    382
    17
    Hi Dave ..... how about a quick picture of the back of the new throttle ...... always helps to see how you laid out the components. Thanks
    Steve F
     
    Scott Eric Catalano likes this.
  19. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Funny you should ask about that, Steve - I am working on a 2nd unit and have been taking photos - I added two to the bottom of my web page, here:

    http://www.trainelectronics.com/DCC_Arduino/Nextion_LCD/index.htm

    You will note that I am not using any additional circuit board and have attached everything directly to the Pro Mini. The unit is also working on a single cell phone battery (the black object a bit left of center in the photo). To keep things as compact as possible I used right angle pins on the Arduino to bring the connectors out the side and I soldered directly to the Nextion display and to the HC-12.

    Hope that helps.

    I also plan on working on the software some today so that will change, as well.

    dave
    [​IMG]
     
    Scott Eric Catalano likes this.
  20. esfeld

    esfeld TrainBoard Member

    443
    382
    17
    Thanks, since there are so few connections to the pro mini I was planning on the same no-circuit board ...... that's why I inquired. BTW I have found that using foamboard spacers between a top and bottom plexi makes for a lighter yet strong throttle. Away for the weekend .... will await the new software.
    Steve F
     
    Scott Eric Catalano likes this.

Share This Page