Encoder (Single Wire) sensor setup and use - input type, freq?

Using Cortex, RobotC. Trying to make a “poor mans” encoder using digital sensors and wanted to take advantage of what I believe is interupt driven counters on the Encoder sensor setup. I wired a switch to the digital input and configured it as a single wire encoder. Enabled sensor debugging. On the first signal edge (press switch) I get a large jump in the value 10-15 range, and on the next edge (release switch), I get a smaller change, like 1-3. If it were consistent I could probably work with it but it’s not. Don’t know the cause of the inconsistency, maybe switch bouncing?

What IS the expected input from a single wire encoder? I don’t have one nor a scope to test it.

If I can’t use the encoder built in counter, that leaves me back to trying to poll the digital input value of 0 and 1, but I’m afraid I’m going to miss counts with that.

What’s the best way to count digital switch inputs and not lose a count? Put in a separate task I thought might help. Wish I knew what the max input frequency of that monitoring would be.

@jpearman? anyone?

1 Like

That sounds like switch bounce.
It’s a good concept, but switch bounce will most likely prove to be a problem unless you can filter that out before sending to the cortex.
using a RobotC task, you can probably sample the switch at least 500 times a second (depending on what else is happening), so that may work for you.