
phoenixsmartphonerepair (Customer) asked a question.
Reading values from Holding Register on P1AM PLC and EA3-S3ML HMI. to print them on the Serial monitor of the PLC P1AM -100.
I am currently trying to read values from the holding register using the holdingRegisterRead function. I would like to be able to enter values into the numeric entry on the EA3-S3ML HMI then read them on the Serial Monitor on the P1AM side. So far all I have been able to see in the Serial Monitor is a -1 despite declaring the variable as either a "int" and uint16_t. The two addresses I am trying to read from are on 40002 and 40003 on the C-more side. I will post the code so you are able to see what I have done so far. Thank you
Lines 68 + 69
The holding register addresses you are trying to read do not appear to be correct to what your c-more is setup and what you have configured on line 52. I think you accidentally put a 0 at the end is my guess.
You're getting a -1 on your prints.
If you look at the modbus library.
https://www.arduino.cc/reference/en/libraries/arduinomodbus/modbusserver.holdingregisterread/
-1 represents a failure for the return value.
Sorry that is bad wording on my part.
The address you passed in is 0x20 and 0x30. I think you meant to put in 0x2 and 0x3 if those are the correct modbus addresses on the c-more panel.
I referenced the configuration because you only assigned 16 addresses starting at 0x0. So you were also trying to read a address out of the range of what you configured.
so should it be 32?
No, fix lines 68+69 addresses.
Example:
C-More --> ON TIME1: 40003
P1AM-100 --> line 68 --> 0x2 NOT: 0x20
ok I erased on of the 0s on the C-more side. and the address is consistent with that you recommended and I am getting 0s on the serial monitor when I enter a number.