Example Code

Multi Thread Serial Port Read For Serial Packet Data In LabVIEW (based on MSP430 EZRF2560)

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview

This VI creates a multithreaded application that reads continuous packet data transferred over a specified Serial (COM) port while continuously displaying the data graphically and writing the data to a file.

 

Description

In this example the data is received from an accelerometer with a fixed packet length. The contents of the packet are Header, Data, CheckSum (comma delimited)

[4bytes] [XData][YData][ZData]

 

Once the Data is read from the COM port and put into the queue the second thread processes it. The shift register initialized at 8 skips to the [XData], the for loop executes three times to extract the accelerometer values. The values are transferred in HEX so they are converted into a number, displayed on a graph and written to a spreadsheet file.

 

Requirements

  • LabVIEW 2013 (or compatible)

 

Steps to Implement or Execute Code

  1. Download the attached VI.
  2. Configure the COM port number into VISA resource name
  3. Configure the specified serial communication parameter (flow control, parity, baud rate, data bits, stop bits)
  4. Run Multithread Serial 2013 NIVerified.vi 

 

Additional Information or References

VI Block Diagram

2-284.png 

 

**This document has been updated to meet the current required format for the NI Code Exchange. **

 

 

Applications/Systems/Test
National Instruments | AWR Group

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.