On Thu, Jun 8, 2023 at 8:12 PM Tomek CEDRO <to...@cedro.info> wrote:

> On Fri, Jun 9, 2023 at 1:53 AM Tomek CEDRO wrote:
> > I am working on ESP32 (no FPU) and using Quadrature Encoder for motor
> > control and range positioning. Current qencoder implementation stores
> > counted values on int32_t so the maximum and minimum value is only
> > around +/- 32k. I need far bigger numbers to be counted and available
> > for readout quickly.
>
> Sorry its 2AM here and I sit too much in front of the computer with no
> fresh air :-P
>
> int is 32 bit with range unsigned 4.294E9 aka 4,294,967,295 and
> -2,147,483,648 to 2,147,483,647 signed.
>
> long is 64 bit with range 1.833E19 unsigned and
> -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 signed.
>
> I need to get familiar with the qencoder code more and know why there
> is a 32k modulo.
>
> I know that float and double are discouraged in embedded. Maybe its a
> silly idea to use floating numbers where speed is important. Will
> changing INT to LONG impact performance a lot?



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.

Nathan

Reply via email to