Algorithms for digital filtering of signals based on the theory of fuzzy sets titov dmitry anatolievich. Laboratory work Algorithms for filtering signals in the process control system goal - document System function of the recursive digital filter

Algorithms for analytical calibration, digital filtering exponential smoothing and moving average methods. Robust, high-pass, band-pass and notch filters. Discrete differentiation, integration and averaging of measured values.

A filter is a system or network that selectively changes the shape of a signal (amplitude-frequency or phase-frequency response). The main goals of filtering are to improve the quality of the signal (for example, to eliminate or reduce interference), to extract information from signals, or to separate several signals previously combined for, for example, effective use available communication channel.

Digital filter - any filter that processes a digital signal in order to highlight and / or suppress certain frequencies of this signal.

Unlike a digital filter, an analog filter deals with an analog signal, its properties are non-discrete (continuous), respectively, the transfer function depends on the internal properties of its constituent elements.

Simplified block diagram digital filter real time with analog input and output is shown in fig. 8a. Narrowband analog signal is periodically selected and converted into a set of digital samples, x(n), n = 0.1. The digital processor performs a filtering, mapping the input sequence x(n) to the output sequence y(n) according to the computational filter algorithm. The DAC converts the digitally filtered output to analog values, which are then analog filtered to smooth out and eliminate unwanted high frequency components.

Rice. 8a. Simplified block diagram of a digital filter

Work digital filters provided mainly software tools Therefore, they are much more flexible in application compared to analog ones. With the help of digital filters, it is possible to realize such transfer functions that are very difficult to obtain by conventional methods. However, digital filters cannot yet replace analog filters in all situations, so there remains a need for the most popular analog filters.

In order to understand the essence of digital filtering, first of all, it is necessary to determine the mathematical operations that are performed on signals in digital filtering (DF). To do this, it is useful to recall the definition of an analog filter.

Linear analog filter is a four-terminal network in which a linear transformation of the input signal into the output signal is realized. Mathematically, this transformation is described by an ordinary linear differential equation N-th order



where and are coefficients that are either constants or functions of time t; - filter order.

Linear Discrete Filter is a discrete version of the analog linear filter, in which the quantized (sampled) is the independent variable - time (- sampling step). In this case, an integer variable can be considered as "discrete time", and signals as functions of "discrete time" (the so-called lattice functions).

Mathematically, the function of a linear discrete filter is described by a linear difference equation kind

where and are the readings of the input and output signals, respectively; and - coefficients of the filtering algorithm, which are either constants or functions of "discrete time" n.

The filtering algorithm (2.2) can be implemented by means of analog or digital technology. In the first case, the readings of the input and output signals are not quantized by level and can take any values ​​in the range of their change (i.e., they have the power of the continuum). In the second case, signal samples and are subjected to level quantization, and therefore they can take only “allowed” values ​​determined by the bit depth of digital devices. In addition, quantized signal samples are encoded, so arithmetic operations, performed in expression (2.2), are performed not on the signals themselves, but on their binary codes. Due to quantization by the signal level and , as well as the coefficients and , the equality in algorithm (2.2) cannot be exact and is fulfilled only approximately.

Thus, a linear digital filter is a digital device that approximately implements the filtering algorithm (2.2).

The main disadvantage of analog and discrete filters is that when operating conditions change (temperature, pressure, humidity, supply voltages, aging of elements, etc.), their parameters change. It leads to uncontrolled output signal errors, i.e. to low processing accuracy.

The error of the output signal in the digital filter does not depend on the operating conditions (temperature, pressure, humidity, supply voltages, etc.), but is determined only by the signal quantization step and the algorithm of the filter itself, i.e. internal reasons. This error is controlled, it can be reduced by increasing the number of bits for representing digital signal samples. It is this circumstance that determines the main advantages of digital filters over analog and discrete ones (high signal processing accuracy and stability of digital filter characteristics).

Digital filters are subdivided according to the type of signal processing algorithm into stationary and non-stationary, recursive and non-recursive, linear and non-linear.

The main characteristic of the CF is filtering algorithm, on which the implementation of the digital filter is carried out. The filtering algorithm describes the operation of digital filters of any class without restrictions, while other characteristics have restrictions on the class of digital filters, for example, some of them are suitable for describing only stationary linear digital filters.

Rice. 11. CF classification

On fig. 11 shows the classification of digital filters (DF). The classification is based on the functional principle, i.e. Digital filters are subdivided based on the algorithms they implement, and not taking into account any circuitry features.

ZF frequency selection. This is the most well-known, well-studied and tested in practice type of digital filter. From an algorithmic point of view, frequency selection digital filters solve the following problems:

selection (suppression) of one a priori given frequency band; depending on which frequencies are suppressed and which are not, a distinction is made between a low-pass filter (LPF), a high-pass filter (HPF), a band-pass filter (PF) and a notch filter (RF);

· division into separate frequency channels of equivalent and uniformly distributed over the entire frequency range of the spectral components of the signal with a line spectrum; distinguish digital filter with decimation in time and with decimation in frequency; and since the main method of reducing hardware costs is the cascading of sets of PFs that are less selective than the original one, the resulting multistage pyramidal structure was called the digital filter of the "preselector - selector" type;

· division into separate frequency channels of the spectral components of the signal, whose spectrum consists of subbands of different widths, unevenly distributed within the operating range of the filter.

A distinction is made between a finite impulse response filter (FIR filter) or an infinite impulse response filter (IIR filter).

Optimal (quasi-optimal) digital filters. This type of filters is used when it is required to estimate certain physical quantities characterizing the state of a system subject to random disturbances. The current trend is the use of the achievements of the theory of optimal filtering and the implementation of devices that minimize the mean square of the estimation error. They are divided into linear and non-linear depending on what equations describe the state of the system.

If the equations of state are linear, then the optimal Kalman digital filter is used; if the equations of state of the system are nonlinear, then various multichannel digital filters are used, the quality of which improves with an increase in the number of channels.

