| Posted: 08:08am 09 Jul 2025 |
|
|
|
Ah, not related, for me.
In my case, 32 bits of encoder position is more than enough. Out of all of the commercially available motion-controllers, I know of only one that has a 64-bit range.
However, I did experiment with this and here's my method:
DIM cn32 AS integer ' 64-bit variable DIM pr32 AS integer DIM roct AS integer ' roll-over counter DIM cn64 AS integer dim fin as float
pr32 = 0 roct = 0 cn64 = 0
' Read the current 32-bit counter value 'counter32 = ReadCounter32() timer=0 for i = 1 to 1000 cn32 = 4294967292 IF cn32 > 2147483647 THEN cn32 = cn32 - 4294967296 ' 2^32 END IF IF cn32 < pr32 - 2147483648 THEN roct = roct + 1 ELSEIF cn32 > pr32 + 2147483648 THEN roct = roct - 1 END IF cn64 = (roct * 4294967296) + cn32 pr32 = cn32 next fin=timer
' Output the extended counter value PRINT "Extended Counter: "; cn64; fin/1000
|