您可以使用Tc2_Utilities具有功能块的免费 TwinCAT 库Profiler。
“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)