Go Down

Topic: help for display Nextion + Arduino (Read 607 times) previous topic - next topic

Lanfra

Hello,
I tried to ask on the forum in Italian but I didn't have any big help. I am a novice with Arduino but I have already created several unpublished projects (iz3zlu.weebly.com), but since my knowledge is rather scarce I stopped myself on a problem.
I built a controller for antenna rotor with Nextion '7 display. Everything works but I would like to implement with a numeric keypad where to write the degrees and sending send the antenna up to that point. Hogià created the numerical testatore and already sends the number of degrees .... but now I do not know what to write on Arduino to make it work. If someone could write me a simple sketch it would make me a great gift. I apologize for Google's English.
I enclose a photo of the message sent by the display.
Thanks a lot.
Lan

Seithan

Hello Lanfra,
I have already wrote an example for another user in this forum.
It is similar to the one you want and you can find it here:

How to send values and store them on Arduino.  

To send the degree value to Arduino (or as you name it "message to send"), you must send it over serial port with a print command (< print > , < printh >, or < prints >).

So when you press the button to send the command from the keyboard, you must send the print command followed by the degrees.

You can send (attach) in a zip file the .HMI file from your Nextion project in this topic and I will try to adapt it to your needs.  :) 

Also, please tell me the minimum and maximum value of the degrees.
UBUNTU:
"I am what I am, because of who we all are", compassion, kindness and humanity that connect us together by sharing  ourselves with others and caring for those around us.

Lanfra

#2
Oct 19, 2019, 06:21 pm Last Edit: Oct 19, 2019, 06:36 pm by Lanfra
Dear Seithan,
I thank you and I attach the HMI file with Wetransfer and the sketch of my project ... Thank you so much.


Wetransfer file HMI
https://wetransfer.com/downloads/45f9a647b991610d4866e8dc10151b0820191019163311/c194fd25ca6c13a0eff23fb71b4af5c220191019163311/6d6ad4

Lanfra

#3
Oct 19, 2019, 06:39 pm Last Edit: Oct 19, 2019, 07:06 pm by Lanfra
The minimum value is 0°, the maximum value is 450° (360° + overlap 90°).

Dear Seithan,
If you were kind enough to explain to me how to enter the direction of rotation to choose based on the distance ...
Arduino commands a shield of relays through two pins, if you were so kind as to make me understand how to write that if the selected degrees are greater than the current ones, digitalWrite (2, HIGH); , instead if the selected grades are smaller than the current ones, digitalWrite (3, HIGH); .
When the selected grades are the same as the current ones then STOP.
You can see a video of my controller on https://www.youtube.com/watch?v=JVZOkg2VBbw and into my website iz3zlu.weebly.com
Many thanks again.
Lan

Seithan

Dear Lanfra,

Because your project is built using a Nextion library, we can't do as many things as we tought.

In your case, There is no need to make many changes to the Arduino code. You can do it from Nextion.

I added two buttons for CW and CCW at  page2  . You can even make them visible or invisible with the < vis > command.

Also, I added a hotspot with some code that runs when you press the "GO TO" button.

Code: [Select]
covx t0.txt,n1.val,0,0
while(n1.val<n0.val)
{
  click b55,1
  doevents
}
while(n1.val>n0.val)
{
  click b50,1
  doevents
}


At the "GO TO" button, I changed the code a little:

Code: [Select]
//print t0.txt
if(t0.txt!="")
{
  t0.txt="INV"
}
click m0,1


A numeric component n1 was added to store the converted numeric value of the t0 .

Because I do not have the hardware needed, I can't test it.
Check if this version matches your needs and let me know. :)

The modified files:
The .HMI file

UBUNTU:
"I am what I am, because of who we all are", compassion, kindness and humanity that connect us together by sharing  ourselves with others and caring for those around us.

Lanfra

Many thanks Seithan, but I have a problem opening the .HMI file.
Tells me:
"Wrong resource file or resource file has been damaged"

Thanks for your patience.

Lanfra

Seithan

just on time i have make chance to .HMI try the new version
@Lanfra because i don't like the <while> command (can cause stack in the while loop)
I make a new version of the HMI with a timer in place of the hot spot and with <if> statement inside.

Code: [Select]
t0.txt=""
if(n1.val<451)
{
if(n1.val<n0.val)
{
  click b55,1
  //n0.val=n0.val-1 //debug
}
if(n1.val>n0.val)
{
  click b50,1
  //n0.val=n0.val+1 //debug
}
if(n1.val==n0.val)
{
  click b55,0
  click b50,0
  tm0.en=0
}
}
else
{
tm0.en=0
}


