Counter Input
Applies to: IOcan · Standalone controller. What this means
Overview
A Counter Input keeps a running count that goes up and down as trigger inputs fire. Three optional triggers drive it: one increments, one decrements, one reloads a reset value.
Use it to tally events — shift counts, button presses — or, more usefully, as a mode selector: two buttons stepping a value between limits, feeding a Mux Input or a map.
The count is not stored. It starts from the Start value every time the device powers up. There is no persistence, so it is not an odometer.
The shift events it counts usually come from a paddle or a lever — wiring concepts covers how a non-standard shifter reaches the device.
Prerequisites
Up to three trigger inputs, each referenced by name. All three are optional and an unassigned one is simply ignored — no fault is raised.
Triggers are read against the standard threshold: a trigger fires on the transition from ≤ 512 to > 512, once per transition. Holding a trigger high does not repeat. Typical sources are a Digital Input or a Compare Input.
Add it in the app
- Add a new input and choose Counter Input as the type.
- Assign the up, down and reset triggers you need.
- Give it a clear name (e.g.
Drive Mode). - Set step, min, max, start value, reset value and rollover.
Settings reference
| Setting | Meaning | Unit | Range / values | Notes |
|---|---|---|---|---|
| Up input | Increments the count | — | an existing input | Optional. Fires on each low→high transition. |
| Down input | Decrements the count | — | an existing input | Optional. |
| Reset input | Reloads Reset value | — | an existing input | Optional. Takes priority — see below. |
| Step | Amount added or subtracted per trigger | count | int32 | Usually 1. A step of 0 makes the counter inert. |
| Min value | Lower limit | count | int32 | Behaviour at the limit depends on Rollover. |
| Max value | Upper limit | count | int32 | As above. |
| Start value | Count at power-up | count | int32 | Loaded on every start. Not restored from the last session. |
| Reset value | Count after a reset trigger | count | int32 | Often, but not necessarily, the same as Start value. |
| Rollover | Wrap instead of clamp | — | on / off | On: past Max wraps to Min, below Min wraps to Max. Off: the count stops at the limit. |
Trigger rules
- Edge, not level. One transition produces one step. A trigger held high does nothing further.
- Reset wins. On the cycle a reset edge is seen, the count is loaded with the reset value and any simultaneous up or down edge is discarded.
- Up and down both firing on the same cycle apply in that order: up first, then down. With equal steps they cancel.
- Both limits are applied per step, so a step larger than the range moves straight to the limit (or wraps once, with rollover on).
Common settings
Counter Input also uses the shared Name setting. See Common IO settings.
Example — a three-position drive mode on two buttons
- Two Digital Inputs,
Mode UpandMode Down, both with the filter on so a held button gives one step rather than a stream. - Type Counter Input, name
Drive Mode. - Up input
Mode Up, down inputMode Down, reset unassigned. - Step
1, Min0, Max2, Start value0. - Rollover on, so pressing up at the top returns to mode 0 rather than sticking.
- Feed
Drive Modeinto a Mux Input selector — remembering the mux needs all eight slots filled.
Example — shift tally for a session
- Up input a Compare Input with its filter on, so one shift is one event.
- Reset input a
Trip Resetbutton. - Min
0, Max999999, Rollover off, Start and Reset values0.
It resets at every power-up. If you need the number after the session, read it before switching off.
Troubleshooting
- The count never changes: the trigger never crosses 512, or Step is
0. Check the trigger in the datalogger, not the button. - One press counts several times: the trigger is a bouncing level rather than an event. Turn the source input's filter on — that is the case the filter is designed for.
- The count runs away while a button is held: the trigger source is a level and the counter is seeing repeated transitions from contact bounce. Same fix.
- It wraps when you wanted it to stop: turn Rollover off.
- It is zero after every power cycle: that is by design. The count is not persisted.
Related
- Digital Input · Compare Input — trigger sources
- Mux Input — use the count to select a value
- Common IO settings — why triggers usually want the filter on