Real-time data acquisition system based on LabVIEW and USB interface

Publisher:EnchantedDreamLatest update time:2011-08-09 Keywords:LabVIEW Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Data acquisition system
In engineering, computers with PCI, PXI, USB, parallel port and serial port are used to obtain test data, which is called PC-based data acquisition system. One of them is to directly obtain data and transmit it to the computer through a plug-in data acquisition card. In view of the high price and inconvenient installation of data acquisition cards, this paper proposes a data acquisition system using STC microcontroller as the front end, using the function of USB bus to asynchronous serial port of CH341T chip to transmit the collected data to PC through only one USB line, and finally display, analyze and process the data under LabVIEW platform.
1.1 System composition and working principle
The overall structure diagram of this system is shown in Figure 1. It mainly includes data acquisition, conversion and transmission parts composed of STC12C5410AD microcontroller and CH341T conversion chip, and data processing part composed of PC-based LabVlEW software. First, the measured voltage analog signal enters the AD conversion channel of the STC microcontroller through the level conversion circuit. After the conversion is completed, it is transmitted to the PC through the USB interface using the USB to serial port function of the CH341T chip, and finally analyzed and processed by LabVIEW software.


2 Lower computer system design
2.1 Hardware design part
The system hardware schematic diagram is shown in Figure 2. The MCU used in the system is STC12C5410AD, and the USB interface chip used is CH-341T. The USB to serial port function of the chip is used to transmit data to the upper computer, thus forming a data acquisition system.

[page]

2.1.1 STC12C5410AD MCU The
STC12C5410AD series MCU is a single clock/machine cycle (1T) 8051 core compatible MCU. It is a new generation of high-speed/low-power enhanced 8051 MCU with an internal integrated MAX810 dedicated reset circuit. 10KBFLASH program memory, 512 bytes SRAM, 8-channel 10-bit high-speed A/D converter, the speed can reach 100KHz. The actual operating frequency can reach 48MHz. When applied, the crystal frequency needs to be set according to the actual situation. This system uses a 11.0592MHz crystal. In this example, P1.0 is used as the A/D conversion channel. Since the input voltage range of each A/D conversion channel is 0~5V, for bipolar signals, direct input will cut off the negative half wave. In order to solve the above problems, a high-speed low-noise dual operational amplifier NE5532 is used. According to the virtual short and virtual open principles of the operational amplifier circuit, its output OUT=2.5-IN. The level of -2.5v~2.5V can be converted to 0~5v, thus meeting the bipolar requirements of the input signal.
2.1.2 CH341T chip
With the continuous development of computer communication technology, the communication speed of the serial port is increasingly unable to meet the current communication requirements. Therefore, more and more computers, especially laptops, no longer retain serial interfaces, but are replaced by convenient, high-speed, and standard USB interfaces. However, for devices that need to communicate with serial ports, this is a troublesome problem. In order to solve this problem, this system uses the CH341T chip to connect the microcontroller directly to the PC through the USB interface, which facilitates the communication between the upper computer without a serial port and the lower computer, and solves the problem of the upper computer without a serial interface. The characteristics of the CH341T chip are as follows:
(1) Simulate standard serial ports, used to upgrade the original serial port peripherals, or add additional serial ports through USB.
(2) The serial port application under the Windows operating system on the computer is fully compatible and does not require modification.
(3) Hardware full-duplex serial port, built-in transmit and receive buffer, supports communication baud rates of 50b/s~2Mb/s.
(4) Support 5, 6, 7 or 8 data bits, support odd check, even check, blank, mark and no check.
2.2 Software design part
This system uses the P1.0 port of STCl2C5410AD as the channel for A/D conversion. To use the A/D conversion function, the corresponding register settings must be made. The registers of the STC microcontroller are shown in Table 1.
1) P1M0, P1M1: P1 port working mode settings P1M0=0x01, P1M1=0x01. Set P1 port to open drain mode.
2) ADC CONTR: A/D conversion controller
ADC_POWER: ADC power control bit.
ADC_ POWER=0: Turn off ADC power. ADC POWER=1: Turn on the A/D converter power. When the internal A/D conversion analog power is turned on for the first time, a proper delay is required. After the internal analog power is stable, the A/D conversion is started.
ADC_START: Analog-to-digital converter (ADC) conversion start control bit. When set to 1, the conversion starts. It is 0 after the conversion ends.
SPEED1, SPEED0: analog-to-digital converter conversion speed control bits.
ADC_FLAG: analog-to-digital converter conversion end flag bit. When the A/D conversion is completed, ADC_FLAG = 1. It must be cleared to 0 by software.
CHS2/CHS1/CHS0: analog input channel selection as shown in Table 2.


The lower computer program flow chart is shown in Figure 3. The lower computer program mainly includes three parts: serial port initialization subroutine, A/D conversion initialization subroutine, and serial port sending subroutine. Among them, the A/D conversion initialization subroutine mainly sets the ADC CONTR, P1M0, P1M1 and other registers.

[page]

