generative modeling for Rhino
I've set up a rotary encoder and attached it to a spool of wire with the aim of working out the length of wire that has been output from the spool. Currently I have the rotary encoder outputting the angle in degrees that it is at. What I want to do, it set up some sort of counter object to count the number of complete rotations that the sppol has gone through (ideally increasing the counter when the encoder goes from 360 -> 0 degrees, and decreasing it when it goes from 360 -> 0 degrees). What's the best way of doing this in Grasshopper?
I've tried a number of ideas, such as state detection, but that only seems to count in one direction.
Thanks very much.
I've come up against some similar issues when dealing with robots with axes with greater range of motion than 360°
To keep track you need to be able to store a value, and compare current to previous state. This isn't possible using only regular grasshopper components, but can be done with a simple script.
See the attached script for a solution. It will zero the counter when reset is true, and count turns when it is switched to false.