From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Imbedded while loops, having an event execute once each time a button is pressed

Hi again guys,

 

I have a simple problem to solve which has been driving me nuts these past few days. I am writing a logger for a calibration test which will be performed later in the week, and I have been tasked with the following: For each test, write the date, the device name, the setpoint, and _calibration.csv.

 

So this means that the process of reading/writing data to/from the DAQ will always be happening, but when the user pushes the "Log Data" button, the program will take a snapshot of the current setup, write the info in the title and header, and then execute a while loop to log the data.

 

I have attached two test vi's which I have been working on with the problem. In the first one, I tried to use a sequence structure to get the title info to execute, and then log data in a while loop. The problem is that the title generator continues to run, which is not what is needed. In the second vi, I tried to use a boolean structure to perform the same process...same issue.

 

 

If anybody could point me towards some resources to read into, or see if my boolean logic in the loop is slightly off, I would appreciate it

 

Thank you again for your help,

Huntr

Download All
0 Kudos
Message 1 of 4
(2,069 Views)

I have attached LV 2015 vi's, as I am using 2018

Download All
0 Kudos
Message 2 of 4
(2,065 Views)

A good rule of thumb- if you think you need a sequence structure to make something work, you are probably doing something wrong 😉

 

I'm honestly not sure what you're trying to do with either of these programs, but based on the description you provided, you should look into Event Structures. Run through the examples in Help -> Find Examples to get you started.

 

It sounds like you want continuous measurement/acquisition to display on the screen at all times. If the user presses a button, you want to start writing the data to a file until some other event happens- maybe another button press, maybe a time delay, whatever.

 

A simple state machine style architecture would work for this, or just a flag that says "Log or not". When you first click the button, execute some code that does your initialization stuff, and set a True flag in a shift register. When you acquire data, plot it to the screen. If the flag is True, log it as well.

0 Kudos
Message 3 of 4
(2,050 Views)

@BertMcMahan wrote:

A good rule of thumb- if you think you need a sequence structure to make something work, you are probably doing something wrong 😉

 


I'd say "If you think you need a sequence structure to make something work, you probably do not understand the Principle of Data Flow", perhaps the key concept in using LabVIEW.  Go back and do Core 1 (or the initial LabVIEW Tutorials mentioned in the LabVIEW Training Resources on the first page of this Forum).

 

Bob Schor

0 Kudos
Message 4 of 4
(2,036 Views)