On 6/8/2023 6:11 PM, Tomek CEDRO 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?

:-)

We don't normally use int or long types explicitly since these types are different with different tools or hardware.  int32_t is always 32 bits wide, int64_t is always 64 bits wide and will be typedef'ed in include/stdint.h to the correct underlying type.

If you have no FPU, have you considered using fixed precision real numbers.  See include/fixedmath.h.  They work well as long as the range of values is restrained.

Reply via email to