LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case structure file write from while loop?

Solved!
Go to solution

I would like to have a Front Panel button that indicates whether or not to start recording streaming data.  If the user does not press a button, no data is recorded, and the front panel operates solely as a data display. 

 

What I have now doesn't do this properly.  The button is in a while loop that is attached to a case-structure outside the loop.  I would like a False statement to not record data to any file, but I needed to wire my case structure nodes to something, so the T and the F currently do the same action (sort of).  How do I wire this configuration properly please?

 

Thanks!

0 Kudos
Message 1 of 14
(5,697 Views)

what is it lately, there have been tons of these recording issues on here..

I can't open your file but does this help?

Message Edited by for(imstuck) on 02-03-2009 03:28 PM
Message Edited by for(imstuck) on 02-03-2009 03:31 PM
0 Kudos
Message 2 of 14
(5,693 Views)
heres the false case. This results in indicators showing your data but no writing to a datafile
0 Kudos
Message 3 of 14
(5,689 Views)
I don't really understand your example but in general, you need to have your write or don't write case inside your loop.
========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 14
(5,680 Views)

what is it lately, there have been tons of these recording issues on here..

 

I think NI has over complicated writing data to a file.

 

Specially since the Write Characters to File.vi  has dissapered in recent LV versions.

 

I swear I used that one vi more than any other vi.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 14
(5,677 Views)

Thanks for the suggestion.  Since I am writing to (1) a binary file, and (2) a textfile, I have been instructed to Open the File outside of the loop - so that the file is only opened once.  All of the writing to file occurs within the while loop, with the refnums wired into the while loop for writing, and then outside the loop when the program ends for a Close File command.  The options provided are good ones, but do not help my particular situation because... when I have a False Case (read: please computer, do not record data to disk), the files are still required to Open for the vi to operate. Code attached as PNG.

 

Still stuck.  Help please!
Download All
0 Kudos
Message 6 of 14
(5,660 Views)

You've basically turned your architecture inside out.  You want the case structure inside the loop.  Since everything is inside out, you have a unusual use of a feedback node.  Your case structure will operate first, and it will be based on the status of the Start a Run button from the last time you actually ran the VI.  You also have a Rube Goldberg construction in there.  A boolean ORed with a False will always return the original boolean. 

 

1.  Open files.

2.  Start the while loop.

3.  Have the boolean control feed to the case structure that has the write file in the True case, and nothing in the false except for wiring through error and file path wires.

4.  The stop button would end the while loop.

5.  Close Files.

 

I see you still love that lime green screen.Smiley Wink

 

Also, on your front panel, please move all the controls near each other so they aren't scattered all over the front panel.

Message 7 of 14
(5,654 Views)

Just because you opend the file it does not mean you have to write to it.

 

Open the file outside your loop

Put a case inside your loop

True case write to file

False case just pass the ref num through

Exit loop and close the  file

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 8 of 14
(5,652 Views)

Your case structure will operate first, and it will be based on the status of the Start a Run button from the last time you actually ran the VI. 

 

This is exactly what I want.  Except for the part about the status of Start a Run being based from the previously opened vi - that's just backwards.  Can I fix that?  I want to be able to NOT open files if Start a Run is not selected.

 

You also have a Rube Goldberg construction in there.  A boolean ORed with a False will always return the original boolean. 

Good eye.  That OR statement was pointless wasn't it?  It's been moved to the Department of Redundancy Department.

 

1.  Open files.  Is there a way I can bypass this?  Indicated by user preference?

2.  Start the while loop.

3.  Have the boolean control feed to the case structure that has the write file in the True case, and nothing in the false except for wiring through error and file path wires.

4.  The stop button would end the while loop.

5.  Close Files.

2-5.  See attached.  This is exactly where I was before I started experimenting with the case structure placement.  I want my vi to open to purely monitoring status, and ONLY WHEN the user pushes a button to Start a Run do the files open (now the user can select what/where) and data stream to disk.  I think you know what the problem is when the Open File commands are moved within the While loop, and I don't know how to cleverly structure a case that doesn't open a file until the button is pushed.  Perhaps encircle everything in another While loop?  Or have an enormous Case statement that encloses the while loop that contains my entire vi (True means operate whole shebang with file-writing capabilities, False means operate whole shebang without)?

 

I see you still love that lime green screen.:smileywink:

Monkey miss jungle.  Everything in cave grey.

 

Also, on your front panel, please move all the controls near each other so they aren't scattered all over the front panel.

Roger that.

0 Kudos
Message 9 of 14
(5,644 Views)
Not sure if I saved the correct version on the last post.
0 Kudos
Message 10 of 14
(5,643 Views)