On Monday 21 April 2003 10:03 am, Ted Larson wrote: > >> Should a basic external interrupt routine work with a single > >> quadrature encoder running a maximum > >> about 1000 per second??? > > > >1000 quadrature cycles per second means 4000 edges per second, or > > one edge every 250uS on average. A 20MHz PIC has a 200nS > > instruction cycle time, and can therefore do 250uS / 200nS = 1250 > > instructions per edge. That's much more than needed to update a > > counter with the current shaft position, and will leave most of > > the processor available to process the result, send it elsewhere, > > or whatever. > > The problem I ran into is that I have 36,000 edges per second, or > one roughly every 28uS...this only gives me 140 instructions per > edge. Plus I want to monitor 2 encoders, so that means I only get > 70 instructions to decode each, plus deal with any other processing > I want to do. Assuming you're using the 18F parts, you can cut down significantly on the interrupt overhead for the fast interrupt. There have been some bugs having to do with mixing fast and normal interrupts, though; it's probably safer to make everything a fast interrupt. Plus you can run these up to 40 MHz (assuming you have recent silicon). -- Ned Konz http://bike-nomad.com GPG key ID: BEEA7EFE -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu