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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save only one data point per variable/input when condition are true

Solved!
Go to solution

I am trying to create something like a summary file for an experimental setup. The experiment is testing the turbidity tolerance of a fish that can freely swim between two tanks with varying levels of turbidity depending on the presence and absence of the fish in the tank. When the fish has been in one of the tanks for 5 min without moving to the other tank, I want several variables/data points to be saved before the turbidity levels in that tank increase. So each time the fish has spent 5 minutes in one of the 2 tanks I want to save only one data point (one row of data) of a couple of variables (my columns) into a text file. The amount of variables (columns) is always the same and they come from turbidity probes I am reading a voltage from and from some boolean conditions that tell me which tank the fish is in.

 

I have attached a simplified VI I have slightly modified from another post (https://forums.ni.com/t5/LabVIEW/Limiting-data-collected-from-a-loop/m-p/4218076#M1223128) and this is as far as I have been able to get. 

 

0 Kudos
Message 1 of 3
(801 Views)
Solution
Accepted by topic author Math808

Looks like you are writing to the text file every 100 mSec, regardless of conditions.

That seems nothing like what you describe you want.

 

If you only want to write a line when the conditions are true, then put your WRITE FILE operations in a CASE structure that detects the conditions you want.

 

If conditions are not right, then don't write the file.

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 3
(795 Views)

Since we don't have any fish to observe, lets assume we simply want to write to the file every 5 minutes.

 

 

 

Some comments:

 

  • You need to initialize your shift register
  • You probably don't need a shift register, because you don't want to write an ever-growing array containing all old data that has already be written
  • %s is NOT the correct format for floating point numbers. (Fortunately, LabVIEW ignores silly values here!)
  • You are writing relative seconds, a very uninteresting value. Maybe you want a real timestamp instead?
  • ...

 

Message 3 of 3
(788 Views)