Labview serial port communication VISA realizes serial port sending and receiving


foreword

  • The method of calling MSComm control ( Labview serial port communication MSComm realizes serial port sending and receiving ) has been used before, that is, using the control object provided by Windows to operate the properties and methods of the control in LabVIEW to realize serial port communication. The reason why the MSComm control is used is that it is more flexible than using VISA to realize serial communication. For example, the registered LabVIEW can be triggered when the number of data bytes in the serial buffer of the PC reaches a certain set value through callback. Callback function to process, this method can avoid reading serial port data during polling, and the efficiency improvement is obvious, especially when the speed and data throughput are slightly higher.

  • Of course, using VISA can also achieve serial communication very concisely. Its advantage is that it is easy to use, although the simplicity of user experience often sacrifices some flexibility in use.

  • In this paper, the VISA module of LabVIEW realizes the serial port to send and receive communication.


1. What is VISA

VISA, short for Virtual Instrument Software Architecture, provides a standard, cross-platform communication protocol that allows LabVIEW to communicate with a variety of different devices, whether through GPIB, serial, USB, Ethernet, or other interfaces. For test software developers, VISA is a callable operation function set. It does not provide instrument programming capability itself. It is just a high-level API that controls the instrument by calling the low-level driver. The hierarchical structure of NI-VISA is shown in the figure below:
insert image description here

2. VISA driver download and installation

1. Download

Link: https://www.ni.com/en-us/support/downloads/drivers/download.ni-visa.html#306043

Select the corresponding NI-VISA version according to the LabVIEW release version used. I use NI LabVIEW 2018 (32-bit) here, and the NI-VISA version selected here is 21.0.

Check the Readme file to determine whether the version of NI-VISA you downloaded is compatible with the version of LabVIEW you are using.
insert image description here
View Readme --> Readme and Release Notes --> NI-VISA 21.0 for Windows Readme
insert image description here
insert image description here

2. Installation

Installing the VISA driver is very simple, just follow the prompts of the installation wizard. After the installation is successful, you will be prompted to restart, just restart.
insert image description here

3. VISA realizes serial port sending and receiving

The official provides us with many examples to facilitate our development. What I want to use here are two port routines for serial writing and reading . The relevant example path is: Help -> Find Examples -> Hardware Input and Output -> Serial -> Serial writes and reads both ports
insert image description here

1. Open the virtual serial port

Refer to my previous blog: https://blog.csdn.net/qq_41839588/article/details/131936554?spm=1001.2014.3001.5501

Here I virtualize two ports COM8 and COM9
insert image description here

2. Operation effect of the front panel

COM8 (send) –> COM9 (receive), enter "hello world!" in the write string, read the string after running the program and you can see the written string.
insert image description here

3. Program block diagram

insert image description here
Interested readers can try other serial port routines, and choose a solution suitable for their own project development according to their needs.


My qq: 2442391036, welcome to communicate!


Guess you like

Origin blog.csdn.net/qq_41839588/article/details/131954508