LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Which is the best structure for start/stop data logging?

Hi everybody,

 

hope I can explain my problem good enough that anyone can help me:

I have a VI which continuely shows on a graph the voltage of a Analog Input of a DAQ device. Now I want to allow the user to start/stop with a click on a button data logging. Means that a second loop writes to a selected path every ms the data to a spreadsheet file.

 

At the moment my VI works like this:

You run the VI and Labview asks you one time for the file path, then you can start and stop the data logging. But you can do it only one time. If you want to log a certain time later another file, you have to close and open the whole VI again which is not very professional...

 

My target is:

It is onlyl necessary to start the VI one time. Then you can select a new file path, log data, select another file path, logging data again....and so on...

 

Which programm structure is necessary, can anyone help me as a labview beginner with that issue? I attached the VI if someone just wants to edit that...

 

Thank you for your help!! Markus

Download All
0 Kudos
Message 1 of 8
(3,970 Views)

Have a question

If the data acquisition loop rate is 10 ms, why is the logging loop rate at 1 ms?

 

Have couple of suggestion (not the best) just a quick workaround and temporary fix, if I understand correctly the function being tried to achieve here,

1. Move the File Dialog VI inside the true state of the case structure

2. Build the data in the Acquisition loop over a period maybe 1 sec or predefined interval in and 1D array and then log the data in the file.

 

Could not edit the VI since, i am using LV2010.

 

 

 

 

0 Kudos
Message 2 of 8
(3,953 Views)

Hi WeißeWolke,

 

in general using a case structure to start/stopping data saveing is ok...

 

- Why do you write to the file each millisecond while your DAQ loop is timed with 10ms?

- Why don't you use the boolean functions for all those boolean logic involved?

- Why do you use a hidden control to forward data to the saving loop instead of a local of the chart?

- You should have a look on notifiers or queues to send data from one loop to the next...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 8
(3,952 Views)

A good start would be to put the logging functions into a state machine.  Having code outside of the while loop means you can never get to it again once the program has started.  Have states for:

Select path

Start Logging

Stop Logging

Use shift registers to store the path and a logging? flag

You could use an event structure to do this.

 

0 Kudos
Message 4 of 8
(3,943 Views)

@NaruF1 and GerdW

 

you are right, there is a mistake, both loop rates should be the same (10 ms) 🙂

 

@NaruF1

yes you understood correctly that the file dialog should appear every time the user wants to start writing a new log-file. The voltage we measure is a analog signal, so there will be several interesting periods we want to save for a later analysis in Excel.

 

To your 2nd point: if it works with a array it will be fine. But it must be possible to log data for lets say 5 minutes, so the array won´t be too large? (5 min @ 10  ms loop rate will be 30000 rows..

 

attached is the VI, saved as LV2009..

 

Thanx a lot!

 

@GerdW

..you ask why I didn´t create a structure like you recommended with notifiers or queues? The simple answer would be that I am not familiar with all this.. just began to write my first Labview programm. I will have al look to the LV help with all that stuff... Thank you a lot

0 Kudos
Message 5 of 8
(3,925 Views)

Hi,

 

I have modified the VI in a very crude method (again not the best way Consider using State Machine at a later stage of development or Queued state machine with Producer Consumer) using event structures.

 

I could not validate the functionality since, do not have a daq card details nor had the chance to simulate the same.

 

Hope this helps.

 

Regards,

 

 

Message 6 of 8
(3,914 Views)

@NaruF1

 

thank you a lot, i will test the VI tomorrow!!

0 Kudos
Message 7 of 8
(3,907 Views)

White Cloud,

Simple cleanup.  A nice addition would be to put the event timeout on a shift register, then use the start logging button to set the timeout to a (user selectable) value.  The stop logging case would set the timeout back to -1.

Michael.

0 Kudos
Message 8 of 8
(3,903 Views)