LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

start/stop data saving

Hello everyone,

 

I am new to labview so the question I have is probably going to be extremely easy for you.

 

I am working with a software to acquire data, I would like my software to save data as well. What I want is a "save" button that once pressed starts saving and a "stop saving " button to terminate the saving without interrupting the data display. At the moment I have the save part inside a while loop (that can be stopped by another stop button), but I am only able to save data if the save button is already pressed before running the program. Ideally I would like my program to be able to save also if I start saving data after the program is already running. 


I hope someone could help me,
Thank you very much in advance!
Best Regards,

 

Meggy

0 Kudos
Message 1 of 4
(3,446 Views)

Meggy,

  • Please do not post screen shots of code unless they are LabVIEW Snippets (I'm guessing you don't know what these are ...).  Pictures of code are difficult to examine "beyond the edges" (and often the problem is in "the rest of the code" that we can't see) and almost impossible to run (there's rarely a workable "run arrow" in a picture).
  • I can't see how your program is structured, but I do notice that you have a Sequence structure in your picture.  The Principle of Data Flow (on which LabVIEW is based) means that you almost never need to use a Sequence, particularly if you use the Error Line that is found at the lower corners of most LabVIEW functions (as functions on the Error Line must run in sequence).
  • Your problem of wanting to acquire data, start saving data, and stop saving data (while continuing to acquire) is not uncommon.  Let's assume you only want to save once (for simplicity -- you can make it more complex later).  What do you need to do?  It seems to me that you have the following steps to take:
    1. Initialize everything.  Get your data acquisition ready to roll.  If you are going to be saving data to a file, open the file for writing.
    2. Start acquiring and keep acquiring until you push the Save switch.
    3. While the Save switch is pushed, keep acquiring but saving the acquired data.
    4. As soon as the Save switch is "un-pushed", close the file and keep acquiring until the Stop button is pushed.
  • I've just described something called a State Machine, with the following States: Initialize, Acquire1, Save-Acquire, Acquire2, and Exit.  If you open LabVIEW, click on Create Project, choose Template, and find Simple State Machine, LabVIEW will build you a Project for a Simple State Machine and explain how it works (read the included Documentation).  Now adapt your problem to this model.

Bob Schor

Message 2 of 4
(3,428 Views)

@meggy92 wrote:

..., but I am only able to save data if the save button is already pressed before running the program.


That makes no sense. You are reading from a local variable that always returns the current control state.

 

The code you show with that unknown subVI is labeled as "create data file". Maybe you should find the location elsewhere that "saves the data" to that created file and also make it dependent on that same boolean.

 

Your problem might be that if you switch later, the file never gets created because that code has already executed.

 

(I won't comment on the code, because we only see a tiny fraction. For more specific help, attach the VI)

Message 3 of 4
(3,420 Views)

Hi,

 

To clarify, do you want to have a button which logs data to file when it is pressed? This is probably relatively simple. You probably have a data acquisition loop. Put a case structure, operated by a Log Data button. Inside the case structure will be a logging vi that writes the data acquired in the current loop to a file. The file open/close functions will be added outside of the acquisition loop as necessary.

CLA - Kudos is how we show our appreciation for comments that helped us!
0 Kudos
Message 4 of 4
(3,382 Views)