“This paper introduces a fast virtual oscilloscope test system based on CompuS, cope82G high-speed data acquisition card and Visual C++ programming tool based on PCI bus interface, which integrates waveform acquisition, data analysis, output and Display. In order to ensure the real-time performance of data acquisition and waveform Display, multi-thread technology is also used in the design.
Virtual instrument (VI-ViItuaIInstrument) refers to the combination of general-purpose computer and functional hardware through application programs. Users can operate the computer through a friendly graphical interface, just like operating a single instrument defined and designed by themselves, so as to complete the control of the instrument. Measurement collection, processing, analysis, judgment, display, data storage, etc. In this instrument system, all kinds of complex test functions, data analysis and result display are completely completed by computer software, which has incomparable advantages over traditional instruments in many aspects, such as flexible and convenient use, rich test functions, low price, a Multi-purpose machines, etc., these make virtual instruments become one of the main directions for the development of Electronic measuring instruments in the future.
The busses used in the development of virtual instrument systems today include traditional Rs232 serial bus, GPIB general interface bus, VXI bus, PCI bus and IEEE 1394 bus that is Firewire (also called FireWire).
This paper introduces a fast virtual oscilloscope test system based on CompuS, cope82G high-speed data acquisition card and Visual C++ programming tool based on PCI bus interface, which integrates waveform acquisition, data analysis, output and display. In order to ensure the real-time performance of data acquisition and waveform display, multi-thread technology is also used in the design.
2 System composition and hardware structure of acquisition card
2.1 System composition
The virtual oscilloscope system is mainly composed of a data acquisition card, a computer and special software. The data acquisition card completes the conditioning, acquisition and buffering of the input measurement signal, and sends it into the memory through the computer PCI bus; the computer processes the data under the control of the application program. , operation, and finally complete various power tests and display them in the form of graphics or data on the screen. All this is done in a human-computer interaction mode.
2.2 The hardware structure of the data acquisition card
This virtual oscilloscope adopts the CompuScope82G high-speed data acquisition card of Gage Company as the PCI interface. The hardware structure of the acquisition card is shown in Figure 1.
The data acquisition card is mainly composed of pre-filter, programmable attenuator, programmable analog amplifier circuit, A/D converter, D/A converter, counting, timing circuit, oscillation circuit, timing control circuit and PCI interface circuit , and its functional circuit is uniformly controlled by a digital control logic circuit. The card is a standard PCI bus card with 2 analog input channels. The working frequency of 2 high-speed 8-bit ADCs integrated on the card is up to 1GHz. The rising edge and falling edge are converted, so the highest sampling frequency can reach 2GHz. The card is equipped with 16M high-speed memory, which solves the matching problem of high sampling rate and relatively low PCI bus data transfer rate. The hardware of the acquisition card must be configured before use, and these control programs use the corresponding underlying DAQ drivers. Through the DLL that comes with the acquisition card, the hardware can be flexibly controlled in the program, such as input impedance, input voltage range, amplifier gain, sampling frequency, and the number of sampling points per time.
3 Software design of the system
3.1 Software development environment of virtual oscilloscope
The core technology of virtual instrument is software technology. At present, there are two main types of software development platforms for virtual instrument development: one is a general-purpose visual software programming environment, including Visual C++ and Visual Basic from Microsoft, Delphi and C++Builder from Inprise, etc.; One is the programming environment dedicated to virtual instrument development software introduced by some companies, mainly including NI’s graphical programming environment LabView and text programming environment IabWindows/CVI, and Agilent’s graphical programming environment Agilent VEE. Considering the flexibility, efficiency and portability of the software, visual C++ is used as the development environment of virtual oscilloscope in this design.
3.2 Software function modules
The virtual oscilloscope has five functional modules: signal acquisition, user interface, spectrum analysis, digital filtering, and waveform display.
3.2.1 Signal acquisition module
The signal acquisition module mainly completes data acquisition, and selects different sampling frequencies according to the difference of the acquired signals. The application in this module communicates with the hardware through the driver of the capture card. If the module is implemented in the main thread of the program, the main interface will freeze when the application communicates with the driver. In order to solve this problem, this article directly creates a kind of child thread to complete the communication task with the driver program separately, so that the main interface is dedicated to responding to the information of the window interface. Data is collected by calling the gage_start_capture() function in the child thread. Figure 2 shows the data acquisition process. The main code for data collection is as follows:
3.2.2 User Interface Module
The interface is mainly divided into 3 views: the base class of the main view is ScrollView, which is used to display the waveform; to operate. The main interface design of the whole software is shown in Figure 3.
3.2.3 Spectrum Analysis Module
The software utilizes the Fast Fourier Transform (FFT) for spectral analysis. The spectrum analysis adopts the FFT algorithm of decimation by time, and then the amplitude spectrum analysis results are displayed in the form of coordinate curves on the user interface. When performing FFT, you can choose the number of points. There are 3 options: 1024, 2048, and 4096. If the number of points is not enough, the program will automatically fill in zeros.
3.2.4 Digital filter module
This software can perform low-pass and high-pass filtering on the acquired signal. Firstly, a Butter-worth analog filter is designed according to the given passband cutoff frequency, stopband cutoff frequency, passband attenuation and stopband attenuation, and then a digital filter is designed by bilinear transformation method.
3.2.5 Waveform Display Module
The working principle of the virtual oscilloscope is to sample the signal waveform at high speed, and the sampled value is digitized and stored. Since the collected analog waveform becomes a series of discrete data after being digitized, how to reconstruct the signal waveform is one of the key issues in the design of virtual oscilloscope. The current waveform display mainly includes segment display and scroll display. The scroll display is adopted here, and a new scroll display algorithm is proposed, which breaks through the limitation that the scroll display can only observe slowly changing signals. The core idea of the algorithm is as follows:
(1) Obtain the abscissas m_xMin and rn_xMax of the first and last data points of the collected data block, where m_xMax-m_xMin is the logical width of the waveform.
(2) The value of m_xMax-m_xMin is the logical coordinate, convert it to the device coordinate cx, and use cx to set the entire scroll
The width of the moving view.
(3) In order to improve the efficiency of drawing, it is only necessary to draw the graphics of the visible part of the scroll view, that is, the graphics of the clipping area, so the clipping area must be obtained.
(4) Draw a waveform in the coordinate and clipping area.
(5) Use the CSplitterWnd::DoSerollBy() function to determine the speed of breaking the scroll view according to the size of the sampling interval. In this way, the corresponding clipping area will also change after the view is scrolled, prompting the dynamic drawing of new waveforms.
The main code is as follows:
4 Experiment and discussion
In the experiment, the system is used to collect the sine signal and the sawtooth wave signal, and the spectrum analysis of the signals of the two channels is carried out respectively. During the experiment, the oscilloscope parameters are set as follows: the sampling mode is dual-channel, in which channel 1 samples the sine signal and channel 2 samples the sawtooth signal; the sampling rate is 120Ms/s; the sampling depth is 16 000 points; the trigger source is software trigger ;Trigger time limit is 20ms; input signal voltage range is ~5V. The experimental results are shown in Figure 4. achieved the intended effect.
Based on Gage’s CompuScope 82G high-speed data acquisition card, this paper designs a fast virtual oscilloscope test system with Visual C++ programming tool, which realizes high-speed data acquisition and dynamic waveform display. At the same time, a new waveform scrolling algorithm is proposed, which greatly improves the dynamic display effect of scrolling waveforms. On this basis, the spectrum analysis and digital filtering functions that cannot be achieved by traditional oscilloscopes are realized. The use of Visual C++ as the instrument programming language makes the written programs more versatile and portable.