here is the new .HMI
Version 2 of .HMI
UBUNTU:
"I am what I am, because of who we all are", compassion, kindness and humanity that connect us together by sharing  ourselves with others and caring for those around us.

Lanfra

You really are a Great Seithan ... thanks for the time you dedicate to me.
Unfortunately I can't open your file with Nextion Editor. See error message.

Seithan

You really are a Great Seithan ... thanks for the time you dedicate to me.
Unfortunately I can't open your file with Nextion Editor. See error message.
try to update the Editor to 0.58

https://nextion.tech/nextion-editor-ver-0-58/#_section1


or happens to me many times, i forgot to unzip the files (try extract)
UBUNTU:
"I am what I am, because of who we all are", compassion, kindness and humanity that connect us together by sharing  ourselves with others and caring for those around us.

Lanfra

YEAAAAH!!! With the new editor the file works fine.....now I begin to study seriously. I'll let you know. Meanwhile, thank you again.
Lanfra

Lanfra

Update.
If I touch the two buttons you created (CW and CCW) the two arduino pins go high (perfect !!) ... But when the software touches the buttons for me, you see the button change color but the Arduino pins don't they go high.
Then I didn't understand if the STOP button (b16) should block the rotation ... if this is his job, he doesn't.
Last thing ... if you exceed the typed degrees I see that the other button is also activated ... I think this causes a problem. for now I'm using two LEDs.
However you did a wonderful job, if you want to correct it when you can. Thank you so much.

Seithan

Here is the link for the fixed .HMI
.HMI file version 3

remember that you can Hide the button's and the n1 componet that i make to page 2 by uncomment (delete the //) from vis command
Code: [Select]

//vis n1,0
//vis b50,0
//vis b55,0


to the Preinitialize Event of page 2
I believe that there not any other bugs  :)

Fill free to ask again
UBUNTU:
"I am what I am, because of who we all are", compassion, kindness and humanity that connect us together by sharing  ourselves with others and caring for those around us.

Lanfra

#12
Oct 21, 2019, 07:21 am Last Edit: Oct 21, 2019, 01:50 pm by Lanfra
HI Seithan,
Now the CW works perfectly, but the CCW button set by numeric keypad does not activate .... it is activated in debugging of Nextion editor but not in reality. An error in the Arduino sketch?
I apologize and thank you very much for this help. I wanted to implement something and I don't have the appropriate knowledge. My knowledge of Arduino and Nextion stops where I came from alone. I had been asking for help for months and you are the only person who was kind enough to do it.

I installed the sketch and the .HMI file in the controller to test if it works. Unfortunately, if the degree counter moves quickly, sometimes it skips a few numbers, so if you set a number of degrees and skip the one where it should stop, the rotor continues to turn until you touch the stop button. Could it be written that the end point has a range of a few degrees so that if the exact number is exceeded it stops on the next one or a few degrees later?

When you have time and desire ... I don't want to bother you
Lanfra

Seithan

Thank you Lanfra for your kind words. I really appreciate your kindness.

Do not blame the people that did not help all this time, because they may not have the knowledge or the time to work with something new.

The problem is that I don't have the controller to test the code. It is like writing code in the blind.


I have set the delay in the timer to 400 milliseconds before the timer runs the code again. This means that the value of the current degrees is checked every 400 milliseconds. You can change that by clicking on < tm0 > component and changing the < tim > value at the right side of the screen (Attributes) and adjust it at a value that can catch up the speed of the rotation.

To see if the CCW problem is caused by the sketch, press the button manually with your finger. If Arduino responds, then the sketch is ok.

Due to the code being based on a Nextion Library, the code is not as efficient as it should be and it limits us a lot.

Could you send the schematics and what type of hardware you are using?

Feel free to ask again and freely add a Karma :)

Thanks a lot.
UBUNTU:
"I am what I am, because of who we all are", compassion, kindness and humanity that connect us together by sharing  ourselves with others and caring for those around us.

Lanfra

Thanks Seithan,
I have attached a drawing of the hardware.
I didn't want to be argumentative saying that for many months I had been asking for help on the forum ... but the fact that after a few hours from my request on the international forum, I received an answer, while on the Italian forum I had little help (not just for this project, but for others), it makes me feel bad. Unfortunately I don't know English and I use Google translator and this is a big problem.
My projects are open source (ham spirit) but I get angry if I can't do something ... I feel stupid.

and then I'm not a kid ... I'm 58 and I'm really struggling  :)  : Smiley-confuse:


I don't know how to write a sketch that makes Arduino work instead of the Nextion library. I understand how it should be theoretically but I can't write it.



For karma .... I've added 3 these days  :)

Ciao Lanfra



Go Up