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.
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.
02-25-2017 10:33 AM
Hi everyone,
I'm pretty new to LabVIEW but have become the person in charge of reworking the code that runs the MFCs on our vacuum system. We run toxic gases, and as such, I wanted to know if there was a way to properly reinitialize the default values of the MFC inputs (all to 0) anytime something makes LabVIEW close or somebody aborts the execution of the VI.
I've tried using an Invoke node for my MFC cluster inside an Event Structure using both the notify and filter events for both Application Instance Close and Panel Close, but both of these have failed to shut off nitrogen flow. I've gotten the Panel Close? filter event to work with the invoke node, but only if LabVIEW prompts me to save changes before shutting down.
Any insight would be greatly appreciated. Thanks!
02-25-2017 10:42 AM
Hi everyone,
I'm pretty new to LabVIEW but have become the person in charge of reworking the code that runs the MFCs on our vacuum system. We run toxic gases, and as such, I wanted to know if there was a way to properly reinitialize the default values of the MFC inputs (all to 0) anytime something makes LabVIEW close or somebody aborts the execution of the VI.
I've tried using an Invoke node for my MFC cluster inside an Event Structure using both the notify and filter events for both Application Instance Close and Panel Close, but both of these have failed to shut off nitrogen flow. I've gotten the Panel Close? filter event to work with the invoke node, but only if LabVIEW prompts me to save changes before shutting down.
Any insight would be greatly appreciated. Thanks!
02-25-2017 10:42 AM - edited 02-25-2017 10:45 AM
Hi Eric,
reinitialize the default values … anytime something makes LabVIEW close or somebody aborts the execution of the VI
Yes, sure!
Program your VI so the user can never abort it!
Program it so it will never close "on its own"!
- Hide the tool menu for running VIs.
- Create executables so your users will never work with VIs in the IDE.
- Check for errors.
- Before you stop your program you need to output your "default" values…
- Think about state machines…
I've tried using an Invoke node…
Ok, you write to an invoke node when your program exits? What should happen when the program just exits?
You need to avoid "exiting" your program when you want to execute certain parts of your code…
02-25-2017 11:52 AM
Let me "second" what GerdW said, and add a few things.
Bob Schor
02-25-2017 12:22 PM - edited 02-25-2017 12:37 PM
@EricJHU wrote:
Any insight would be greatly appreciated. Thanks!
OK, you need to discard the "panel close?" filtering even by wiring a TRUE to the discard? terminal, then trigger all your shutdown code instead. Resetting all values to default is ineffective if the program closes nanoseconds later, before the new values have even been read elsewhere in the code and propagated to the external hardware.
Of course there also needs to be external, non-software features to properly shutdown the hardware if somebody would accidentally unplug the computer or the computer crashes due to some other event.
It is difficult to tell but it seems that the communication with the hardware is via TCP/IP. Is on the other end a cRIO or similar, also running LabVIEW code? In this case you could implement some watchdog code there that automatically shuts down the hardware if no communication has been received from the master over a certain interval.
In any case, looking at the code I see big NoNo's! It is a mess with many very questionable constructs and many places where race conditions and even deadlocks could hide. Some casual observations:
This is just the tip of the iceberg. My laptop screen is only 1080p so I cannot efficiently inspect your code. Good luck!
02-25-2017 12:53 PM
And certainly you need to stop using the Abort button.
What was that LabVIEW Proverb? Oh yes.
02-25-2017 01:09 PM - edited 02-25-2017 01:26 PM
@altenbach wrote:
- Most of your scaling and math could be done on arrays instead, using 10% of the code.
Here's a quick example how you could use array operations. Also check the math for your convoluted unsigned>signed 16 bit integer conversion (insert on right).
02-25-2017 01:54 PM
Shame on me for posting a response without first looking at the code! The First Priority should always be to have code as "clean and transparent" (meaning easy to see and understand by someone who knows LabVIEW) as possible. If you can't understand the code by looking at it (which means not having to scroll around just to see the entire Block Diagram), you won't be able to grasp the logic and feel confident in handling "unusual cases" such as shutdowns and error conditions.
Bob Schor