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? :-) -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info