Design of Virtual Instrument Interface Based on LabVIEW and USB

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

0 Introduction
LabVIEW is a virtual instrument programming language based on graphical programs. Compared with traditional instruments, virtual instrument technology uses computers as a platform. In the program interface, there are controls for simulating real instrument panels that can be called, which can be used to set input values, observe output values, and realize charts, texts, etc., so it has a friendly human-computer interface. LabVIEW has powerful data acquisition, analysis, processing, display and storage functions. It has been widely used in test and measurement, data acquisition, instrument control, digital signal analysis, factory automation and other fields, showing its strong vitality. Under the same hardware conditions, virtual instruments developed under the LabVIEW platform can realize different instrument functions by changing the software, truly realizing the design concept of "software is instrument".
To realize data acquisition and processing by LabVIEW, the traditional method is to use data acquisition cards, but these data acquisition card devices have the disadvantages of inconvenient installation, high price, limited by the number of computer slots, addresses, interrupt resources, and poor scalability. Under the LabVIEW platform, USB bus is used for data transmission. Since the USB interface bus has the characteristics of plug-and-play, simple interface, and high transmission rate, virtual instruments based on Lab-VIEW and USB interface are flexible, reliable, and economical.
In view of the advantages of LabVIEW and USB interface instruments, it is particularly important to implement the interface program of USB interface under LabVIEW. Here, a method of designing virtual instrument interface based on LabVIEW and USB is introduced.


1 Design Scheme
Since all kinds of virtual instruments for data acquisition and control based on USB bus involve the design of LabVIEW and USB interface program, in order to avoid loss of generality, the design method of the interface program is introduced by taking virtual oscilloscope as an example.
1.1 Hardware Design Scheme
This system is a virtual oscilloscope, whose main work is to collect the analog signal to be measured, and transmit the signal to PC104 computer through USB2.0 interface, run the application software under the computer LabVIEW platform to complete the data processing and recording, and draw the curve on the display.
The system is mainly composed of analog signal acquisition module, FPGA control module, USB transmission module and computer, and its system structure block diagram is shown in Figure 1.

1.1.1 FPGA control module
This design uses Alter's Cyclone series field programmable gate array (FPGA), chip EP1c3T144 to achieve high-speed data control and transmission.
EP1C3T144 uses TPFQ package, has 100 I/O ports and 2910 logic units, and is a high-density, high-performance FPGA.
The main functions of FPGA are high-speed data acquisition, data frame control, and communication with USB microcontroller. The specific description is as follows:
(1) High-speed data acquisition and gain control. The high-speed data acquisition function is to control the timing of high-speed A/D for data acquisition; the gain control function is to send control commands to the programmable gain amplifier circuit to achieve the purpose of controlling the amplification factor of the analog circuit. Due to space constraints, these two aspects are not introduced in detail.
(2) Data frame control. FPGA sends 100 frames of data per second and 512 B per frame to the PC. Accurately controlling and transmitting such high-speed data is one of the technical difficulties of the system. In this scheme, each frame of data consists of three parts: as shown in Figure 2.

Among them, the start bit and end bit of each frame of data are fixed data. The computer's logging application software determines whether the frame header and frame tail of each frame of data received are wrong. If an error occurs, the frame data is discarded and the next frame of data is prepared to be received. The second part of the data, the analog signal is collected by the FPGA-controlled A/D chip.
1.1.2 USB transmission module
Cypress's EZ-USB FX2 chip CY7C68013 is a high-performance USB 2.0 microcontroller. The USB 2.0 transceiver, SIE (serial interface engine), enhanced 8051 microcontroller and programmable peripheral interface are integrated on the single-chip microcomputer. The intelligent SIE in EZ-USB FX2 can handle most of the USB 2.0 protocols, allowing the microcontroller to focus on application functions, thereby reducing development time and ensuring USB compatibility.
CY7C68013 has 3 available interface modes: port, GPIF master and Slave FIFO mode. In this system, according to the system's requirements for data transmission speed and real-time performance, the interface mode of CY7C68013 is configured as Slave FIFO mode. In Slave FIFO mode, the external logic or external processor is directly connected to the FX2 endpoint FIFO. In this mode, the external master controller FPGA communicates data with CY7C68013 in an asynchronous manner.
The hardware interface block diagram between FPGA and CY7C68013 is shown in Figure 3. SL_WR/SL_RD is the write enable/read enable signal of Slave FIFO. FPGA provides CY7C68013 with Slave FIFO output enable signal SL_OE, which is only valid when data is output. FB[7:O] is an 8-bit bidirectional data bus. ADDR[1:0] is the FIFO endpoint selection signal. It is fixed to 00 when data is input, and endpoint 2 is selected; it is fixed to 10 when data is output, and endpoint 6 is selected. [page]

