From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I fire an event case on the value change of an indicator, or a network variable?

Hi!  I have an event structure setup to look for a value change of an indicator on the front panel.  The indicator is updated by the value of a boolean network-published shared variable through a seperate parallel loop that is polling all of the network-published shared variables.  The event, however, does not fire when the indicator changes value.  I have switched the indicator to a control and tested it with user interaction and that works just fine.

I want to use the event structure space for my code exectution because it seems logical that that is where it would go, and it will help keep my block diagram tity.  The code is also something I would like executed with the front pannel temperarily disabled.  I would rather not have the code in my network-variable polling loop because again the tity issue.   I would also rather not use a notification VI wired to an independent loop for this particular code.

Is there a way to have an event structure fire an event with the value change of an indicator, or a network variable directly?

Thanks for your input.
LV 8.5
-Nic
0 Kudos
Message 1 of 8
(4,630 Views)
You can fire an event by writing to a signaling value property of your boolean indicator. Be aware that this will fire the event unconditionally, even if the new and old values are the same. To filter for value change, you would need to place the property node in a case structure and use e.g. a feedback node to activate the case only if the value has actually changed.
0 Kudos
Message 2 of 8
(4,622 Views)
Thanks for the reply.

I went about things a little differently, but got them to work so..... .  It really was not my desire to have a boolean indicator on the front panel.  As previously stated, my ultimate goal was to have an event fire on the change of a network variable, which I had to poll for anyway but that is tucked away in a section where I am handling all my network variables.  I ended up using that Create User Event, Register User Event, and Generate User Event SubVIs to handle the task.

I've read the help for all of those SubVI's and it is not entirely clear to me if the event fires every time the "Generate User Event" receives some inputs, or if it only fires when the value changes.  I could do a test to find out.  It wouldn't be too difficult to add a shift register or a feedback node and place the Generate User Event in a case structure so that it is only fired when the input changes state.
0 Kudos
Message 3 of 8
(4,614 Views)
Oh yeah, it is firing like crazy.  I'll have to use a feedback node in my loop.
0 Kudos
Message 4 of 8
(4,613 Views)

@Altenbach, this is exactly what is happening in my case. I didn't use feedback node. I just compared old val and new value and only changed the property node if they were different.

 

However, I would like to know if using feedback node is better, how would one accomplish that? THanks!

I may not be perfect, but I'm all I got!
0 Kudos
Message 5 of 8
(4,012 Views)

@VeeJay wrote:

@altenbach, this is exactly what is happening in my case. I didn't use feedback node. I just compared old val and new value and only changed the property node if they were different.


Yes, that's what I do these days. (However, if the event case shares several events, the feedback node needs to be used.)

0 Kudos
Message 6 of 8
(4,009 Views)

Hi Altenbach,

 

What about when I want to trigger an event when a boolean in another while loop switches to TRUE, i.e. when my main control loop detects an error, I want the event loop to fire an event to stop the program. Would I still have to use shift register or can I just monitor the new value and if it is true, I trigger the event. And also, would property node (value signaling) or local variable be the best option for this?

 

Thanks!

I may not be perfect, but I'm all I got!
0 Kudos
Message 7 of 8
(3,990 Views)

Duh! I just read what I wrote and I figured out what to do. I have to compare TRUE or FALSE before I trigger the event. Not just compare the NEW VALUE inside the event case (in this case the event has already triggered).

 

Anyway, help with property node vs local variable would be helpful. Plus, I am triggering out of an indicator (error indicator boolean).

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 8 of 8
(3,989 Views)