08-16-2016 04:53 PM
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.
08-16-2016 04:58 PM
Did you try a Case Structure?
08-16-2016 11:26 PM - edited 08-16-2016 11:27 PM
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
08-16-2016 11:43 PM
Try this VI may help you to solve your requirement
08-17-2016 12:13 PM
Thank you, I will look into this
08-17-2016 02:28 PM
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.
08-17-2016 02:40 PM
08-17-2016 04:47 PM
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.
08-17-2016 05:10 PM
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?
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 ...
08-18-2016 12:30 AM
@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.