Labview realizes serial communication

First, the introduction of serial communication

The serial port sends and receives bytes in bits. Serial communication refers to a communication method between a peripheral device and a computer to transmit data by bit through a data signal line, a ground line, a control line, and the like. This communication method uses less data lines and can save communication costs in long-distance communication, but its transmission speed is lower than parallel transmission.

The serial port sends and receives bytes in bits. Although slower than parallel communication in bytes, the serial port can receive data with one line while using one line. It is simple and capable of long distance communication. For example, when IEEE488 defines the parallel traffic state, the total length of the specified device line must not exceed 20 meters, and the length between any two devices must not exceed 2 meters; for the serial port, the length can reach 1200 meters. Typically, the serial port is used for the transmission of ASCII characters. Communication is done using three lines, which are ground, transmit, and receive. Since serial communication is asynchronous, a port can send data on one line while receiving data on another line. Other lines are used for handshaking, but they are not required. The most important parameters for serial communication are baud rate, data bits, stop bits, and parity. These parameters must match for the two ports that are communicating.

Second, LabVIEW Introduction

LabVIEW is a program development environment developed by National Instruments (NI), similar to the C and BASIC development environments, but the significant difference between LabVIEW and other computer languages ​​is that other computer languages ​​generate code in a text-based language. LabVIEW uses a graphical editing language G to write programs, and the resulting programs are in the form of block diagrams. LabVIEW software is at the heart of the NI design platform and is ideal for developing measurement or control systems.

LabVIEW Features

As far as possible, the general hardware is used, and the difference between the various instruments is mainly software.

Can fully utilize the power of the computer, with powerful data processing functions, can create more powerful instruments.

Users can define and manufacture various instruments according to their needs.

Third, Labview realizes serial communication steps

1. Add VISA configuration interface on the program panel

Labview realizes serial communication

2. After adding, open the display of the help document. Help->show context help of the menu, as shown below

Labview realizes serial communication

The mouse selects the target and a help box is displayed. As shown below.

Labview realizes serial communication

3. Create the appropriate configuration

In the program panel, move the mouse to the corresponding pin and click the right mouse button - "create-" control. After the creation, the corresponding control box will appear on the interface panel. Create a VISA resource name as shown below.

Labview realizes serial communication

The front panel displays as follows:

Labview realizes serial communication

4 sequentially created, baud rate, stop bit, data bit, etc.

As shown below.

Labview realizes serial communication

5. Create a while loop to place the sent program

Labview realizes serial communication

Move the mouse to the loop control pin to create a control. Used for debugging, no condition processing, will report an error.

6 front panel placed a button to control the transmission of data

7. Create an event for the response send button

Move the mouse to the location of TImeout, right click and select edit events... as shown below.

Labview realizes serial communication

After the operation above, the following interface appears: select the control that needs to respond, select "ok button" here, select the mouse to press

Labview realizes serial communication

After clicking ok, the name of the event has also changed. As shown below.

Labview realizes serial communication

If the mouse clicks on the button, it will enter the event processing.

8. Create a VISA write function

Labview realizes serial communication

9 connection port and write function

Labview realizes serial communication

10 add a close function

Labview realizes serial communication
Labview realizes serial communication

11. Create a string control, passed to the write function, used to send

Labview realizes serial communication

Select the write buffer of VISA Write, right click create-"control,

12 interface is as follows

Labview realizes serial communication

13. Install virtual serial port, provide a download address

Configure two ports with a virtual serial port. After the configuration, the two serial ports are automatically connected, and the two serial ports on the analog hardware are connected.

Labview realizes serial communication

14 running serial port tool

15. Run the serial port tool, open the serial port, run the VI, and send the data.

My computer is configured with COM12 and COM13, vi selects COM12

Labview realizes serial communication

Run the VI, fill in the test in the write buffer, click OK to send.

Labview realizes serial communication

Send once per click

16. Establish the receiving module

Add a while loop,

Labview realizes serial communication

Create a while loop for receiving. Create VISA Read and click the right mouse button create-"indicator" on the Read buffer pin to create a display control.

Labview realizes serial communication

17 Create a constant in the event type of the VISA Enable Event

Labview realizes serial communication

Then select Serial Character from the drop-down list of constants. This means that the serial port receives the data and can go to the help file for detailed instructions.

18. Create an event wait

Labview realizes serial communication

19. Connect the event, wait for the type of the event to connect directly to the Event type of the VISA Enable Event.

Labview realizes serial communication

20. Add a property node, Visa Bytes at serial port, to get the number of bytes in the serial port

Labview realizes serial communication

The number of bytes is connected, which tells the number of bytes that need to be read. It is also guaranteed to read the data in the serial port every time.

Labview realizes serial communication

0.50mm Pitch Series Connector

0.50Mm Pitch Series Connector,0.5Mm High Speed Board-To-Board Connectors,Double Slot Board-To-Board Connectors,Single Slot Board-To-Board Connectors

Dongguan SOLEPIN Electronics Co., Ltd , https://www.wentae.com