algorithmic modeling for Rhino
Heya,
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.
Any thoughts?
Thanks very much.
Tags:
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.
@mohoyt
Hi, I know this discussion is super old but I was wondering if you might be able to show me how you received data from your encoder and processed it in Firefly to accurately map clockwise and counter clockwise movement?
Many thanks!
In case anyone else might come across this discussion I have made an attempt and do have a semi successful result.
The way I understand the rotary encoder is that 0s and 1s are being sent from the encoder to the two output pins. If the encoder is turned anti-clockwise values alternate in sync. However when turned clockwise values alternate a fraction of a second out of sync. The way my Grasshopper sketch works is that it evaluates if the results change out of sync and reduces a counter by one otherwise the counter continues upwards.
The problem is at the moment I am getting some inconsistency on the clockwise turns, smoothing doesn't seem to be enough.
Any suggestions would be greatly appreciated.
Thanks!
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by