Skip to content

Conversation

@ngu-niny
Copy link
Contributor

@ngu-niny ngu-niny commented Mar 22, 2023

Add code to get the real time cycle time and latency, the maximum/minimum/average values would be printed out in the logs as a summary at the end of the OpenPLC running. The following diagram describes the logic.

"|": Beginning of execution of the PLC code
"s": Start of execution of PLC code
"e": End of execution of PLC code

Therefore, the time interval between two "|" symbols is usually 20ms by default(defined in OpenPLC Editor program), while "timeof(e) - timeof(s)" represents the cycle time and "timeof(s) - timeof(|)" represents the latency after sleep.

|s____e_____|s___e____|s_____e______|_____________|

Also a new function RecordCycletimeLatency() was added which uses special_function[4] and special_function[5] to store the cycle time and latency in the running OpenPLC cycle, so in the webpage they can be displayed if necessary.

Thanks my colleagues Alexander Lougovski, Marcelo Tosatti and Wenkang Ji a lot for the initiating, ideas and help.

Add code to get the real time cycle time and latency. The following
diagram describes what does it do.

"|": Beginning of execution of the PLC code
"s": Start of execution of PLC code
"e": End of execution of PLC code

Therefore, the time interval between two "|" symbols is usually
20ms by default(defined in OpenPLC Editor program), while
"timeof(e) - timeof(s)" represents the cycle time and
"timeof(s) - timeof(|)" represents the latency after sleep.

|_s____e______|__s___e______|s_____e______|_____________|

Signed-off-by: Nini Gu <ngu@redhat.com>
@ngu-niny ngu-niny force-pushed the RT_CycleTime_Latency branch from 81abca9 to 80aad90 Compare March 22, 2023 08:54
@ngu-niny
Copy link
Contributor Author

The statistics for about 12 minutes in the OpenPLC runtime log is as follows:
###Summary: The maximum/minimum/average cycle time in microsecond is 149/14/18
###Summary: The maximum/minimum/average latency in microsecond is 26/5/7

The webpage display effect of cyclic time and latency is as follows:
OpenPLC_LatencyCycleTime 2023-03-21 17-13-12

@thiagoralves thiagoralves merged commit 9a2f14b into thiagoralves:master Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants