Hello, I am looking for some help with my code. My programming skills are basic.
I have a Controllino Mega and a Fatek HMI.
I am using the MgsModbus library from http://www.myarduinoprojects.com/modbus.html.
I am trying to read data from an HMI. I am declaring a boolean variable (dint), and initializing it as false, and added an “if” statement to start a routine when a button is pressed on the HMI.
On the code, I am doing: dint = Mb.GetBit(1); to read the data sent from the HMI, but, it doesn’t work.
If I manually change the boolean variable to “true”, the routine is executed. Any support with this code is welcome.
Is it a ModbusTCP server or client? In your code it should be a client but then it must know the details of your Arduino server and must actively push it's data to the Arduino. Does the HMI device really do that?
On the code, I am doing: dint = Mb.GetBit(1); to read the data sent from the HMI, but, it doesn't work.
You cannot read data from the HMI, it has to send it to the Arduino. If the HMI is configured as a server (in Modbus RTU terminology this is a slave), you must restructure your code accordingly (use the other example sketch).
Hello, thanks for your reply. This is the link of the HMI manual. http://fatekas.com/downloads/yuklemeler/FvDesigner_V1.5_Manual_EN.pdf
I modified the code, and it seems the Controllino is detecting the input. But when I first press 8, or 9, the digital input does not change to 1. I have to press 2, 3 or 7 and it changes to 1. Then I can press 8, and it changes to 0.
Instead of reading a 1 or a 0, how should I modify the code, to read the values 1,2, 3, 4, etc.
And, instead of input numbers from the HMI how can I read 1 or 0, from a switch button on the HMI.