LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to holding registers using Modbus TCP

Hi everybody.

 

I have a question regarding writing to holding registers using Modbus TCP. I am currently trying to make a VI that can control my SMA Sunny Island Inverter through Modbus TCP.

The reading of values from a holding register works fine with the inverter, but i have met problems when i try to write. Every time I try to write to holding register, Labview returns error 538183. I am kinda new to the program and not sure how to fix it.

 

Labview version: 17.0.1f1 on Windows 10

 

Regards

Jonas

Download All
0 Kudos
Message 1 of 4
(2,880 Views)

Did you see that the error message tells you "illegal data value"?  The value you wrote is not valid for the server.

 

You wrote to address 40151.  While device manuals will give holding registers an address starting with a 4, the real value you send should not have that prefix.  Also,  devices start their register addressing at 1 in the manuals, but in reality the Modbus protocol starts with register 0.

 

So for 40151, drop the 4.  Subtract 1.  Try writing to address 150.

 

It is the same situation when reading registers as well.  So I don't know how you managed to get it to read successfully like you say you did.  Unless you used some other piece of software that accepts the manual's 4xxxx1 addressing on its front panel, and does the conversion behind the scenes to the  0-based address without the prefix.

0 Kudos
Message 2 of 4
(2,827 Views)

Hi,

 

Thanks for your help, I have now solved the issue. The address was correct in my case. The issue lied within the number of registers sent with the Modbus. It had to be specified to only send two registers (of 16 bit each), because the address used U32 (32 bit). I have linked a picture which shows the working VI.

 

Best regards

Jonas

Download All
0 Kudos
Message 3 of 4
(2,795 Views)

Dear Jonas,

 

I am currently facing the same problem you did a year ago and want to kindly ask you to share the implemented VIs?

 

Kind regards,

Christopher

0 Kudos
Message 4 of 4
(2,085 Views)