LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to File controlled my a boolean

Guys,

I'm looking some help with a VI I'm creating, I'm new to labview so I hope ye can help. I have a loop that is receiving data from an rs232 device and I want to be able to send this data to a text file. To activate the data capture with a Boolean and then to stop the data capture with the same boolean. Any ideas. I can get the data capture to start automatically when the while loop starts no problem but this is not ideal. Do I need to create a sub VI for the data capture?

Regards,
P
0 Kudos
Message 1 of 9
(4,170 Views)
If I understand correctly, you just have to replace the while loop that is doing the file write with a case statement. The while loop is bad anyways because you can't stop it and you don't need to constantly do a file open and close. I've attached a modified version. I also cleaned up some of the wiring and removed the local variables. You might want to read the LabVIEW Style Guide chapter in the LabVIEW Development Guidelines (Help>Search the LabVIEW Bookkshelf). Also, the use of a stacked sequence structure is unneccessary and just hides the code. You could use the flat sequence structure or just use data flow to do all of those VISA Reads and Writes before you get to the main while loop.
0 Kudos
Message 2 of 9
(4,151 Views)
Hi Dennis,

Thanks for the help. I'm still new to Lab view so thanks for the tips. I have a request, I need to be able to capture multiple *.txt files from the one execution of the VI, how is this possible? Do i need to create a sub VI for this? I have being trying to figure this one out but I can't. Also apologies I uploaded the wrong file, I had one similar to yours, with the file open close outside the while loop, but I uploaded the wrong one. (Must have been in a rush out the door, Friday evening!)

Thanks once again,
P
0 Kudos
Message 3 of 9
(4,139 Views)
What do you mean "capture multiple *.txt file"? Capture usually means read. Do you also need to read files or do you want to write to multiple files? If you want to write multiple times, you can duplicate the code you have with a different file name for each, create a subVI from the code and call it multiple times, or do a single write and then use the Copy function (File I/O>Advanced).
0 Kudos
Message 4 of 9
(4,123 Views)
Hi Dennis,

I'll try to explain myself a bit better and hopefully I can get my idea across.

Once the data has started streaming from the sensor I wish to write data to a file controlled by a Boolean.

Once the Boolean becomes true it will prompt the file name (file open) and begin writing raw data, when this Boolean becomes False Boolean the raw data will stop being written to this file and the file will be closed.
The data from the sensor will remain streaming no matter what state the Boolean to control the file is in. If the Boolean state is changed to True again it will create a new file or replace (file open) and again write the data to a file, once the Boolean changes to false the file will be closed.
This file write operation should be possible as many times as one wants without having to restart the sensor VI.

I hope this helps clarify the situation.

Regards,
P
0 Kudos
Message 5 of 9
(4,106 Views)
Can anyone help with this please. I'm farily stuck and i have not been able to find any examples of how to do what i need to do.

Regards,

P
0 Kudos
Message 6 of 9
(4,087 Views)
Hi,

Please find attached example useful and helpful 🙂

Cheers!
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 Kudos
Message 7 of 9
(4,075 Views)
Hi Ian,

Thank you very much for that example it appears to be perfect for my application, your a life saver.

Once again thanks,

P
0 Kudos
Message 8 of 9
(4,061 Views)
You're most welcome!

Cheers!
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 Kudos
Message 9 of 9
(4,052 Views)