But the precision is terrible, can you explain me the right way?
157/1440 = .109 mm per encoder tick
.109 * 256 * 10 = 279
distance * 10 = (counts * 279)/256
to use pbp's higest resolution integer functions
problem here is that when enc_counter > 60000 [or thereabouts] the internal 32bit result will overflow and the result will be wrongCode:counter = enc_counter */ 279 lcdout Dec counter/10 ,".", dec counter//10 ; display counter value on LCD
you could look at nbit math
ps you could also use div32
Code:counter = enc_counter * 1000 counter = div32 917 lcdout Dec counter/10 ,".", dec counter//10 ; display counter value on LCD




Bookmarks