Hej a b. Tack fšr ditt meddelande 13:44 1999-10-05 -0700 enligt nedan: >Hello Picers..., > >Can anybody tell me how to read out a Rotary encoder with a pic (16f84)?? There was recently a thread about this! Subject "Quadrature incremental pot decoding on PIC" Search the Piclist archive... I forgot where it is... ... Is there an up to date piclist archive? Where? goto table method: (Probably have (IMHO) the shortest max process time, but not smallest code) First get two phase bits into the same byte as the old ones, by rotating them left into the storebyte position 0 and 1. The phase bits from previous time this routine was called is now in bit 2 and 3, and the now new bits will be used as old next time. (Also, earlier input states is now in bit 4:5 and 6:7, but whatfor?) : Total 8 cycles Then use theese four bits to telll what have happened: movf storebyte, W ;1 cycle andlw b'1111' ;1 cycle addwf PCL ,f ;2 cycles + 2 cycles for the goto selected in table ;Change Old New goto isrBchange_NO ; 0 0 0 0 goto isrBchange_UP ; 0 0 0 1 goto isrBchange_DN ; 0 0 1 0 goto isrBchange_ERR ; 0 0 1 1 goto isrBchange_DN ; 0 1 0 0 goto isrBchange_NO ; 0 1 0 1 goto isrBchange_ERR ; 0 1 1 0 goto isrBchange_UP ; 0 1 1 1 goto isrBchange_UP ; 1 0 0 0 goto isrBchange_ERR ; 1 0 0 1 goto isrBchange_NO ; 1 0 1 0 goto isrBchange_DN ; 1 0 1 1 goto isrBchange_ERR ; 1 1 0 0 goto isrBchange_DN ; 1 1 0 1 goto isrBchange_UP ; 1 1 1 0 goto isrBchange_NO ; 1 1 1 1 Timing is total 14 cycles, isosynchronous, including goto appropriate routine (count up/down/error/nochange) Then make ypur own routines, i.e isrBchange_DN for counting down your variable, etc The decode routine can be driven by interrupt on change on port B, or you can call it regularly to poll signals if interrupt on change is not available. Regards /Morgan >Every help is welcome, > Manny Thank's, > Joep Schroen (PD3ROG) Morgans Reglerteknik, HŠllekŒs, 277 35 KIVIK, SWEDEN tel +46(0)414-446620, fax -70331, mrt@iname.com