Variable names changed to protect the innocent. In C, for two encoders, ONE and TWO: Place this in your ISR to trigger each time the T0IF is set, or at whatever sampling rate you want: /********** read encoder state *********/ curr_enc_state = 0; curr_enc_state = (ONE_A << 3) | (ONE_B << 2) | (TWO_A << 1) | TWO_B; if(curr_enc_state != prev_enc_state) //test if changed { encoder_move = 1; //set fl ag prev_enc_state = curr_enc_state; //copy image } Then in a function somewhere, use this: if(encoder_move) { encoder_move = 0; curr_two_state = curr_enc_state & 3; curr_one_state = curr_enc_state >> 2; if(curr_two_state != prev_two_state) { dir = (prev_two_state & 1) ^ (curr_two_state >> 1); if(dir) { two--; if(two < TWO_MIN) { two = TWO_MIN; } } else { two++; if(TWO > TWO_MAX) { TWO = TWO_MAX; } } prev_two_state = curr_two_state; } if(curr_one_state != prev_one_state) { dir = (prev_one_state & 1) ^ (curr_one_state >> 1); if(dir) { one--; if(one < ONE_MIN) { one = ONE_MIN; } } else { one++; if(one > ONE_MAX) { one = ONE_MAX; } } prev_one_state = curr_one_state; } } The function allows changes between two extremes (MAX and MIN). Variables one and two hold the adjusted numbers. The premise is to do an XOR between the last state of channel 0 and the current state of channel 1. In my wiring, Clockwise movement results in a 0, thus advance the count; a 1 means reduce the count. Hope this helps. Craig > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Peter > Sent: November 24, 1999 1:02 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Shaft Encoder Interfacing. > > > Hello, > > Anyone with experience in interfacing a PIC with a shaft encoder before? > > I am quite new with PIC programming. > Can someone help? > > Cheers. >