LabVIEW reads serial port data

Publisher:TranquilWhisperLatest update time:2020-03-15 Source: elecfansKeywords:labview Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

LabVIEW software, as a virtual instrument development platform, has been increasingly widely used in the design of emerging electronic instruments and in the fields of information transmission and reception due to its intuitive and simple programming, flexible display characteristics, and wide compatibility. For example, the serial RS232 interface can be used to realize the information interaction between the computer and the single-chip microcomputer. Therefore, in the field of measurement and control based on single-chip microcomputers, the use of virtual instrument technology has also been greatly developed, reducing the investment of traditional measurement technology in hardware equipment. Based on the theoretical research on the information transmission between LabVIEW's VISA and single-chip microcomputers, this paper designs the processing of receiving, saving and displaying the information sent by the serial port based on LabVIEW for the data information sent by the serial port.


1. Serial communication modeling

Connect the serial port data of the computer to the receiving line of the computer, and use the characteristics of LabVIEW software to receive the data to the computer. When connecting the serial communication line, cross-connect the 2-pin receiving line and the 3-pin sending line at the two communication ends.

LabVIEW reads serial port data

Figure 1 Design block diagram


The LabVIEW design block diagram is shown in Figure 1. Setting the VISA serial port related parameters mainly involves the settings of the baud rate, data bits, parity, and flow control in the VISA configuration serial port (the setting values ​​in this article are typical values ​​9600, 8, 0, and 1.0, respectively).


The communication settings are mainly for the preparatory work before information exchange with the microcontroller: for example, when a character or string is sent to the microcontroller, the microcontroller obtains the corresponding code and sends the collected data to the computer through the serial port.


The reading of information is mainly for the post-processing of the relevant information returned from the serial port to the computer: In order to facilitate users who are not familiar with computer operation, the convenience of LabVIEW reading and writing files is applied, and the current folder where the LabVIEW file is running is specified. Users can directly open "Data Save.txt" to query the data of historical time. The display information can be the display of the instantaneous information received; other auxiliary functions involve functional requirements in specific environments, such as alarm prompts, and waveform display of data fluctuation characteristics within a certain time or space range.


2. Programming block diagram

2.1、Program board diagram

LabVIEW reads serial port data

Figure 2 Frame 1 Program Diagram


Figure 2 is the program diagram of the first frame: In the sequential structure, one part sends instructions to the serial port through VISA: the content of the instruction must be consistent with the microcontroller agreement: for example, when 0x32 is sent, the microcontroller sends the collection result of the temperature data to the serial port, and the other part prepares for the extraction of the write prompt save time.

LabVIEW reads serial port data

Figure 3 Frame 2 Program Diagram


The second frame program box is shown in Figure 3. The received data is processed as a group of strings, the string length is identified, and each element is indexed and taken out for processing, forming a one-dimensional array, and then converted into character output. When saving the file, through the special application of "Create Path", combined with the application of "Open/Create/Replace File" and "Set File Location" controls, it is automatically created and saved or continued to be saved in the "Data Save.txt" file when running the program. From the moment of execution, the obtained data is displayed in a trend chart. The method of converting the string obtained each time in the serial port into a numerical value can be realized by using the "Fractional/Exponential String to Numeric Conversion" control, and then these data are formed into an array and displayed in a waveform chart. In order to reflect the specific time, the horizontal axis of the waveform display is implemented by the definition coordinate method. When vI stops running, the data in the buffer still exists. By appropriately customizing the horizontal axis time, the trend chart display of a longer time period can be realized.


2.2. Operation results display

In this test process, "0x32" is sent to obtain the temperature data. When the hand touches the temperature sensor 18820, the temperature change in a short time is displayed in a trend chart: the test data trend chart from 2011.9.19 20:58:38 to 2011.9.19 21:02:48 is shown in Figure 4. The corresponding saved TXT file screenshot is shown in Figure 5.

LabVIEW reads serial port data

Figure 4 Test data trend chart

LabVIEW reads serial port data

Figure 5: Screenshot of the saved TXT file


In Figure 4, a warning was set to occur when the temperature was outside 10.32 degrees Celsius, and the test results met the design expectations.


This paper uses the computer's $232 serial port to realize the information transmission between LabVlEW software and the single-chip microcomputer. The information collected by the sensor of the single-chip microcomputer is preliminarily identified and processed, and the results are returned to the computer through the serial port. The VISA characteristics of LabVIW are used to receive serial port signals, display current data, waveform trend chart within a certain period of time, and save them in the form of text files.

Keywords:labview Reference address:LabVIEW reads serial port data

Previous article:Labview serial port data analysis
Next article:How to save serial port data in 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号