Hi Richard, sorry for later response. Thanks for pointing me in to right way how to do it. Your first method not works for me, the second method polling works just fine but slows down the response time. The third method inc/dec detent counter only when enca and encb both = 1 works but count every second detent and also slowes down the reading.
My encoder has 30.position and give 15.pulses/rew. My solution is simply divide the CNT by 2.
Code:
enc_isr:
ev=ev<<2 ;shift last reading into position
ev=ev|((portb&12)>>2) ;read enc pins 2,3 mask off others then combine this reading with last reading
LOOKUP (ev&$f),[0,255, 1, 0, 1, 0, 0, 255, 255, 0, 0, 1, 0, 1, 255, 0],tmp ;lookup the decision matrix
if tmp then ; decide to inc , dec or ignore
if tmp.1 then
cnt=cnt+1
else
cnt=cnt-1
endif
endif
detent=cnt
detent=detent/2
By the way, here is the nearly finished product where i used this solution and skills learned here.
It's a stick welder controller with "advanced" functions like softstart, fan control, pulse welding, antistick, arcforce, hotstart, voltage and current measurement and so on.
It's based on PIC16F1847, when I used sw multiplexing, multiple interrupts, direct register controls, mixed code ASM/PB and so on.
Thanks for this great forum and helpful members, happy New Year to all.
Bookmarks