3 Upper computer system design
3.1 CH341T driver
Before communicating with the upper computer, the CH341T driver must be installed, which can be downloaded from the company website. After the driver is installed, a virtual serial port will be automatically created in the port column of the computer device manager. This virtual serial port is the same as the original COM port of the computer for the application. By selecting this virtual serial port, you can communicate with the lower computer.
3.2 LabVIEW program design
VISA (Virtual Instrument Software Architecture) is a high-level application programming interface developed by National Instruments Corporation of the United States for communicating with various instrument buses. The VISA library resides in the computer system and completes the software connection between the computer and the instrument to realize program control of the instrument. Its essence is a standard API for virtual instrument systems. VISA itself does not have programming capabilities. It is a high-level API that realizes instrument programming by calling the underlying driver.
This design uses the serial communication subVI of VISA in LabviEW to develop serial communication software. These include VISA (Configure Serial Port.Vi: Initialize the specified serial port according to specific settings. VISA Write.Vi: Write the data written to the buffer to the specified device or interface. VISA Read.vi: Read the specified number of bytes from the specified device or interface and return the data to the read buffer. VISA Close.Vi: Close the open serial port. First, use VISA Configure Serial Port.vi to initialize the serial port, in which the timeout for read and write operations is set to 10s, the baud rate is 9600, 8 data bits, no parity bit, 1 is the stop bit, and no flow control. Then open the serial port, transfer the data in the read buffer to the waveform chart for real-time display, and use the shift register and connection string control to store the collected data in the receiving data area. When the collected data reaches 950, the amplitude spectrum is transformed and displayed. At the same time, clear the receiving data area to prepare for the next acquisition. The LabVIEW program block diagram is shown in Figure 4.


4 System test and results
In order to test the reliability of the system, the P1.0 port and power ground of the system are connected to the DG 2041A digital signal generator for testing. The signal generator generates a sine wave signal with a frequency of 100Hz and a peak-to-peak value of 3V, with a high level of 1.5V and a low level of -1.5V. Through the level conversion circuit, a sine wave with a low level of 1v and a high level of 4V is obtained. The A/D converted data is transferred to Lab-VIEW. Before displaying, the A/D conversion value of 2.5V voltage must be subtracted by 128, and the scaling ratio of the Y axis of the waveform chart must be set to 0.02, so that it can be displayed correctly. The results of the collection displayed on the LabVIEW software through the designed system are shown in Figure 5.


5 Conclusion
This paper uses the STC microcontroller as the front end of data acquisition, and uses the USB interface to communicate with LabVIEW after conversion by the CH341T chip. At the same time, the powerful signal analysis and processing capabilities of LabVIEW are used to display the signal in real time and perform spectrum analysis on the signal. After debugging and improving the system, the experiment proves that the collected signal can meet the requirements and the system runs well.

Keywords:LabVIEW Reference address:Real-time data acquisition system based on LabVIEW and USB interface

Previous article:Developing Parts Finishing and Inspection System with LabVIEW
Next article:Application of Virtual Instrument Technology in Metrology

Recommended ReadingLatest update time:2024-11-17 00:40

What are the new highlights of LabVIEW8.6?
LabVIEW 8.6 adds the development and control of wireless networks, such as Bluetooth, GPRS, and GSM. This is a wise choice made by NI in the context of the development of wireless communications. In addition, the new version of LabVIEW enhances the support for multi-core and FPGA. National Instruments (NI) has annou
[Test Measurement]
What are the new highlights of LabVIEW8.6?
A brief analysis of the application design case of LabVIEW intelligent car simulation system
This simulation system is developed based on LabVIEW virtual instrument technology and is used for algorithm simulation and analysis of smart cars. 1 Basic structure Figure 1 is the architecture diagram of the entire simulation system, which is mainly divided into the basic model layer, control algorithm layer, comm
[Power Management]
A brief analysis of the application design case of LabVIEW intelligent car simulation system
labVIEW time domain-frequency domain analysis
      Frequency domain (frequency domain) - the independent variable is frequency, that is, the horizontal axis is frequency and the vertical axis is the amplitude of the frequency signal , which is usually called a spectrum diagram . The spectrum diagram describes the frequency structure of the signal and the relation
[Test Measurement]
labVIEW time domain-frequency domain analysis
Industrial control system based on 51 single chip
0 Introduction In recent years, the field of automation control has been changing with each passing day, and control systems such as PLC, DCS, PAC, etc. have emerged in an endless stream. However, the application of such control systems requires relatively expensive costs. On the one hand, in order to facilitate
[Microcontroller]
Industrial control system based on 51 single chip
In-depth exploration of LabVIEW-----Time node functions in LabVIEW
LabVIEW provides a special time type control --- TIMESTAMP. The time control is a new data type in 8.X. It uses an 18-bit integer or a 19-bit floating point number to represent time in seconds. The starting time is Friday, January 1, 1904, 12:00 am (UTC). LabVIEW has several time-related node functions in the functi
[Test Measurement]
In-depth exploration of LabVIEW-----Time node functions in LabVIEW
Development of reverse automatic braking system based on LabVIEW
Application areas: control and simulation, automotive active safety, low-speed control, brake control Challenges: The speed control range of low-speed control is small and the accuracy requirement is high. Since the body parts are nonlinear time-varying systems, the accumulated errors generated have a great impact o
[Test Measurement]
Development of reverse automatic braking system based on LabVIEW
LabVIEW in-depth exploration ------ global variables, local variables and memory management
Many textbooks suggest that local variables and global variables should be used with caution. There are several reasons for this:  Programming that violates data flow. Reading local variables requires copying data. Data BUFFER cannot be reused like SUBVI. It is not conducive to program debugging and is pr
[Test Measurement]
LabVIEW in-depth exploration ------ global variables, local variables and memory management
Design and application of high voltage reactive power compensation monitoring system through LabVIEW
1 Introduction In recent years, with the continuous increase of high-power nonlinear loads, the reactive impact and harmonic pollution of the power grid have been on the rise, resulting in an increase in line loss of the power grid and a decrease in the voltage qualification rate, which seriously affects the power s
[Power Management]
Design and application of high voltage reactive power compensation monitoring system through LabVIEW
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号