INT
环形计数器100ms
数据寄存器充当环形计数器。寄存器值每100ms增加一(计数范围:0–32767和-32768–0)。 比较两个不同时间(v1和v2)的寄存器值(v)以确定经过时间(t): t = (v2-v1) x 100ms.
if (NOT bIsInitialized) then
bIsInitialized:=TRUE;
iRingCounter_Old:=sys_iRingCounter_100us;
iScans:=1;
else
iRingCounter_New:=sys_iRingCounter_100us;
iRingCounterDiff:=iRingCounter_New-iRingCounter_Old;
if (iRingCounterDiff>0) then (* Important to work also for shorter scan times *)
diScanTime_µs:=(INT_TO_DINT(iRingCounterDiff)*10000)/INT_TO_DINT(iScans);
iRingCounter_Old:=iRingCounter_New;
iScans:=1;
else
iScans:=iScans+1;
end_if;
end_if;