COUNT node - bug or feature?

I have made a patch that will take three measurements from an ultrasonic sensor. On the first reading I set the servo angle to zero, and read the distance. I increment the COUNT node. The COUNT node feeds back to a SELECT node that then sets the servo angle to 70 degrees (approximately forward looking). I increment the COUNT and the SELECT node sets the servo angle to 120 degrees (the max for my servo).

I would like the count to go from 1 to 3. I noticed that when I initially set the output (accumulator) of the COUNT node to 1, the count does indeed start at 1. But, when I reset the COUNT node so that we can start the process all over again, then the original value of the output node (accumulator) is ignored and the count is reset to zero (which is what the help says it will do).

Is this a bug (i.e., should the COUNT node “remember” the original value that the user set for the output/accumulator of the COUNT node), or is it a feature that it will always reset to zero regardless.

It’s no big problem. Obviously I can index from 0 to 2, or test for zero and act accordingly. I am just curious if this is actually the desired behavior.

Here is the patch if anyone is interested:

Using nth-input instead of equal-pulse-select would make your patch much simpler (and make starting at 0 a non-issue).

There should probably be an advanced count node that lets you set start & end values for count, but the base one was designed to be simple. Do you reset or stop on reaching max? (If you stop, but have an output pulse when max is reached, you can feed that back to RST if you want to loop.)

1 Like

gweimer, excellent suggestion, as usual!

This is simpler and works better (also fixed my ultrasonic sensor timing pan issue mentioned in another post!)

Thank you!