Move x amount of encoder pulses


I have an incremental encoder connected to the robot. I want to activate a digital output until a given number of encoder pulses have been counted.

the output is actually a motor, the encoder measures the angle of rotation of the motor. In effect I want to rotate the motor a specific number of degrees and then stop.

(in speudo code) would it be something like:

target = angle_in_tick_count
b = get_conveyor_tick_count()
d = 0
while d < target
c = get_conveyor_tick_count()
d = c-b

This seems cumbersome, any suggestions for a better solution welcomed!


Something like that is probably going to work just fine for you. If you’re concerned about the “cumbersome” part making your polyscope difficult to read, just put all this code into a script function. You can even make the “target” an input parameter. Then anywhere in your polyscope program, you just put a single Script node “waitForConveryer(ENCODER_COUNT)” or whatever you decide to name your function. you may want to add a “sync()” line at the bottom of your while loop. Depends on if the robot gets mad about it using too much time or whatever.