From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

How to Only Save One Data Point Each Second

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

Code that shows how to log data every second on a LVM file.

 

Description

Many applications take more than one data point per second. But sometimes, only one data point per second is necessary to log due to such small change in the data. Obviously the one "per second" is arbitrary, and could easily be replaced with one per minute, per hour, etc. But this program does one per second.

The VI builds an array of random numbers (obviously not the most memory efficient, but fine for this simple program). It will then take an input of Hz, which is also used to calculate the time for the wait function. It then takes the remainder of the iteration count and the desired value. When that equals zero (meaning its a multiple of the Hz input, or on the exact second) it will log that data to OneValuePerSecond.lvm on your C drive.

You will notice in the first column (time) of the lvm, that the seconds will start becoming non-exact. This is due to the software timed nature of this particular program. If your application requires exact timing to the second, than this program is not for you. However, if you are looking to free up some memory in data logging, or save yourself some time in looking through all your data, this is for you!

 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code
1. Configure the Hz to sample. Currently is set to be for 1 sec.
2. Select the path where the file will be, with the name of the file.
3. Select the Run button.

 

Additional Information or References

 Snippet.png

Chris Van Horn
Applications Engineer

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

Comments
j_paiz
Member
Member
on

Is there a way to modify this example to use data from two RTD temperature sensors that I am working with?  I get an error just before the convert to dynamic data function saying I have wired two different data types.   

j_paiz
Member
Member
on

Block Diagram.JPG

j_paiz
Member
Member
on

There is a picture of the block diagram I am trying to work with.  I want to add a producer/consumer loop eventually but for now I was just hopeful that I could get the RTD to log every minute or so. 

 

Also if there is a better way to post my .vi please let me know

 

Thanks in advance  

j_paiz
Member
Member
on

Ive attached my updated .vi where I seem to have worked out my above problems.  Does anything in my .vi raise any red flags??Capture.PNG

j_paiz
Member
Member
on

This one ^ writes to the data file every 180 sec (5min)