There are various special cases when algorithms implemented by optimal (quasi-optimal) digital filters can be simplified without a significant loss of accuracy: this is, firstly, the case of a linear stationary system, leading to the well-known Wiener digital filter; secondly, the case of observations only at one fixed point in time, leading to a digital filter that is optimal according to the criterion of the maximum signal-to-noise ratio (SNR); thirdly, the case of equations of state of the system close to linear leading to nonlinear filters of the first and second order, etc.

An important problem is also to ensure the insensitivity of all the above algorithms to the deviation of the statistical characteristics of the system from predetermined ones; synthesis of such digital filters, called robust ones.

Adaptive CFs. The essence of adaptive digital filtering is as follows: to process the input signal (usually adaptive digital filters are built as single-channel ones), a conventional FIR filter is used; however, the IR of this filter does not remain set once and for all, as it was when considering the digital filter of frequency selection; it also does not change according to an a priori given law, as it was when considering Kalman's CF; IR is corrected with the arrival of each new sample in such a way as to minimize the mean square filtering error at this step. An adaptive algorithm is a recurrent procedure for recalculating the vector of IC samples at the previous step into a vector of “new” IC samples for the next step.

Heuristic CFs. There are situations when the use of processing procedures that are correct from a mathematical point of view is impractical, since it leads to unreasonably large hardware costs. The heuristic approach is (from Greek and Lat. Evrica- “I search”, “discover”) in the use of knowledge, studying the creative, unconscious thinking of a person. Heuristics is associated with psychology, physiology of higher nervous activity, cybernetics and other sciences. The heuristic approach is "generated" by the desire of developers to reduce hardware costs and has become widespread despite the lack of a rigorous mathematical justification. These are the so-called digital filters with author's circuit solutions, one of the most famous examples is the so-called. median filter.

Introduction

1. Analysis of the state of the issue of digital signal filtering, including filtering non-stationary random signals 9

1.1 Linear digital filtering algorithms 9

1.2 Algorithms for optimal digital filtering 11

1.3 Algorithms for adaptive digital filtering 14

1.4 Digital filtering algorithms based on fuzzy set theory "19

1.5 Neural network digital filtering algorithms 27

1.6 Conclusions 33

2. Development of algorithms for digital signal filtering based on the theory of fuzzy sets 35

2.1 Development of the low-pass filter algorithm 35

2.2 Development of a bandpass (notch) filter algorithm 58

2.3 Evaluation of membership functions of fuzzy sets - 65

2.4 Digital filtering criteria used 66

2.5 Analysis of digital filtering algorithms 68

2.6 Conclusions 72

3. Designing digital filters based on the developed algorithms 73

3.1 Designing a Digital Low Pass Filter 73

3.2 Band-pass (notch) filter design 75

3.3 Conclusions 77

4 Computer simulation of digital filters 78

4.1 Computer model of a digital low-pass filter 79

4.2 Computer model of a band-pass (notch) filter 105

4.3 Conclusions 108

5 Experimental studies 109

5.1 Investigation of a computer model of a digital low-pass filter 115

5.2 Investigation of a computer model of a notch filter 134

5.3 Conclusions136 CONCLUSION137 LITERATURE139 APPENDICES148

Introduction to work

Relevance of the topic. In a number of areas of technology, the shape of signals is associated with the object of study, an example of this is radar, technical and medical diagnostics, telemetry, etc. As a rule, non-stationary random signals of short duration take place here. As a result of processing such signals, for example, using a linear digital filter, their shape, and, consequently, the diagnostic features contained in it, can be greatly distorted. In this regard, the development of digital filtering algorithms for signals aimed at preserving their original (not distorted by noise) form is of particular relevance. In modern literary sources devoted to the metrological support of radio measurements (in particular, in the works of V.I. Nefedov), the signal shape is defined as the dependence of the instantaneous value of the signal on time.

Consider, for example, an electrocardiogram (ECG) signal. As you know, the ECG curve has a characteristic shape containing the so-called teeth (extreme points): P, Q, R, S, T. Each of these teeth corresponds to a certain process of occurrence and conduction of electrical excitation in the heart muscle. Establishing a diagnosis in this case is reduced to determining the quantitative signs of diseases using the shape of the teeth. Quantitative signs are understood as the amplitude of the teeth, their duration, time intervals between the teeth, etc. The difficulties that arise when filtering noisy ECG signals are that the characteristics of the signals under different patient conditions differ significantly from each other. So, for example, a linear digital filter designed for optimal selection of a normal cardiogram from a mixture with white Gaussian noise distorts the amplitudes of the teeth of cardiograms with different

diseases. When analyzing an ECG signal that has been processed using a linear digital filtering algorithm, a disease (defect) is skipped. Similar difficulties arise in the recognition of curves in technical diagnostics. Here, information about the state of the system (machine) is contained in the form of a record of the values ​​of the diagnostic parameter or its deviations from the normal at various points in time. An example is the time recording of engine vibration level values.

If adaptive algorithms (adaptive digital filters) are used for waveform-preserving digital filtering, then a number of difficulties also arise for them, since the purpose of applying the adaptive signal filtering algorithm is to achieve a local or global extremum of the quality functional. In the problem of preserving the original waveform, the quality functional is understood as the dependence of the mean squared error (RMS) on the adaptation parameters of the digital filter. If the statistical properties of the signals change over time, then the quality functional can be considered "fuzzy" or fuzzy, i.e., changing its shape and location relative to the entered coordinate system. In this case, the adaptation process consists not only in moving towards the extremum point, but also in tracking this point, since it changes its location in space. Under the conditions considered, the use of adaptive algorithms based on the principles of optimal linear filtering is inefficient and irrational in terms of computational costs. Thus, in order to solve the problems of digital filtering with the preservation of the signal shape, the development of alternative algorithms for digital signal filtering, which makes it possible to compensate for the lack of statistical characteristics with the help of a training sample, is of particular relevance.

