LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Activating/Deactivating a SubVI with a boolean switch

I am curretly trying a setup a SubVI which can be activated and deactivated using a boolean value. The subVI is capable of toggling on/off with its own switch, though external values do not appear to help.

 

I am ultimately trying to automate the  subVI such that every hour it will run for 1 minute and then wait until the next hour again and have been trying to keep that in mind with the design.

 

I've attached a photo of my current setup with the computer image representing my current VI (lower) and subVI (upper). Any help would be appreciated. Thank you.

0 Kudos
Message 1 of 12
(4,254 Views)

Did you try a Case Structure?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 12
(4,246 Views)

Just use State Machine Architecture with states for Polling Time and executing Sub VI,

In the Polling state check for Elapsed time whether 1 hour is reached, if reached transverse to Executing sub VI State and again start polling for Time

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 3 of 12
(4,204 Views)

Try this VI may help you to solve your requirementWait for Polling.png

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
Message 4 of 12
(4,198 Views)

Thank you, I will look into this

0 Kudos
Message 5 of 12
(4,167 Views)

What would the secondary case structure for executing the VI look like? I am able to cycle to the execute function, however it won't cycle back to the wait period proeprly.

0 Kudos
Message 6 of 12
(4,149 Views)
-You need to pass poll for state after your vi execution in other case.
-you can check basic state machine tutorial here : http://www.ni.com/white-paper/3024/en/
Thanks
uday
0 Kudos
Message 7 of 12
(4,144 Views)

I am struggling to understand how to properly hold it in an on state for more than a second. Everything else appears to function just fine using the timers and picture above.

0 Kudos
Message 8 of 12
(4,124 Views)

Although I often dislike Express VIs, the Elapsed Time VI has really won me over.  In its simplest form, it has two inputs that matter to you -- the Time Target (number of seconds until the Time has Elapsed output becomes True) and Auto Reset, which makes it automatically start over.  Oh, there's one other input you should leave unwired, called Set Start Time -- if left at its default value of 0, it starts everything running from the first time you call the function.

 

To illustrate, here is a "Blinker" that flashes the Time has Elapsed indicator once every 2 seconds (you'd wire your "Do This Code every N seconds" routine to the True case of a Case Statement driven by this indicator, with the False case being empty).  This entire loop runs 10 times a second, which means that it is pretty responsive to outside control (such as pushing the Stop button) -- if you need "faster" response, you can shorten the wait time.  You probably don't need to worry about lengthening it, as I'm guesstimating that the Elapsed Time routine will only add sub-microseconds of "wasted" processing, so why not have a reasonable response time?

Elapsed Time.png

By the way, if you are wondering where the nice Icon came from, I right-clicked the Express VI and chose "View as Icon".

 

Bob Schor

 

P.S. -- out of curiosity, I removed the Time has Elapsed indicator and the Wait function, then ran the loop "as fast as possible" for about 10 seconds in order to measure the "raw" loop time.  I "guesstimated" it was sub-microsecond -- wrong, it was about 10 microseconds.  Still, 10 microseconds every 100 milliseconds means that this Elapsed Time function occupies 0.01% of the loop time, pretty good in my book ...

Message 9 of 12
(4,120 Views)

@Vorfall wrote:

I am struggling to understand how to properly hold it in an on state for more than a second. Everything else appears to function just fine using the timers and picture above.


I have attached the snippet in my above post, if you are having LV2015 you can able to access as a VI where you will get proper direction.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 10 of 12
(4,104 Views)