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

Publisher:sky0001Latest update time:2010-03-11 Source: 电子技术Keywords:LabVlEW 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 and serial ports are used to obtain test data, which is called a 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 that uses STC microcontrollers as the front-end, and uses the function of the USB bus to asynchronous serial port of the CH341T chip to transmit the collected data to the PC through only one USB line, and finally display, analyze and process the data under the LabVIEW platform.

1.1 System composition and working principle

The overall structure of the system is shown in Figure 1. It mainly includes the data acquisition, conversion, and transmission parts composed of the STC12C5410AD microcontroller and the CH341T conversion chip, and the data processing part composed of the PC-based LabVIEW 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, the USB to serial port function of the CH341T chip is used to transmit it to the PC through the USB interface, and finally it is analyzed and processed by the LabVIEW software.

2 Lower computer system design

2.1 Hardware Design

The hardware schematic diagram of the system 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 host computer, thus forming a data acquisition system.

2.1.1 STC12C5410AD MCU

The STC12C5410AD series microcontroller is a single clock/machine cycle (1T) 8051 core compatible microcontroller. It is a new generation of high-speed/low-power enhanced 8051 microcontroller with an internal integrated MAX810 dedicated reset circuit. It has 10KBFLASH program memory, 512 bytes of SRAM, 8-channel 10-bit high-speed A/D converters, and a speed of up to 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 oscillator. 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 requirement 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, and 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 that the upper computer has no serial interface. The characteristics of the CH341T chip are as follows:

(1) Emulates a standard serial port, used to upgrade the original serial port peripherals, or add additional serial ports via USB.
(2) The serial port application under the Windows operating system on the computer is fully compatible and does not need to be modified.
(3) Hardware full-duplex serial port, built-in transmit and receive buffer, supports communication baud rate 50b/s to 2Mb/s.
(4) Supports 5, 6, 7 or 8 data bits, supports odd parity, even parity, blank, mark and no parity.

2.2 Software Design

This system uses the P1.0 port of the STC12C5410AD as the channel for A/D conversion. To use the A/D conversion function, the corresponding register settings must be performed. 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 the ADC power supply. ADC POWER = 1: Turn on the A/D converter power supply. When the internal A/D conversion analog power supply is turned on for the first time, a proper delay is required. After the internal analog power supply is stable, the A/D conversion can be started.

ADC_START: Analog-to-digital converter (ADC) conversion start control bit. When it is set to 1, the conversion starts, and 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. When the A/D conversion is completed, ADC_FLAG = 1 and must be cleared to 0 by software.

CHS2/CHS1/CHS0: Analog input channel selection is 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.

3 Host computer system design

3.1 CH341T Driver

Before communicating with the host computer, you must install the CH341T driver, 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 Programming

VISA (Virtual Instrument Software Architecture) is a high-level application programming interface developed by National Instruments Corporation to communicate 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. In essence, it 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 of LabviEW to develop serial communication software. It includes 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 of the 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, the receiving data area is cleared to prepare for the next acquisition. The LabVIEW program block diagram is shown in Figure 4.

4 System Testing 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 transmitted 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:LabVlEW Reference address:Real-time data acquisition system based on LabVIEW and USB interface

Previous article:Application of smoke sensor in hotel fire automatic alarm system
Next article:Design and application of photoelectric sensors in airport logistics industry

Recommended ReadingLatest update time:2024-11-17 08:39

Design and Application of Embedded USB Host Based on ARM and μC/OS-Ⅱ
1 Introduction Normally, printers, mass storage devices and other devices are driven by ordinary PCs. Since a large number of measurement and control, medical and other systems need to store and print data, it is very practical to develop embedded drivers for such devices. At present, various embedded devices a
[Microcontroller]
Design and Application of Embedded USB Host Based on ARM and μC/OS-Ⅱ
USB-Powered 433.92MHz RF Low-Noise Amplifier Receiver with Overload Protection
USB-Powered 433.92MHz RF Low-Noise Amplifier Receiver with Overload Protection The International Telecommunication Union (ITU) has allocated the 433.92 MHz Industrial, Scientific and Medical (ISM) radio frequency band for use in Region 1, which geographically consists of Europe, Africa, Russia, Mongol
[Analog Electronics]
USB-Powered 433.92MHz RF Low-Noise Amplifier Receiver with Overload Protection
Comparison of power consumption between USB3.0 and USB2.0 interfaces
There are several factors that we cannot avoid when comparing the advantages of USB3.0 interface over USB2.0 interface, namely bandwidth, power consumption, bus utilization, physical bus, and transmission speed. The specific contents are as follows: 1. Bandwidth The USB 3.0 interface uses two unidirectiona
[Embedded]
Comparison of power consumption between USB3.0 and USB2.0 interfaces
Application of AVR Soft USB Interface in Data Acquisition System
  When designing the AVR soft USB interface firmware (ATmega8 microcontroller program), the USB interface parameter configuration is set according to the USB-isp (also the AVR soft USB virtual RS232 interface) download line; and its virtual serial port driver is installed in the PC system. It can support PC operating
[Microcontroller]
Application of AVR Soft USB Interface in Data Acquisition System
Features and Applications of USB2.0 Controller CY7C68013
1 Main features of USB2.0 Version 2.0 of the USB protocol was released in April 2000. It supports the following three speed modes: Low speed mode: 1.5Mb/s; Full speed mode: 12Mb/s High speed mode: 480Mb/s The USB2.0 protocol supports all existing USB devices . It can plug a USB
[Microcontroller]
Features and Applications of USB2.0 Controller CY7C68013
Understanding of USB buffer after using STM32 USB module
I recently developed a project using the STM32 USB module. I thought it was quite simple, but it took me almost two days to get the USB packet buffer accessed. Here is a brief summary.   The STM32 USB module packet buffer has 512B, but the memory image in the STM32 reference manual shows 0x40006000-0x400063ff, which i
[Microcontroller]
Design of ARINC429 bus interface module based on USB
introduction The ARINC429 bus is sponsored by the American Aerospace Radio Equipment Corporation and is a data bus transmission standard widely used in current avionics equipment. Compared with the traditional analog transmission between avionics equipment , ARINC429 bus has the advantages of s
[Embedded]
Design of ARINC429 bus interface module based on USB
Exposed iPhone 15 Pro supports USB 3.2: qualitative change in speed
According to MacRumors reports on March 24, the entire iPhone 15 series is equipped with a USB-C interface as standard. The USB-C here is essentially just a description of the shape of the interface. The specific transmission rate depends on what USB specifications it supports. The protocol is generally either USB 2.0
[Mobile phone portable]
Latest Analog Electronics 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号