FB_CXProfiler
The function block FB_CXProfiler can be used to measure the execution time of the PLC code under Microsoft Windows CE.
![]() | For other operating systems, refer to the Profiler function block in the Tc2_Utilities library. |
Internally, an instance of the GETCPUCOUNTER function block is called. The measurement is started by a rising edge at the bStart input, and is stopped by a falling edge. The measurements are evaluated internally, and are then made available for further processing at the stData output in a structure of type ST_CX_ProfilerStruct. As well as the current, minimum and maximum execution times, the function block calculates the mean execution time for the last 100 measurements. The times measured are given in microseconds. The output variable stData.dwMeasureCycle 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 measured values in the DATA structure that have already been determined then become invalid, and are re-calculated when the function block is called again.
Comment:
The determined times can deviate from the actual values, since already for the calls of the GETCPUCOUNTER function block some time is needed. This time depends on the particular computer, and is included in the determined times. Task interruptions, e.g. by the NC, are not detected and lead to longer measuring times.
Inputs
VAR_INPUT
bStart : BOOL;
bReset : BOOL;
END_VAR
Name | Type | Description |
---|---|---|
bStart | BOOL | A positive edge at this input starts the measurement of the execution time. A negative edge at this input stops the measurement, and causes the current, minimum, maximum and mean execution times to be recalculated. The variable stData.dwMeasureCycle is incremented at the same time. |
bReset | 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. |
Outputs
VAR_OUTPUT
bBusy : BOOL;
stData : ST_CX_ProfilerStruct;
END_VAR
Name | Type | Description |
---|---|---|
bBusy | BOOL | This input is set at the start of the measuring procedure, and remains set until the time measurement has been completed. Once the bBusy output has been reset, the latest times are available at the stData output. |
stData | ST_CX_ProfilerStruct | Structure of type ST_CX_ProfilerStruct with the measured times [in µs]. |
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1 | CX (WEC6/7: TC RT x86, WEC7: TC CE7 ARMV7) | Tc2_SystemCX |