Development of External Serial Port Data Acquisition Control Card Based on LabVIEW

Publisher:平凡梦想Latest update time:2011-06-01 Keywords:LabVIEW Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

introduction

At present, the LabVIEW development platform of NI Company in the United States is widely used in the development of virtual instruments. LabVIEW software implicitly considers the various difficulties faced in designing virtual instruments and simplifies the design process. It is quite convenient for developing virtual instruments, but its hardware card is expensive, which affects the promotion and use of virtual instruments in China. Therefore, this paper proposes to use the LabVIEW virtual instrument development platform and design the hardware card by ourselves.

The design uses a single-chip microcomputer as the lower computer and uses a standard RS-232 serial port to communicate with a PC to build an acquisition control system. The upper computer sends control acquisition commands to implement channel selection, range selection, data acquisition, etc. of the acquisition control card, and then transmits the collected data to the PC through the serial port to realize data storage and analysis. In addition, the acquisition control card developed based on the serial port is also very practical because of its hot-swappable advantages.

Composition of external serial port acquisition control system

The external serial port acquisition control system is mainly composed of two parts: the lower computer hardware/software and the upper computer control software. The lower computer performs corresponding operations by receiving PC commands, such as the selection of data acquisition channels, the selection of input voltage ranges, or the selection of other quantities (such as temperature, humidity, etc.). The upper computer software mainly sends control commands, receives, displays, stores and processes data. Among them, the data transmission adopts the data frame format, and the accuracy of data transmission is guaranteed by identifying the frame header flag and other rules. This design is achieved by combining the A/D converter MAX197 provided by MAXIM.

Acquisition control card hardware design

The hardware circuit of this design uses the single-chip microcomputer 89C51 as the control core, and communicates with the PC through RS-232 to realize the data acquisition control, data processing and storage of the entire data acquisition system. The single-chip microcomputer controls MAX197 by receiving PC instructions, and the A/D acquisition is carried out in interrupt mode. The control card hardware circuit structure is shown in Figure 1.

Simple diagram of the hardware structure of the acquisition control card

Figure 1. Hardware structure diagram of acquisition control card

Acquisition control card software design

The MCU receives channel and range selection commands from the serial port to perform data acquisition of the corresponding channel and range, and then sends the data acquisition results to the PC in the format of a data frame. The two-byte frame header flag and the two-byte A/D conversion result are collectively called a frame of data. The MCU software design process is shown in Figure 2.

MCU program flow chart

Figure 2 MCU program flow chart

Design of host computer control processing program

The host computer control processing program is developed on the LabVIEW platform. The LabVIEW program consists of two parts: the front panel and the program block diagram.

The function of LabVIEW front panel is equivalent to that of traditional instrument front panel. It can not only simulate many traditional instruments, but also simulate traditional concept instruments that cannot be realized due to complex structure. Therefore, the design has great flexibility. The front panel designed this time includes the settings of communication ports and modes, the configuration of acquisition control card, the display of current acquisition conversion results, the real-time dynamic monitoring of acquisition conversion results, and the settings of writing acquisition conversion results into Excel files.

The front panel is like the appearance design of the instrument, while the flowchart is the internal circuit of the instrument and is the core part of the design. The convenience of LabVIEW is that it can easily convert the flowchart into a graphical programming language. The loop in the flowchart can directly call the While loop in LabVIEW, the sequential execution can call the Sequence Structure in LabVIEW, and the conditional execution can call the Case Structure in LabVIEW. The program flowchart design is shown in Figure 3. LabVIEW adopts a parallel execution structure. The left and right sides above the horizontal dotted line in the main flowchart are two independent units that are executed simultaneously.

Program flow chart

Figure 3 Program flow chart

The graphic programming of this design can be divided into three parts: serial communication, data reception and file reading and writing.

In LabVIEW, there are three ways to implement serial port communication: directly calling the Serial series subVI provided by NI; VISA serial series (located in Functions->All Functions->Instrument I/O->serial); using Active X controls to control access to the serial port (first add an Active X Container control to LabVIEW, and then add the MSComm control to it). This design uses the second method to access and control the serial port, that is, by calling the Serial series in the VISA function template (including VISA Configure Serial, VISA Write, VISA Read, VISA Close) to access and control the serial port. The advantage of using this design method is that each function starts to receive a port number and outputs a copy of the port number after the end, so there is no need to worry about forgetting or repeating operations on a port in the design, making the program design clearer.
[page]

In LabVIEW, the reading and writing of the serial port are all realized by transmitting its ASCII code in units of characters, so the data characters to be transmitted need to be converted into corresponding ASCII codes. This design embeds the C language program into the entire design by calling CIN (code interface node), and then uses mixed programming of LabVIEW and C language to realize the required functions (the calling path of CIN in LabVIEW is Functions→All Functions→Advanced→Code InteRFace Node).