One of the options for constructing digital filtering algorithms that preserve the original shape of the signals is the use of fuzzy logic. Adaptive filters based on algorithms with fuzzy logic have increased performance and provide a lower filtering error due to a more adequate description of the processed signals. "Neural networks serve as an alternative to fuzzy logic, however, the implementation of neural network systems for digital signal filtering is hindered by the extremely high complexity of the training procedure. All this makes it very actual development of existing, as well as the creation of new digital filtering algorithms using fuzzy logic, which provide more high quality restoring the shape of random signals, including non-stationary ones.

The purpose of the dissertation work is development of digital filtering algorithms based on the theory of fuzzy sets for signals with different spectra.

To achieve this goal, the following tasks were solved in the dissertation:

    The existing algorithms for digital signal filtering using fuzzy logic and artificial neural networks.

    Algorithms for digital filtering of signals based on the theory of fuzzy sets have been developed.

    The design and computer implementation of digital filters with fuzzy logic have been carried out.

    An experimental verification of the developed digital filters has been carried out.

Research methods. When performing the work, the provisions of the general theory of radio engineering signals, the theory of fuzzy sets, numerical methods, methods of computational mathematics and the theory of

programming, methods of statistical processing of experimental data.

Scientific novelty. The solution of the tasks set determined the novelty of the dissertation, which is as follows:

    A modified signal digital filtering algorithm based on the theory of fuzzy sets has been developed, the distinctive feature of which is the adaptive change of membership functions depending on the values ​​of the first-order finite differences of the signal.

    An algorithm for digital signal filtering has been developed, which makes it possible to tune the filter center frequency in accordance with the signal characteristics while maintaining all other filter parameters.

The following are submitted for defense:

    Signal Digital Filtering Algorithm with Adaptively Variable Membership Functions.

    Algorithm for digital filtering of signals with a variable center frequency of the filter while maintaining all other parameters.

The practical significance of the research.

Developed in the dissertation software is of practical importance, since it allows to reduce the time spent on designing radio engineering devices such as a digital filter with fuzzy logic by almost 10 times.

Implementation and implementation of the results of the work. The developed algorithms and software have been implemented in LLC NTK "Intellectual complex systems”, as well as in the NOU “Institute of Radio Electronics, Service and Diagnostics”, which is confirmed by the relevant acts.

Approbation of work. The main provisions of the dissertation work received a positive assessment during the discussion at 9 international and all-Russian conferences, including:

VII International Conference "Actual problems of electronic
Instrumentation” (Novosibirsk, 2004);

III International Technological Congress "Military equipment, weapons
and dual-use technologies” (Omsk, 2005).

Publications. On the topic of the dissertation, 13 printed works were published, of which 2 - articles in scientific periodicals, 10 - materials and abstracts of reports in the proceedings of international and all-Russian conferences, 1 - certificate of industry registration of the development.

Structure and scope of work. The thesis consists of an introduction, five chapters, a conclusion, and applications. The total volume of the dissertation is 159 pages. The main text is set out on 138 pages, includes 73 figures, a bibliography of 86 titles.

Optimal Digital Filtering Algorithms

AT general case An optimal filter can be defined as a frequency selective system that performs the processing of the sum of signal and noise in some best way. This type of filters is used when it is required to estimate certain physical quantities characterizing the state of a system subject to random disturbances. The current trend in the development of optimal digital filters is the implementation of devices that minimize the RMS of the estimation. Optimal digital filters are divided into linear and non-linear depending on what equations describe their state.

Let there be two probabilistically related random process d(t) and x(t), while the first process is the useful signal, and the second is the received oscillation in the form of the sum of the useful signal and some noise u(/):

It is required to estimate the signal d(t) from the available observation х(ґ). The required estimate d(t) must be obtained at some points t = v, x v t2, x and tl are some constants.

When solving the problem, it is assumed that all the necessary probabilistic characteristics of the processes d(t) and x(t), as well as the observational data x(u), and є (tl,t2), are given. As an optimality criterion, we take the minimum standard deviation criterion: the mathematical expectation of the square of the error, where M is the operator of the mathematical expectation, should be minimal. Consider the case of linear estimation for continuous time t, i.e., we will look for an estimate in the form

In this case h(y) - impulse response estimation system (optimal stationary filter). The function h(y) is found as a result of solving the Wiener-Hopf integral equation: (v) is the optimal (Wiener) impulse response of the system.When h(v) - h(v), the mathematical expectation of the squared error is minimal. From equation (1.6), an expression is obtained for calculating the minimum RMS value when using the optimal linear system. Signal processing using non-linear filtering methods is detailed in the references.

One of the best known is Kalman's optimal digital filtering algorithm. This algorithm implements a recursive adaptation procedure based on an autoregressive model of the signal generation process. If the input signal is random and Markovian, then it can be represented as the output signal of a linear discrete system excited by white noise w(ri) with zero mean and variance ow .

The signal generation model is described by the expression where a is some constant. It is assumed that the signal passes through the communication channel, the impact model of which is described by the equation where c is a constant describing the amplitude changes of the signal; u(w) is additive white noise with zero mean and variance cu . Kalman's optimal digital filtering algorithm makes it possible to obtain an estimate d(ri) as close as possible to the signal d(n) according to the minimum standard deviation criterion. The expression that describes the algorithm has the form: where

The value of K(s) is called the "confidence factor" and depends on the noise parameters of the communication channel and the current RMS value. Synthesis of optimal digital filters is possible only if there is a priori information about the statistical characteristics of the signal and noise, as well as about the method of combining the signal and noise. An important problem is also to ensure the insensitivity of all the above algorithms to the deviation of the statistical characteristics of the system from the predetermined ones. The synthesis of such digital filters, called robust ones, is described in detail in .

