DCC++ Hardware - Throttles

KE4NYV Jan 25, 2016

  1. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Gents - the software serial does go to 4 AND 5 - the HC-12 goes to the hardware serial (rx/tx) - the encoder has to go to pins 1 and 2 as it uses interrupts that are only available on those two pins
    dave
     
    Scott Eric Catalano likes this.
  2. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Steve
    Good catch!!! I compared the two codes but only looked at the comments (my sloppiness) ...... that was the problem. Once again, I owe you a pint.
    Steve F
     
    Scott Eric Catalano likes this.
  3. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Sorry about that, Steve - don't pay too much attention to comments - stick with the code! Please keep in mind that this is VERY much a work in progress!
    dave
     
    Scott Eric Catalano likes this.
  4. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Dave I fully understand .... you are doing a dynamite job!
    Steve F
     
    Scott Eric Catalano likes this.
  5. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    I have done the same thing many times. change the code, but forget to, or not have time enough to update the comments, or even add any. no big deal on code under construction, but it is a hassle to fix it all when the code is complete.

    Keep up the good work Dave. even though I can't afford a Nextion display right now, I am still following the design process. I will likely use the same or similar display when I build my walk-around.

    ~Travis
     
    Scott Eric Catalano and esfeld like this.
  6. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
  7. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Dave/Steve
    Finally got an encoder hooked up to the controller ........ curious, changing locos does not zero out speed, but maintains the speed setting for each new loco ... is this by design? I would think not..... also is there a way to possibly code a button to zero speed without resorting to winding the encoder to zero?
    Steve F
     
    Scott Eric Catalano likes this.
  8. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Steve - if you using the software version that is on the web page now (Version 2-10) it should maintain the speed for each loco as you move from one to another.

    Yes, we could add a button (either a physical button or a spot on the screen) to zero one or all locos.

    Did you note that the speed displayed goes up or down slowly if you turn the knob slowly and more rapidly if you turn it faster?

    dave
     
    Scott Eric Catalano likes this.
  9. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Dave
    What I meant was that the speed stays constant as you change locos ie:if loco 1 is at 23 and I change to loco 2 it is at 23 as is loco 3 .... I can understand holding speed for each individual loco to it's last entered speed but the speed is holding the last speed set, for each loco. A software button to zero speed (for the active loco only) would be great. Yes saw the incremental speed increase, love it.
    Steve F
     
    Last edited: Sep 6, 2016
    Scott Eric Catalano likes this.
  10. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    HVT, esfeld and Scott Eric Catalano like this.
  11. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    Actually....changing locos should keep the other at the same speed it was left at....just like a digitrax controller you can toggle back and forth to each loco and it will not zero out...which it was designed to do...same thing with MRC, NCE etc
     
  12. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Dave, will do, in the AM ... I was using the older version. Thank you.
    Steve
    Couldn't wait till AM ...... tried ver 3 ... same problem:set speed for loco 1 ...... loco 2 and loco 3 show the same speed as loco 1 ..... change loco 3 speed and all three reflect that speed
    Steve
     
    Last edited: Sep 6, 2016
    Scott Eric Catalano likes this.
  13. esfeld

    esfeld TrainBoard Member

    442
    382
    17
  14. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Steve,

    Not my experience, works as it should for me, however there is every possibility I've made edits to make it work as it should.
    Have been working with Dave on several bug fixes.

    I'll look it over in the AM, ways too late over here right now.

    Steve.
     
    Scott Eric Catalano likes this.
  15. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Steve F

    Can you please post me a full copy of this function,

    Code:
    void getActiveAddress() {
      message = myNextion.listen(); //check for message
      if (message != "") {
    I.E the one that is in your latest edition of the code.
    This is where the Speed settings are meant to be switched between throttles.

    I can make the necessary changes for you, if that is where the problem is.

    Steve.
     
    Scott Eric Catalano likes this.
  16. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Steve ..... here is the function from my copy of ver 3:
    void getActiveAddress() {
    message = myNextion.listen(); //check for message
    if (message != "") {
    char mostSignificantDigit = message.charAt(5);// for function numbers
    String myString;
    myString = mostSignificantDigit;
    FNbutton = myString.toInt();
    FNbutton = FNbutton - 1;
    if (FNbutton == -1) {
    if (myString == "a") FNbutton = 9;
    if (myString == "b") FNbutton = 0;
    }
    if (FNbutton >= 0 && FNbutton <= 9) doFunction();
    if (message.startsWith("65 2 e")) { // move to page 1
    getLocoAddress(); // get new DCC address #
    }
    if (message.startsWith("l1")) { // DCC1 button page 2
    Serial.println("one"); //Selected DCC address #1 on page 2
    encoderPos=LocoSpeed[0];
    updateDCC1();
    }
    if (message.startsWith("l2")) { // DCC1 button page 2
    Serial.println("two");//Selected DCC address #2 on page 2
    encoderPos=LocoSpeed[1];
    updateDCC2();
    }
    if (message.startsWith("l3")) { // DCC1 button page 2
    Serial.println("three");//Selected DCC address #3 on page 2
    encoderPos=LocoSpeed[2];
    updateDCC3();
    }
    }
    }
     
    Scott Eric Catalano likes this.
  17. UK Steve

    UK Steve TrainBoard Member

    453
    683
    12
    Steve,

    Looking through that code, everything seems to be in order.

    Can't see why it does't work for you.

    Unfortunately Dave has taken down the latest code on his site. We'll have to wait for his input I'm affraid.

    Update: I've traced the problem. The HMI does not match that code.

    Code:
    if (message.startsWith("l1")) { // DCC1 button page 2<----------------This line detects the key touch event
      Serial.println("one"); //Selected DCC address #1 on page 2
      encoderPos=LocoSpeed[0];<--------------------------------------------------------Here encoderPos is set accordingly to whatever is stored in the LocoSpeed variable
      updateDCC1();
      }
      if (message.startsWith("l2")) { // DCC1 button page 2
      Serial.println("two");//Selected DCC address #2 on page 2
      encoderPos=LocoSpeed[1];
      updateDCC2();
      }
      if (message.startsWith("l3")) { // DCC1 button page 2
      Serial.println("three");//Selected DCC address #3 on page 2
      encoderPos=LocoSpeed[2];
      updateDCC3();
      }
    Alter the if (message. startsWith) entries to what I've posed below

    Code:
    if (message.startsWith("65 2 15")) { // DCC1 button page 2<----------------This line detects the key touch event
      Serial.println("one"); //Selected DCC address #1 on page 2
      encoderPos=LocoSpeed[0];<--------------------------------------------------------Here encoderPos is set accordingly to whatever is stored in the LocoSpeed variable
      updateDCC1();
      }
      if (message.startsWith("65 2 16")) { // DCC1 button page 2
      Serial.println("two");//Selected DCC address #2 on page 2
      encoderPos=LocoSpeed[1];
      updateDCC2();
      }
      if (message.startsWith("65 2 17")) { // DCC1 button page 2
      Serial.println("three");//Selected DCC address #3 on page 2
      encoderPos=LocoSpeed[2];
      updateDCC3();
     
    Last edited: Sep 7, 2016
    Scott Eric Catalano likes this.
  18. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Steve
    Had to "slash" out one comment line but that works ..... thank you. I don't know if you saw my suggestion to Dave about a software button to zero the speed of the selected loco (not all of them) but I would love to see that added to the HMI and code. I'll be gone most of the day today ..... glad we got this worked out. Again, thank you, thank you.
    Steve F
     
    Scott Eric Catalano likes this.
  19. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Gents - I hope to have time to get back to the code revisions later today or tomorrow - I have been otherwise distracted (see:
    http://www.trainelectronics.com/Animation-thunder-lightning/ )

    I need to test Steve's revisions and add the STOP button -- the good news is I may have an easy way to implement that.

    Stay tuned

    dave
     
    Scott Eric Catalano likes this.
  20. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Dave
    Nice project ...... you amaze me with the sophistication, not only of your coding but your instructional photos and project descriptions.
    Regards, Steve F
     
    Scott Eric Catalano likes this.

Share This Page