In this design, the channel number and range of the acquisition control system are first sent to the lower computer, and then the program enters the corresponding data receiving processing program. In the data receiving process, the data frame method is adopted: the lower computer sends the acquisition results of the corresponding channel number and the corresponding range to the PC in a cycle in units of one frame of data, and the PC identifies the data by judging the frame header, thereby improving the accuracy of data transmission. The frame data format is as follows:

Frame data format

The first two bytes of data 0xAA and 0xAB are frame header marks, DATA1 and DATA0 are acquisition results, but they are not the final results, and they still need corresponding processing (this processing is performed in the service subroutine).

The collected data must be converted into actual voltage values ​​before being displayed and stored. This design can easily store each actual voltage value in an Excel file for easy viewing and processing. In addition, during the storage process, the channel number, range, and collected data sequence number information can all be written into the file, so that it is easy to generate report output.

The program flowchart of the acquisition control system designed according to the flowchart is shown in Figure 4.

Acquisition control system program block diagram

Figure 4: Block diagram of acquisition control system

System Testing

After the acquisition control system hardware and software are designed as required, run the control software, configure the acquisition control system accordingly, and then you can watch the voltage value of a certain channel in real time. Adjust the input voltage, and you can watch the change process of the input voltage through the real-time monitoring interface. After the program runs, you can find an Excel file named by the previous configuration in the program installation directory. Open this file to see all the collected data (including channel number, range, collected data and collected data sequence number information). The test shows that the acquisition control system is simple and convenient to operate, collects data accurately, is inexpensive, and has the advantage of hot plugging.

Conclusion

Because the data acquisition cards provided by NI are expensive, it is of great practical significance for users to independently develop acquisition control cards based on LabVIEW. Using the LabVIEW platform to implement it greatly simplifies the design. I hope this article can bring new design concepts to many designers.

Keywords:LabVIEW Reference address:Development of External Serial Port Data Acquisition Control Card Based on LabVIEW

Previous article:How to use Maxim's ambient light sensor for EOC detection
Next article:A new method for testing weft tension of loom based on virtual instrument

Recommended ReadingLatest update time:2024-11-16 22:37

Design and development of an automated system for isolating rare cells based on LabVIEW
Challenge: Design, develop, and manufacture a tool that can detect and isolate circulating tumor cells (CTCs) for personalized therapy in oncology or fetal cells in maternal blood for non-invasive prenatal diagnosis. Solution: Developed a patented technology called "lab-on-a-chip" that uses the microelectronic prope
[Test Measurement]
Design and development of an automated system for isolating rare cells based on LabVIEW
How should I start learning LabVIEW?
   Step 1: First read NI's introductory materials to understand the concept of virtual instruments, the application areas of LabVIEW, programming features, etc.    Step 2: Follow the instructions in LabVIEW Getting Started. (Click New to LabVIEW Getting Started with LabVIEW on the right side of the LabVIEW start scree
[Test Measurement]
CNC machine tool network measurement and control system based on LabVIEW--Research on key network communication technologies 1
4 Research on key network communication technologies for remote measurement and control systems of CNC machine tools There are currently two basic modes for building a network measurement and control system for CNC machine tools based on the Internet: C/S and B/S modes. The two communication modes each have their own
[Test Measurement]
CNC machine tool network measurement and control system based on LabVIEW--Research on key network communication technologies 1
Spectral Data Acquisition and Analysis Based on LabVIEW
1. Introduction With the development of science and technology and the extensive research on spectral analysis systems, people have put forward higher and higher requirements for the main indicators of spectral analysis systems, such as spectral measurement range, resolution, accuracy, etc. The current development di
[Test Measurement]
Spectral Data Acquisition and Analysis Based on LabVIEW
LabVIEW-based CNC machine tool network measurement and control system - overall design (Part 2)
3.3 Driver design of universal data acquisition card In the system, in the data acquisition card part, LabVIEW provides a large number of data acquisition subroutines. These drivers range from simple to advanced and can be provided to users. However, these subroutines only support NI data acquisition cards (DAQ) and d
[Test Measurement]
LabVIEW-based CNC machine tool network measurement and control system - overall design (Part 2)
I forgot the password for the subVI I created with Labview.
    The subVI written in Labview can be protected by a separate password, so as to protect the program flowchart from being seen by others. This is undoubtedly a good way to protect some of your own labor results. But this function is also a double-edged sword. If you forget the password, it will be troublesome.      
[Test Measurement]
Feasibility study and analysis of constructing experimental soft platform based on LabVIEW software
introduction "Signals and Systems" is a professional basic course for electrical engineering majors and is widely used in fields such as automatic control, signal processing, circuits and systems. Because the course is highly theoretical and the content is abstract, students generally find it difficult to understand a
[Test Measurement]
Feasibility study and analysis of constructing experimental soft platform based on LabVIEW software
Design of a certain type of rudder system detection equipment based on PXI bus
O Introduction With the development of high-tech technologies such as virtual instrument technology, PXI bus technology and computer technology, test equipment is required to be miniaturized, integrated and intelligent. In addition, when repairing military equipment, higher requirements are also placed on t
[Microcontroller]
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号