High Speed Counter
Overview
Counts changes in the value of one or two GPIO pins (ON→OFF or OFF→ON) at high speed. Can be used with rotary encoders and similar devices.


Supported GPIO
- Raspberry Pi 0~4
- Raspberry Pi 5
- BeagleBone Black/Green
- Jetson Nano
On hardware other than Raspberry Pi 0~4, errors may occur when counting signals over 1000 times per second.
Commands
[INIT]
Configures initial settings for the high speed counter.
Item | Type | Description |
---|---|---|
Type | WRITE | Select the high speed counter type. (1 Phase, 2 Phase, CW/CCW) |
Pin A | WRITE | Enter the GPIO pin where Phase A will be input. |
Pin B * | WRITE | Enter the GPIO pin where Phase B will be input. |
Pull up/down ** | WRITE | Configure GPIO internal Pull Up/Down resistor. (Off, Pull Down, Pull Up) |
* Displayed only when 2 Phase or CW/CCW type is selected.
** For explanation of Pull up/down resistors, refer here.
** For explanation of Pull up/down resistors, refer here.
[START_COUNT]
Starts the high speed counter.
Item | Type | Description |
---|---|---|
Counter Type * | WRITE | Select the counter type. (Linear Counter, Ring Counter) |
Multiplier ** | WRITE | Select the multiplier. (1x, 2x, 4x) |
Minimum Count | WRITE | Enter the minimum value for counting. |
Maximum Count | WRITE | Enter the maximum value for counting. |
* The counting range is determined by the count type.
– Linear Counter : Stops counting when it exceeds the minimum to maximum range.
– Ring Counter : When it exceeds the maximum value, it starts again from the minimum value, and when it becomes smaller than the minimum value, it starts again from the maximum value.
** Multiplier, Frequency Multiplier means multiplying the frequency by an integer multiple. 2x and 4x mean that the counting precision (resolution) becomes 2x and 4x respectively.
– Linear Counter : Stops counting when it exceeds the minimum to maximum range.
– Ring Counter : When it exceeds the maximum value, it starts again from the minimum value, and when it becomes smaller than the minimum value, it starts again from the maximum value.
** Multiplier, Frequency Multiplier means multiplying the frequency by an integer multiple. 2x and 4x mean that the counting precision (resolution) becomes 2x and 4x respectively.
[STOP_COUNT]
Stops the high speed counter.
[SET_COUNT]
Manually sets the count value.
Item | Type | Description |
---|---|---|
Count | WRITE | Enter the count value to set manually. |
[REVERSE_COUNT]
The counting increase and decrease are reversed.
Item | Type | Description |
---|---|---|
Reverse | WRITE | If true, increase/decrease is reversed. |
[GET_COUNT]
Reads the count value.
Item | Type | Description |
---|---|---|
Count | READ | The measured count value. |
Example
Objective
Display the count value of the rotary encoder on the dashboard widget.
Parts
Part | Quantity |
---|---|
Raspberry Pi 4 * | 1 |
Rotary Encoder | 1 |
* Other hardware can also be used. Refer to Supported GPIO.
Wiring
Connect each component to the corresponding connection as listed in each row below.
Rotary Encoder | GPIO |
---|---|
CLK (A) | 18 * |
DT (B) | 15 * |
VCC(+) | 3.3V |
GND | GND |
* All GPIO pins can be used.