In many cases, digital filters with constant parameters cannot be used because the correlation properties of the input and reference signals are unknown or change over time. Therefore, it is necessary to first train the digital filters on the training statistics, and then monitor them if they change slowly. If the frequency characteristics of digital filters depend on the spectra of the processed signals, then such filters are called adaptive. The monographs of Ya. 3. Tsypkin, R. L. Stratonovich, V. V. Shakhgildyan, M. S. Lokhvitsky, B. Widrow and S. Stearns can be considered fundamental works on the synthesis of adaptive digital filters.

In this work, adaptive is understood as such a decision-making algorithm, in the construction of which preliminary training is used to overcome a priori uncertainty. The main task of the adaptive filter is to improve the quality of signal processing. An ordinary FIR filter is used to process the input signal, however, the impulse response of this filter is not set once and for all, as it was when considering digital frequency selection filters. At the same time, it also does not change according to an a priori given law, as in the case of the Kalman filter. Requirements for the frequency response of adaptive filters are usually not specified, since their characteristics change over time.

Development of a Bandpass (Notch) Filter Algorithm

Taking into account the research carried out in the dissertation, an algorithm for digital filtering of signals with a variable center frequency of the filter was also developed, while maintaining all its other parameters.

The digital filtering algorithms presented in some well-known works are designed to be used as the basis of low-pass filters, and their adaptation to changing signal characteristics is carried out by changing the filter bandwidth. In many practical cases, the signal spectrum is concentrated in a certain band, i.e., problems arise that require the creation of band-pass or notch filters with a variable center frequency.

Let's return to equation (2.12) and once again write down the corresponding transfer coefficient:

Approximation and implementation capabilities of a particular type of filters are determined by the values ​​of the amplitude function (or frequency response) that they acquire at the boundaries of the main frequency range, i.e., at frequencies β = 0 (f = 0) and ω = i (f = i q/2), regardless of the coefficients. Let us analyze the frequency response values ​​at frequencies o = 0 and w = n. As already discussed in this chapter, at a frequency of β = 0, the value of the frequency response for any coefficients will be equal to one, and at a frequency of u = %, we obtain (for L = 8):

Thus, at a frequency ω \u003d i, the value of the frequency response will be completely determined by the filter coefficients, i.e., the samples of its impulse response. From all of the above, the properties of any discrete filters follow, the frequency transfer coefficient of which is described by expression (2.20): 1. It is possible to implement low-frequency, multi-frequency and rejector selectivity filters; 2. It is impossible to design bandpass and high-frequency filters. Statement 3. The operation of a digital bandpass filter is described by the formula where s are the coefficients that determine the center frequency; bk є .

Proof. As is known, the transfer of the signal spectrum to the region of high frequencies means the transition from a video pulse to a radio pulse. A similar statement applies to the frequency response of digital filters. In general, the transfer coefficient digital device when multiplying its impulse response by the harmonic function will be determined by the expression

When a signal is multiplied by a harmonic function, its spectrum breaks up into two terms of half the level, shifted by W0 to the right (co + W0) and to the left (co - o) along the frequency axis. Thus, expression (2.22) can be written in the following form: samples of a harmonic signal. To create a band-pass filter, it is necessary that the condition Kp (co0) = 1 be satisfied, therefore, a factor of 2 appears in expression (2.22). Based on formula (2.22), we can write an algorithm for digital signal filtering, which will have a frequency response of the band-pass filter

The assertion has been proven. Taking into account the tunable coefficients and the artificial shift of the origin of the variable k, expression (2.23) takes the form:

In expression (2.24), the weight coefficients u(xn_L) determine the width, and s(xn.k, k)=sn_k is the center frequency of the filter.

The adaptation of the center frequency of the filter, i.e. the coefficients sn.k, can be carried out as follows. Let a mixture of a harmonic signal and Gaussian noise be fed to the filter input:

