Example Code

Decimal to Serial Binary Data Using LabVIEW

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

Overview

Demonstrates how to convert a decimal array into a digital array for serial communication.

 

Description

 

This example converts a numeric array of decimal values into the binary representation of those values arranged serially in another array.  For example, the array {5,6} becomes {0,1,0,1,0,1,1,0} with the bit depth set to 4 and the bit order set to MSB First.  This example is meant to be used as a subVI.

 

Example Use Case: Converting decimal values that you output in parallel across a digital I/O port to serial values that you output serially on one digital I/O line.

 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Complete or Execute Code

1. Enter in values in numeric array to convert to serial data.

2. Choose the bit order (MSB to LSB or LSB to MSB).

3. Set the bit depth (8,16,24,32,64,etc).

4. Run the VI.

 

 

Additional Information or References

If someone would like to improve the example to provide functionality for byte order (i.e. big endian/little endian), please do so.

 

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

Ben

National Instruments
Certified LabVIEW Associate Developer
Certified TestStand Developer

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