LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to let a boolean restrict data passing.

Im using Labview 8.2 and I need some help with a VI. How do you let a boolean (on Okay button on the front panel) become a button to let a signal pass though a wire. In my VI, I want the user to have control over when he want to take data. When he/she press start, the program will take data and display it on the front panel, but not store them to write in a file at the end. When the user click Okay, data will be stored..in this case, at the end of a loop. Plus I would like to know if there is a way to have a counter to display how many signals was passed and stored. Thanks!
0 Kudos
Message 1 of 7
(3,237 Views)
OK,

You're asking something quite basic.

Connect the boolean to a case that in true save to file.
I recommend one thing... start doing the program. Then, post the code and I help you completing it.

But see the following example to give you some tips.
http://forums.ni.com/ni/board/message?board.id=170&message.id=239385#M239385

It's very simple. But try a little bite
Software developer
www.mcm-electronics.com





PORTUGAL
0 Kudos
Message 2 of 7
(3,224 Views)
I dont think a case structure will work. I want to destory the data when the boolean is false. In a case structrue, what should be in the false window so the outside while loop does not store anything. I attached a screenshot of my vi, because it containes other sub VIs.

I have 3 signals that merge into one. Afterwards, I want the control to restrict/allow data to flow.
0 Kudos
Message 3 of 7
(3,219 Views)
post an piece of code and the labview version.


Software developer
www.mcm-electronics.com





PORTUGAL
0 Kudos
Message 4 of 7
(3,207 Views)
Your program has some major flaws I think and a small picture isn't enough to expose all of them I suspect. Your idea of destroying the data is not very efficient. It would appear that you are always taking data. If you really don't want to acquire anything until the user selects that option, it would be better to put the actual acquisition code inside a case statement. Also, the data you pass to the next frame (and why are you using a sequence structure?) would only be the very last results of an acquisition. If you intend to save everything that was acquired while the Boolean was true, you need to redo that. If the user were to acquire some data, click the acquire Boolean to false, and then click the stop button, you would lose everything. You need to spend some time studying data flow and shift registers.
0 Kudos
Message 5 of 7
(3,204 Views)
Labview 8.2.

I added a case structure, but I dont know if the data going out of the loop to be stored will be dynamic data.
0 Kudos
Message 6 of 7
(3,201 Views)
Virus,
 
I think that your code would be well served with a properly placed shift register.  The shift register will pass data from one iteration of a loop to the next.  This way, you can keep a running tally of things like the number of averages calculated, or the signals which you have acquired.  In a case structure you would have your VIs for acquiring and analyzing the signal, the signals that these VIs produce would be appended to the signal coming in from the shift register.  This would effectively add the current signal acquired to the signal that was acquired in the past.  In the false case (when acquire data is not pressed), you could either just pass on the data without appending anything new, or you could append a constant of some kind to show that no signal was acquired for your graph.  It just depends on what you want your data to be shown as. 
 
Around this case structure, you would have a while loop where you would have your stop acquisition button wired.  The data from the while loop's shift registers will not be passed out until execution of the while loop is complete, so one graph in the example shows nothing until the stop acquisition button has been pressed.  The one inside the loop will show the data that is being acquired.
 
Finally, as a note, you should handle your errors through your program, not only is it good coding style, it helps to define the data flow patern so that you don't need sequence structures.  Note also that I unbundle the error cluster and if there is an error, the program will be ended.  I think that this is something that is often overlooked, but is important, because if there is an error with the acquisition or the analysis, you probably want your program to end, and at the very least, you would want to know of that error and clear it for the next iteration of the loop.
 
Take a look at the example VI I have attached, I think that you should be able to take the concepts there and apply them to your own code.  These programming concepts are discussed in some of our learning LabVIEW material.  You may want to consider going through one of our free online courses to pick up some of these concepts, or better yet, sign up for one of the classes where a certified LabVIEW instructor will cover all the programming concepts of LabVIEW.  You can find all of these resources here:
 
 
Have a great day.
Brian Coalson

Software Engineer
National Instruments
0 Kudos
Message 7 of 7
(3,163 Views)