As is known, the mathematical spectrum of a harmonic signal is a delta function located at frequencies ±co0. Therefore, it is necessary to choose a filter with the narrowest bandwidth. The smallest bandwidth at given order has a uniform filter. Therefore, all coefficients \i(xn_k) will have the same value l/(2iV+l), and sw_A will be equal to cos((o0(n-k)T + p0) .

According to the principles set out in the work, the width of the signal spectrum is estimated using the differences Axn_k = xn-xn_k. The same differences can also be used to estimate the signal frequency o0. In our case, the useful signal is periodic, i.e., the condition for the presence of a synchronous channel for the formation of reference oscillations is fulfilled, the equality of the estimated sample of the signal xn and the sample spaced in time by k sampling periods means that the central frequency of the signal takes a value from the set co0 = 2n-fjk . In this case k = ±2, ±3, ... ±N, kf ±\. In other words, each sample of the signal хп_к can be considered from the point of view of belonging to fuzzy sets F = SIGNAL WITH CENTRAL їАІк, к Ф ±1. One of the possible forms of the membership function \і?(xn_k) of fuzzy sets F has the form shown in Fig. 2.3(a).

To find the values ​​of sn_k, it is necessary to implement a number of fuzzy rules: “Rk: if Axn_k is close to zero, then the center frequency of the filter should be close to fa/b. These rules will be combined in the future. Based on the results of their combination, an estimate of the frequency of the signal ω0 will be obtained. The representation of the range of variation of the filter center frequency in a fuzzy space (fuzzification ) is made as a family of fuzzy sets fk = FILTER CENTER FREQUENCY ABOUT ijk with separate membership functions Hjt(fo), which is shown in Fig. 2.14.

Designing a band-pass (notch) filter

According to the linear digital filtering algorithm, a block diagram of a physically implemented device can be built. At the same time, it includes blocks that perform addition, multiplication by a weight coefficient, as well as a delay in signal samples by one sampling interval. We obtain a block diagram of a digital filter that implements algorithm (2.19). From the possible forms of implementation, we choose the direct form, as the most clearly illustrating the algorithm underlying it. As was considered earlier, formula (2.19) differs from expression (2.1) by variable coefficients \i(xn.k, k, b), as well as by the presence of a denominator. Consequently, the block diagram of the filter based on the algorithm (2.19), in addition to the standard blocks of a linear digital filter, will contain a division block and an additional adder that calculates the sum of the weight coefficients. In addition, the block diagram will also contain a weight calculator block. Thus, the block diagram of the digital low-pass filter will have the form shown in Fig. 3.1.

An adaptive digital filter with algorithm (2.19) has the following characteristics (at a signal sampling rate of 250 Hz and N=4):

Taking into account all that has been said above, algorithm (2.24) can also be used to construct a block diagram of a digital filter .

According to Chapter 2, for a digital filtering algorithm with a variable center frequency of the filter, it is necessary to have membership functions I F (X "-) and (fo), which determine the values ​​of s ( x "4, k). In addition, algorithm (2.24) retains the coefficients \i(xn.k) that determine the bandwidth of the filter. Therefore, the block diagram of the bandpass filter will be close to the circuit in Fig. 3.1, however, additional multipliers of signal samples by coefficients s(xn.k, k) will appear in it. The case of the direct form of expression (2.24) is shown in fig. 3.2.

On the basis of the bandpass one can build a notch filter by transforming transfer function. As you know, the high-pass filter is the difference between the all-passing yn=xn and low-pass filters. One of the options for constructing a notch filter is the parallel connection of an all-passing and previously considered band-pass filters according to the circuit shown in Fig. 3.3.

In this chapter, the design of low-pass filters, as well as band-pass and notch filters with fuzzy logic, was carried out. In particular, block diagrams of adaptive digital filters have been developed using algorithms (2.19) and (2.24). The presented block diagrams allow microprocessor implementation of the developed algorithms on their basis, and can also be used to create programs in various simulation systems for the purpose of experimental research.

Based on the results of the research, computer simulation of the developed digital filters was performed. To create computer models, the MATLAB 6.5 system was used, which has significant advantages over existing ones. mathematical systems and packages. The MATLAB system was created for scientific and engineering calculations and is focused on working with data arrays. The mathematical apparatus of the system is based on calculations with matrices, vectors, complex numbers. The programming language of the MATLAB system is quite simple and contains only a few dozen operators. The small number of operators is compensated by the procedures and functions that are available for correction and modification. Recording programs in the system is traditional and therefore familiar to most users. The system uses a mathematical coprocessor and allows access to programs written in FORTRAN, C and C++. The system also has great capabilities for working with signals. In stock available a large number of specialized extension packages designed to solve various classes of mathematical and technical problems. In addition, the system is significantly ahead of many other similar programs in terms of the speed of operations. All these features make the MATLAB system very attractive for solving very many classes of problems.

The Simulink package of the MATLAB system allows you to simulate dynamic nonlinear systems. The characteristics of the systems under study are entered in an interactive mode, by graphical assembly of the connection diagram of standard elementary links. Elementary links are blocks (or modules) stored in the built-in library. The content of the library can be

Computer model of a band-pass (notch) filter

The author of the work also carried out a simulation of a band-pass (rejector) digital filter based on the theory of fuzzy sets. The computer model in the MATLAB software environment was registered with the industry fund of algorithms and programs. General form models for the case of tuning the center frequency of the filter from fJ5 to і d/3 (at N=4) is shown in Fig. 4.23. As before, the additive mixture xx (the output of the Suml block) of the useful signal from the From Workspace block and the noise from the Noise source is fed to the input of the Delay line subsystem. The structure of this subsystem has already been mentioned by us, and its appearance was presented in Fig. 4.2. The vector of samples of the input signal X is divided by elements using a demultiplexer, which are then fed to the inputs of the same type subsystems Subsystem1 - Subsystem6 (see Fig. 4.23). The internal structure of the Subsysteml subsystem is shown in fig. 4.24. This subsystem is used to find the values ​​of HF(X„.) (see Chapter 2 of this work). The subsystem calculates the difference between the signal samples (in this case, these are the xn_8 and xl_3 samples) and uses it as the input signal of the Gaussian MF block (see Fig. 4.24). The Gaussian MF block outputs the values ​​of the Gaussian function, the argument of which is the difference х„_8 - х„_3. The output signals of the Subsysteml-Subsystem6 subsystems are fed to the MinMaxl - MinMax3 blocks (see Fig. 4.23). These blocks are used to combine the rules regarding the variables I x "xn-k I and I chi" xn + k I and output the minimum of the two inputs. 4.24 signals. The outputs of the MinMaxl - MіnMax3 blocks are directed to the MATLAB Fcn2 - MATLAB Fcn4 blocks, respectively. In this case, the outputs MinMaxl - MіnMax3 are formed into a three-dimensional vector and fed to the input of the MATLAB Fcnl block.

First of all, consider the action of the MATLAB Fch2 - MATLAB Fcn4 blocks. Applications 11-13 show the programs executed by these blocks. Each of the programs calculates all possible values ​​of the coefficients s(x„.A) and, depending on the input signal, selects the necessary ones from them. Each of the blocks produces four-dimensional vectors consisting of the values ​​sn+l,sn+2 Sw+3 sn+4 The program according to which the MATLAB Fcnl block works is presented in Appendix 10. The operation of this program has already been discussed in detail in this chapter. In this computer model, it is used to select the vector of coefficients s(x„.A). The output signal of the MATLAB Fcnl block is fed to the control input of the Multiport Switch 1 switch. Next, the four-dimensional switch output signal is divided into elements using a demultiplexer and sent to the inputs of the Product 1 - Product 8 multipliers (Fig. 4.23). These blocks multiply the samples of the xn_k signal and the coefficients s(xn.A) according to expression (2.24). In this paper, we consider a computer model of a digital filter with a constant bandwidth (notch). In the case under consideration, the passband (rejection) has the smallest width for a given filter order. Therefore, all coefficients \i(xn.k) are equal to one, and their sum is equal to 9. Thus, the denominator of expression (2.24) is represented as a Constantl block (Fig. 4.23). The numerator (2.24) is the adder signal Sum2, and the division operation is performed using the Product 9 block. The output signal of the divider is doubled (Gain 1 block) and sent to the output of the digital filter.

This chapter has developed computer programs, modeling the action of an adaptive digital low-pass filter based on the theory of fuzzy sets and allowing in the training mode to tune the membership functions. Also, a computer model of a bandpass (rejector) filter with a variable center frequency of the filter was developed.

The computer models of digital filters considered in the previous chapter have been applied to the processing of various signals. First, the case was considered when digital filters based on the theory of fuzzy sets are trained on signals in the absence of noise, and noise is applied only to the testing sample. In the second case, noise-added signals were used as a training sample. Further, until the end of the chapter, only the second case of training will be considered, since it is more effective.

The characteristics of the LPF computer model considered in this paper were compared with the characteristics of filter models based on previously known algorithms. For comparison, computer models of a digital filter based on the algorithm of Japanese scientists K. Arakawa and Y. Arakawa and a linear digital filter were used. Further, the digital low-pass filter model with adaptively variable membership functions will be referred to as F1, the linear digital filter model as LPLF, and for the filter model from the work we will leave the name proposed by its authors - SFF (see Chapter 2).

To study the characteristics of the LPF, fragments of digitized real cardiograms posted on the website http://www.physionet.org were used.

The absolute error of calculations at computer simulation does not exceed 10"7, which is determined by the limits of the permissible absolute error set by the user.

As you know, any electrocardiogram is a graphical display of potential fluctuations on the surface of the body, due to the work of the heart. The ECG curve has a characteristic shape containing the so-called teeth (extreme points): P, Q, R, S, T. Each of these teeth corresponds to a certain process of occurrence and conduction of electrical excitation in the heart muscle.

The most important step in the analysis of the cardiogram is the analysis of the waves (analysis of the atrial P wave and the QRS complex). Establishing a diagnosis is reduced to determining the quantitative signs of diseases using the shape of the teeth. Quantitative signs are understood as the amplitude of the teeth, their duration, time intervals between the teeth, etc. As for the form, here information about the disease is mainly based on the presence of splitting, or expansion of the top. Of great importance is the polarity of the P and T waves.

Karasev Oleg Evgenievich

St. Petersburg State Polytechnic University

Faculty of Technical Cybernetics

Department of Automation and Computer Engineering

REPORT

on laboratory work No. 3

Study of recurrent digital filtering algorithms

signals by the averaging method.

Performed by student gr. 4081/1 Volykhin A.N.

Checked by: Yarmiychuk V.D.

St. Petersburg

1. Goals of the work

The purpose of the work is to get acquainted with various algorithms for digital filtering of signals by the averaging method and to study the effectiveness of their work under conditions when a “white noise” type interference with zero mathematical expectation is superimposed on the useful signal and

adjustable dispersion.

2. Research methodology

Filters based on the following algorithms are studied:

one). Recurrent averaging algorithm with infinite memory.

