09-19-2023 07:01 PM
Hi,
I am trying to save analog output from a pressure transducer to a spreadsheet using NI USB-6218 and LabVIEW 2022. The transducer works fine.
I have a case structure inside a while loop. The case structure contains the part where the data is stored to a file.
My goal is to initiate the save operation using a Boolean switch. I want to save the data for 10 seconds, without stopping the while loop, and be able to repeat the process of saving the data (for 10 seconds every time I hit the Boolean switch) until I choose to stop the program.
I have tried working with the 'Elapsed Time VI' but I can't seem to make it work for me.
Any help would be appreciated.
Thanks,
lza
Solved! Go to Solution.
09-20-2023 12:55 AM - edited 09-20-2023 12:59 AM
Hi Iza,
@laz_2331 wrote:
My goal is to initiate the save operation using a Boolean switch. I want to save the data for 10 seconds, without stopping the while loop,
I have tried working with the 'Elapsed Time VI' but I can't seem to make it work for me.
I see two options:
Btw. why are there two attachments with the very same filename, but with different size?
09-20-2023 12:04 PM
@GerdW wrote:
Btw. why are there two attachments with the very same filename, but with different size?
The smaller one is LabVIEW 2019, the larger 22.3. (Yes, It is typically a very bad idea to use the same file name for different files!)
09-20-2023 12:15 PM
There are several serious flaws, for example having the path control inside would stall the code if the path is invalid.
Why are there two stacked case structures all you need is make the "extract data" button latch action and reset the timer if true, then wait for the tome to elapse.
Your bias has a race condition because if will only apply to the next iteration, not the current because of glaring misuse of a local variable.
Of course you also need to decide how to handle exceptions, for example what should happen if the users presses save again while it is already saving, etc.
09-20-2023 12:57 PM
See if this can give you some ideas....
(You should use low-level file IO to keep the file open. "Write to spreadsheet file" will open and close the file with each call for significantly more overhead. Not sure of the bias control should be latch or switch action)