Example Code

Incorporating Meta Data to Queued Message Elements Using LabVIEW

Code and Documents

Attachment

Overview
This code demonstrates how to add meta data to elements being sent through a queue in a producer consumer

 
Description
While methods such as the use of variants can allow the developer to transmit any information they wish via queues or similar systems, it can also be useful to be able to append additional information to an element which can then be deconstructed on the consumer side and processed.

This example has example use cases in real-time systems using DMA FIFOs, where single elements are transmitted/received between target and host.

To add the additional meta data to an element, the queue must first be configured to have sufficient bit-width to host the additional information. In this example, where our actual information is 16-bit information and our meta data is a 16-bit numerical identifier, this means configuring the queue to hold a 32-bit integer.

To append the meta data to the channel data, we use the Join Numbers function, and to separate the data we use the Split Number Function.

Examples of where this may be useful would be the transmission of encoder information, where both the magnitude of the speed and the direction of the encoder could be sent together. This example could be expanded/altered to also enable us to send a channel identifier if multiple encoders were being used (for e.g. 16-bit for actual data, 8-bit for direction and 8-bit for channel identifier).


Requirements

  • LabVIEW 2013 (or compatible)


Steps to Implement or Execute Code

  1. Download Project Zip and Extract (Built for 2013)
  2. Open Project and Launch MetaData.vi
  3. Run the VI
  4. Set the channel you wish to send data to and how many elements you want to send to that channel
  5. Click send
  6. Click stop to end the execution

 

Additional Information or References

Front Panel

FP.png

VI Block Diagram

 1.png

 

 

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

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