Profiler

Profiler 1:

This functionality is not available in the PLC under Windows CE!

Profiler 2:

The function block Profiler can be used to allow the execution time of PLC code to be measured. Internally, an instance of the GETCPUACCOUNT function block is called. The measurement is started by a rising edge at the START input, and is stopped by a falling edge. The measurements are evaluated internally, and are then made available for further processing at the DATA output in a structure of type PROFILERSTRUCT. In addition to the current, minimum and maximum execution times, the function block calculates the mean execution time for the last 10 measurements. The number of averaged measured values can be configured via the global variable MAX_AVERAGE_MEASURES between 2 and 100. The times measured are given in microseconds. The output variable DATA.MeasureCycle provides information about the number of measurements that have already been carried out. In order to measure the execution time for a specific segment of the PLC program the measurement must be started by a rising edge at the START input when the segment to be measured starts, and stopped by a falling edge at the START input at the end of the segment. All values at the DATA output can be reset if a rising edge is generated at the RESET input at the same time as the rising edge at START. The old measured values are then reset when a new measurement starts and are recalculated from the subsequent calls of the function block.

Comment:

The times measured can differ from the actual values, since a certain amount of time is needed just for the call of the GETCPUACCOUNT function block. This time depends on the particular computer, and is included in the times that are found.

Profiler 3: Inputs

VAR_INPUT
    START  : BOOL;
    RESET  : BOOL;
END_VAR

Name

Type

Description

START

BOOL

A positive edge at this input starts the measurement of the execution time. A falling edge at this input stops the measurement, and causes the current, minimum, maximum and mean execution times to be recalculated. The variable DATA.MeasureCycle is incremented at the same time.

RESET

BOOL

All variables at the DATA output are reset if a rising edge is generated at this input at the same time as a rising edge at the START input. The old values for the current, minimum, maximum and mean execution times are reset, and are re-calculated for following measurements.

Profiler 4: Outputs

VAR_OUTPUT
    BUSY  : BOOL;
    DATA  : PROFILERSTRUCT;
END_VAR

Name

Type

Description

BUSY

BOOL

This output is set at the start of the measuring procedure, and remains set until the time measurement has been completed. Once the BUSY output has been reset, the latest times are available at the DATA output.

DATA

PROFILERSTRUCT

Structure with the measured times in [µs].

Example 1:

PROGRAM ProfilerTest_ST
VAR
   Profiler1     : PROFILER;
   ProfilerData  : PROFILERSTRUCT;
   a             : LREAL;
END_VAR

Online display of the measured times:

Profiler 5:

Example 2:

PROGRAM ProfilerTest_FUP
VAR
   Profiler2      :PROFILER;
   Profiler2_Busy :BOOL;
   Profiler2_Data :PROFILERSTRUCT;
   b              :LREAL;
END_VAR

Online display of the measured times:

Profiler 6:

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86, x64)

Tc2_Utilities (System)