Design of virtual digital oscilloscope based on LabVIEW

. Electrical and electronic experiment teaching is an indispensable and important part of engineering teaching. Oscilloscope is an indispensable experimental instrument in the teaching of these experiments, which is used to measure the electrical signals in the experimental process for analysis and processing. In this paper, a dual-channel virtual oscilloscope was designed based on the PC 16-bit sound card, which could correctly collect electronic signals within ±1V. Through LabVIEW graphical programming and multi-threading technology, these functions such as waveform display, channel selection control, parameter measurement and display, waveform storage and playback were realized. The innovation of this design is that it could automatically generate experimental report, simplifying the tedious operations such as drawing waveforms and filling parameters, finally quickly getting illustrated experimental report. From the test results, it can meet the requirements of daily experimental teaching, and it is of great significance to improve the quality of electrical and electronic experimental teaching.


Introduction
Experimental teaching is an important part of teaching activities in higher engineering colleges or universities. Electrical and electronic experiment is one of the compulsory experiments in the engineering. Some basic measuring instruments, such as oscilloscopes and multimeters, need to be equipped to measure the electrical signals in the experimental process for analysis and processing.
With the rapid development of computers, the concept of virtual instrument was first proposed by NI (National Instrument Company) in 1980s. It is a computer-based software instrument, which usually uses a general-purpose computer as a controller, completes data acquisition by adding necessary modular hardware, and completes human-computer interaction and data processing by an efficient and powerful software system [1]. Compared with traditional instruments, they have obvious technical advantages, and gradually become the development direction of modern measurement and control system. For virtual digital oscilloscope, a lot of research has been done, which is mainly divided into two categories, i.e.non-LabVIEW platform and LabVIEW platform, for example, Tian Fuze [2], Tian Xiangxiang [3], Yuan Dongxu [4] designed non-LabVIEW oscilloscopes respectively. Both hardware and software are needed for this kind of virtual oscilloscope, which has long development cycle and high cost, inconvenient for students to carry and easy to be damaged. There are three hardware sources used in the development of virtual digital oscilloscopes based on LabVIEW platform, such as external data acquisition card, PC sound card and USB interface. Because these hardwares are ready-made, there is no need to consider them, and the development cycle is short, which is convenient for students to carry. Therefore, many scholars have done some research, Li Xiaobo et al. [5] who designed virtual digital oscilloscopes based on LabVIEW software and built virtual laboratories on the basis. Practice has proved that it can reduce investment, improve teaching effect, and has the characteristics of flexibility and convenience. Lv Hongying et al. [6] developed a virtual and double trace oscilloscope based on sound card by using LabVIEW software, and the functions and interfaces are the same as those of real oscilloscopes. Wang Meigang et al. [7] designed a simple dual-channel virtual oscilloscope based on sound card and LabVIEW software, which could collect electrical signals within ±1V. Li Na [8] designed a multi-functional virtual oscilloscope and virtual signal generator, which used the sound card of computer instead of the expensive professional data acquisition card. It could realize waveform display, channel selection control, parameter measurement, spectrum analysis, waveform storage and playback, etc. Tao Sha [9], Deng Kui et al. [10], Feng Zhang et al. [11], Si Huiling et al. [12], Zeng Minggang et al. [13], Li Yanjie et al. [14] all designed virtual digital oscilloscopes based on computer sound cards and LabVIEW software. These virtual oscilloscopes are introduced into experimental teaching, which can not only reduce costs, but also improve test efficiency and teaching quality.

Scheme design and working principle
The virtual digital oscilloscope is composed of hardware and software in the design. The sound card from Dell G3 9750 computer was adopted, which had optional two channels and its own analog-to-digital converter and digital signal processing chips and circuits, and whose voltage measurement range from -1V to +1V, the sampling frequency up to 48KHz, and the sampling bit for 16-bit.
The oscilloscope working principle based on LabVIEW is that the measured signal is connected to the input end of the computer sound card through the audio cable (as shown in Figure 1), then the card processes these signals, finally they are read and displayed by the LabVIEW software. However, it should be noted that, it is theoretically impossible to accurately collect the signals with higher frequency and exceeding 1V voltage amplitude due to the limitation of sound card. Therefore, in order to collect signals beyond the range, it is necessary to be pretreated before the sound card.  According to the actual needs of the oscilloscope, the interface was divided into five functional areas (as shown in Fig 2): waveform display area, waveform parameter display area, channel A and B vertical control area, waveform horizontal control area and experimental report writing and generating area, which are convenient for users to operate and view.
The waveform display area was used to display the waveform of the measured signals in the grid diagram for users to view and read. In the waveform parameter display area, these parameters such as amplitude, frequency and period of the measured signals of channel A and B were displayed in real time, so that users can quickly know the situation of the measured signals. Channel A and B were separated from each other in the vertical control area, and independently controlled the waveform display of the two channels. The waveform horizontal control area was used to control the parameters and positions of the waveform in the horizontal direction. The horizontal position adjustment knob was used to move the measured signal waveform in the horizontal direction to align it with a certain grid line, which was convenient for subsequent reading. The experimental report writing and generating area was divided into sound card parameter setting page and experimental report writing and generating page by using tab control. When using virtual oscilloscope for the first time, you need to set the sampling rate, number of channels and sampling bits on the sound card parameter setting page. And these parameters are generally set in the first time for the same computer.

