Design of Virtual Instrument System Based on LabVIEW

Publisher:温馨的家庭Latest update time:2012-08-09 Source: 21ic Keywords:LabVIEW Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This article will introduce how to quickly build a virtual oscilloscope and spectrum analysis software based on MSP-060101 under LabVIEW .

1. Hardware

The MSP-060101 used in this article is a 16-bit, 500ksps single-channel USB data acquisition card. It has the advantages of simple interface, optional range (±1V and ±10V), fast speed, high accuracy, simple driver function interface, etc. It is very suitable for quickly realizing virtual oscilloscope and spectrum analysis functions.

The hardware connection of MSP-060101 is very simple. Insert the acquisition card into the USB port of the PC, install the driver according to the instructions, and then you can collect data. No external power supply or other cumbersome equipment is required. There are only two ports for connecting signals at the front end of MSP-060101, which can be connected to the positive and negative ends of the differential input signal respectively. It is simple and clear at a glance.

2. Underlying Functions

After connecting the hardware, let's learn how to use the card driver functions. There are only two card driver functions, which are encapsulated in MSP-16bitDAQCard.dll. Users can execute functions by calling DLL. The function definition is as follows:

int SetSampleRate (int SampleRate, int DeviceNumber)

int GetVoltage(float *DataArray, int ArraySize, float mult, float Offset, int DeviceNumber)

The SetSampleRate function is used to set the sampling rate of the acquisition card. Its parameters are SampleRate (sampling rate, which can be set arbitrarily within the range of 1K-500K) and DeviceNumber (device serial number, supporting 10 acquisition cards at the same time).

The GetVoltage function is used to collect voltage data. Its parameters are DataArray (buffer array), ArraySize (buffer length), mult (gain coefficient), Offset (offset), and DeviceNumber (device serial number).

Both functions have return values, 1 if the function is executed successfully, and 0 otherwise.

In LabVIEW, DLL functions are called through Call Library Function Node. For ease of use, we make the code for calling DLL into subVI functions. There are two main subVIs, namely, Data Collection VI and Frequency Setting VI. The internal program flowchart is as follows:

Internal flowchart

Internal flowchart

3. Software Writing

After writing the subVI, the next step is to design the application software according to the programming method of LabVIEW. This article takes the basic oscilloscope software as an example and combines it with spectrum analysis to demonstrate how to use the efficient controls of LABVIEW to write test software.

The overall design idea of ​​the software is as follows: the software executes as an infinite loop, and each loop is divided into three steps: the first is to set the sampling rate of the acquisition card, the second is to continuously collect a length of data, and the third is to perform data analysis. Therefore, the main framework of the program is a sequence structure nested in a while loop.

Next, let's look at the first step of each loop, setting the sampling rate. The sampling rate setting is very simple, just call the subVI directly. However, in order to make the program run stably, prevent the program from freezing due to the unresponsive acquisition card, and make the software more user-friendly, a hardware check error reporting mechanism needs to be added here. The idea is to call the function that sets the sampling rate. If the acquisition card hardware is not connected well or the hardware is not working properly, the function will not execute successfully and will return 0. By judging whether the return value is 0, it can be determined whether there is a problem with the acquisition card hardware. If there is a problem, an error will be reported to the user, prompting the user to check the hardware, and the program will be stopped and no longer executed. If the hardware is normal, the data acquisition program will continue to execute.

The next step is to collect data of a certain length. This part is also relatively simple, and you can directly call the collection function. While collecting data, you can set the gain coefficient and offset of the data to obtain a better waveform effect, and it can also be used for data calibration.

For a data acquisition software, the focus is on the third step, that is, data processing. In this example, the purpose is to display a stable waveform and make a preliminary analysis of its spectrum. Here, a relatively important function will be used, namely the internal trigger of the software. This function determines the starting point of the subsequent displayed waveform by judging whether the waveform is rising or falling (trigger polarity) at a certain level (trigger level). After the internal trigger, each acquired waveform will start from the same voltage point and follow the same change trend. Therefore, for periodic signals, the waveform can be repeated more stably, which is convenient for people to observe and analyze. In this example, the internal trigger function is made into a functional subVI, and the waveform can be triggered by software by calling this VI.

