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
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
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
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
I have uploaded revised code for the Nextion throttle (version 10) to my web page http://www.trainelectronics.com/DCC_Arduino/Nextion_LCD/index.htm It includes the display code as HMI and TFT files Many thanks to Steve Lowry for help with the code revision..... dave
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
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
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
Steve - you may have an older version of the software - the latest one on the web page http://www.trainelectronics.com/DCC_Arduino/Nextion_LCD/index.htm is version 3.0 dated today - give that one a try. I just tested it and it remembers the proper speed from loco to loco - dave
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
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
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.
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.
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(); } } }
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();
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
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
Dave Nice project ...... you amaze me with the sophistication, not only of your coding but your instructional photos and project descriptions. Regards, Steve F