08-01-2022 03:02 PM
Hi All
1st post. I want to be able to abort Process_1 with the stop button in the attached VI and then reset the stop button so it can be used to abort process 2. I cannot figure out how to reset the stop button so it can be used in the Process_2 event structure. It stays true when I read the new value in the value change event. Tried local variable, value signaling. Any help or suggestions would be appreciated.
Solved! Go to Solution.
08-01-2022 03:17 PM - edited 08-01-2022 03:20 PM
Hi Brian,
@brianmacinnes wrote:
Any help or suggestions would be appreciated.
Restart your VI from scratch! (Sorry for sounding harsh…)
@brianmacinnes wrote:
I cannot figure out how to reset the stop button so it can be used in the Process_2 event structure. It stays true when I read the new value in the value change event.
Because you don't read the stop button (terminal) within the event!
Because you set the mechanical behaviour to "switch…" when you want to use a "latch…" behaviour instead!
08-01-2022 03:29 PM
There are two obvious problems with your code.
Rethink your Event Handling logic and use a single Event Structure.
Bob Schor
08-01-2022 03:36 PM
@Bob_Schor wrote:
There are two obvious problems with your code.
- By "convention" (which you are allowed to ignore, but possibly at your peril!), the "Rectangular" Boolean Icons (Stop, OK, Cancel) have their Mechanical Action set to "Latch when Released", and are meant to be used in a Top-Level VI's Event Structure. You can, of course, change this, but it is ill-advised (it will certainly be confusing to most LabVIEW Users who expect the Latching behavior).
- Much more serious, you have two Event Structures in your VI. I wouldn't dare predict what complex behavior will result, but there's probably a good reason NI warns against this. .
Rethink your Event Handling logic and use a single Event Structure.
Bob Schor
I've noticed that new LV programmers are just fine with case structures having multiple cases, but fail to make the connection that an event structure is just a fancy case structure where cases are executed according to what event happened instead of the value of a wire. They end up thinking that they need a separate event structure for each event.
08-02-2022 04:28 PM
I can make sub VI with their own event structure for each of the processes but I am still stuck on how to provide the user with 1 button to abort each process in the master VI and then reuse the button as a possible abort for the next process.
08-02-2022 06:25 PM - edited 08-02-2022 06:42 PM
@brianmacinnes wrote:
I can make sub VI with their own event structure for each of the processes but I am still stuck on how to provide the user with 1 button to abort each process in the master VI and then reuse the button as a possible abort for the next process.
You make very little sense. Please carefully read all advice, starting with Gerd's.
The secret is a clean state machine, not a pyramid of event structures inside loops inside case structures, and so on! One toplevel loop, one (or NO!) event structure. If your processes can happen in parallel, a little more code is needed but I doubt that's the case here.
You also don't need any local variables!
Don't use signaling value properties!
Process_2_max has the wrong representation.
Since you are polling anyway, you don't need any event structures at all!
If you use typedefs, please attach them too! Why does the state enum not have an idle state?
It is super annoying if the front panel and diagram windows are maximized to the screen. Why?
08-02-2022 06:44 PM
08-05-2022 04:31 PM
Thanks for the input. I will take another stab at defining the flow issue. I have attached 2 main vi and 1 sub vi. The first Main vi uses a while loop to start the vi and using references is able to stop the conditional for loop in the subvi. This is the behavior I want. The second main vi is done with event structure. My current work around is to open the subvi front panel so the user can stop the ramp if needed. I would like to start and stop the subvi with event queue in the event structure but have not figured out how to do the event structure correctly.
08-05-2022 05:45 PM
You have several serious problems:
As I said, you should really improve the overall architecture. This is just a band-aid fix to get it working with minimal changes. Not recommended!
08-05-2022 08:04 PM
Can you resend attachment in version 19. Thanks in advance.