I create a program to obtain data through Modbus-TCP server (192.168.2.16) on TwinCAT3 to obtain data from other PC (slave: 192.168.2.20):
Also I create and configure the modbus server task with 100ms. enter image description here
However, I noted in wireshark that the period of request is around 200ms and not 100ms. Why the period is 200ms?
I was hoping that the period would be the same (100ms)
Your function-block is taking more than a single cycle to run.
Depending on the application a function-block can take multiple cycles to complete, which is why they are often configured with:
In your case I believe that you will be seeing a single cycle of bBusy being high after you have set bExecute to TRUE. This is often the case when a function-block needs to communicate with some external object (like a network device).
The recommended solution to your timing problem is to reduce your cycle time (5/10ms should do), and then set 'bExecute' on your desired cycle time. This allows the function-block to run for several cycles and return its data before starting a new request.