The purpose of the filter is to highlight the constant component of the useful signal against the background of noise.

The expression for it in recursive form is:

When it provides .

2). Recurrent averaging algorithm with constant correction factor.

The purpose of the filter is to highlight the low-frequency components of the input useful signal against the background of noise.

If we accept , then we can write this equation in the form:

Whence, in the transition to continuous time, we obtain the transfer function of the filter:

That is, a filter built according to such an algorithm, for small values, is equivalent to

analog low-pass filter of the first order.

3). Recurrent averaging algorithm with finite memory.

The purpose of the filter is to highlight the low-frequency components of the input signal

using averaging only a limited number of its latest measurements.

The efficiency of digital filtering, that is, the measure of reducing the noise level at the filter output compared to the noise level at the input, will be estimated as follows:

Where: - noisy signal at the filter input

Useful signal at the filter input

Filter output signal

Useful signal at the filter output

3. Scheme of the experiment (see Appendix 1)

4. Results of the experiment

4.1. Recurrent averaging algorithm with infinite memory

The studies were carried out at a constant sampling period of 100 ms.

Let's consider how the efficiency of the filter changes from the value of the constant input signal (X).

Physically feasible digital filters that operate in real time can use the following data to generate an output signal at a discrete time point: a) the value of the input signal at the moment of sampling, as well as a certain number of “past” input samples, a certain number of previous samples of the output signal Integer numbers type determine the order of the digital filter. The classification of the digital filter is carried out in different ways depending on how information about the past states of the system is used.

Transversal CFs.

So it is customary to call filters that work in accordance with the algorithm

where is a sequence of coefficients.

The number is the order of the transversal digital filter. As can be seen from formula (15.58), the transversal filter performs a weighted summation of previous samples of the input signal and does not use past samples of the output signal. Applying the z-transform to both parts of the expression (15.58), we see that

It follows that the system function

is a fractional-rational function of z that has an -fold pole at and zeros whose coordinates are determined by the filter coefficients.

The operation algorithm of the transversal digital filter is illustrated by a block diagram shown in fig. 15.7.

Rice. 15.7. Scheme for constructing a transversal digital filter

The main elements of the filter are the blocks for delaying the reference values ​​by one sampling interval (rectangles with the symbols ), as well as scale blocks that perform digital multiplication operations by the corresponding coefficients. From the outputs of the scale blocks, the signals enter the adder, where, when added together, they form the output signal count.

The type of scheme presented here explains the meaning of the term "transverse filter" (from the English transverse - transverse).

Software implementation of transversal digital filter.

It should be borne in mind that the block diagram shown in Fig. 15.7 is not circuit diagram electrical circuit, but only serves graphic image signal processing algorithm. Using the FORTRAN language tools, let's consider a fragment of a program that implements transversal digital filtering.

Let in random access memory The computer formed two one-dimensional arrays of length M cells each: an array named X, which stores the values ​​of the input signal, and an array named A, containing the values ​​of the filter coefficients.

The content of the cells of the X array changes every time a new sample of the input signal is received.

