I have a setup that controls the rotation of two stepper motor using Arduino UNO, HBS860H stepper drivers, 4X4 keypad and LCD screen. I have replaced the Arduino Uno by a Controllino Mega and it works good. Now I am trying to replace the Keypad and LCD screen by a FATEK HMI PN2043NK. I have the sketch for the Controllino, I can use RS485 to communicate both devices. I use FV Designer to program the HMI, but I don't understand how to run the sketch from the HMI. I need some help with a simple example Please, any help I could use to start learning to communicate the HMI with the Controllino and run the steppers will be welcome.
The usual "sketch" is "always" running on your arduino (Controllino) unless it is put into a non-run mode (like when loading a program) or doesn't have power. What you need in your sketch is to do something IF a command is received on the serial (RS485). Rather than simply running the command you want, the sketch needs to check the serial and only execute the command if the HMI sent the correct signal.
For motor control, you could use G-code where your HMI sends G-code move commands over RS485 and your Controllino executes them. A handy RS232 example is grbl.