04-22-2013 08:18 AM
Hi all,
The purpose of this LabView is to simulate a DAQ&writting-to-file scenario. The first loop creates the data, within this loop, if the user pushed the write to file toggle switch, the data will be queued and then sent to a TDMS file writing loop (second loop). Finally the last loop retrieves the saved data and displays it in the scroll bar Waveform graph.
If TDMS-OPEN VI option operation option is "open or create"; at first the program seems to work fine but if I want to run the program again, new values will be appended to the ‘first run’ values. The correct operation would be to rewrite or replace the old file and save it with new values (keep same file name). The most logical thing to do is to change the option of the TDMS OPEN to “create or replace” but this doesn’t work and the data or file is not even created. I do not understand why this is happening.
Thanks in advance for your help
호아킨
Solved! Go to Solution.
04-23-2013 03:47 AM
Hi,
From your problem description, I think if your purpose is to append new values to end of old values in file, then your current VI diagram is fine and the appending work should be done correctly.
But if you want to create a brand new file every time you run this VI, then you've changed the open option to "create or replace", I assume you were change this open option for the writing while loop(second loop), that's correct but still not enough, you should branch an error out wire from the "create or replace" Open(second loop) to the error in of "open or create" Open(third loop), this can avoid errors which you haven't noticed and the file/data will be created correctly.
Then you can try if the VI works as your expectation.
04-23-2013 04:01 AM
Worked perfectly.
Thank you!
05-08-2013 12:48 AM
I wanto further improve this VI.
As you can the the while loop that generates the data contain the Write to File boolean control. Would it be possible create the TDMS file ONLY when the user presses this buttom.
Any suggestions on how to get started?
05-08-2013 02:22 AM
The below diagram should work for your needs. Put your second and third loop in the case structure, and use a "local variable" of "Write To File" control for this case structure input in the below while loop. Then the VI can generate the file only when "Write To File" is clicked, not at the beginning time you run this VI.
P.S.: To create the local variable, right-click on "Write To File" >> Create >> Local Variable.
case structure
05-08-2013 03:24 AM
Thank you so much!!
I did what you told me but I'm having trouble generating the Local variable which you told me to generate by right cliking in the Boolean icon. If I do this I get another kind of variable which does not work with the case structure.
05-08-2013 03:47 AM
You may try this way: Right click on your generated local variable, and click "Change To Read" menu item. This changes the local variable to output its value, and then you can wire it to the case structure. In the "FALSE" case structure frame, it should give a default false boolean value to "Stop While Loop", otherwise, the below loop will stop when "Write To File" is false, I assume it's not what you expect.
By the way, you should be careful with "Create or Replace" input, this can help you create a brand new file(or overwrite old file) each time you run this VI, but you should make sure it will not overwrite your data every time you click the "Write To File".
05-08-2013 06:04 AM
Worked fine. Thanks for the tip regarding file saving options, thats why I have changed the first 'TDMS Open' to "Open or Create" this way my data wont be rewritten but new samples will be added to the existing file.
So for the "FALSE" case of the Case structure, I should simply wire the Case structure terminal to the while loop condition terminal?
I noticed that once the Stop Writting or the Stop reading Data buttons are pressed, I wont be able to save data any more until I restart the program, even when the Write To File button is pressed. I would like to have a common swtich between the Stop DAQ, Stop Writting and Stop reading and their respective while loops. So when I press it, all the loops finish and the program terminates. Is there any way to do this?
Cheers!
05-08-2013 09:57 PM
For the "False" case frame, it's fine to wire the case structure terminal to the while loop condition terminal, or just wire a "F" boolean constant to it, both way shuold work.
To stop the VI by clicking only one stop button, I think you should use a global STOP button for all the while loops. For example, you can wire this STOP button to the loop condition terminal of your DAQ while loop, and use two local variable copies of this STOP button in the other write and read while loop. Then all the loops are controlled by the common switch, once it is clicked, the VI will stop running.
By the way, you should configure this STOP button's properties as below dialog(Right click >> Properties), otherwise the VI might be broken because the local variable copy doesn't work.
05-09-2013 05:58 AM
Gotta ya!
谢谢 🙂