Software Design
To make the virtual digital oscilloscope realize these functions, software design is needed. The design was mainly divided into the following modules: signal acquisition module, waveform pause module, parameter display module, vertical sensitivity and position adjustment module, time base and horizontal position adjustment module and experimental report generation module and so on. The main modules were introduced as follows.  The signal acquisition module was the core module of the virtual oscilloscope. In this design, because the sound card was selected as the signal acquisition equipment, it needed to be set before the signal acquisition. LabVIEW software provided the configuration sound input function for the developers, which was convenient to call the sound card directly. In the module, the sampling rate and the number of channels were set to 44.1KHz and 2 respectively, and sampling bit was set to 16 bit according to the sound card. Then you could start to collect the input signals through the sound card, and processed and displayed them. When the program ended, stopping collecting input signals and cleared them. The module flow chart was shown in Fig 3 and the sound card collection program chart was shown in Fig 4.   The waveform pause module was used to pause the waveform in a certain state, so that the user could observe the waveform or generate an experimental report. The flow chart was shown in Fig.6.When the pause button was pressed, it would stop signal input acquisition from the sound card, and the program had time delay until the pause button was clicked again, after exiting the delay waiting, the signals would be collected again. LabVIEW program diagram was as shown in Fig.5.

Parameter display module
The parameter display module was used to display the amplitude, frequency and period information of the measured signal in the interface, which was convenient for the user to know the signal in real time, as shown in Figure 7. Single Frequency Measurement module provided by LabVIEW was used to present the amplitude and frequency parameters of the measured signals, and to generate an experimental report. By calling the reciprocal function in the Programming/Mathematics module of the Function Selection Board, the reciprocal of the frequency, i.e. the period, was obtained. At this time, the period was one second, and the multiplication function in the numerical module was called, and the data stream was multiplied by 1000 to obtain the period parameter in milliseconds. The program was shown in Figure 8.

Experimental report generation module
The experimental report generation module was used to form an experimental report from the current waveform diagram and the parameters of the measured signal, and saved locally, which was convenient for students to organize and write the experimental report. Filling in your own information at the beginning of the experiment, other parameters would be filled in automatically during measuring the signals, the current waveform(in bmp format called wave.bmp) and experimental report could be saved in the E disk by clicking Generate Report button; The content of the experimental report included the fixed text part and the data filled in by the user, in which the amplitude and period value would be obtained. The module program was shown in

Test and analysis
The virtual oscilloscope designed in this paper is based on the computer sound card and LabVIEW software. In order to test the performance, the signals are generated by the traditional signal source for input signals, and the effect was tested by the designed oscilloscope.
In order to further analyze the acquisition performance of the system, the sampling frequency range of the test signal could be modulated. When the sound card was set to single channel and 16-bit sampling accuracy, sine signal frequency from 1Hz to 4KHz and 0.9V peak-to-peak value, the virtual oscilloscope could still show a better waveform. As the frequency continues to increase, i.e. beyond 4kHz, there was some distortion. The sine waveform chart of 123.7 Hz frequency and peak-peak value 0.5054 was shown in Fig 10  below. Fig. 11 and Fig. 12 were the experimental report interface and the generated experimental report diagram respectively.

Conclusions
The virtual oscilloscope developed in this paper uses the data acquisition technology of computer sound card to collect electrical signals, which reduces the development cost. With the help of graphical programming and multithreading technology of LabVIEW, it improves the universality, flexibility and stability of virtual instrument, has high performance and good human-computer interaction. From the test results, it can meet the requirements of daily experimental teaching. The function of generating experimental report is the innovation of the paper, which can simplify the tedious operations such as hand-drawing waveforms, drawing tables and filling parameters writed in experimental reports, and quickly get illustrated experimental reports. This design improving the experimental teaching conditions and environment, is an important way to cultivate students' practical and innovative ability, complete comprehensive and design experimental teaching, and is of great significance to improve the quality of university experiments.