this should correct the quadrature decoding ,the big problem with this technique for quadrature decoding is that its is completely intolerant to noise.;check to see if encoder has moved
movf _enc_old,W ;move enc_old to W
movwf _enc_tmp ;put W to enc_tmp
movf _enc_new,W ;move enc_new to W for XOR
xorwf _enc_tmp,F ;XOR enc_tmp to detect encoder movement
btfsc _enc_tmp,7 ;if bit is clear, encoder moved. ************Not sure what needs to happen here**************
goto Continue ;no movement exit isr
given that you encoder is optical I would expect noise problems would be minimal
Code:movf _enc_old,W ;move enc_old to W movwf _enc_tmp ;put W to enc_tmp movf _enc_new,W ;move enc_new to W for XOR xorwf _enc_tmp,F ;XOR enc_tmp to detect encoder movement btfsc STATUS,Z ;if result is not zero, encoder moved. goto Continue ;no movement exit isr




Bookmarks