A Design of Virtual Digital Filter Based on VB

Publisher:chaohuangmeitaoLatest update time:2012-07-19 Source: 21ic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Composition of virtual instruments

In terms of components, the virtual instrument system is composed of computers , application software and instrument hardware. Computers and instrument hardware are also called VI's general instrument hardware platform. Virtual instruments based on PC platforms not only have powerful software development resources, but also have low costs and are suitable for ordinary users. This design is implemented using a PC DAQ system. The system structure of this design is shown in Figure 1. It mainly uses Advantech's PCL2818LS data acquisition card to build computer hardware peripheral circuits to achieve signal conditioning and high-speed data acquisition. The PCL2818LS data acquisition card has the following functions and features:

16 single-ended or 8 differential analog inputs; 40 kHz 12-bit A/D converter ; programmable gain for each input channel; automatic channel/gain scanning with DMA; 16 digital inputs and 16 digital outputs; one 12-bit analog output channel (D/A conversion); programmable timing trigger/counter; software support includes VisiDAQ 3.1, ActiveDAQ and Windows 3.1/95/NT high-speed DLL drivers. Since the measurement signal is not hardware filtered , the collected signal must be digitally filtered, otherwise it will cause great interference to the measurement result and affect the measurement accuracy.

2 Digital filter structure

Digital filter is used to filter the input signal.

The so-called digital filter refers to a device whose input and output are both digital signals, and which changes the frequency components contained in the input signal through a certain operation relationship. Compared with analog filters, the main advantages of digital filters are:

(1) High accuracy and stability;

(2) System functions are easy to change, so they are highly flexible;

(3) There is no impedance matching problem;

(4) Easy to integrate on a large scale;

(5) Multi-dimensional filtering can be achieved. A digital filter can be expressed as a system function:

There are two ways to implement digital filters: one is to use a general-purpose computer, and use the computer's memory, arithmetic unit and controller to compile the operations performed by the filter into a program and execute it through the computer, that is, to use computer software to implement it; the other method is to design dedicated digital hardware to implement it. There are two types of digital filters: IIR and FIR. From a structural point of view, IIR digital filters use a recursive structure, and FIR digital filters mainly use a non-recursive structure. Since the infinite impulse response filter IIR has the characteristics of infinite memory and a small number of operation items, this article will introduce the design method and implementation of the IIR filter to meet the technical indicators of the filter in the "terminal".

3 IIR filter design theory and method

The structure of the recursive filter and the form of its transfer function determine its design method. The transfer function of the recursive filter is generally in the form of formula (1). Designing a recursive filter is to determine the coefficients ak and bk of the filter so that it meets the technical specifications of the filter.

3.1 Recursive Filter Design

There are two main methods for designing IIR digital filters. One is to use the theory of analog filters for design; the other is computer-aided design, which is to use the optimal technology for design. His design steps are as follows:

(1) Determine the transfer function H(s) of the analog filter that meets the required technical specifications;

(2) Digitize the analog filter. To design a digital filter using an analog filter, the s plane is mapped to the z plane, so that the analog system function Ha(s) is transformed into the required digital filter system function H(z). This mapping relationship from complex variable s to complex variable z must meet two basic requirements:

① The frequency response of H(z) must be able to mimic the frequency response of Hz(s), that is, the imaginary axis jΩ of the s plane must be mapped to the unit circle ejΩ of the z plane, that is, the frequency axes must correspond;

② The causally stable Ha(s) should be able to be mapped into the causally stable H(z), that is, the left half plane of the s-plane Re(s)<0 must be mapped to the interior of the unit circle of the z-plane |z|<1.

The above two conditions maintain both the frequency characteristics and the stability of the analog filter, so the frequency characteristics and the stability of the digital filter obtained by the mapping relationship remain unchanged.

3.2 The solution of obtaining digital filter from analog filter

There are three main solutions for converting from analog filters to digital filters:

Design steps: Convert the given digital filter into an analog low-pass filter according to certain technical indicators; design the analog low-pass filter H(s) according to the converted technical indicators. Then convert H(s) into H(z): For the design of high-pass, band-pass or band-stop digital filters, first convert their technical indicators into the technical indicators of the corresponding low-pass analog filter as a "sample", then perform frequency conversion, and then design the low-pass H(s) according to the above steps, and then convert H(s) into the required H(z).

The main disadvantage of the impulse response invariance method to design IIR digital filters is that the amplitude response of the digital filter produces aliasing distortion. The bilinear transformation method can overcome this disadvantage, but it causes frequency distortion. The nonlinear distortion of the frequency scale of the bilinear transformation can be compensated by the pre-distortion method, that is:

The analog filter is designed according to these two pre-distorted frequencies ΩP and ΩT, so that the digital filter obtained by bilinear transformation has the desired cutoff frequency characteristics. Therefore, this article discusses the latter method. The bilinear transformation method first finds the transfer function H(s) of the analog filter, and then finds the corresponding transfer function H(z) of the digital filter:

T is the sampling period.

[page]

4 Design and implementation of virtual IIR digital filter

4.1 Software

