Latency/Delay Issues: Profinet IRT Gateway and RevPi Core S
Posted: 09 Feb 2023, 13:07
Hi,
I am using a RevPi Core S and the Profinet IRT gateway. My setup is as follows (see complete source code below):
Sending out a byte from the Revpi and waiting for the response from the Profinet IO controller takes (on average) 48 ms.
I am wondering if this is the minimum delay which can be achieved using the setup with the Profinet IRT gateway and the RevPi Core S?
Or should the delay be much smaller and I am missing something in my setup?
By the way: According to wireshark, most of the time is lost from the gateway input to the gateway output (i.e. the response from Codesys is pretty fast).
Thank you very much for any support
Florian
The (complete) MWE code is:
I am using a RevPi Core S and the Profinet IRT gateway. My setup is as follows (see complete source code below):
- Profinet IO Controller:
- Codesys Control Win V3 running on my PC.
- Increase Output1 (which corresponds to Input__1 of the Profinet IRT gateway) every 1 s.
- Output2 mirrors Input1. I.e. the IO controller sends back values from the gateway Output__1 to the gateway Input__2.
- RevPi:
- The revpimodio2 mainloop() is running (cycletime = 5 ms) and reacting to Input__1 and Input__2.
- As soon as Input__1 changes, the start time (performance_counter) is stored and the incoming value is sent back to Output__1.
- When the response from the IO controller arrives at Input__2, the time measurement is stopped.
Sending out a byte from the Revpi and waiting for the response from the Profinet IO controller takes (on average) 48 ms.
I am wondering if this is the minimum delay which can be achieved using the setup with the Profinet IRT gateway and the RevPi Core S?
Or should the delay be much smaller and I am missing something in my setup?
By the way: According to wireshark, most of the time is lost from the gateway input to the gateway output (i.e. the response from Codesys is pretty fast).
Thank you very much for any support
Florian
The (complete) MWE code is:
- Profinet IO Controller (Codesys Control Win V3, cycle time 1 ms, priority 1):
Code: Select all
// note: controller outputs correspond to gateway inputs and vice versa PROGRAM latency_test VAR Timer: TON; Output1 AT %QB0: BYTE := 0; Output2 AT %QB1: BYTE := 0; Input1 AT %IB4: BYTE := 0; END_VAR Output2 := Input1; // mirror input Timer(IN:=TRUE, PT:=T#1000MS); IF NOT(Timer.Q) THEN RETURN; END_IF Timer(IN:=FALSE); // every 1000 ms DO: output1 := output1+1;
- Python code running on RevPi:
Code: Select all
import revpimodio2, time global start_timer_ns, end_timer_ns start_timer_ns = {} end_timer_ns = {} def inputCallback(ioname, iovalue): if ioname == 'Input__1': start_timer_ns[iovalue] = time.perf_counter_ns() # store start time rpi.io.Output__1.value = iovalue # set Output__1 elif ioname == 'Input__2' and iovalue in start_timer_ns: end_timer_ns[iovalue] = time.perf_counter_ns() # stop time measurement duration = (end_timer_ns[iovalue] - start_timer_ns[iovalue])/1000000.0 print('duration: ' + str(duration)) rpi = revpimodio2.RevPiModIO(autorefresh=True, debug=False, shared_procimg=False) rpi.cycletime = 5 # register input variables for callback rpi.io.Input__1.reg_event(inputCallback) rpi.io.Input__2.reg_event(inputCallback) # start main loop rpi.mainloop(blocking=False)