1.2 Software Design Plan
In order to fully utilize the advantages of other programming languages ​​in LabVIEW, LabVIEW provides powerful external program interface capabilities. These interfaces include DLL, C language interface (CIN), ActiveX, .NET, DDE, Matlab, etc. Through DLL, programs written in programming languages ​​such as C, VC, VB, and a large number of API functions that come with Windows can be easily called. Dynamic Link Library (DLL) is a program module that can be shared by multiple parties, and the shared routines and resources are encapsulated internally. The extension of the dynamic link library file is generally .dll. DLL and executable files (exe) are very similar. The biggest difference is that although DLL contains executable code, it cannot be executed alone and must be called directly or indirectly by Windows applications.
Therefore, the first task of developing upper-level application software is the development of DLL dynamic link library. Here, DLL dynamic link library is developed using VC++6.0. The schematic diagram of LabVIEW calling DLL is shown in Figure 4. Since DLL can call API functions to communicate with USB devices, the use of NI's virtual instrument software development platform LabVIEW can give full play to the flexibility of virtual instruments. Therefore, combining the advantages of both, the designed virtual oscilloscope user control panel has the advantages of friendly interface and intuitive operation. Through the various controls on the panel, functions such as data acquisition, storage, reproduction and analysis can be realized.

2 Software Design
Software design is an essential part of virtual instrument development. The software design of virtual instruments based on LabVIEW and USB is divided into four parts: client driver on the host operating system, host application, Ez-USB FX2 firmware program and FPGA software.
2.1 Driver
The host software part includes USB client driver and host application. The USB client driver is a standard WDM driver that supports plug-and-play functions. It provides standard interface functions for controlling transmission, interrupt transmission and batch transmission. In general, the client driver provided by Cypress can meet the needs. If there are special needs, you can develop your own driver based on it.
2.2 Application LabVIEW calls DLL
The host application is the interface between the system and the user. A graphical user interface is required to control the called function. Here, LabVIEW is used to write the application. It communicates with the driver by calling the DLL to complete the data transmission to the peripheral. When writing a user program, you must first establish a connection with the peripheral before you can implement data transmission. There are two main API functions used in the DLL program: one is to use Create-File to get the USB handle; the other is to use DeviceIoControl to send a request to the device driver to complete the reading and writing of data batch transmission in EZ-USB FX2.
LabVIEW is used to design the application here. The key is to call each function in the previously written DLL file through the Call Library Function node. This node is located in Connectivity | Libraries & Executables | Call LibraryFunction Node of the Functions Palette, as shown in Figure 5.

The steps to call the previously written DLL through the CLF node are as follows:
(1) Click the node to place it in the program flowchart. At this time, the node is not connected to any DLL;
(2) Right-click the node and select the Configure option or double-click the node to open the library function configuration dialog box;
(3) Select a function contained in the DLL file in the property settings of the module, and then set the return type and parameter type of the function. In this way, LabVIEW can call a function in the DLL file (a CallLibrary Function Node needs to be set for each function in the DLL). Finally, connect the other end of the module to the display module to display the data read from the USB interface.

[page]

2.3 Firmware Program of EZ-USB FX2
Firmware program refers to the program running in the device CPU. Only when this program is running can the peripheral be called an external device with specific functions. The firmware program is responsible for initializing each hardware unit and reconfiguring the device. There are generally two storage locations for firmware code:
the first is to store it in the host. After the device is powered on, the driver downloads the firmware to the on-chip RAM and executes it, which is called "re-enumeration";
the second is to fix the firmware code into an E2RPOM. After the peripheral is powered on, FX2 downloads it to the on-chip RAM through the I2C bus and automatically executes it. The author chooses the first method, which is convenient for system debugging and upgrading.
In order to simplify and speed up the user's development process of USB peripherals using the EZ-USB FX2 chip, Cypress provides a complete firmware program architecture. The user only needs to provide a USB descriptor table, add other endpoints to receive and send data communication code, and control the program code of the peripheral circuit. For specific operations, please refer to the content in reference [1].
2.4 FPGA software
The system uses a combination of VHDL and BlockDiagram/Schematic to describe the logic of each functional module, and then programs the FPGA chip through the EDA development platform to achieve the design requirements of the system.
The data direction of the data acquisition system is bidirectional. From the computer side, "read data" means that the FPGA sends logging data to the computer through CY7C68013; "write data" means that the computer sends logging commands to the FPGA through CY7C68013.
As shown in Figure 6, the working principle of the "read data mode" is that when the computer is in data acquisition mode, PD7 of CY7C68013 is set to a low level, and the FPGA determines that the level of this bit is low, then it works in the mode of sending data to the USB. At this time, the FPGA determines whether the FULL pin of the USB microcontroller is valid. If FIFO6 in CY7C68013 is not full, it will continue to send data to FIFO6. After the computer receives the A/D data, it completes the calculation, drawing, saving and other functions.

