Re: emulator quadrature encoder
Yes, you can use, just use timer1 and DT interrupt.
Assuming you will use the internal oscillator @ 8 MHz, timer1 should be set with prescaler at 1 tmr1h =252 and tmr1l = 24. This will give you the right timing.
Use the following array:
Chan VAR byte [4]
A0 VAR byte
Forward VAR bit
chan[0]=0
chan[1]=1
Chan[2]=3
Chan[3]=2
Within the ISR I will call overflow as an example you will write the following code:
Overflow:
If forward = true then
A0 = A0 + 1
If A0>3 then A0 = 0
Else
A0=A0 - 1
If A0>200 then A0 = 3
Endif
PortB = Chan[A0]
@Return
You will use portB.0 and portB.1 as your output. Set flag Forward to true (1) for channel A high prior of channel B, set flag to False (0) to reverse.
Cheers
Al.
Last edited by aratti; - 13th August 2012 at 15:56.
All progress began with an idea
Bookmarks