Hi, I need help how to calculate distance using rotary encoder. I wanna show pulse in LCD.

The rotary encoder spesification as follows:-

Pulse/Revolution: 200 p/r
output: 2 phase, A & B
Micro C: PIC 16F877A, 4 MHz

I try the code below, but I cannot see the pulse of rotation exactly.

Code :


Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG PORTE
Define LCD_EBIT 1
define PULSIN_MAX 200
ADCON1 = 4 ' Set PortA 0, 1, 3 to A/D inputs

pulse VAR BYTE

loop:
pulsin portd.2, 1, pulse
Lcdout $fe, 1
Lcdout #pulse
Pause 1000

GOTO loop