Working principle of "write data mode": When the computer is in send command mode, PD7 of CY7C68013 is set to high level. FPGA determines that the bit level is high, and then it works in the USB send command receiving mode. At this time, FPGA determines whether the EMPTY pin of the USB microcontroller is valid. If FIFO2 in CY7C68013 is not empty, it will continue to read the command data in FIFO2, and change the number of channels collected by A/D and the gain value of the programmable amplifier according to the command.


3 Conclusion
The designed virtual instrument based on LabVIEW and USB not only has the characteristics of small size, low power consumption, low cost, flexible and convenient use, simple hardware circuit, and online update, but also makes full use of microcomputer resources and the flexibility of LabVIEW, so it is easy to develop and has good scalability. At present, the virtual instrument based on LabVIEW and USB has been used in the construction of the electronic and electrical laboratory of our school, which can meet the requirements of high-speed data transmission, recording and display, and has high practical value.

Keywords:LabVIEW Reference address:Design of Virtual Instrument Interface Based on LabVIEW and USB

Previous article:Design and implementation of virtual spectrum analyzer based on LabVIEW platform
Next article:Design of Liquid Level Control System Based on Virtual Instrument

Recommended ReadingLatest update time:2024-11-16 17:53

Labview realizes pulse modulation (PDM)
Pulse Width Modulation Generate a sine signal and get its amplitude input to the duty cycle of a square wave signal Since the duty cycle of the square wave signal contains the information of the sine signal Thus, by filtering out the duty cycle information of the square wave signal, the waveform can be restored Ac
[Test Measurement]
Labview realizes pulse modulation (PDM)
Waveform Chart in LabVIEW
   A curve is a graphical display of a set of X and Y corresponding values. Usually, the Y value in the curve chart represents the data value, while the X value represents the time. The waveform chart control can be found in the Modern>>Graph sub-panel of the Controls tool panel. This control is a numerical indicator c
[Test Measurement]
Waveform Chart in LabVIEW
LabVIEW serial port passively receives data
1. Motor speed The motor speed is successfully obtained in the machinery factory. When connecting the serial port, connect the four wires of VCC, RXD, TXD and GND, including VCC-8, GND-9, RXD-10 and TXD-11. The power input of the TTL-232 level conversion module can be input from VCC, that is, in the connection between
[Test Measurement]
Research on the Fault Detection System of Marine Motor Based on LabVIEW
0 Preface Since marine motors work in harsh environments with high ambient temperature, high humidity, oil pollution and high vibration, their overall performance and technical working conditions will gradually decline. Once a motor fails, it may cause the power system and power system service to be terminated, thus
[Test Measurement]
Research on the Fault Detection System of Marine Motor Based on LabVIEW
Design of Photovoltaic Power Supply Monitoring System Based on LabVIEW
0 Introduction Photovoltaic power generation technology is one of the development trends of new energy in the world. It requires more system efficiency, reliability and economy. Traditional monitoring is generally based on close-range conditions, that is, close-range monitoring. This method requires a certain amount o
[Test Measurement]
Design of Photovoltaic Power Supply Monitoring System Based on LabVIEW
Design of Electronic Transformer Calibration System Based on LabVIEW
1 Introduction With the accelerated pace of digital substation and smart grid construction, electronic transformers have developed rapidly. Electronic instrument transformers include electronic current transformers and electronic voltage transformers. In order to ensure the accuracy of electronic instrument transfor
[Test Measurement]
Design of Electronic Transformer Calibration System Based on LabVIEW
How do I install the DAQ Assistant in LabVIEW?
  To be honest, this problem really bothered me for many days. At the beginning, I searched almost the entire Internet but couldn't find the correct solution. The answers from netizens are all the same. Either you don't have DAQmx installed, and ask you to download NI-DAQmx from the official website and install i
[Test Measurement]
Monitoring a Historic Site Using LabVIEW and NI Wireless Sensor Networks
Measurement Nodes Author: Juan José Cabana González - OPIDIS Implementación y Optimización Marian Chiriac - Santa María La Real Fundación Jose M. de Uña García - OPIDISIndustry: ConstructionProducts : WLS-9163, NI WSN-3202, NI 9791, LabVIEWChallenge : Protect historic si
[Test Measurement]
Monitoring a Historic Site Using LabVIEW and NI Wireless Sensor Networks
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号