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.
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
- 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
- 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!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- High-Speed Serial I/O Made Easy (FPGA Application Designer's Guide)
- DSP development based on dual-core chip of CCS
- Working principle and function of encoder
- 【LuatOS-ESP32】Series Column Preview
- HTS221 temperature and humidity sensor driver has been added to makecode
- Urgently recruiting a development engineer who knows assembly language
- Arrow Electronics Seminar: Intel FPGA Deep Learning Acceleration Technology will be held both online and offline. We look forward to your presence!
- Three safety regulations
- What are the types of triggers? What is the difference between a trigger and a latch? What are the aspects of the latch's locking and storage?
- [RISC-V MCU CH32V103 Review] ---Advancing Wiki---GPIO and TIMER