Technology instructions
10.1 Counting (High-speed counters)
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
565
The "HSC_Frequency" data type corresponds to an HSC configured for "Frequency" mode.
The instruction CTRL_HSC_EXT provides program access to the frequency of input pulses,
measured over a specified time period.
Using the CTRL_HSC_EXT instruction in Frequency mode provides the following
capabilities:
Table 10- 6 HSC_Frequency structure
Frequency OUT DInt Returns a frequency in Hz, measured over the measurement
interval time. When the HSC counts down, the instruction
returns a negative frequency.
EnHSC IN Bool Enables the HSC for Frequency measurement when true;
disables Frequency measurement when false.
Enables NewPeriod value to take effect.
NewPeriod IN Int Specifies the measurement interval time in milliseconds. The
only allowed values are 10, 100, or 1000 ms.
The CTRL_HSC_EXT instruction measures the Frequency using the same measurement
technique as Period mode to find the ElapsedTime and EdgeCount. The instruction
calculates the frequency as a signed integer value in Hz using the formula: Frequency =
EdgeCount/ElapsedTime
If you require a floating-point value for frequency, you can use the above formula for
frequency when the HSC is in Period mode. Note that in Period mode, ElapsedTime is
returned in nanoseconds and can require scaling of the value.