We are writing a Windows Service to read the data from PLC using Modbus TCP protocol at the polling interval of 1 sec through Socket programming in c#. Windows Service will receive random registers of the PLC to read the register values. Expected registers randomly such as 40150,40250,40270,40320.
From the above case how to create the Modbus TCP request header? We could found two possible ways:
- Using the function code 3, we can read the values of the registers on a specific range, for example from 40150 to 40320, in this way we can read these 40150,40250,40270,40320 register values.
- Another way is requesting these 40150,40250,40270,40320 registers one by one(this will cause performance problem).
Am I missing any point here? Is there any better way for reading registers randomly one or more?