At 04:48 AM 1/8/02 +0100, you wrote: >I am wondering, have anyone tested max speed for a polled program >decoding an rotary encoder ? Would an interrupt driven program >do better ? > >PIC16F877 @ 20 MHz. Approx 50 instructions in the active loop >Encoder is 100 pulses/rotation, quadrature decoding (400 flanks/rotation) >I have reached around 2000-2500 rpm. 3000 rpm gives overspeed error. Let's see, 3000 rpm is 60 rps, with 400 counts per revolution, that is about 24k counts per second. With some code tweaks, I think you could easily be doing more than 5x better than that as I got at least that many counts per second out of a 4MHz part before tweaking my code a bit more and using it on a 20MHz part - but I didn't test its performance after that. I think polled mode has a _slight_ edge if you aren't doing much else, I do recommend doing interrupts on encoders if accuracy is important, just make sure that all your other interrupts are kept to a minimum. Here are several examples you can look over to compare with your code: http://www.piclist.com/techref/microchip/qenc.htm Jeff -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics