Skip to content

How to read several register Modbus TCP

edited June 2021 in PLCnext Engineer
Hi,
I am using Modbus TCP library and I must read several registers. This register are separeted, so they have different addresses, so I must read each register separated. When I read a register, I save its value into a variable. I do the same for each register. I can read one register succesfully, but when I try to read more than one, problems appear. the value which is stored into each variable is not the correct. For example, if i read two values, both variables where I store data are updated to the second value read (second register).
I have checked the modbus documentation I can read something of xNDR flag, but I am not very sure how I must use it.

Where could the problem be?

Best regards.

Comments

  • Hello seg_rolgar,

    please send me the following additional information:

    1. Used PLC and the FW
    2. PLCnext Engineer Version
    3. Used Modbus TCP library Version
    4. Are you using FB "Modbus TCP Sever" and FB "Modbus TCP Client" provided by the Modbus TCP Library?
    5. I assume you are using one instance of FB "Modbus TCP Server" and several instances of FB "Modbus TCP Client", is it possible to send me your application program or the screenshot in debug mode?

    Thanks & Best Regards
    Eduard
  • I have an external component as Modbus server and I am one instance of Modbus Client. Should I use one instance of Modbus Client for each Modbus register?
  • Eduard, this is the information requested:
    - AXC F2152 firmware 2021.03 LTS
    - PLCNext Engineer 2021.3
    - Modbus TCP_9
    - My PLC is the client in the Modbus TCP communication. I have different external components like Modbus servers and I need to access them in order to read ther registers. If I read just one, it works perfectly but I need to read more. I can't show here an screenshot, but basically I followed the example structured. I create an UDT-example instance, 1 instance of client, 1 instance of FC3 and 1 instance of FC16 (to write). When I use FC3, I try to read all registers needed.

    Thanks in advance

    Best regards,
  • Hello seg_rolgar,

    thanks for additional information! I have provided your request to the responsible support team and will give you feedback as soon as I have it.

    Best Regards
    Eduard
  • Hello seg_rolgar,
    to read different start register or to use several Querys there have to instance several FC FB . This have to be assigned by the MT_ ID number (1-10) see also documentation.

    Please see the attached Exampel, I think it will help you.

    Thanks & Best Regards
    Eduard
Sign In or Register to comment.