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?
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.
|1||To execute the "Control high-speed counters" [CTRL_HSC] operation, you must enable the high-speed counters "HSC" in the device configuration.
|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.
|3||Create a time interrupt OB (OB201) with a cycle time of 10 ms, for example, and insert the "MOVE" instruction in Network 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.
|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).
|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).
|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)".
The screens in this FAQ response were created with STEP 7 (TIA Portal) V11.