User Manual

Programming made easy
6.6 High-speed counter (HSC)
Easy Book
118 Manual, 03/2014, A5E02486774-AF
6.6
High-speed counter (HSC)
Use the high-speed counters (HSC) for counting events that occur faster than the OB
execution rate. The CTRL_HSC instruction controls the operation of the HSC.
Note
If the events to be counted occur within the execution rate of t
he OB, use CTU, CTD, or
CTUD counter instructions. If the events occur faster than the OB execution rate, then use
the HSC.
You configure the parameters for each HSC in the device configuration for the CPU:
counting mode, I/O connections, interrupt assignment, and operation as a high-speed
counter or as a device to measure pulse frequency.
Table 6- 27 CTRL_HSC instruction
LAD / FBD
SCL
Description
"counter_name"(
hsc:=_hw_hsc_in_,
HSC:= ,
DIR:=_bool_in_,
CV:=_bool_in_,
RV:=_bool_in_,
Period:=_bool_in_,
New_DIR:=_int_in_,
New_CV:=_int_in_,
New_RV:=_dint_in_,
New_Period:=_int_in_,
Busy:=_bool_out_,
Status:=_word_out_);
Each CTRL_HSC instruction uses a structure stored
in a data block to maintain counter data.
For SCL, you must first create the DB for the
individual counter instruction before you can
reference it. For LAD and FBD, STEP 7 automatically
creates the DB when you insert the instruction.
The CTRL_HSC instruction is typically 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.
Note
The current count value is not available in the CTRL_HSC parameters. The process image
address that stores the current count value is assigned during the hardware conf
iguration of
the high
-speed counter. You may use program logic to directly read the count value. The
value returned to your program will be a correct count for the instant in which the counter
was read. The counter will continue to count high
-speed events. Therefore, the actual count
value could change before your program completes a process using an old count value.