DINT
Ring counter resolution
Resolution in nanoseconds of the PLC-dependent 10.24ms or 10.67ms type ring counter.
Use conditional compilation to ensure that the exact time value is calculated for each PLC type:
#if (IsSystemVariableSupported('sys_iRingCounter_10usXX')) #then
if (NOT bIsInitialized) then
bIsInitialized:=TRUE;
iRingCounter_Old:=sys_iRingCounter_10usXX;
else
iRingCounter_New:=sys_iRingCounter_10usXX;
iRingCounterDiff:=iRingCounter_New-iRingCounter_Old;
diScanTime_ns:=INT_TO_DINT(iRingCounterDiff)*SYS_RINGCOUNTER_10us_RESOLUTION_ns;
iRingCounter_Old:=iRingCounter_New;
end_if;
#end_if;