augustinetez
Active Member
Thanks Dan, will give it a try later tonight.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
If the pins are a slight different in impedance it would.. As I said... The code works, so its definitely in hardware..I don't understand why it would act different with a different LCD either. However, crappy cheap mechanical encoders work perfectly happily with the algorithm I posted above as any bounce will cause an increment and then a decrement and no error will occur. The important thing is to read it as fast as possible. I could write the encoder routine in asm if it will help?
Mike.
The LCD pins or the encoder pins? Are pullups turned on? I've never had a problem with mechanical rotary encoder. Debounce just gets taken care of by the algorithm.If the pins are a slight different in impedance it would..
Ok... The SA1057 is an FM transmitter?? You have a DDS module.. Is it an AD9850?? Confused... An FM transmitter is a different beasty..but note that while trying to sort this problem, the SAA1057 is not connected (and it doesn't make any difference connected or not, to the problem).
getEncoder
rlf previous,f
rlf previous,w
andlw 0x0c ;keep only bits 2 & 3
btfss PORTA,0 ;move encoder bits
iorlw 1 ;to bits 0 & 1
btfss PORTA,1
iorlw 2
movwf previous ;keep for next time
addwf PCL,f ;index into table
dt 0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0
abAB
0000 = 0
0001 = +1
0010 = -1
0011 = invalid, treat as zero
0100 = -1
0101 = 0
0110 = invalid, treat as zero
0111 = +1
1000 = +1
1001 = invalid, treat as zero
1010 = 0
1011 = -1
1100 = invalid, treat as zero
1101 = -1
1110 = +1
1111 = 0
As I explained above, debounce is not required. If a contact bounces then it's exactly the same as going one step in one direction and one in the other - end result - zero. The code I've posted above works perfectly without debounce and contains the table you posted (only negative).The encoder you are using is awful for bounce so it needs more filtering than a resistor+capacitor on the A and B channels can provide.