With S7-1200/S7-1500, how do you measure the total cycle time of an organization block?
The "RUNTIME" instruction is in the "Basic Instructions > Program Control Instructions" palette and the "RT_INFO" instruction is in the "Advanced Instructions > Diagnostics" palette. The examples below show the calculation of the runtime.
Example 1: Runtime measurement with the "RUNTIME" instruction for the S7-1200/S7-1500
Figure 1 shows you the calculation of the runtime for a called program block:
- The first call of the "RUNTIME" instruction sets the starting point for the runtime measurement and saves this as a reference for the second call in the DB variable "Memory".
- Then the "LoadModule" program block is called.
- When the block has been processed, the "RUNTIME" instruction is called a second time. This second call calculates the runtime of the "LoadModule" program block and writes the result (seconds)to the DB variable "RunTimeResult".
Example 2: Runtime measurement with the "RT_INFO" instruction for the S7-1500
With the "RT_INFO" instruction you generate statistics on the runtime of specific organization blocks of communication or of the user program. Via the "MODE" parameter you define which runtime you want to read out at the "INFO". In the example below (Fig. 2) the "RT_INFO" instruction for the output of four different runtimes called four times in one SCL program.
- MODE:= 1 (runtime of a specific OB)
- MODE:= 2 (maximum runtime of a specific OB)
- MODE:= 3 (minimum runtime of a specific OB)
- MODE:= 25 (current / last cycle time or duration of the last cycle)
Evaluation of the cycle time with the temporary variables
Alternatively, with the S7-1500, you can also determine the cycle time via the temporary variables in the OB "Main" [OB1]. For this you have to change the block access beforehand in the Properties, because this method is not possible with optimized block access.
- Right-click the OB "Main" and in the pop-up menu you select "Properties...".
- Go to the "Attributes" tab and disable the "Optimized block access" attribute (remove check mark).
- Click OK and also confirm the next message with OK.
Now, as for STEP 7 V5.x, you have the temporary variables available for calculating the cycle time. You can determine the following cycle times with the temporary variables of the OB "Main".
- PREV_CYCLE: Output the time of previous cycle.
- MIN_CYCLE: Output the minimum cycle time.
- MAX_CYCLE: Output the longest cycle time.
Fig. 3 shows you the calculation of the cycle time with the temporary variable "PREV_CYCLE".
The parameters are already stored in the declaration part after the change of block access. You can also change the variable names in the declaration part of the OB without the content being changed.
More information on runtime measurement is available in the manual under:
The screens in this FAQ response were created with STEP 7 (TIA Portal) V14.