On Mon, 31 Jan 2005 23:14:01 +0100, Wouter van Ooijen wrote: > > No, I meant what I wrote. > > > > If the PID calculation was done in the background loop, there would be > > a variable number of instructions between the setting of the DO_IT_NOW > > flag and the start of the PID update. > > I don't grok this. Which instructions would be inbetween? There are > techniques to re-start a loop at fixed intervals, with zero jitter. while (TRUE) { if (DO_IT_NOW) pid_calculations(); code_a(); code_b(); code_c(); code_d(); } since the DO_IT_NOW flag could be set at any time by the interrupt (or the TMR1IF flag), the PID code could run immediately, or after all the other routines, or... Bill -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist