Page 1 of 1

RevPiModIO: RuntimeWarning: cycle time of 20 ms exceeded

Posted: 07 Feb 2022, 13:54
by saardrimer
Hello all

On one of our two CONNECT+ systems (with MIO and DO modules connected) we occasionally get the following warning from revpimodio2:

Code: Select all

/usr/lib/python3/dist-packages/revpimodio2/helper.py:617: RuntimeWarning: cycle time of 20 ms exceeded - can not hold cycle time!
  RuntimeWarning

I'd like to investigate why this happens -- and why on only one of the systems -- but I'm not sure what the warning actually means. In plain English, does it mean something like:
I'm warning you that it took me longer than 20ms to perform the IO refresh cycle
or
I'm warning you because I'm supposed to refresh the IOs every 20ms, but it took longer than that between my invocations
or something else?

Any suggestions for where to look, what to do to debug, etc. would be welcome.

This is how I instantiate RevPiModIO:

Code: Select all

import revpimodio2
revpi_io = revpimodio2.RevPiModIO(autorefresh=True)

Re: RevPiModIO: RuntimeWarning: cycle time of 20 ms exceeded

Posted: 11 Mar 2022, 15:17
by RevPiModIO
Hi saardrimer!

Your cycle loop function takes to long to execute - Maybe because of a .sleep or .wait or things like that. If you are using the cyclelooop, the cycle function must return in the given cycle time.

Do you have a code example you are using?

Re: RevPiModIO: RuntimeWarning: cycle time of 20 ms exceeded

Posted: 24 Mar 2022, 13:56
by saardrimer
RevPiModIO wrote: 11 Mar 2022, 15:17 Hi saardrimer!

Your cycle loop function takes to long to execute - Maybe because of a .sleep or .wait or things like that. If you are using the cyclelooop, the cycle function must return in the given cycle time.

Do you have a code example you are using?
Thanks for the clarification! I was careful to code in such a way that there are no idle sleeps. And, curiously, it only happens in one of the systems. I have since re-written some of the code and will see if the issue persists.