LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Structure Triggering Questions: Local Variables, Value & Value(Signaling) Property Nodes

I am having trouble with data-flow and priority when it comes to event structures.

 

Somehow, local variables work to trigger the event even though all the examples and advice I have seen point to either using a value (signaling) property node or the actual Boolean control?

garretw_2-1587581962396.png

 

In regards to Value(signaling) I have found multiple ways that they will work. Is it better to use the property node outside or inside the event structure?

If property nodes inside are better, how should you be setting it once inside the event structure, 'True' or 'False', i.e. does that have any affect on if the event structure triggers or not?

garretw_3-1587582233959.png

However, this also works with the property node outside, signalling the actual boolean inside.

garretw_4-1587582446014.png

 

My problem lies with this last frame, even with the 'Times Up' variable in a false state  when I begin the program, if I return two false states to the OR gate prior it still registers the 'Times Up' event case even though the value (false) should technically never have changed.

 

I want to be able to use an event structure with a timed event inside it, however, I also want to be able to stop it at any time and none of this has been working very well so far. The event may enter the desired case where my timing starts but then I need the user to be able to trigger a 'STOP', I can't figure out how to immediately move to my 'stop' event without waiting for the timer to finish...

 

Very confusing. I could be using property nodes all wrong so that is also a consideration.

 

Any help is much appreciated!

 

 

 

0 Kudos
Message 1 of 17
(4,443 Views)

Hi garretw,

 

a value(signal) property triggers an event even when the value didn't change. Point.

 

Your images don't make a lot of sense: triggering the event case twice inside the event case is nonsense. Using a while loop inside an event is not recommended. Using an event structure inside an event case is not recommended...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 17
(4,436 Views)

Thank you for the points, that is helpful!

 

My program has multiple sequential stages where I am checking limit switches to verify that it is behaving correctly. I am using a state machine to accomplish the segue between states. I am using an event structure in most of the stages of the state machine to either move forward or move to the STOP state based on user input. In this way I have already used my 'Stop' and 'Interlock' variables in an event structure in the earliest frame of the state machine. How can I accomplish this same construct later in the program using value(signaling)/property nodes?

Also, some cases are dependent on timing. The user inputs will not work immediately and it won't exit as soon as I add any kind of timing element into the structure. This is mainly what is causing me so much grief.

 

garretw_1-1587592364113.png

 

0 Kudos
Message 3 of 17
(4,400 Views)

@garretw wrote:

 

If property nodes inside are better, how should you be setting it once inside the event structure, 'True' or 'False', i.e. does that have any affect on if the event structure triggers or not?

garretw_3-1587582233959.png

 


As has been said, none of your code makes any sense. Yes, a value(sgl) property fires unconditionally, even the new and old values are the same. Now let's look at the picture above. You are firing two events in parallel and there is no telling which one will execute first (assuming these events are in the same event structure).

 

If you want help, you need to show us your entire code. Long verbal descriptions and flat pictures are too ambiguous to give guidance.

 

 

0 Kudos
Message 4 of 17
(4,368 Views)

DO NOT bury an event structure inside another event structure like you posted in that one picture!

 

Read Caveats and Recommendations when Using Events in LabVIEW - LabVIEW 2016 Help

0 Kudos
Message 5 of 17
(4,362 Views)

Hi garret,

 


@garretw wrote:

My program has multiple sequential stages where I am checking limit switches to verify that it is behaving correctly. I am using a state machine to accomplish the segue between states.


I don't see a state machine in your images. Again: please attach the real VI(s)!

 


@garretw wrote:

In this way I have already used my 'Stop' and 'Interlock' variables in an event structure in the earliest frame of the state machine. How can I accomplish this same construct later in the program using value(signaling)/property nodes?


There is no "frame" visible in your images…

And it most probably is the wrong code architecture when you need to rely on some property nodes firing events "later in the program"!

To start a state machine you should draw your algorithm - using a pen on a sheet of paper! Have you done this before?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 17
(4,346 Views)

It doesn't make any sense because I don't know how to use the property nodes to trigger an event, that is what I am asking:

I also can't use just one event structure in the state machine because if I step into a timed state (there are several), the user stop inputs won't trigger the 'Stop' event until that piece has timed out. In this way, I am using an event structure in almost every state of the state machine, however I am still running into timing issues vs. an immediate stop. This is my main question and what I am trying to accomplish in the 'Charge Wait' state, but I simply cannot figure out a way without waiting for the timing to end.

 

