Example Code

Last Value Items Data Storage 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
It is sometimes useful to be able to store the last value for a given item in memory. When you have updated values for the memory item, being able to replace the item in memory is helpful.


Description
This example uses a functional global variable to store the last value of a data point in memory. It uses a Name string to uniquely identify items and each item can have additional information that is stored along with it. When inserting an item into memory, the functional global checks to see if the item with the given name is already in memory. If it is, it replaces the existing item with new data values. If not, it adds the item to memory. Functionality to get the contents of memory and clear it are provided in the functional global.

 

  1. Open the project and run Example.vi.
  2. Provide information in the Item to Insert control.
  3. Press Insert Item in Memory. The item should appear in the All Data indicator.
  4. Modify the data in the Item to Insert, leaving Name the same. Press Insert Item in Memory.
  5. Notice the All Data indicator continues to have 1 data point, but with updated data.
  6. Modify all values of Item to Insert and insert it into memory. Notice how the item is added to All Data.

To change the elements of the data to store in memory, modify the Data.ctl typedef.


Requirements

Software:

LabVIEW 2012(or compatible)

 

Steps to Implement or Execute Code

  1. Download the .zip file
  2. Set your desired configuration (a, x1, x2, degrees, etc)
  3. Run the VI

 

Additional Information or References
VI Block Diagram

1.png

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

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