Topic Author
Posts: 13
Joined: 21 Nov 2022, 13:56

Latency/Delay Issues: Profinet IRT Gateway and RevPi Core S

09 Feb 2023, 13:07


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


The (complete) MWE code is:
  • Profinet IO Controller (Codesys Control Win V3, cycle time 1 ms, priority 1):
    // note: controller outputs correspond to gateway inputs and vice versa
    PROGRAM latency_test
    	Timer: TON;	
    	Output1 AT %QB0: BYTE := 0;
    	Output2 AT %QB1: BYTE := 0;
    	Input1 AT %IB4: BYTE := 0;
    Output2 := Input1; // mirror input
    Timer(IN:=TRUE, PT:=T#1000MS);
    IF NOT(Timer.Q) THEN
    // every 1000 ms DO:
    output1 := output1+1;

  • Python code running on RevPi:
    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
    # start main loop
Posts: 72
Joined: 09 Mar 2022, 13:08

Re: Latency/Delay Issues: Profinet IRT Gateway and RevPi Core S

02 Mar 2023, 08:47

Hy flk,

Have a look at the following forum post. A similar question was answered there.
RevolutionPi Hardware FAQ | Advantages of using the Profinet IRT Gateway - Revolution Pi Forum

Best regards
Giuseppe Pagano

Who is online

Users browsing this forum: No registered users and 0 guests