The index signal (Z index) should be used to reset the encoder position.
You can miss an encoder step for various reasons, and without periodically
checking the absolute position (index pin), you will accumulate errors.
Then, if you set the maximum count of an encoder timer to encoder
resolution, the values [0, encoder_resolution] map to the position of the
motor rotor.
Your app should be responsible for handling zero position crossing and any
calculation regarding the distance traveled by the rotor.

There are ioctls to handle this (QEIOC_SETPOSMAX, QEIOC_SETINDEX) but ESP32
doesn't support them.


pt., 9 cze 2023 o 05:22 Tomek CEDRO <to...@cedro.info> napisał(a):

> On Fri, Jun 9, 2023 at 3:24 AM Nathan Hartman wrote:
> > I know it is sometimes unpopular to suggest adding more Kconfigs but
> maybe
> > this is something that should be configurable, allowing developers to
> > choose if they need a 64-bit count for range or a 32- (or even 16-) bit
> > count for efficiency. The needed speed and counter size really depends on
> > how the application is going to use the qencoder.
>
> Allright, mystery solved, the value returned is just a ESP32 specific
> register value (16-bit), according to the documentation this is mostly
> used for direction and speed decoding.. I will have to adapt it to a
> position value stored on a 32-bit or even 64-bit variable.. using
> floating numbers seems overkill.. thank you everyone for the hints!
> :-)
>
> --
> CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
>

Reply via email to