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:
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.
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.
Previous article:Basic BMS Test System
Next article:Labview serial communication
Recommended ReadingLatest update time:2024-11-17 10:48
- Popular Resources
- Popular amplifiers
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Arduino Nano collects temperature and humidity data through LabVIEW and DHT11
- Modern Testing Technology and System Integration (Liu Junhua)
- Computer Control System Analysis, Design and Implementation Technology (Edited by Li Dongsheng, Zhu Wenxing, Gao Rui)
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Zhongke Bluesun (AB32VG1) development board (based on RT-Thread system) --- Music player -- Sharing
- What exactly is a sine filter?
- Pingtouge RVB2601 board-GPIO
- [TI recommended course] #DC/DC switching regulator packaging innovation#
- ST60 short-distance, contactless connector evaluation 1: application environment and principle
- 【AT-START-F425 Review】Reading USB files to achieve image reproduction
- Looking for open source enthusiasts to improve the BabyOS open source project
- Can experienced friends recommend some useful power modules?
- J-JLINK always fails to download LM3S800 program.
- What is the appropriate sampling rate for an oscilloscope?