Programming instructions
6.1 Basic instructions
Parameter
HSC
DIR
CV
RV
PERIOD
NEW_DIR
NEW_CV
NEW_RV
NEW_PERIOD
BUSY
STATUS
You must configure the high-speed counters in the project settings PLC device configuration
before you can use high-speed counters in your program. The HSC device configuration
settings select counting modes, I/O connections, interrupt assignment, and operation as a
high-speed counter or as a device to measure pulse frequency. You can operate the high-
speed counter with no program control or with program control.
Many high-speed counter configuration parameters are set only in the project device
configuration. Some high-speed counter parameters are initialized in the project device
configuration, but can be modified later under program control.
The CTRL_HSC instruction parameters provide program control of the counting process:
● Set the counting direction to a NEW_DIR value
● Set the current count value to a NEW_CV value
● Set the reference value to a NEW_RV value
● Set the Period value (for frequency measurement mode) to a NEW_PERIOD value
If the following boolean flag values are set to 1 when the CTRL_HSC instruction is executed,
the corresponding NEW_xxx value is loaded to the counter. Multiple requests (more than
one flag is set at the same time) are processed in a single execution of the CTRL_HSC
instruction.
● DIR = 1 is a request to load a NEW_DIR value, 0 = no change
● CV = 1 is a request to load a NEW_CV value, 0 = no change
● RV = 1 is a request to load a NEW_RV value, 0 = no change
● PERIOD = 1 is a request to load a NEW_PERIOD value, 0 = no change
The CTRL_HSC instruction is usually placed in a hardware interrupt OB that is executed
when the counter hardware interrupt event is triggered. For example, if a CV=RV event
triggers the counter interrupt, then a hardware interrupt OB code block executes the
CTRL_HSC instruction and can change the reference value by loading a NEW_RV value.
106
Parameter
Data type
type
IN
HW_HSC
IN
Bool
IN
Bool
IN
Bool
IN
Bool
IN
Int
IN
DInt
IN
DInt
IN
Int
OUT
Bool
OUT
Word
Description
HSC identifier
1 = Request new direction
1 = Request to set new counter value
1= Request to set new reference value
1 = Request to set new period value
(only for frequency measurement mode)
New direction:
1= forward
-1= backward
New counter value
New reference value
New period value in seconds: .01, .1, or 1
(only for frequency measurement mode)
Function busy
Execution condition code
S7-1200 Programmable controller
System Manual, 11/2009, A5E02486680-02