Abstract:
A digital high-pass filter derived from a digital low-pass filter of conventional design. The digital low-pass filter periodically calculates respective low-pass filter output values. Corresponding high-pass filter output values are then calculated by subtracting the low-pass filter output values from input samples provided by digitizing an input signal. The high-pass filter output values are then used to generate samples which are applied to a digital-to-analog converter for outputting a high-pass filtered replica of the input signal. The digital high-pass filter compensates for sudden, relatively large changes in the input signal by comparing the low-pass filter output value to the input sample and, in the event that there is a large discrepancy therebetween, setting the low-pass filter output value to the input sample before calculating the high-pass filter output value.

Description:
TECHNICAL FIELD 
     This invention relates to high-pass filters, and, more particularly, to a digital high-pass filter having means for restoring a filtered output signal to a zero volt baseline. 
     BACKGROUND OF THE INVENTION 
     In the field of electronics, a wide variety of filters are used to eliminate or select specific ranges or bands of frequencies. Low-pass filters are used to pass the spectral components of a signal that are below a cutoff frequency of the low-pass filter while attenuating spectral components that are above the cutoff frequency. Conversely, high-pass filters are used to pass the spectral components of a signal that are above a cutoff frequency while attenuating spectral components that are below the cutoff frequency. Band-pass filters are used to pass the spectral components of a signal falling within a predetermined range of frequencies while attenuating the frequency components above and below that range. 
     The most elementary low-pass and high-pass filters simply use a resistor connected in series with a capacitor. However, the current trend of implementing electronic devices using digital circuitry makes it less desirable to utilize these analog low-pass and high-pass filters. Therefore, various digital filtering techniques have been devised that can easily be implemented by properly programming a microprocessor that receives samples of the signal to be filtered. A digital low-pass filter can be easily derived by modeling the step response of an analog low-pass filter. Basically, the output of the low-pass filter changes by a magnitude equal to the exponential decay during the time between successive samples from the value of the prior output sample to the current input value. Although the step response of an analog low-pass filter can be easily modeled to provide a digital low-pass filter, it is substantially more difficult and processor intensive to implement a digital high-pass filter. In summary, while it has been relatively simple to implement a digital low-pass filter with modest processing requirements, it has not been heretofore possible to easily implement a digital high-pass filter without requiting substantially more processing power. 
     Another problem with digital high-pass filters results from baseline shift. In many field, such as medical electronics, a relatively low amplitude AC signal rides on a substantially greater DC voltage. In the event that only the AC is of interest, the signal is normally passed through a high-pass filter which then brings the AC signal down to a zero volt baseline. Thereafter, the AC signal can be greatly amplified. High-pass filters are capable of maintaining the AC signal on the baseline only if the rate at which the baseline shifts is relatively slow. If the baseline shifts at a sufficient rate that the spectral components of the shift are above the cutoff frequency of the high-pass filter, the shift will pass through the high-pass filter. Under these circumstances, the signal of the output of the high-pass filter will either saturate amplifiers downstream from the filter or cause a display of the AC waveform to extend beyond the visible bounds of the display. 
     SUMMARY OF THE INVENTION 
     It is an object of the invention to provide a digital high-pass filter that can be easily programmed using existing techniques for implementing digital low-pass filters. 
     It is another object of the invention to provide a digital high-pass filter that operates using relatively little processing power. 
     It is a further object of the invention to provide a digital high-pass filter that outputs a signal that can be easily restored to a zero volt baseline. These and other objects of the invention are provided by a fast response low-pass filter formed by first and second low-pass filters each of which receive a common input signal and output a respective output signal. The first filter has a relatively high cutoff frequency so that it accurately follows the input signal but fails to significantly attenuate tipple. The second filter has a cutoff frequency that is changed from a relatively low frequency to a relatively high frequency in response to a control signal. When the cutoff frequency of the second filter is relatively low it effectively attenuates tipple, although it may not always respond fast enough to accurately follow the input signal. When the cutoff frequency of the second filter is relatively high it, like the first filter, fails to significantly attenuate tripple, although it accurately follows the input signal. A comparator connected to the first and second filters compares the respective values of the first and second output signals to each other and generates the control signal when their difference exceeds a predetermined value. As a result, the fast response low-pass filter has a relatively low cutoff frequency to attenuate tipple until the input signal changes at a sufficient rate to cause the comparator to generate the control signal. The response time of the second filter then changes to the relatively high cutoff frequency so that it can accurately follow the input signal. The fast response low-pass filter may be implemented using either analog circuitry or digital filtering techniques. 
     Regardless of which technique is used, the comparator may generate the control signal to change the cutoff frequency from the relatively low frequency to the relatively high frequency when the difference between the first and second output signals is greater than a first predetermined value. Similarly, the comparator may terminate the control signal to change the cutoff frequency from the relatively high frequency to the relatively low frequency when the difference between the first and second output signals is within a second predetermined value. The first predetermined value may be greater than the second predetermined value to provide hysteresis to the changing of the cutoff frequency between the relatively high frequency and the relatively low frequency. 
    
    
     BRIEF DESCRIPTION OF THE DRAWING 
     FIG. 1 is a waveform diagram of a signal that can be advantageously filtered with the inventive high-pass filter. 
     FIG. 2 is a waveform diagram showing the waveform of FIG. 1 along with low-pass filtered and high-pass filtered versions of the input waveform. 
     FIG. 3A is a schematic of a typical low-pass filter. 
     FIG. 3B is a waveform diagram showing the waveforms input to and output from the filter of FIG. 3A. 
     FIG. 4 is a waveform diagram showing the manner in which the sampling of a waveform approximates a series of voltage steps. 
     FIG. 5 is a schematic of a typical high-pass filter. 
     FIG. 6 is a block diagram of a presently preferred embodiment of the inventive high-pass filter. 
     FIG. 7 is a flowchart of the software used to control a processor used in the embodiment of FIG. 6. 
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     Although the inventive digital high-pass filter can advantageously be used to filter virtually any type of signal having both high-frequency and low-frequency spectral components, an example of a signal that can be advantageously filtered with the inventive filter is illustrated in FIG. 1. The signal is shown with a relatively low amplitude AC component riding on a substantially larger DC component, known as a &#34;baseline&#34;. As shown in FIG. 1, the baseline initially drifts upwardly and then downwardly. The spectral components of this relatively slow drift can be well below the cutoff frequency of a high-pass filter that can be used to pass the AC components. However, at time t 1 , the baseline undergoes a substantial and very rapid shift. The rapid nature of this shift causes it to have frequency components that would inherently be above the cutoff frequency of a high-pass filter that would be used to pass the AC components of the signal. While the shift occurring between t 1  and t 2  could be eliminated by using a high-pass filter having a higher cutoff frequency, a higher cutoff frequency would attenuate the AC components of interest that are riding on the baseline. After the shift from t 1  -t 2 , the baseline of the signal shown in FIG. 1 once again drifts slowly downwardly and then upwardly. 
     As mentioned above, in order to display the AC signal of interest it is usually necessary to bring the AC signal down to a zero volt baseline. Relocating the AC signal to a zero volt baseline allows the signal to be amplified so that the AC components are readily viewable in a visual display. If the signal was not brought down to a zero volt baseline, amplification of the signal to the extent that the AC signal was readily visible would cause it to be offset outside the viewing area of the visual display. The problem of baseline drift and shifting is fairly common in the field of medical instrumentation and it is caused by such phenomena as artifact. 
     The response of a low-pass filter and a high-pass filter to the input signal of FIG. 1 is shown in FIG. 2. The input signal is shown as waveform A of FIG. 2. The waveform B of FIG. 2 shows the input signal after is has been filtered by a conventional low-pass filter. Note that the AC signal riding on the input is not present in the low-pass filtered output signal, but the rapid baseline shift occurring between times t 1  and t 2  has affected the output. 
     The waveform C shown in FIG. 2 is the output of a high-pass filter without a baseline restoration capability that has received the input waveform shown at the top of FIG. 2. Note that the AC signal is initially shown at a zero volt baseline. However, at time t 1 , the baseline suddenly shifts in the same manner as the input waveform. Thereafter, the baseline of the signal output from the high-pass filter exponentially decays to zero volts with the AC component riding on the exponential decay. However, because of the magnitude of the baseline shift, the AC signal, after being amplified and coupled to a visual display, would not be visible until the baseline signal returned to substantially zero volts at about time t 3 . The waveform D of FIG. 2 shows the output of the inventive high-pass filter which is the AC component of the input signal (waveform A) maintained at a zero volt baseline and immediately restored to a zero volt baseline at time t 2 . 
     FIG. 3A shows a convention low-pass filter 10 consisting of a resistor 12 connected in series between an input terminal 14 and an output terminal 16, and a capacitor 18 connected between the output terminal 16 and a common ground terminal 20. As is well known in the art, the transfer function of the filter 10 is fairly constant up until a cutoff frequency of the filter, and it then declines at the rate of 20 dB per decade. The cutoff frequency f c  is given by the formula: ##EQU1## where R is the resistance of the resistor 12 and C is the capacitance of the capacitor 18. 
     Viewed in the time domain, the filter responds to a voltage step applied to its input as shown in the waveforms of FIG. 3B. Specifically, at time t 0  the voltage applied between the input terminal 14 and the ground terminal 20 steps from 0 to V 1  volts, as shown in the upper waveform of FIG. 3B. The voltage V 1  gradually charges the capacitor through the resistor 12 so that the output voltage between the output terminal 16 and the ground terminal 20 gradually increases as shown in the lower waveform of FIG. 3B. The rate at which the output voltage responds to the voltage step applied to the input terminal 14 is a function of the time constant of the filter, which is equal to the product of the resistance of resistor 12 and the capacitance of capacitor 18. Mathematically, the time domain response of the filter is given by the formula: ##EQU2## 
     As illustrated in FIG. 4, an input waveform 30 is sampled at times t 1 , t 2 . . . t 6 . After each sample is taken, the value of the sample remains constant until a next sample is taken. Each of the samples thus creates a step waveform in which the voltage changes from the prior sample voltage to the voltage of the input waveform 30 when the sample is taken. The response of a low-pass filter to each of the samples is given by the formula: ##EQU3## As mentioned above, the cutoff frequency f c  of the filter 10 illustrated in FIG. 2 is given by the formula: ##EQU4## where R is the resistance of the resistor 12 and C is the capacitance of the capacitor 18. This equation can be rearranged to: ##EQU5## Substituting equation [3] into equation [1] yields the equation: ##EQU6## 
     In a digitized system, the voltage V c  is equal to V 0  from the previous sample. Sampling can also occur at a sufficient rate that the input voltage is essentially constant over the sample interval. Under these circumstances, the output voltage V 0 .sbsb.n for sample n is given by the formula: ##EQU7## The term 1-l -2 πf.sbsp.c t  can be represented by the constant K since the time constant of the filter is substantially longer than the interval between samples. It will be apparent to one skilled in the art that the term 1-l -2 πf.sbsp.c t  is an exponential increase from 0 to 1 as a function of time. For the limiting value of T equals 0, the constant K is equal to 1-l -0  which is equal to 1-1 which is equal to 0. For the limiting value of T equals infinity, the constant K equals 1-l - α  which equals ##EQU8## which can be reduced to ##EQU9## which equals 1-0 which is equal to 1. Under these circumstances, the output V 0 .sbsb.n can be given by the formula V 0 .sbsb.n =V 0 .sbsb.n-1 +KV 1 .sbsb.n -KV 0 .sbsb.n-1. Since the constant K will be a fraction having a value of between 0 and 1 which can be a problem in calculating using floating point arithmetic in a real time digitized system, the above equation can be rearranged to the equation: ##EQU10## which can be rearranged as follows: ##EQU11## 
     If the term ##EQU12## is defined as the term M, the above equation can be rewritten as: 
     
         MV.sub.0.sbsb.n =MV.sub.0.sbsb.n-1 +V.sub.1.sbsb.n -V.sub.0.sbsb.n-1.[8] 
    
     It will be apparent to one skilled in the art that the term M is an exponential decay from infinity to 1 as a function of time. For the limiting value of T equals 0, the term M is equal to ##EQU13## which reduces to ##EQU14## which is 1 divided by 0 or infinity. For the limiting value of T equals infinity, the term M is equal to ##EQU15## which equals ##EQU16## which can further be reduced to ##EQU17## which is equal to 1. It will also be apparent to one skilled in the art that an exponential decay from infinity to one and an exponential increase from zero to one are reciprocals of each other. If the term SUM is now defined as: SUM=MV 0 , then V 0  =SUM/M. Combining these equations yields: 
     
         SUM.sub.n =SUM.sub.n-1 +V.sub.1.sbsb.n -V.sub.0.sbsb.n-1.  [9] 
    
     The variable SUM is thus the sum of the variable SUM from the prior sample and an incremental step equal to the difference between the current input to the filter and the output from the filter just prior to taking the current sample. The variable SUM is thus, in effect, the sum of all incremental steps that have previously occurred. 
     One the variable SUM n  is calculated for each example, a corresponding low-pass filter output sample can then be calculated by the formula: ##EQU18## 
     With reference to FIG. 5, a single high-pass filter 40 can be implemented with a capacitor 42 connected in series between an input terminal 44 and an output terminal 46, and a resistor 48 connected between the output terminal 46 and a common ground terminal 20. 
     With reference also to FIG. 3A, it will be apparent that, for any input signal applied to the filters 10, 40, the signal across the capacitors 18, 42, respectively, will be the low-pass filtered input signal. Also, the signal across the resistors 12, 48, respectively, will be the high-pass filtered input signal. The sum of the high-pass signal V H  and the low-pass signal V L  is equal to the input signal V 1 , i.e., V 1  =V H  +V L . This equation can be rearranged as follows: 
     
         V.sub.H =V.sub.1 -V.sub.L                                  [ 11] 
    
     Equation 11 shows that the high-pass signal can be calculated simply by subtracting the low-pass signal from the input signal. As a result, a high-pass filter can be implemented by using a digital low-pass filter to obtain a low-pass signal, and then simply subtracting the low-pass signal from the input signal. 
     Assuming a sample rate of 1,000 samples per second, a low-pass filter can be implemented with a 10 Hz fast response filter and a 1 Hz low response ripple filter as follows: the value t in the above equations is given by 1/1,000=0.001. For the fast response filter, M is calculated as ##EQU19## M for the low response time ripple filter is calculated as ##EQU20## The inventive fast response time, low-pass filter can also be implemented digitally as illustrated in FIG. 6. As illustrated in FIG. 6, the input signal is supplied to an analog-to-digital converter 80 which digitizes the input signal and applies it to a microprocessor 82. The operation of the microprocessor 82 is controlled by a set of instructions stored in memory 84. The memory 84 is also used for other purposes, as is conventional in the art. The microprocessor 82 calculates a value corresponding to the output of the filter and applies a corresponding byte to a digital-to-analog converter 86 which then outputs a voltage V 0 . By choosing appropriate sample times for the analog-to-digital converter 80 and appropriate operating times for the digital-to-analog converter 86, the output voltage V OUT  accurately follows the input voltage V IN  without passing ripple present on the input signal V IN . 
     A flowchart of a program for controlling the operation of the microprocessor 82 is illustrated in FIG. 7. The program is entered at 100 where the current value of the low-pass filter voltage V LP  is set to zero and the current value of the high-pass filter output V HP  is set to zero. The program then reads a sample of the input voltage V IN  from the analog to digital converter 80 (FIG. 6) at step 102. The input sample V IN  is then compared to the current low-pass filter output value V LP  at 104 by comparing the absolute value of V HP  with a predetermined threshold V TH . If the absolute value is greater than the threshold, the program branches to step 106, where the low-pass filter output value V LP  is set to the current input sample V IN , thereby &#34;precharging&#34; the variable SUM. If the low-pass filter output value V LP  is fairly close to the input sample, the program instead branches to 108 where a new low-pass filter output value V LP  is calculated using the formula explained above. In either case, the high-pass filter output value V HP  is calculated at 110 by subtracting the low-pass filter output value V LP  from the current input sample V IN . The microprocessor 82 (FIG. 6) then outputs to the D/A converter 86 the high-pass output sample at step 112 before returning to 102 to once again read another input sample from the A/D converter 80. The D/A converter 86 then outputs a voltage corresponding to V HP . 
     The high-pass digital filter illustrated in FIG. 6 can also be implemented using the program shown in Table 1 in the C-language. 
     
                       TABLE 1______________________________________ 1       #define   m        16 2       #define   vth      25 3       int       sum 4       int       vhp 5       int       vin 6       int       vlp 7       void filter (void)    { 8             if(abs(V.sub.hp) &gt; V.sub.Th)          { 9                  V.sub.Lp = V.sub.in ;10                  Sum = m * V.sub.Lp ;          }11             Sum = Sum + V.sub.in - V.sub.Lp ;12             V.sub.Lp = Sum/m;13             V.sub.hp = V.sub.in - V.sub.Lp ;  }______________________________________ 
    
     The program defines the variable &#34;m&#34; as 16 in line 1 and, in line 2, it defines the threshold V TH  which is the maximum allowed deviation of V HP  from the zero volt baseline. Memory space is then reserved for the variables SUM, V HP , V IN , and VLP at lines 3-6, respectively. Line 7 is a void statement that serves as a program entry point and is called after each sample is taken. The program checks at line 8 to determine if the absolute value of the V HP  is greater than the threshold V TH . If the program determines at line 8 that the high-pass filter output V HP  is within the threshold V TH , the program branches to line 11 where the variable SUM is calculated according to Formula 9 on page 7. The variable SUM to the fight of the &#34;=&#34; sign in line 11 is calculated from the value of SUM from the previous input voltage sample V IN , and the variable SUM to the left of the &#34;=&#34; sign in line 11 is the new value of SUM. The program then calculates the low-pass filter output V LP  at line 12 using Formula 10 on page 7. The high-pass filter output V HP  is then calculated as the difference between the input voltage V IN  and the low-pass filter output V LP . As explained above, it is important that the low-pass filter be able to respond to substantial shifts in the baseline, and this is done by setting the low-pass filter output to the input. The programs sets the low pass filter output V LP  to the input voltage V IN  at line 9 and precharges the variable SUM at line 10 by setting it equal to the product of M and V LP . The program then performs the calculations at lines 11-13 as described above. 
     If the program determines at line 8 that the high-pass filter output V HP  is outside the threshold V TH , then the variable SUM is &#34;precharged&#34; to restore the baseline starting at line 9. After a high-pass filter output V HP  sample is calculated as explained above, it is output by the microprocessor 82 (FIG. 6) to the digital-to-analog converter 86 which then outputs a corresponding voltage. At line 14, the program then calls the void filter statement of line 7 to loop through lines 8-13 and calculate a subsequent high-pass filter output V HP  sample. 
     Instead of using the digital-to analog converter 86 to generate an analog output signal, the microprocessor 82 can directly drive a digital display (not shown) to display the numeric value of the high-pass filtered input signal or a graphic display (not shown) to plot the high-pass filtered value.