03-14-2011 01:55 PM
Hello all,
I have two VIs. One that generate some complicated signals (sine wave, impulse, etc.). The other one takes manually inputted voltage and pressure send them out to some hardware with a pump, and reads back the output of the pump.
What is the best way of sending the waveforms from the signal VI to the manual control VI? I still need to be able to control the signals manually in that manual control VI.
Thanks.
Solved! Go to Solution.
03-14-2011 01:59 PM
Hi,
Functional globals (SubVI, NO global variable) should be the best way to go.
03-14-2011 02:16 PM
I would use queues for this. They guarantee delivery and do not have sequencing issues (they are FIFO). They are also very fast (faster than functional global).
03-14-2011 02:50 PM
I am not familiar with queues. Does this mean I will be running the two VI in parallel? Also, how does the manual control VI know whether to use the manual input or the input from the queue? Thanks.
03-14-2011 03:43 PM
hi
For exactly this kind of process, I am using queues, FG and (relax ppl, I know..) global variables. If you are writting a global in one Vi and reading it in another (to prevent accidental (fake)updating); globals are easy to implement. Many people hate them (I do, sometimes) but for these kind of cases I think they are well adapted.
For FG you need a user control and a vi for each variable you want to share... Both FG and globals are "bottle in the ocean" like of information : you send some info and sometimes this info will arrive somewhere...
If you need to be sure that the info is passed then Queues are to be used...
N
03-14-2011 04:26 PM
Did you try a search? This question has come up several times before. A few examples:
http://forums.ni.com/t5/LabVIEW/How-to-pass-pass-data-between-the-VIs-in-real-time/td-p/1067496
http://forums.ni.com/t5/LabVIEW/Pass-data-to-SubVI-state-machine/td-p/330180
http://forums.ni.com/t5/LabVIEW/pass-data-of-a-vi-to-another-vi/td-p/139856
03-14-2011 04:35 PM
Thanks, but this still doesn't answer my problem with the manual control part. How does my VI know whether to use the value from the control or from the queue. I think the first post might actually be talking about that, but most of it was beyond me.
03-14-2011 04:40 PM
Your UI would handle that. If you are using a state machine (hint-hint) you would simply chose the appropriate state for your current configuration. You would provide some mechanism (UI, configuration file, command line argument to name a few) for setting which mode to use and the application would chose the appropriate action.
03-14-2011 04:45 PM
@nitad54448 wrote:
hi
For exactly this kind of process, I am using queues, FG and (relax ppl, I know..) global variables. If you are writting a global in one Vi and reading it in another (to prevent accidental (fake)updating); globals are easy to implement. Many people hate them (I do, sometimes) but for these kind of cases I think they are well adapted.
For FG you need a user control and a vi for each variable you want to share... Both FG and globals are "bottle in the ocean" like of information : you send some info and sometimes this info will arrive somewhere...
If you need to be sure that the info is passed then Queues are to be used...
N
While you may not run into race conditions using global variables in a write once/read many approach they do not protect you from some part of your application deciding to write to them. FG at least provide some level of protecting access while globals do not. In addition, global variables can create multiple copies of your data. If your data is large, this can be problematic. I much prefered using a defined messaging scheme. The intent is very clear and you can provide safe guards. Even FGs are better. I personally would never recommend the use of global variables even though some cases MAY work out. A defined API is always a prefered approach and helps to keep the code modular and decoupled. This leads to greater reuse. Global variables tie things together and make reuse more difficult.
03-14-2011 06:06 PM
@DFGray wrote:
I would use queues for this. They guarantee delivery and do not have sequencing issues (they are FIFO). They are also very fast (faster than functional global).
I would probably go with DFGray and use a queue. But be careful that you are not enqueuing faster than you are dequeuing or your pump control may be responding to last year's events...