Start a new topic

Arduino main loop slows down and inputs are blocked

Hello guys,

 


I use the Nextion Display (enhanced) together with an Arduino MEGA 2560 for the control of a test bench on which electric motors are tested continuously. Here I use the display for all necessary inputs and outputs. Through weeks of intense intensive testing, I could already create a good HMI. However, there are still problems for which I am looking for better solutions.

 


Problem 1: The Arduino does not accept any input from the display, for example when text fields of the display are updated with too high a rate.

 

Apparently the UART interface is blocked ... I have solved the problem in that I have written with a timer interrupt a function, which ensures that the display fields are updated only every 700 ms. Within this 700 ms all inputs "almost" are always registered by the Arduino. Are there any better solutions for this?
 


Problem 2: Updating 9 text fields at once (for example) is done cleanly, but this results in a considerable dead time in the main loop, although the commands have already been transferred to the display. If 4 commands are sent to the display, this problem does not exist.

 

It is of crucial importance for continuous control that the digital controller does not have any dead times. I checked with an oscilloscope the program parts, in which I have run times with an output pin of the Arduino have looked. I was able to find the above problem. There seems to be something in the main loop when too much is sent to the display at once. If I remove the update of the display fields from the function, then no dead times arise.I hope you can follow the problem.

 

The baud rate is set to 115200 and the program code has no delays. Thank you in advance!


without see your exact code, nothing to tell ...


upload your HMI and INO ...

Basic TTL Serial

  - byte sent/received is 10 bits at width of 1/baud seconds. 

  - what is sent/received can not be more than size of buffer

With this all the math for flow control is available.


Prioritizing "no dead time" perhaps is not allowing all in synchronization and concert.

Basic debugging - find bottlenecks and optimize


700ms @115200 baud  = 11520*70% = 8064 ~92% for error rate at higher speeds

~7418 bytes in 700ms.

Arduino Mega will not have such a buffer that size

Nextion will not have a buffer that size


I disagree with your conclusions.


Install a loop() counter - loop should run minimally 100,000 on Mega

Variable update should be less than 25ms in worst case

  - and if so, make less chatty

If default buffer handlers are insufficient make your own.


But can not really see what your cause is without code and HMI

Login or Signup to post a comment