Quadrature encoder question

Hi,

I have a question about connecting a quadrature encoder to the Pisound Micro.
I bought a 24 PPR endless rotary quadrature encoder.
In the Pisound Micro documentation, it says that by default it is limited to 24 PPR.
But since it’s quadrature, shouldn’t I be able to get 96 PPR?

From what I understood, I can set a higher value range. In the documentation, it mentions 1023 as an example. That would result in changes in steps of around 43, but that doesn’t actually increase the PPR. 1023 divided by 43 still brings me back to about 24 PPR.

Am I missing something here? How can I make use of the actual quadrature logic?

Hey, which particular place in Pisound Micro’s documentation are you referring to?

The resolution of the encoder (how many changes are detectable over whole 360 degree turn) depends on the encoder part itself.

Pisound Micro keeps track of a numeric value as a helper for you - you may choose to use that to simulate a bounded value between a desired minimum and maximum range, or you may simply keep the last value and subtract it from the latest value to know the direction of movement.

Hey Giedrius.

Its here under the Encoder section.

"
As encoders only produce usually between 12 or 24 value changes in 360
degree turns, it can be convenient to expand its output value range to
something larger:
echo 1023 > /sys/pisound-micro/elements/enc/value_high
Now there should be changes in steps of ~43, and the maximum value should
be 1023.
"

I’m honestly not 100% sure how quadrature encoders work. I thought the Pisound Micro supported hardware quadrature decoding, but it seems that’s not the case.
A higher max value doesn’t necessarily give me higher resolution, the steps just bigger to the next value, I’ll still be limited to those 24 value changes, if that makes sense.
But I should be able to get up to 96 value changes (24×4).

My solution so far is to switch to an analog endless rotary potentiometer instead.

The encoders do produce only 12 or 24 or some other number of detectable change events per whole turn, depending on the actual encoder part number - there’s no way to get more updates other than getting a more ‘dense’ encoder which can get expensive. The comment there suggest scaling the value range, so you get higher numbers quicker, but it won’t increase the resolution.

Hey Giedrius,

Thank you very much for clarifying. That all makes sense. It really looks like I would need an analog endless rotary potentiometer instead. I think that’s what Elektron devices use as well. I was under the assumption that a digital encoder would work for this, but with such low resolution it’s probably impossible to get smooth transitions.
I wonder though, something like the Akai mpk mini mk3 seems to be using digital encoders with pretty smooth transition.

I have used Elektron’s Analog Four (original version) and their encoders seem to have around 24 positions in a revolution, but they also allow ‘quick’ changes when the encoder is pushed down and turned, the change gets multiplied by 8. They also do some additional filtering I think to make accidental little changes less likely, where if you do it slowly, it indicates that it’s about to change, but doesn’t change the value immediately, so you have to keep turning more.

This is handled by their software, so user software would have to account for it. In your software, you could keep monitoring the value fd object for changes (or element’s value attribute if accessing sysfs directly, not through libpisoundmicro), and whenever a change is signaled, read the latest value and subtract the previous value cached in memory, so you know the exact amount of change and the direction of change (positive or negative result), and then apply your logic to that.

Making use of input_min, input_max, value_low and value_high attributes might help with the scaling side of things, but all of that can be done by your code too.