Oops, accidentally sent this reply only to Rampant Land at first (new
mail client -- have to use "Reply List" instead of "Reply").
On 4/4/2025 5:47 PM, Rampant Land wrote:
> What's a good method for creating a timer? Something like 'after so
> many ticks, value changes'.
The standard counter block will do that (if it must be based on tick
events instead of time), and if you need a count greater than 16, then
you just stack them up to multiply until you get as close as you can,
and then take another that is always reset by the last one in the
multiply chain just to count from there up (the remainder) and AND its
output with the multiplier chain's last output.
But any given counter block can only have a single, fixed target value
that it counts to. Instead, you can build a counter circuit of your own
that you could combine with a comparison against the value set as a
constant in a formula block, or provided by some other sub-circuit. The
advantage of doing it this way instead of using standard counter blocks
is that you can let the target value change dynamically (by other
circuitry) instead of being hard-set within a standard counter block.
There are probably better ones out there somewhere, but I just threw
this one together (see attached). It is slightly more complicated by
forcing a trigger event to get changed to a single-sample -1, which lets
it work as intended, but you might need something different. I also
toyed with the idea of using the reciprocal of the count value (1/count)
just because ABox likes to work with fractional values, so the
sub-circuit outputs both; but there really is no advantage and might
even be some chance of inexact values causing errors (ideally, you would
use a <= instead of the = that I used here).
Regards,
Keith W. Blackwell