To accurately detect a change in frequency of the relaxation oscillator, two variables and one constant are used. The average variable keeps a running average of 16 previous samples from the TMR1 registers. This running average is used to eliminate noise created by changes in temperature, voltage, and environment. The raw variable holds the current value in TMR1 registers. The predetermined trip constant is the minimum difference between the raw data and the average value.