TwinCAT - 如何测量程序执行时间?

Pip*_*per 4 plc twincat

我想测量结构化文本(ST)程序的执行时间。与程序关联的任务运行时间为 10 毫秒。

如何衡量执行时间?

Qui*_*rzo 5

您可以使用Tc2_Utilities具有功能块的免费 TwinCAT 库Profiler

https://infosys.beckhoff.com/english.php?content=../content/1033/tcplclib_tc2_utilities/35053195.html&id=1344160655692967299

“Profiler”功能块可用于测量 PLC 代码的执行时间。

Infosys 页面也有一个示例代码:

VAR
    Profiler1     : PROFILER;
END_VAR


Profiler1(START := TRUE, RESET := TRUE);

//Do something here

Profiler1(START := FALSE);
//Now Profiler1.Data has the execution time
Run Code Online (Sandbox Code Playgroud)