I've built a pendant for my CNC using an R4 Minima to work with Mach 4, a CNC software controller. The display I'm using is an Elegoo 2.8" Touch Screen. For the most part, it works, but only for a few minutes.
The Touch interface sends keyboard keys to through USB to be used by Mach 4. After plugging in, I can use the pendant for just a few minutes. At some point, the touch screen 'freezes' up and it will not accept any touch input, nor does the rotary encoder send input to the computer.
I've had issues when compiling and uploading, where I get these errors:
Failed to retrieve language identifiers
Failed to retrieve language identifiers
error get_status: LIBUSB_ERROR_TIMEOUT
Failed uploading: uploading error: exit status 74
After the 'freeze' occurs, I'm often unable to connect the pendant on my PC to troubleshoot, as it no longer finds the COM port. I instead get a DFU 1-3 port, which doesn't connect. Resetting the Uno gets me connected again.
While resetting the Uno addresses the issue, my guess is that the code I've written is causing the issue. Since I'm reasonably new to programming, I've used Cursor AI to help write the code.
From other topics, I see that a high volume of serial output could be an issue, but I'm unsure how to determine that is the problem. My code is attached. Any guidance on the code or approach would be greatly appreciated.
Pendantv3.ino (17.9 KB)
