HSC (High-Speed Counter)
Hardware-accelerated counter for high-frequency pulse inputs beyond normal scan rate.
The High-Speed Counter (HSC) function block is designed for counting high-frequency pulse inputs that exceed the normal PLC scan rate. Standard counters miss pulses when the input frequency is faster than the scan cycle. HSC uses dedicated hardware interrupts or high-speed input modules to count pulses at frequencies up to hundreds of kHz. HSC is essential for encoder feedback, flow meter pulse counting, high-speed packaging lines, and any application where accurate high-frequency pulse counting is required.
Parameters
Inputs
| Name | Type | Description |
|---|---|---|
| Enable | BOOL | Enable the high-speed counter |
| Reset | BOOL | Reset counter value |
| PV | DINT | Preset value |
| Mode | INT | Counter mode (single phase, quadrature, etc.) |
Outputs
| Name | Type | Description |
|---|---|---|
| Q | BOOL | Done output when CV reaches PV |
| CV | DINT | Current counter value |
| Direction | BOOL | Count direction (quadrature mode) |
Ladder Logic Example
// High-Speed Counter - Encoder Position // (Configuration is typically done in hardware setup) // // |----[ HSC_Enable ]-------[HSC Encoder_Count]----| // | Channel: HSC0 | // | Mode: Quadrature | // | PV: 10000 | // | CV: Position |
Structured Text Example
// HSC configuration is platform-specific
// Siemens example using CTRL_HSC
VAR
HSC_Control : CTRL_HSC;
Position : DINT;
At_Target : BOOL;
END_VAR
HSC_Control(
HSC := 0, // HSC channel 0
DIR := TRUE, // Count direction
CV := 0, // New counter value (when NEW_CV)
NEW_CV := FALSE // Load new value flag
);
Position := HSC_Control.CV;
At_Target := (Position >= 10000);20 Production-Ready Ladder Logic Templates
Stop writing the same rungs from scratch. Get copy-paste-ready templates for motor control, PID loops, safety interlocks, conveyors, and more.
Platform-Specific Implementation
Siemens (TIA Portal)
Use CTRL_HSC system function in TIA Portal. Configure HSC channels in device configuration. S7-1200 supports up to 6 HSC channels.
Allen-Bradley (Studio 5000)
Configure HSC module in I/O tree. Use HSC instruction or high-speed counter module (1756-HSC). Micro800 series has built-in HSC.
CODESYS
Platform-dependent; requires vendor-specific HSC library. Configure in device I/O settings.
Common Applications
- Rotary encoder position feedback
- Flow meter pulse counting
- High-speed packaging line counting
- Spindle speed measurement
- Length measurement (wheel encoder)
Common Mistakes to Avoid
- Not configuring dedicated high-speed inputs in hardware config
- Using standard counter for high-frequency signals
- Incorrect quadrature mode selection for encoders
Frequently Asked Questions
What is HSC (High-Speed Counter) in PLC programming?
Hardware-accelerated counter for high-frequency pulse inputs beyond normal scan rate. The High-Speed Counter (HSC) function block is designed for counting high-frequency pulse inputs that exceed the normal PLC scan rate. Standard counters miss pulses when the input frequency is faster than the scan cycle.
What are common applications of HSC (High-Speed Counter)?
HSC (High-Speed Counter) is commonly used for: Rotary encoder position feedback, Flow meter pulse counting, High-speed packaging line counting, Spindle speed measurement, Length measurement (wheel encoder).
How do I use HSC (High-Speed Counter) in different PLC platforms?
Siemens: Use CTRL_HSC system function in TIA Portal. Configure HSC channels in device configuration. S7-1200 supports up to 6 HSC channels. Allen-Bradley: Configure HSC module in I/O tree. Use HSC instruction or high-speed counter module (1756-HSC). Micro800 series has built-in HSC. CODESYS: Platform-dependent; requires vendor-specific HSC library. Configure in device I/O settings.
Related Function Blocks
CTU (Counter Up)
Counts up on each rising edge; output activates when count reaches preset.
View Reference →CTUD (Counter Up/Down)
Counts both up and down with separate done outputs for each direction.
View Reference →R_TRIG (Rising Edge Detection)
Detects FALSE-to-TRUE transition, outputs single-scan pulse on rising edge.
View Reference →CTD (Counter Down)
Counts down from preset value; output activates when count reaches zero.
View Reference →CTU with Auto-Reset
Counter that automatically resets after reaching preset, creating repeating count cycles.
View Reference →Stop Writing Ladder Logic From Scratch
Get 20 production-ready ladder logic templates for $29 -- download instantly and use them on your next project today.
Instant download - 30-day money-back guarantee - Use on unlimited projects