LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Case

Solved!
Go to solution

Hi,

 

I have created this vi for setting high a digital I/O by a variable in TS (which is initialized at true). The I/O is set low when the variable become false. For checking the false event I use an event struct but it seems that it never catches the event. I don’t understand why, can you help me to understand my mistake? In TS I launch the vi in a sequence in another thread respect to the main sequence.

 

Best Regards,

Zuc

0 Kudos
Message 1 of 13
(1,513 Views)

Can u send a file for 2020 version ? 

 

0 Kudos
Message 2 of 13
(1,512 Views)

Here the 2020 version

0 Kudos
Message 3 of 13
(1,483 Views)

Grazie.

 

The event structure has to be inside the loop. .

But if you want to measure the time when the StopWhile boolean is true, you probably don't need the event. 

 

 

0 Kudos
Message 4 of 13
(1,475 Views)
Solution
Accepted by topic author Zuc_Lab

Events are primarily for user interactions, not for indicator changes (except for writing to values signaling properties, which would not be useful here because writing to one fires the event even if the value has not changed.)

 

All you probably need is a "last value" tunnel, e.g. as follows:

(And if you are really only interested in whole milliseconds, a simple tick count would not require any multiplication.)

 

 

altenbach_0-1685975737575.png

 

Message 5 of 13
(1,472 Views)

Hi,

 

thank you for the answer! It was the same solution that i have implemented, but i don't get how the event struct works. How is it possible that it catches the event even if there is no change in value?

 

Best Regards,

Zuc

0 Kudos
Message 6 of 13
(1,396 Views)

An event triggers if the value is changed by the user.

 

(A special case is writing to a signaling value property of the control assigned to the value changed event. In that case, the event fires unconditionally. This is intentional. You can always compare old vs new value from the event data node and execute something else (e.g. an empty case inside the event structure) if the are equal.)

 

Event structures require some basic knowledge to avoid problems. (There are a lot of landmines if you don't know what you are doing so start reading here but be aware that I don't agree with some of the statements). LabVIEW is primarily a dataflow language and event structures came much later, Still, they are one of the best tools for UI design if used correctly.

0 Kudos
Message 7 of 13
(1,389 Views)

HI,

 

so if i'm not wrong, the change of a TS FileGlobals variable is not generating any event in labview even if i check the boolean Indicator value, is that right? 

I have tried the Labview API Value(signaling) suggested by you, but it works only on Controls, ad it simply set the Control value, I suppose at the beginning of the vi run, to the wired value, so how do you use it in a vi?

thank you for your patience!

 

Best Regards,

Zuc 

0 Kudos
Message 8 of 13
(1,372 Views)

Hi Zuc

 

You are right the Event structure will not be "triggered" by the FileGlobals Variable. 

The Event structure was mainly design to trigger events from the user interface, like change values, mouse clicks, etc. When using the event structure on a Queue message handler template for example, there are 2 looks one looking for any User interface interaction and a second loop as the executor of the actions triggered by the  other loop. This way you avoid having 2 loops running continuously consuming machine time. 

Check this example to learn more about the template. 

LVNinja_0-1686058104076.png

 

Now, going back to your problem, if you are looking to trigger something from HW input in order to trigger an action (in your example, a digital output), then you will have to continuously read the source of your input. 

 

The Value (signaling) may be used to generate an event programmatically, by reading a hw input an then assigning that to a Control, that control will then generate the event. I don't know how much benefit will this bring rather than watching the HW input directly to trigger some action. 

 

 

 

0 Kudos
Message 9 of 13
(1,342 Views)

@LVNinja wrote:

The Value (signaling) may be used to generate an event programmatically, by reading a hw input an then assigning that to a Control, that control will then generate the event. I don't know how much benefit will this bring rather than watching the HW input directly to trigger some action. 


Careful there! As already mentioned, writing to a signaling value property of a control linked to a "value change" event will fire the event 100%, even if the value did not change (i.e. new=old).

 

We do have "is value changed", "boolean crossing", and other useful tools.

 

If you are spinning the loop to poll a value anyway, an event structure is completely pointless!

0 Kudos
Message 10 of 13
(1,314 Views)