Let us assume that this array is filled with previous samples of the input sequence, and consider the situation that occurs at the moment of arrival of the next sample, which is given the name S in the program. This sample should be placed in cell number 1, but only after the previous record is shifted by one position to the right, i.e. in the direction of delay.

The elements of array X thus formed are multiplied term by term by the elements of array A, and the result is entered into a cell named Y, where the reference value of the output signal is accumulated. Below is the text of the transversal digital filtering program:

impulse response. Let's return to formula (15.59) and calculate the impulse response of the transversal digital filter by performing the inverse z-transform. It is easy to see that each term of the function gives a contribution equal to the corresponding coefficient shifted by positions towards the delay. So here

This conclusion can also be reached directly by considering the block diagram of the filter (see Fig. 15.7) and assuming that a "single pulse" is applied to its input.

It is important to note that the impulse response of a transversal filter contains a finite number of terms.

frequency response.

If in formula (15.59) we change the variable, then we get the frequency transfer coefficient

With a given sampling step A, it is possible to implement a wide variety of frequency response forms by properly selecting the weighting coefficients of the filter.

Example 15.4. Investigate the frequency characteristics of a transversal digital filter of the 2nd order, which averages the current value of the input signal and two previous samples using the formula

The system function of this filter

Rice. 15.8. Frequency characteristics of the transversal digital filter from example 15.4: a - frequency response; b - PFC

where we find the frequency transfer coefficient

Elementary transformations lead to the following expressions for the frequency response in the phase response of this system:

The corresponding graphs are shown in fig. 15.8, a, b, where the value is plotted along the horizontal axes - the phase angle of the sampling interval at the current frequency value.

Suppose, for example, that , i.e., there are six samples per period of the harmonic input oscillation. In this case, the input sequence will look like

(the absolute values ​​of the samples do not matter, since the filter is linear). Using algorithm (15.62), we find the output sequence:

It can be seen that it corresponds to a harmonic output signal of the same frequency as at the input, with an amplitude equal to the amplitude of the input oscillation and with the initial phase shifted by 60° towards the delay.

Recursive CFs.

This type of digital filters is characterized by the fact that the previous values ​​of not only the input but also the output signal are used to form the output sample:

(15.63)

moreover, the coefficients defining the recursive part of the filtering algorithm are not equal to zero at the same time. To emphasize the difference between the structures of the two types of digital filters, transversal filters are also called non-recursive filters.

System function of recursive digital filter.

Having performed the z-transform of both parts of the recurrence relation (15.63), we find that the system function

describing the frequency properties of the recursive digital filter, has poles on the z-plane. If the coefficients of the recursive part of the algorithm are real, then these poles either lie on the real axis or form complex conjugate pairs.

Block diagram of a recursive digital filter.

On fig. 15.9 shows a diagram of the algorithm for calculations carried out in accordance with formula (15.63). Top part block diagram corresponds to the transversal (non-recursive) part of the filtering algorithm. Its implementation requires, in the general case, scale blocks (multiplication operations) and memory cells in which input samples are stored.

The recursive part of the algorithm corresponds to the lower part of the block diagram. It uses successive values ​​of the output signal, which, during the operation of the filter, move from cell to cell by shifting.

Rice. 15.9. Block diagram of a recursive digital filter

Rice. 15.10. Structural scheme of the canonical recursive digital filter of the 2nd order

The disadvantage of this implementation principle is the need for a large number of memory cells, separately for the recursive and non-recursive parts. The canonical schemes of recursive digital filters are more perfect, in which the minimum possible number of memory cells is used, equal to the largest of the numbers . As an example, in fig. 15.10 shows the block diagram of the 2nd order canonical recursive filter, which corresponds to the system function

In order to make sure that this system implements a given function, consider an auxiliary discrete signal at the output of adder 1 and write down two obvious equations:

(15.67)

After performing the -transformation of equation (15.66), we find that

On the other hand, according to expression (15.67)

Combining relations (15.68) and (15.69), we arrive at the given system function (15.65).

Stability of recursive digital filters.

A recursive digital filter is a discrete analog of a dynamical system with feedback, since the values ​​of its previous states are stored in the memory cells. If some initial conditions are given, i.e., a set of values, then in the absence of an input signal, the filter will form elements of an infinite sequence playing the role of free oscillations.

A digital filter is called stable if the free process that occurs in it is a non-increasing sequence, i.e., the values ​​for do not exceed some positive number M, regardless of the choice of initial conditions.

Free oscillations in the recursive digital filter based on the algorithm (15.63) are the solution of the linear difference equation

By analogy with the principle of solving linear differential equations we will look for a solution (15.70) in the form of an exponential function

with an unknown value. Substituting (15.71) into (15.70) and reducing by a common factor, we make sure that a is the root of the characteristic equation

Based on (15.64), this equation exactly coincides with the equation that is satisfied by the poles of the system function of the recursive digital filter.

Let the system of roots of equation (15.72) be found. Then the general solution of the difference equation (15.70) will have the form

The coefficients must be chosen so that the initial conditions are satisfied.

If all the poles of the system function, i.e., the modulo numbers do not exceed one, are located inside the unit circle with the center at the point, then, based on (15.73), any free process in the digital filter will be described by terms of decreasing geometric progressions and the filter will be stable. It is clear that only robust digital filters can be applied in practice.

Example 15.5. Investigate the stability of a 2nd order recursive digital filter with a system function

Characteristic equation

has roots

The curve described by the equation on the coefficient plane is the boundary, above which the poles of the system function are real, and below which they are complex conjugate.

For the case of complex conjugate poles, therefore, one of the boundaries of the stability region is line 1.

Rice. 15.11. The region of stability of the recursive filter of the 2nd order (the poles of the filter are complex conjugate in the region marked in color)

Considering the real poles at , we have the stability condition in the form

Physically feasible digital filters that operate in real time can use the following data to generate an output signal at the i-th discrete time point: a) the value of the input signal at the moment of the i-th sample, as well as a certain number of "past" input samples; b) some number of previous samples of the output signal The integers m and n determine the order of the digital filter. The classification of the digital filter is carried out in different ways depending on how information about the past states of the system is used.

