09-02-2011 10:16 PM
I have attached a simple code (test.vi) with a case structure. Is it possible replace the case structure with an event structure (testvi.vi)( using user event?)
If yes please let me know the solution . I am trying to modify an already existing code with an event structure and am running into problems.
Thanks in advance,
-P
Solved! Go to Solution.
09-02-2011 10:28 PM
Anything is possible. But a case structure has a completely different purpose than an event structure. A case structure is to take one of two or more different actions based on a condition. An event structure is designed to wait for something to happen than take an action.
We can't answer your question without know what it is you are really trying to do here.
09-03-2011 03:06 PM
It appears that you are simulating checking the level in a Tank and you want to perform an action when the level reaches a certain point.
Assuming this is correct, it is usually best to do the data acquisition and level check in a loop that is separate from your Event Structure loop.
This is called a Producer/Consumer design pattern.
See the attached example "test1vi mod.vi".
For extremely simple situations or a quick test, the Timeout Event can be used for what I call a "Poor man's Producer/Comsumer".
See the attached example "test1vi mod 1.vi".
09-03-2011 04:17 PM
The Answer is most definitely yes, you can use user events. In fact, it is my preferred method of communication between processes. You will need 2 while loops one will hold the event structure, the other will fire off a user event whenever a condition is met. Look up some examples of user events. There are many, many other ways to accomplish what you are trying to do (queues, local variables, etc.). It's all a matter of preference and need.
09-03-2011 04:17 PM
The Answer is most definitely yes, you can use user events. In fact, it is my preferred method of communication between processes. You will need 2 while loops one will hold the event structure, the other will fire off a user event whenever a condition is met. Look up some examples of user events. There are many, many other ways to accomplish what you are trying to do (queues, local variables, etc.). It's all a matter of preference and need.
09-03-2011 04:50 PM - edited 09-03-2011 04:51 PM
I re-wrote your test1.vi using User Events. Take a look. Hope it helps!
09-05-2011 08:18 AM
Thanks everyone for the response. Here is what I am actually trying to do.
I have a Labview code (attached) which 'sends out a trigger and saves data from 4 channels every time we hit F8 or a button on the front panel.
('Triggering' in the Event structure)
I would now like to modify the code as follows:
1) Press F8 and the very first time one of the channel signal crosses (yet to determine which channel) a user defined threshold, I would like
to 'sends out a trigger and saves data from 4 channels'
2) I would like to make minimum modification to the structure of the code and use the event structure that already exists.
I am working with somebody else's code and am not an expert in labiview. Any help will be highly appreciated
09-06-2011 10:09 AM
Thank you.
09-06-2011 10:09 AM
Could you plesae convert it to 8.2 and send it to me please .
Thanks
09-06-2011 12:23 PM
Here are my examples converted to 8.2.