USB serial data transmission based on LabVIEW and Python

Source: Internet
Author: User

1. The aim is to use the upper computer LabVIEW programming, realize the transmission through the USB serial port to the Raspberry Pi, the Raspberry Pi receives the data to display, and returns the received data to the upper computer.

2. Raspberry Pi USB Serial Programming:

(1) In the online borrowing about Raspberry Pi USB communication, you will find that Python has its own pyserial module, you can set the serial port

Installation Instructions: Pip Install pyserial

(2) Check the USB serial port situation, after access to a USB cable, the Raspberry Pi will refresh the display:

Find directive: LSUSB

(3) Python Programming:

1). Set the serial port to '/dev/ttyusb0, 115200 '

2). The realization function is: waits for the serial port data to receive, if has the data, then carries on the Echo and sends the data the first place machine

3. Upper Computer LabVIEW Programming:

(1) function is to implement the command to send and display the received data (the next computer sent over the data)

(2) is the LabVIEW serial port program receiving module, because the next computer just will receive the data, and then feedback to the host computer, so the data does not set the size of the byte. Therefore, the bytes at port function to receive judgment, it is the principle that as long as the data received (size ≥ 1), the data to Visa R.

With 10ms delay, the receiving time is extended to make the received data more complete. Otherwise the Receive box is emptied (the Receive box does not have a feedback node set) and only the last received data is displayed.

(3) As long as the computer is connected to the USB cable, LabVIEW will be refreshed, you can see the "Port Selection" list will be more than one port, that is the USB cable. The baud rate is consistent with the Raspberry Pi by 115200.

4. Running the program results

(1) This image is the last time the data command is sent, and the receive box receives the message from the Raspberry Pi.

(2). The Raspberry Pi receives data from the host computer LabVIEW and displays it in real time.

USB serial data transmission based on LabVIEW and Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.