Hello Richard, thank you again for help. Your code works and take a little improvement. I make some changes, first got a smaller precision wheel dia. 25mm (circ. 78,53975mm) and divide the encoder reading /2. Now the encoder reading is only 720 per one rev.
The code is as follows:
Code:
Main_Loop:
enc_counter = enc_counter /2
if Flag = 1 then
frac = enc_counter.lowbyte * 1090
posn1 = div32 100 ;mm*100
posn2 = (enc_counter.highbyte&15) * 2794 ; mm*100
frac = (enc_counter.highbyte>>4) * 44680
posn3 = div32 100 ;mm
posn3= posn3 + (posn1+posn2)/100 ;mm
frac= ((posn1+posn2)//100 +10)/10 ;round it up
Lcdout $fe, 1
lcdout "Dist: ",dec posn3,".",#frac
Flag = 0
endif
goto Main_Loop
Now I can measure up to 7100mm, but still more or less precise.
Next step will be order one of the PIC18x mcu and try long variables.
Here are suitable to use the same encoder reading code (written in ASM) and simple change the word var to long var?
I think its not that easy. When I have the 18x PIC I think, I will need more help with this project. Thanks.
Bookmarks