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):

enter image description here

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?

enter image description here

I was hoping that the period would be the same (100ms)

1

There are 1 answers

3
Steve On BEST ANSWER

Answer

Your function-block is taking more than a single cycle to run.


Explanation

Depending on the application a function-block can take multiple cycles to complete, which is why they are often configured with:

  • bExecute: The function-block is activated on a rising edge at this input
  • bBusy: Indicates TRUE while the function-block is running

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).


Solution

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.