12-04-2018 01:36 AM
Hi, guys.
I have a trouble with saving data in VI. I think it would be simple, but I don't know how to solve it...
I will use DAQ assistant to measure 4 sensors, but I keep working on the data save process before doing that with waveform formula.
In my VI, data is saved in every hour into the .txt format, for 1 second only.
I want to save data for 30 seconds or for 1 minute in every hour.
(because in the real process, I need measurement results for 5 minutes at least).
so is it possible to do this easily without adding loop structure?
I found some questions related to mine, they are similar but I don't understand how it works...
12-04-2018 02:47 AM
Hi MSK,
no need for one more loop. And no need for your inner While loop!
All you need is to use ElapsedTime together with an additional shift register. Keep the state of the "save? condition in the shift register.
When state is FALSE you have ElapsedTime to wait for 59min, when state is TRUE you have a wait target of 1min.
Change/negate the state when the time has elapsed…
12-04-2018 05:44 AM
I'd probably get time as time record and check the Minutes. If it's 0, sample and record. That way it'll record the 1st minute of the hour, every hour.
/Y
12-04-2018 12:13 PM
you can certainly use the elapsed time VI to trigger the acquisition and save. This approach, however, means that you are only reading your sensors during that time; a short window once an hour in your case.
If you attack the problem from the other direction, you can get a more fluid user interface and even enable some emergency actions if required (sensor value out of range type of things). Look at Action Engine (AE) https://forums.ni.com/t5/LabVIEW/Community-Nugget-4-08-2007-Action-Engines/m-p/503801#M240328 for your data storage.
1) based on your sampling rate and desired save window (30 sec, 45 sec, whatever) initialize your AE shift registers with an array of the required size. Think of this as a data buffer
2) Continually sample your sensors, updating the front panel and the AE with the new values (rotate 1D array combined with in-place structure "replace array element"); buffer update (most recent N values)
2a) using an array of set size and the "in-place" structure keeps your memory segment within the OS as a contiguous segment.
2b) since you are continuously sampling the sensors, you can add logic for emergency situations (process out of control) and respond accordingly (notification or even emergency shut down if you have that level of control with your hardware)
3) in terms of data saving, you can again rely on the "elapsed time" vi to trigger the save. In this case, however, you will simply fetch the values from your AE data buffer and write them to the file. As opposed to triggering a hardware data fetch event.
4) for implementing this, think two parallel loops (this is why i suggest the Action Engine as opposed to simple shift registers). 1 for monitoring the sensors and updating the AE "buffer" (for lack of a better word). The other loop will check for "elapsed time" and save.
12-04-2018 06:24 PM
Thanks for your comment
But the problem is that I don't understand how to use the shift register to realize this code because I never used LabVIEW like this before.
If you don't mind, could you show me the example?
I am just trying to erase inner while loop and change the condition loop, but still it is hard to do this...
I am really sorry to bother you with this...
12-05-2018 06:52 PM
You can watch the link below.
It explains "How to use Shift Registers"
https://forums.ni.com/t5/forums/replypage/board-id/170/message-id/1096630
12-05-2018 08:42 PM - edited 12-05-2018 08:43 PM
Hi MSK,
the problem is that I don't understand how to use the shift register to realize this code because I never used LabVIEW like this before.
Then you should take those FREE online resources offered to you to learn LabVIEW.
See at the top of this LabVIEW board for "Training resources"!
If you don't mind, could you show me the example?
I don't mind:
(Using XOR to negate the boolean condition when time has elapsed. I love boolean logic operations…)