LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

start and stop data saving while running the vi

Hi everybody!

Maybe someone can help me on this topic:

I would like to run a vi which displays voltage values on a waveform graph without saving the values automatically. But - while running the vi - I would like to have the option to save the data. That's why I created a switch (on: save data, off: don't save data). I wanted to wire the switch to a case structure, but I don't know where to put the case structure and the "open/create file-vi". If I put both into the while loop (where I write the data to the spreadsheet file) then - of course - it asks me with every run of the loop where to save the data.
If I put the "open/create file-vi" outside the loop it asks me at the beginning of the application where to save the data, even though I maybe don't want to save data.

I don't know if it's understandable what I mean:
If I run then vi I would like to see the data without saving it first (on the waveform graph), then I maybe would like to save it, so I want to press a button to save the data. The vi should ask me where I want to save the data while still running. I would also like to stop saving data without stopping the run of the vi. Maybe I would like to save data to another file within the same run.
Do you know what I mean?

Thank you very much.
Kind regards,
Steffi

0 Kudos
Message 1 of 7
(3,590 Views)
Hi Steffi,

you should use a shift register to remember to path of the save file for the next iteration. When you switch back to "don't save" you delete the value by wiring "not a path" to the shift register...

Also worth of optimizing:
Try to avoid opening/closing the file in each iteration.
Try to use an event structure to catch the save on/off switch to separate UI handling from data aquisition.
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(3,584 Views)
Hi GerdW,

I'm sorry, I don't know exactly what you mean (I'm new in this stuff). Maybe you can give me an example? I also post my vi.

Thank you very much.

Steffi

0 Kudos
Message 3 of 7
(3,582 Views)
Hi Steffi,

see attached vi for some changes Smiley Wink
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 7
(3,580 Views)
Hi GerdW,

that's really good, thank you very much!! It works the way I wanted to: )

You said I should initialize my shift register for the delta t values. I thought the constant "0" would be a good idea, but then my time is only running until 0.250 (in steps of 0.05s) and then starts at 0 again. Do you have an idea why? Otherwise I don't know how to initialize the shift register.

I have another "small  problem":
I would like to have a control on the front panel for scaling the axis of the waveform graph. I set a property node where I can set the values for minimum and maximum. I would like to have a case structure. It should autoscale the graph when it's true and the user should set the values for minimum and maximum when it's false. I'm ok with the "false-part", but I don't find the autoscale function at the property node. Do you have an idea where it is or how I can solve that problem?

Thank you very very much!
Steffi


0 Kudos
Message 5 of 7
(3,573 Views)
Please forget about the "autoscale thing", someone already found it. Thanks
0 Kudos
Message 6 of 7
(3,571 Views)
Hi Steffi,

your first solution was ok as long as you don't restart the vi without removing it from memory before.
When loading the vi into memory the shift register (SR) is reset to zero and is keeping the value from last iteration.

Now you initialized the SR in each iteration to zero, hence the 0-0.250 range of the time scale. To keep the last value you can use another SR as shown in the attachment or use some math based on the iteration count (start time= i * 0.25).

You should only learn from this: initializing SRs makes your vi more reliable... A SR is nothing more than a variable in text based languages, so keep them initialized!


Message Edited by GerdW on 11-07-2007 01:27 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 7
(3,569 Views)