Reset optical shaft encoders

I am working on a program using the optical shaft encoders. i want to be able to reset the variable. i tried to use the assignment code block (EasyC V2) to make Encodername = 0. however it only resets it for a infantesimal amount of time and then goes back to where it would have been had i never have tried to reset it. is there a way to set it back to zero? this is what i tried:


while 1==1
{
OSE = StartEncoder(1)

while OSE >= 500

OSE = 0

however after setting to 0 it just goes back to the same number and keeps counting up.

In order to accomplish this, you need to preset the actual encoder (versus simply assigning a zero value to the same variable that you use to retireve your encoder value).

When you insert a “Optical Encoder” block into your code, select “Preset”. Once you define the port number, you will need to enter a value to preset the encoder to (“0” in this case). It should now look like this: PresetEncoder(1 , 0).

Good Luck.

thanks!

it worked like a charm!
:):):):slight_smile:

Is there a way to reset the audience presets to factory defaults?
Thank you.