Skip to content

Latest commit

 

History

History
98 lines (72 loc) · 9.25 KB

File metadata and controls

98 lines (72 loc) · 9.25 KB

Up/Down Counters

A counter is a calculation that steps a value up or down on the edges of boolean input channels. Its output is an ordinary generated channel, so it can feed math channels, User Conditions, transmit messages, or be watched live in Monitor Channels. Counters are evaluated on the device at 100 Hz.

To edit counters, choose Calculations → Up / Down Counters…. The dialog lists every counter with columns #, Active, Output, Type and Inputs. Use Add…, Change… (or double-click a row) and Remove to manage the list. The device supports at most 50 counters. Changes are written into the configuration only when you close the dialog with OK; Cancel discards them.

To add a counter

  1. Choose Calculations → Up / Down Counters… and click Add…. The Up / Down Counter Settings editor opens.
  2. Under Output, click Select… and pick or create the output channel. An output channel is required.
  3. Under Input, choose the Type :Up / Down, Follow Changes or Every x Hz — and select the trigger channels (or, for Every x Hz, the rate and direction).
  4. Set the limits and step under Options, tick Active, and click OK.

Counter settings

ControlMeaning
Channel : (Output)The generated channel the counter writes. The decimal precision of the value fields below follows this channel's decimal places.
Type :Up / Down counts edges on separate Up and Down inputs; Follow Changes counts changes of a single Follow input; Every x Hz is driven by the device's own clock and reads no input channel at all. The selection enables the matching rows.
Up :Adds Step on each rising edge (Up / Down type).
Down :Subtracts Step on each rising edge (Up / Down type).
Follow :Adds Step every time the input's value changes — by any amount, in either direction, so 3000 to 3100 counts exactly as 0 to 1 does. A repeated value is not a change, so a cyclic message re-sending the same reading does not step (counting frames is what the message option on Up/Down is for). Non-finite readings are ignored rather than counted forever. (Follow Changes type.)
Rate :How many steps a second, and whether each one Increments or Decrements (Every x Hz type). See below.
Reset :On its rising edge the counter is set to Reset value. Reset always applies, even while the counter is disabled.
Enable :The counter counts only while this channel is true (value > 0). Leave it empty to count always.
The source listUp, Down, Reset and Enable each start with a list choosing what drives them: a Channel, or Message received / Message transmitted naming a message instead. Picking a message swaps the channel picker for a message list.
Minimum value : / Maximum value :The counting range. If the maximum does not exceed the minimum, no limiting is applied (validation warns about this).
Reset value :The value loaded on a reset edge.
Step :How far each edge moves the value. A step of 0 counts as 1.
Roll at limitsTicked, the value wraps around within the Minimum–Maximum range instead of stopping; clear, it holds at the limit.
Preserve valueKeeps the counter's value across power cycles — see below.
ActiveOnly active counters run on the device.

Note: All counter inputs are boolean channels: true means the channel's value is greater than 0. A User Condition output is the usual way to build a clean trigger from an analog channel.

Note: The Reset value is always forced into the Minimum–Maximum range, even when the limits are disabled for counting (Maximum ≤ Minimum), so keep it inside the range you configure.

Every x Hz — counting on the clock

A counter set to Every x Hz is driven by the device's own clock instead of by a channel. It moves one Step at the chosen rate, in the direction you pick, for as long as it is enabled. Choose from 1, 2, 5, 10, 20, 50 or 100 Hz, and Increment or Decrement.

The Up, Down and Follow rows are switched off in this mode — a rate counter reads no input channel, and the configuration is sent without those references. Reset and Enable still work, and they are most of what makes the mode useful:

Note: Switching type keeps what you typed. Changing an Up/Down counter to Follow Changes greys the Up and Down rows out but does not erase them, so switching back brings your inputs with you. A greyed-out input is genuinely dormant: it is not sent to the device, it is not counted as a use of that channel by Check Channels, and it cannot hold up a Send — even if the message or channel it names has since been deleted. Renaming a message in Communications Setup carries every counter input that names it along too, and deleting one is reported by File → Check Channels against the counter rather than left to fail the Send. Only the inputs the current type actually reads are shown in the grid's Inputs column, which is the same list that reaches the unit.

  • Enable gates the counting, and the period is frozen while the gate is shut rather than continuing to run. Re-enabling therefore costs no step and banks none: the counter picks the period up where it left it.
  • Reset loads the Reset value on its rising edge and restarts the period, so the first step after a reset is a full 1/rate away rather than whatever remained on the clock. Reset applies even while disabled.

The limits behave as they do in the other modes: the value stops at Minimum or Maximum, or wraps if Roll at limits is ticked. A 1 Hz counter with Step 1 rolling between 0 and 60 is a seconds hand; a decrementing counter with a Reset channel is a countdown.

Note: The device evaluates at 100 Hz, which is why 100 Hz is the fastest rate offered — one step per evaluation. Every rate in the list divides 100 exactly, so each is a whole number of ticks per step and the timing is exact rather than averaged.

Note: This is close to what an integrator does, and the difference is worth knowing: an integrator adds the value of a channel at a rate, while a rate counter adds a fixed Step. Use a counter when you want a clock-driven ramp or countdown, and an integrator when you want to accumulate something the bus is telling you.

Counting messages

Set Up to Message received and pick a message, and the counter advances once for every frame of that message that arrives. Message transmitted does the same for frames the device sends. Before this you had to build a User Condition on the message and point the counter at its output; the counter says it directly now.

One frame, one step. The counter is evaluated on the frame itself rather than on the device's 100 Hz calculation pass, so a burst of frames between two passes is counted in full rather than collapsing into one.

Note: Follow Changes has no message option, and that is not an omission. Follow tracks the value of a channel, and a frame arriving has no value — only a moment.

Note: Enable behaves differently from the others if you point it at a message. Up, Down and Reset act on an edge, which a frame gives them naturally. Enable is a level: it lets the counter run while it is true, and a message is true only on the frame itself — so a message-gated Enable permits counting on those instants and no others. That is occasionally what you want and rarely what you meant; a User Condition holding a latch is usually the better gate.

Preserve value

Ticking Preserve value keeps the counter's value across power cycles. The value is written to a small flash store about once a minute, so up to a minute of counting can be lost on a sudden power cut, and the store is reset whenever you send a changed configuration — preserved values never reattach to a different counter.

At most 20 values can be preserved, and the store is shared between counters and integrators. The label at the bottom of the dialog shows a running budget of the counters in this list ("Preserved across power cycles: N of 20."); the combined counter + integrator total is enforced by Check Channels, which reports an error when the two together exceed 20.

Warning: On a device whose flash has no room for the retained-value store, preserved counters still run but start from their reset value at every power-up. Without Preserve value, every counter starts from its reset value at power-up.

See also

Timers · Integrators · User Conditions · Channels · Monitoring Live Values · Validation & the Config Summary