LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Structure

Solved!
Go to solution

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

Download All
0 Kudos
Message 1 of 15
(3,308 Views)

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.

0 Kudos
Message 2 of 15
(3,307 Views)
Solution
Accepted by pnam

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".

 

 

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
Download All
Message 3 of 15
(3,273 Views)

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.

 

0 Kudos
Message 4 of 15
(3,266 Views)

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.

 

0 Kudos
Message 5 of 15
(3,266 Views)

I re-wrote your test1.vi using User Events. Take a look. Hope it helps!

 

 

0 Kudos
Message 6 of 15
(3,264 Views)

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

0 Kudos
Message 7 of 15
(3,221 Views)

Thank you.

0 Kudos
Message 8 of 15
(3,192 Views)

Could you plesae convert it to 8.2 and send it to me please .

 

Thanks

0 Kudos
Message 9 of 15
(3,191 Views)

Here are my examples converted to 8.2.

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
Download All
0 Kudos
Message 10 of 15
(3,162 Views)