Traversal CFs. So it is customary to call filters that work in accordance with the algorithm

where -sequence of coefficients.

Number t is the order of the transversal digital filter. As can be seen from formula (2.138), the transversal filter carries out a weighted summation of the previous samples of the input signal and does not use the past samples of the output signal. Applying the z-transform to both parts of the expression (2.138), we see that

It follows that the system function

is a fractional rational function z , having an m-fold pole at z= 0 and t zeros whose coordinates are determined by the filter coefficients.

The operation algorithm of the transversal digital filter is illustrated by a block diagram shown in fig. 2.17.

Rice. 2.17. Scheme for constructing a transversal digital filter

The main elements of the filter are blocks for delaying the reference values ​​by one sampling interval (rectangles with symbols z -1), as well as scale blocks that perform digital multiplication operations by the corresponding coefficients. From the outputs of the scale blocks, the signals enter the adder, where, when added together, they form the output signal count.

The type of scheme presented here explains the meaning of the term "transverse filter" (from the English transverse - transverse).

impulse response. Let us return to formula (2.139) and calculate the impulse response of the transversal digital filter by performing the inverse z-transform. It is easy to see that each term of the function H(z) makes a contribution equal to the corresponding coefficient , displaced by P positions in the retarded direction. So here

This conclusion can also be reached directly by considering the block diagram of the filter (see Fig. 2.17) and assuming that a “single pulse” (1, 0, 0, 0, ...) is applied to its input.

It is important to note that the impulse response of a transversal filter contains a finite number of terms.

frequency response. If in formula (2.139) we change the variable , then we get the frequency transfer coefficient

For a given sampling step BUT It is possible to implement a wide variety of frequency response shapes by properly selecting the weighting coefficients of the filter.

Digital filter synthesis methods. The most widely used in the practice of digital filter synthesis are three methods described below.

    Method of invariant impulse responses.

This method is based on the assumption that the synthesized digital filter must have an impulse response, which is the result of sampling the impulse response of the corresponding prototype analog filter. Bearing in mind the synthesis of physically realizable systems for which the impulse response vanishes at t<0 , we obtain the following expression for the impulse response of the digital filter:

where T time sampling step.

It should be noted that the number of individual terms in the expression for the impulse response of the digital filter can be either finite or infinite. This determines the structure of the synthesized filter: a transversal filter corresponds to an impulse response with a finite number of samples, while a recursive digital filter is required to implement an unlimitedly extended impulse response.

The relationship between the impulse response coefficient and the structure of the digital filter is especially simple for a transverse filter. In the general case, the synthesis of the filter structure is carried out by applying z-transformations to a sequence of the form given above. Finding a system function H(z) filter, you should compare it with the general expression and determine the coefficients of the transversal and recursive parts. The degree of approximation of the amplitude-frequency characteristic of the synthesized digital filter to the characteristic of the analog prototype depends on the selected sampling step. If necessary, you should calculate the frequency gain of the digital filter by implementing in the system function H(z) change of variable according to the formula
, and then compare the result with the analog circuit's frequency gain.

    Synthesis of digital filter based on discretization of differential equation

analog circuit.

The structure of the digital filter, which approximately corresponds to the known analog circuit, can be obtained by discretizing the differential equation describing the analog prototype. As an example of using this method, consider the synthesis of a digital filter corresponding to a 2nd order oscillatory dynamic system, for which the relationship between the output oscillation y(t) and input waveform x(t) is set by the differential equation

(2.142)

Let's assume that the sampling step is t and consider sets of discrete samples at 1 and X 1 . If we replace the derivatives in the formula with their finite difference expressions, then the differential equation turns into a difference equation

Rearranging the terms, we get:

(2.144)

The difference equation defines a 2nd order recursive filter algorithm that models an analog oscillatory system and is called a digital resonator. With an appropriate choice of coefficients, the digital resonator can act as a frequency-selective filter similar to an oscillatory circuit.

    Method of invariant frequency characteristics .

It is fundamentally impossible to create a digital filter, the frequency response of which would exactly repeat the frequency response of some analog circuit. The reason is that, as is known, the frequency gain of the digital filter is a periodic function of frequency with a period determined by the sampling step.

Speaking about the similarity (invariance) of the frequency characteristics of the analog and digital filters, we can only require that the entire infinite range of frequencies ω a related to the analog system be converted into a frequency segment ω c of the digital filter that satisfies the inequality
while maintaining the general form of the frequency response.

Let K a (R) transfer function of the analog filter, given by a fractional-rational expression in powers p. If we use the relationship between variables z and p , then we can write:

. (2.145)

With this law of communication between p and z it is impossible to obtain a physically implemented system filter function, since substitution in the expression K a (R) will give a system function that is not expressed as a quotient of two polynomials. Therefore, for synthesizing low-pass filters, the relation of the form

, (2.146)

which also maps the points of the unit circle in the z-plane to the points of the imaginary axis in the p-plane. Then

, (2.147)

whence follows the relationship between the frequency variables  of analog and digital systems:

. (2.148)

If the sampling rate is high enough ( c T<<1), then, as is easily seen from formula (2.147), a  c. Thus, at low frequencies, the characteristics of the analog and digital filters are almost the same. In general, the scale transformation along the frequency axis of the digital filter must be taken into account.

In practice, the procedure for synthesizing a digital filter consists in the fact that in the function K a (R) analog circuit, the variable is replaced according to the formula (2.145). The system function of the digital filter obtained in this case turns out to be fractionally rational and therefore allows one to write down the digital filtering algorithm directly.

Questions for self-examination

    Which filter is called matched.

    What is the impulse response of a filter.

    What is the signal at the output of the matched filter.

    What filters are called digital.

    What is the difference between recursive and transversal filter algorithms.

    Name the main methods for synthesizing digital filters .

    What are the main properties of the discrete Fourier transform.

Internet