Topic: DMD0126

TICKus - Get Microsecond System Timer Value


This instruction can only be used in the Expression parameter of the Calculate Expression (MATH) instruction.

 

The Get Microsecond System Timer Value (TICKus) instruction stores the current value of the CPU's internal clock in a user-accessible memory location. This value is a 32-bit integer which should be stored in a DWord location. This value has no meaning except when used with a future call to TICKus().

 

 

This value is in microsecond resolution which makes it useful for measuring intra-scan events. One example is doing real-time instruction-level profiling, that is, measuring the execution time of one or more ladder logic instructions during a single scan.

 


Parameters:

This instruction has no parameters.

 


See Also:

 


Related Topics:

 


Instruction Profiling Example:

It is recommended that the TICKus instruction be used within the same rung of the logic you want to measure as follows:

 

  1. save the current tick counter to an unused DWord register

     

  2. perform the ladder logic instructions you want to profile

     

  3. subtract the value in the DWord register from step 1 from the current tick counter and store the result in a second unused DWord register.

 

In the example below D101 will contain the number of microseconds required to perform the Math calculation and store the result in R0. There is a small amount of overhead in reading and calculating the elapsed time in microseconds which should be taken into account if measuring very fast logic.