In the concept of virtual instrumentation, "software is the instrument". In addition to the basic software such as the operating system required by the computer, the software used in the virtual instrumentation system also requires device driver software and user applications. Powerful, ready-made driver software is the heart of the data acquisition system. It provides users with a powerful application programming interface (API) using different programming environments and languages. The driver software hides the underlying, complex hardware programming details while maintaining high performance, providing users with an easy-to-understand interface. For device driver software, it is generally provided by the manufacturer of the hardware device or interface board. When programming, users only need to directly call these device drivers, which generally comply with the VISA (Virtual Instrument Software Architecture) standard.

For user application software, we selected the tool software VB, which has the characteristics of short development cycle, good product visibility, high reliability and strong maintainability. The software development steps are as follows:

(1) Create a form according to the design requirements, and then edit the code in the code editing window. The form should contain input control information and output display information. In the program code, perform digital filtering on the collected raw signal to prepare for the subsequent electrical parameter measurement.

(2) Use file input and output operations to store data or read data from files to facilitate storage and display of waveform data. It can also be used to print and analyze results.

(3) VB 6.0's debugging tools include breakpoints, break expressions, watch expressions, running statement by statement, running procedure by procedure, and displaying the values ​​of variables and properties through a window. VB 6.0 also includes special debugging features, such as editing during execution, setting the next execution statement, and performing procedure testing when the application is in break mode.

4.2 Design and Implementation of IIR Digital Filters

This design uses a digital Butterworth filter. The amplitude response of the Butterworth filter has the flattest characteristics in the passband, and the amplitude characteristics are monotonically changing in the passband and stopband. The amplitude square function of the analog Butterworth filter is:

Where ω is the angular frequency, ωc is the cutoff frequency, and N is the order of the filter. From equation (9), it can be seen that as N increases, the amplitude response curve becomes steeper near the cutoff frequency, that is, more parts of the amplitude are close to 1 in the passband, and decrease to zero at a faster rate in the stopband. If s is used instead of jω, that is, after analytical extension, equation (9) can be written as:

This gives the extreme point

From the above formula, we can see that the pole distribution of Butterworth filter has the following characteristics: there are 2N poles in the s plane, which are equally spaced on a circle with a radius of ωc. These poles are symmetrical to the imaginary axis, and there are no poles on the imaginary axis. When N is an odd number, there are two poles on the real axis. When N is an even number, there are no poles on the real axis. The angular distance between each pole is π/N, and the Butterworth transfer function is as follows:

When N is an even number:

When N is an odd number:

According to the above method, we have compiled a design program for IIR digital filters. Using this program, you only need to select the analog low-pass filter prototype and the target filter type, input the sampling frequency ω and the target filter cutoff frequency ωc, and you can automatically complete the design of the IIR digital filter. For example, the design example of a 3rd-order low-pass digital filter is as follows:

A normalized 3rd-order Butterworth low-pass filter is selected as the design model, with a sampling frequency of 10 kHz and a cutoff frequency of 1 kHz. The transfer function of the low-pass digital filter obtained by running the design program is:

The amplitude-frequency diagram is shown in Figure 2.

A normalized 3rd-order Butterworth low-pass filter is selected as the design model, with a sampling frequency of 10 kHz, a cutoff frequency ωc1 of 1 kHz, and ωc2 of 2kHz. The transfer function of the bandpass digital filter obtained by running the design program is:

The amplitude-frequency diagram is shown in Figure 3.

5 Conclusion

Digital filters can be programmed to realize various systems to meet different needs, and the coefficients can be changed at any time, the filter parameters can be adjusted, and the best solution can be selected. The use of virtual instruments to gradually replace traditional instruments has become a development trend in the testing field. However, in practical applications, it is still necessary to optimize the program and combine software and hardware according to specific circumstances to enable virtual instruments to perform at higher performance. The innovation of the author of this article is to use the VB software platform to develop electrical parameter measuring instruments, etc. Virtual instruments achieve higher efficiency, save more hardware expenses, facilitate system maintenance and reduce the burden of instrument updates.

Reference address:A Design of Virtual Digital Filter Based on VB

Previous article:Optimizing Automated Test Applications on Multicore Processors Using NI LabVIEW
Next article:Application of NI Compact RIO in Multi-physics Field Measurement of Marine Environment

Recommended ReadingLatest update time:2024-11-16 17:47

51 single chip microcomputer water temperature control LCD display plus VB host computer temperature curve drawing
The current function is that 1L of water is heated by a 1KW electric furnace. The water temperature is required to be manually set within a certain range and can be automatically adjusted as the ambient temperature changes to maintain the set temperature unchanged. Matrix keyboard input sets the temperature, LCD1602
[Microcontroller]
Electric sunroof durability test system based on VB serial communication
1 Overview The car sunroof is designed to meet the health and comfort requirements of consumers. Therefore, people's requirements for the performance of the sunroof are not only beautiful and luxurious, but also must meet all-round requirements such as safety, reliability, and smooth operation. Therefore, befor
[Test Measurement]
Electric sunroof durability test system based on VB serial communication
Using VB 6.0 to realize the communication between network remote PC and single chip microcomputer
In the design of various single-chip microcomputer application systems, the communication problem between single-chip microcomputer and PC is often encountered. In the occasions where the speed requirement is not high and the transmission distance is not far, the RS 232 standard serial interface is generally used. I
[Microcontroller]
Using VB 6.0 to realize the communication between network remote PC and single chip microcomputer
Latest Test Measurement Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号