05-19-2010 02:25 PM
Using 8.6
I am trying to figure out how to have all my tab pages update continuously. Is this even possible? When I run the VI, the tab does not start "aquiring" data until I click on the particular page number.
The end result is I will be hooking up 10 Geokon crack-meters to a structure and want to select which meter to view via tab control so that I do not have to have so many different deformation gauges on my front panel. Again the issue I am having is that i want data to be read continuously from each individual meter all the time, not just when I select the tab related to the individual meter. I have tried moving the Tab Control in my block diagram outside the inner while loop as well as outside both loops.
Any suggestions would be greatly appreciated.
Thanks
-Dan
Attached is my Vi and two sub VI's
05-19-2010 02:40 PM - edited 05-19-2010 02:48 PM
And here come the state machine suggestions :). I'll let others take care of those.
However, the first thing that jumped out at me is the stop button. Your program wont respond to a user pressing stop if that inner loop is running. That means you are using the abort VI. Tisk, tisk. Also, why are you using property nodes for variables in the same loop? Why not just connect the wire? for instance, move the iteration terminal up by the number to fractional string VI and just wire it straight in, rather than using a property node for the iteration value. I think you are giving yourself a possibly race condition using these property nodes. For example, D_Corrected_1 property node may be read BEFORE the value is updated. Then, you are not getting the value you want.
The main thing here is, get rid of all property nodes you use to get values. You don't need them, just use the wires.
That said, to answer your question, have your data aquisition in a parallel thread. As you get data, queue it up and in another thread dequeue it and write it to the tabs/files there. You CAN use a property node for the tab control and use the pages property. This will return an array of references to the pages. From that you can get the page name. See picture. I don't have time now to get into more detail than that, but that should get you started. Others will come along and add input.
05-19-2010 02:47 PM
aviator3 wrote:Using 8.6
I am trying to figure out how to have all my tab pages update continuously. Is this even possible?
Of course, but not the way you've done it. The VI will only execute the case that evaluates to whichever tab is selected. If you want to update all the meters in all the tabs, then you need to use a loop to update all the meters, rather than a case structure. The tab control doesn't need to be wired to anything.
Other comments:
05-19-2010 02:50 PM
Other comments:
- You are creating race conditions (and you didn't even need local variable to do it!). For example, down at the bottom you are wiring the iteration to a front panel indicator, and on the right you are reading the value using a property node. LabVIEW does not execute left to right. The right part can be read before the write has occurred. This is a race condition. You have other ones in there as well, like with the "Digits_I" indicator being written in the for loop and being read in the case structure. How do you know which one will occur first?
- You don't really need two loops to accomplish what you're doing, and in this case it works against you since when the inner loop is running, the outer loop is blocked (meaning clicking on the Stop button won't respond until the inner loop is done).
- You may want to consider an architecture such as a state machine or a producer consumer.
Great minds think alike! Right on! haha.
05-19-2010 02:54 PM
In general, don't have the tab control do anything at all in your code. I don't think I've ever had the terminal of a tab control connected to any other code in a block diagram. I just use it for its user interface to organize what is seen on the front panel.
Disconnect the tab control. Remove the case structure and let the code inside execute on every iteration of your while loop. (A lot of that code has been duplicated unnecessarily between all of the cases because you wanted it to run all the time any way.)
As imstuck said, don't use the value property node. Use wires instead.
Where you do have repetitive code, make a subVI out of it so you don't have to have 10 copies of the same code.
05-19-2010 03:06 PM
for(imstuck) wrote:
Other comments:
- You are creating race conditions (and you didn't even need local variable to do it!). For example, down at the bottom you are wiring the iteration to a front panel indicator, and on the right you are reading the value using a property node. LabVIEW does not execute left to right. The right part can be read before the write has occurred. This is a race condition. You have other ones in there as well, like with the "Digits_I" indicator being written in the for loop and being read in the case structure. How do you know which one will occur first?
- You don't really need two loops to accomplish what you're doing, and in this case it works against you since when the inner loop is running, the outer loop is blocked (meaning clicking on the Stop button won't respond until the inner loop is done).
- You may want to consider an architecture such as a state machine or a producer consumer.
Great minds think alike! Right on! haha.
Yeah, I saw your post after I posted mine (I was interrupted while writing it), and then when I went to try to edit it to indicate that you had already said the same thing, my computer promptly crashed. Just got it back up.
05-19-2010 03:09 PM
In reply to Ravens Fan, The reason I am duplicating so much code is to simulate the fact that I will eventual have ten Crack-meters running into my DAQ. Currently in the lab I am only running on crack-meter while waiting on hardware to be shipped so that I can get as much of the code out of the way.
That being said I don't know if I explained it right the first time. If I remove the case structure then I will only be manipulating data from one meter not all ten. Every meter comes with its own calibration sheet with values in need to write as constants in order for the calculation to be accurate. So with that being said, how would I remove them from the case structure and yet still have tab control on the front panel and update every meter continously. I am in the process of removing all the property nodes now.
Thanks for you help
-Dan
05-19-2010 03:40 PM
aviator3 wrote:In reply to Ravens Fan, The reason I am duplicating so much code is to simulate the fact that I will eventual have ten Crack-meters running into my DAQ. Currently in the lab I am only running on crack-meter while waiting on hardware to be shipped so that I can get as much of the code out of the way.
That's all well and good, but you don't need to duplicate the code. Let's say you continued with the case structure and tab control the way it is now. Every case in the case structure has identical code, with the only differences being what values you are inputting and what indicators you are writing the results to. Let's say you discover a flaw in your code and you need to divide somewhere rather than multiply. Now you have to find all instances where those calculations are occurring and correct them all.
Instead, if all of those caculations were embedded in a subVI, with the only differences being the values you are sending in and the results you are getting out. Now you have one instance of a subVI that you can duplicate that subVI 10 times.
If you realized you made a mistake, you just correct the subVI one time. If you need to add an 11th instance, now you just drop in another copy of the subVI.
I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
There are other things you can do to make the code more modular and expandable, but wrapping up duplicate code into a subVI is the bare minimum you should be doing.
05-19-2010 03:46 PM
smercurio_fc wrote:Yeah, I saw your post after I posted mine (I was interrupted while writing it), and then when I went to try to edit it to indicate that you had already said the same thing, my computer promptly crashed.
Just got it back up.
Technology sucks.