12-20-2018 01:07 PM
Hi all,
Does a switch (boolean) set to a mechanical action "switch until released" keep a "true" value after the command initiates a specific case structure? I'm developing software to control an existing instrument whose front panel switches have different purposes depending on what part of the menu is active. As such, I'd like to reset a switch as soon as the command initiates a specific case structure, so as to keep using it deeper into the menu... Would I need to use a property node? Anyhow, if anyone could point me to an example VI or have any suggestions it would be appreciated.... Thanks in advance, Fred
12-20-2018
01:13 PM
- last edited on
05-06-2025
02:09 PM
by
Content Cleaner
You usually don't want to use a front panel control / button to store a value through multiple parts of your code. Ideally, you can use the event triggering of the button press to set a boolean value within a data cluster or variable that makes its way through your code.
"Switch until released" will stay True until the use un-clicks the button. This is usually only used when you want to allow the user to hold down a button for a period of time and the amount of time they hold down the button directly affects the application.
Please include a Snippet of your code, or attach your VIs, so that we can better assist you.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
12-20-2018 01:14 PM
12-20-2018 01:36 PM
Thanks for the fast reply James.
I'm just beginning the coding and thinking about the approach. Would there be a way to "disable" a specific case structure? That might provide the functionality of the same front panel switch being used for different purposes. I'm thinking indexing would allow different parts of the case structure/code to be disabled or enabled.
12-20-2018
01:39 PM
- last edited on
05-06-2025
02:09 PM
by
Content Cleaner
Without seeing your current attempt or fully understanding what you're trying to do, you probably can use one of the simple architectures commonly used in LabVIEW to do what you want.
The Simple State Machine template that ships with LabVIEW is really the best way for new developers to get familiar with LabVIEW while utilizing a semi-scalable architecture.
Here's a broad example of how a state machine works:
The Producer/Consumer architecture is based on a producer loop adding data to a queue and the consumer loop dequeueing the data. The process-intensive or time-hogging code goes in the consumer loop to free up the producer loop to run at the speed you need it to run.
For example, you have code that acquires data every 100ms and needs to write that data to file. It takes 50ms for the acquisition code to run and 80ms for the write-to-file code to run. Uh Oh! You're now taking 130ms per loop and your application is backing up. Now you move the write-to-file code to a consumer loop and enqueue data to it from your producer loop. Voila! Your 50ms code and 80ms code run in parallel and can both keep up with the 100ms period.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'