LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Activate after elapsed time of inactivity

Hi there.
 
I am attempting to change the status of FieldPoint output if there has been no activity on the VI after 30 minutes. I have no idea if there is a way in LabVIEW to update a time stamp every time there is input from the user and then compare that the the current time.
 
However, I have bigger fish to fry before I ge to that problem.
 
Here's my scenario: My VI controls a pump via FieldPoint. If the user starts the pump, I want to also start a timer. If the user turns the pump off, the pump immediately turns off. If the timer expires the pump also turns off regardless of the button. So far I am ignoring the above section on user inactivity, I am just focusing on trying to turn the pump off after 30 minutes starting when it is activated.
 
Take a look at the following screenshot (note that the 2 seconds will be eventually changed to 30 minutes once I figure out the code):
 
 
Right now here's the series of events:
 
1. I click the button corrisponding to the top-left on the block diagram
2. The loop runs until 3 and THEN the pump starts.
 
My problem is that LabVIEW seems to pause for all inputs to arrive to a boolean AND and thus it is processing serially and not in parallel as I wish it to do. It's almost like I need to move the loop to another thread - would that be a sub VI in LabView?
 
Any suggestions?
 
Thanks!
0 Kudos
Message 1 of 8
(3,032 Views)

Hi jcarter,

      I'm not sure I understand exactly what you want to do, but the attached VI will implement the limited (30min) time-on logic you described.  Post-back if it doesn't meet your needs!

Cheers!

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Message 2 of 8
(3,003 Views)
Hey tdb!
 
Thanks a lot for making that custom VI for me. I was able to change it to work exactly in the manor I need.
 
Thanks again for your time, Joel.
0 Kudos
Message 3 of 8
(2,952 Views)
Hey again.
 
One more problem maybe you can help me with......
 
Now that I have that block diagram you sent me integrated into my own VI none of my other controls work. My guess is the fact that your block diagram contains a while loop and thus nothing outside of the while loop is executed. Do you have any suggestion for me?
 
Thanks, Joel.
0 Kudos
Message 4 of 8
(2,949 Views)

Hi Joel,

      It would be good to see your diagram!  It should be possible to drop that loop on a diagram and have it work independently (unless it's been wired to something.)  When diagram objects are not connected, they should run simultaneously, when connected (dependent on each other for data) they run sequentially.  I've read [here] of problems with programs that use two event structures to process the same events.   Again, it would be good to see - at least a snapshot of - your code. Smiley Wink

Cheers!

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 5 of 8
(2,929 Views)

Hey there.

Thanks again for your continued assistence on my issue.

So taking your suggestion of showing my diagram, I took it a step further and modified what you sent me to show the problem. See the attached "timeout.vi". This is a simplied version of the issue I'm having as it eliminates the FieldPoint unit I am using for controlling the pump.

The problem is that no code executes outside of the timeout While loop, so I have just put a simple boolean control connected to a boolean indicator. I need the indicator to light up when the control is pressed! If you get that working I believe I can adapt it for my more complicated setup.

Thanks! Joel.

 

0 Kudos
Message 6 of 8
(2,899 Views)
Hi jcarter,
 
I decided to take a look at your VI.  The reason your test light is not working is that the only time the VI is checking the status of the button is when you start the VI.  To solve this, you can place the control/indicator in a while loop seperate from the other while loop, so they both run simultaneously.  I'm not sure this will directly translate to how you want your main VI to run, but hopefully its a start.
 
Mike
0 Kudos
Message 7 of 8
(2,895 Views)
Are you trying to run this example on your FieldPoint target? Tbd's example would work great for a desktop computer, but probably not for your FieldPoint, because it uses an Event Structure. The Event Structure is set up to catch user events, but the problem is that the code isn't running on your desktop PC where you press the buttons or whatever, but on the FieldPoint device. So it won't catch those events in its Event Structure.

To run this on your FieldPoint, you will have to revise the code to be based just on polling values, similar to your initial post. You can obtain the same basic functionality using Queues and timeouts. Here's an example that might get some ideas going. The basic idea is to have a second loop apart from the loop the that polls the boolean control and turns the pump on or off. This second loop acts like a Timer loop, and is only active when you first turn the pump on. It then counts down the specified amount until either you turn the pump off manually, or the time elapses. If the time elapses, the timer loop turns the pump of and goes back to sleep.
Jarrod S.
National Instruments
0 Kudos
Message 8 of 8
(2,872 Views)