Skip to content

Modbus Client writes to PLC

Hello,

I am running Modbus TCP server on the PLC and have a Modbus client connected to it. Connection and reads work fine, however the client cannot write to the PLC.

Variable definition in PLCNext:

I have played with the port types but I was able to get the writes to work. Also checked OPC/HMI options and it does nothing.

Can someone please help me with this. I am not sure if I am missing here.

Comments

  • Is there any diagnostic available on the FB?

  • Martin,

    No Error code in the function block.

    Is there a working example for Modbus server that I can refer to? I Can try monitoring modbus traffic using Wireshark, but not sure if that could help resolve the issue.

  • edited August 2022

    Hello Teegala3;

    if you unzip the latest version of the Modbus TCP Library you will find a working example for the Modbus Server functionality.

    I hope this helps.

    Also as xAutoAck is always true you will mostlikely not see errors for long...

    With fast cycles the debug mode will not show the error code at all probably.

    To see the errors try logging the Diag registers and Error bits via the LogicAnalyser featuer.

    The connection state looks good however.

    Maybe have a look at the whole register array, maybe your client adds an offset to the write Address?

    Which registers are you writing to ?

    Make sure not to overwrite these registers in your application.

    kind regards,

    Oliver

  • Oliver, Thank you for pointing to the example. Example project works for modbus writes.

    For my application, there is an offset in the modbus client and the below are the registers i am trying to write to.

    Here is the screenshot from the client. I tried writing to all the registers but none of them work. The application does not write to these registers.

    Please let me know if you see anything wrong in the array definition.

    I have also added the Diag code to Logic analyzer but the data shows the status as 8000 and no other useful data is recorded.

    I will re-check my example and use the TCP server example to troubleshoot further. Thank you!

  • I think it's because you are using the array as an Output Port


  • Hello Teegala,

    I still think the issue is that you overwrite the incoming values in your IEC Application.

    Try writing to index 12 for example to see if that is possible.

    e.g.

    Client changes Index 10 to TRUE.

    Application runs and instantly overwrites the value with the contents of AInTE800 as FALSE


Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.