After the waveform is triggered, it basically has a relatively stable display effect. Next, you need to add time characteristics to the waveform data. The method is to calculate the sampling interval time Δt based on the sampling rate, and assign Δt to the waveform data by creating a waveform control.

So far, we have obtained a relatively complete displayed waveform, and the function of a simple oscilloscope has been realized.

If you want to add spectrum analysis function to the software, it is also very easy to achieve in LabVIEW. Just feed the waveform data we obtained earlier directly into the FFT function to get the frequency domain data of the waveform. But for the convenience of analysis, we hope to automatically extract the main frequency of the signal from the frequency domain. The algorithm is also very simple, which is to scan the power distribution values ​​of different frequencies from low to high in sequence. After finding the maximum value, the main frequency is calculated based on the position number of the maximum value. It is worth noting that the scan cannot start from frequency 0, otherwise the 0 frequency may correspond to the maximum power distribution, and the first few points should generally be excluded. [page]

So far, the basic functions of the software have been completed, and we have realized a simple oscilloscope software. Applying this software, in conjunction with the MSP-060101 data acquisition card, it is possible to observe and analyze the signal.

4. Effect display

The following figure is a screenshot of the acquisition effect. The 100Hz sine wave and 200Hz triangle wave generated by the signal source are used for testing respectively. The effect is quite satisfactory.

Capture the effect

Capture the effect

Capture the effect

This article introduces the construction of a simple virtual oscilloscope. I hope it can be of some inspiration to beginners and provide a reference for friends to write their own data acquisition software and build their own test systems.

Keywords:LabVIEW Reference address:Design of Virtual Instrument System Based on LabVIEW

Previous article:Basic BMS Test System
Next article:Labview serial communication

Recommended ReadingLatest update time:2024-11-17 10:48

FCT (Functional Circuit Test) Test System Based on PXI and LabVIEW
Challenge: Through PXI control board and LabVIEW software, a relatively complete PCB board functional test (FCT) system is built. The system can realize comprehensive and fully automatic testing of audio, video and various static parameters (voltage, current, frequency). For newly developed and produced PCB boards, the
[Test Measurement]
FCT (Functional Circuit Test) Test System Based on PXI and LabVIEW
Using ZLGCAN Interface Function Library in LabVIEW
1. Overview The Virtual CAN Interface (VCI) function library is an application program interface specifically provided for the use of ZLGCAN devices on PCs. The functions in the library are exported from ControlCAN.dll and can be used directly in LabVIEW7.0 without any additional operations. The use process
[Test Measurement]
Local variables and global variables in Labview
The scope of a local variable is the entire VI and it is used to transfer data within a single VI. The scope of a global variable is the entire computer, and it is mainly used to share data between multiple VIs.  
[Test Measurement]
Local variables and global variables in Labview
How to correctly understand EXPRESS XY GRAPH in LABVIEW
   The XY graph can be said to be the most flexible control of Labview data graphic display control. It can replace most of the functions of waveform graph and waveform chart. Its input parameter form has many changes. In the following two articles, the various uses of XYGRAPH are discussed in detail.   Express VI (
[Test Measurement]
How to correctly understand EXPRESS XY GRAPH in LABVIEW
Based on PXI modular instruments and LabVIEW software
"Compared to the early manually connected desktop equipment, users can save 90% of radar test time by using NI PXI modular instruments and LabVIEW to develop a secondary surveillance radar (SSR) automatic test system. Compared with other automatic test equipment based on traditional box instruments, this design can al
[Test Measurement]
Based on PXI modular instruments and LabVIEW software
A brief description of the TDS1000-2000 series oscilloscope API under LabVIEW
    Problem description: There are many functions for processing waveform data in LabVIEW, but the screen of an oscilloscope is generally small, which is not convenient for observation. The waveform diagram in LabVIEW is very flexible, but it needs the support of powerful external hardware acquisition equipment. NI its
[Test Measurement]
Application of LabVIEW and MATLAB in Digital Antenna Array Test
Introduction Digital antenna array is the product of the combination of antenna and digital signal processing technology. It has many advantages such as flexible working mode, excellent anti-interference performance and super angular resolution. Therefore, it has been widely used in military and civilian fields.
[Test Measurement]
Application of LabVIEW and MATLAB in Digital Antenna Array Test
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号