show the entry list
STEP 7 (TIA Portal) -- Creating S7 programs -- Calling blocks and functions
How do you parameterize the "TM_MAIL" instruction to send e-mails with the SIMATIC S7-1200?
Where do you find the latest firmware for the SIMATIC S7-1500 CPU and which SMC do you need for an Offline Update?
How do you program and parameterize Modbus/TCP communication between S7-1500 CPUs and S7-1200 CPUs?
What should you watch out for in STEP 7 (TIA Portal) when transferring FC and FB parameters for new S7-1200/S7-1500 controllers?
What is the maximum number of parameters you are allowed to define in STEP 7 (TIA Portal) for a function in the S7-1200/S7-1500 CPU?
How do you read out the IP address of the PROFINET interface of a S7-1500 CPU in the user program?
What are the block protection facilities available in STEP 7 to protect the the know-how of your blocks?
Why is the "GET_NAME" instruction not executed in STEP 7 (TIA Portal) V12?
Why should whole structures instead of many single components be transferred for the S7-1500 when a block is called?
What differences should you watch out for between optimized data storage and the standard type of block access in STEP 7 (TIA Portal) V12?
What types of access, value columns and operator input options are available for the global data blocks in STEP 7 (TIA Portal) V12?
How do you program the TC_CONFIG instruction to change the parameters of a CP1242-7 configured in STEP 7?
How are the automatic PID controller settings (optimization) made for asymmetrical temperature control paths in STEP 7 (TIA Portal) V11 and higher?
How do you change the pulse length for the pulse width modulation (PWM) in the user program of the S7-1200 CPU?
How do you compile blocks with know-how protection in STEP 7 (TIA Portal) V11 when they have been copied from another project?
Where can you download the F FBs for the Mobile Panel 277F IWLAN for the Safety option of STEP 7 V5.5, STEP 7 Professional V11 and STEP 7 Professional V12?
Which organization blocks can you use in STEP 7 (TIA Portal)?
How in STEP 7 V11 do you save the value of an "HSC" (high-speed counter) for the S7-1200 after STOP mode or after a restart?
Which Motion Control functions are there in STEP 7 (TIA Portal) V11 and how do you use these functions?
In STEP 7 (TIA Portal) how do you configure data blocks with the "Only store in load memory" attribute?
How do you open blocks that are know-how protected in STEP 7 V11 in a different project when they have been downloaded from the CPU?
How in STEP 7 V11 do you save the value of an "HSC" (high-speed counter) for the S7-1200 after STOP mode or after a restart?
Part number:

With the "Control high-speed counters" [CTRL_HSC] operation you can call and parameterize the high-speed counters supported by the CPU in your program. These high-speed counters are used to count the pulses generated by a rotary transducer, for example.

After changing from STOP to RUN mode or after switching the power supply off and on again, the high-speed counters "HSC" are reinitialized and the counters are reset to zero. The table below explains how to proceed to retain or save the values of the high-speed counters after a CPU STOP.
No. Procedure
1 To execute the "Control high-speed counters" [CTRL_HSC] operation, you must enable the high-speed counters "HSC" in the device configuration.
  1. In the project navigation, open the device configuration in the mark the "PLC_1..." folder.
  2. In the device configuration, open the "Properties" of the CPU and open the "High-speed counters (HSC)" folder in the area navigation. The properties of the high-speed counters are displayed in the right window.
  3. To enable the high-speed counter "(HSC)1", you activate the "Enable this high-speed counter for use" option.
  4. For the high-speed counter (Name: "HSC_1") you define the functions as shown in the example in Fig 01.

Fig. 01

2 Create a global data block with the symbolic name "DB HSC retain", for example, and define the variable "HSC_1" of data type "DInt" in the DB. The counter value is saved in this DB variable.

Fig. 02

The current counter value is not provided for in the parameters for the "Control high-speed counters" [CTRL_HSC] operation. The address for the process image is assigned to the high-speed counter in the hardware configuration and includes the current counter value. You can read out the counter value directly via the program logic. The value output in your program is a correct counter value for the moment in which the counter was read. The counter continues counting high-speed results. The actual counter value can therefore change before your program has completed a process with an old counter value.

3 Create a time interrupt OB (OB201) with a cycle time of 10 ms, for example, and insert the "MOVE" instruction in Network 1.
  1. Parameterize the input parameter of the "MOVE" instruction with the initial address of the high-speed counter "HSC_1" and define a symbolic variable for this ("HSC1_CV", for example). The initial address for the high-speed counter HSC_1 is ED1000 by default.
  2. Parameterize the output parameter with the DB variable "DB HSC retain.HSC_1".

When the program is executed, the counter value of the high-speed counter "HSC_1" is transferred to the DB variable every 10 ms.

Fig. 03

  1. Create a start OB (OB100) and insert the "MOVE" instruction in Network 1.
  2. Parameterize the input parameter of the "MOVE" instruction with the DB variable "DB HSC retain.HSC_1" and the output parameter with the defined variable "NEW_CV1" (MD24). The "NEW_CV1" variable is also assigned to the "NEW_CV" parameter of the "Control high-speed counters" [CTRL_HSC] operation.
  3. Now do a restart. The counter value in the DB variable is transferred as start value to the "NEW_CV1" variable with which the high-speed counter begins to count again.
5 To enable the counter value, insert the "Set output" [S] instruction in another network and parameterize the operands with the defined variable "CV1" (M10.1).

Fig. 04

6 Now, call the "Control high-speed counters" [CTRL_HSC] operation in a block (OB1, for example) and parameterize the input and output parameters. Once the current counter value has been enabled with the variable "CV1" (M10.1), the parameter "CV" is reset again. Insert the "Reset output" [R] instruction in another network and parameterize the operands with the variable "CV1" (M10.1).

Fig. 05

7 Compile your program by right-clicking on the "PLC_1..." folder in the project navigation and executing the menu command "Compile > All" from the pop-up menu. Then save your project.

More information is available in the STEP 7 (TIA Portal) V11 Online Help under "CRTL_HSC: Control high-speed counters (S7-1200)".

Creation environment
The screens in this FAQ response were created with STEP 7 (TIA Portal) V11.

 Entry ID:41995947   Date:2012-02-20 
I regard this helpfulas not helpful                                 
My Documentation Manager 
Support Request
To this entry
Create PDF 
Send to a friend
Compatibility tool 
Online Help
Guided Tour