Otherwise,

As in this picture, I want the 'STOP' event to execute if 'Stop' OR 'Interlock' user inputs have been activated by the user. From what I have seen online it is totally acceptable to be using two different triggers for an event case. My confusion comes from how I can repeat this functionality in other states.

garretw_0-1587657421060.png

I meant for the pic below to have the same functionality as that above, but I could not use the original booleans anymore. The true driving the 'Stop' or 'Interlock' was not to trigger the state, it just won't compile if I don't give them a value + I don't know how to use them.

garretw_1-1587658711685.png

 

See VI: Right now, it seems to work fine even if I don't have the boolean that I am using to trigger the event, inside the event. I even took out the local variable for the trigger of that event and it still worked.

 

The VI attached only works up to the 'Charge Wait' state of the state machine. Use the LED status on the front panel to advance. Dump Status needs to be 'On' before the program is started. I am new to Labview so I'm sure there are a million things wrong otherwise and I COULD build it much better but for now I am still learning and the questions above are the most pressing.

 

In conclusion, I have no idea how to have an event that is dependent on timing but also have the ability to bug out whenever the user desires.

Also, is there a standard way to trigger event structures when the original boolean has already been used in the program?

 

0 Kudos
Message 7 of 17
(4,309 Views)

Hi garret,

 

place just one event structure, holding all event cases, before (or after) the case structure.

Place indicators like "Status" or "Sequence#" after the case structure: no need for local variables in each case!

Use shift registers for "variables" (like "Sequence#" to get rid of even more local variables!

Using a LED as control (like "Interlock") isn't this intuitive…

 

This can be so much simpler in the end.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 17
(4,305 Views)

Trust us on this one: your current code will be a nightmare to debug. Using multiple event structures is VERY prone to errors. The killer here is that ALL event structures statically monitoring a button press will catch the event, so if you have two in series that watch the Stop button, BOTH will trigger the first time you push it, even if the dataflow hasn't reached the second event structure yet.

 

I'd say your quick solution to fix this would be to use dynamic event registration. Right click the event structure and choose "Show dynamic event terminals". You can right click those and get the Events function menus. Use a Register For Events and wire a refnum for your Stop control (right click -> Create Reference), then wire that into the Register For Events, then select Value Change. (I'd also right click that event and make sure "Lock front panel until event executes" is unchecked). In the Event Structure, make sure you're registering for the *dynamic* Stop- Value Change event, *not* the static Stop- Value Change event. They're in different places in the list; dynamic ones are towards the top and are by themselves.

 

The last thing you MUST do is to add an Unregister For Events after that event structure executes.

 

Event structures are sneaky. They begin listening for events when the VI first starts, NOT when they're encountered in dataflow. You want them to only "kick in" after the program gets to that point in the code, so you'll need to manually register the events (i.e., "start listening for events") with the Register For Events function, then Unregister for them once you're done.

 

The rule of thumb for new event structure users is to only have one in your code, but the more thorough rule is "never have two event structures listening for the same thing at the same time, and if you have multiple event structures, be VERY careful to not deadlock them".

 

Shifting gears, re: "I do not know how to use the property nodes to trigger an event": Write a value, ANY value, changed or not, to the Value(Signaling) property node and it'll trigger. Reading the value can be done in the NewVal terminal inside the event case, and you can filter for only True values there.

0 Kudos
Message 9 of 17
(4,299 Views)

The Value (Signaling) property simulates a user's value change to the control. That's all. Every event structure in the VI will queue the events it is registered for, no matter how long ago it happened. That's why it is always the best advice to never have more than 1 event structure in a VI.

 

You just need to stop using event structures entirely. It's unnecessary for this simple of an application. Time to go back to basics with your state machine. Why can't you just use a simple polling mechanism in the waiting loop(s)? It stays responsive and uses next to nil resources. Save the optimizations for when you understand these concepts better.

 

NI online training is free during these strange times. Look it up and take advantage!

_______________________________________________________________
"Computers are useless. They can only give you answers." - Pablo Picasso
0 Kudos
Message 10 of 17
(4,284 Views)