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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Switching between loops based on elapsed time.

Solved!
Go to solution

Hi,

This is my first interaction with LabVIEW so the solution to my problem might be very obvious. I want a nested loop structure. The outer loop is to run for a defined amount of time during which it switches to the inner loop at regular intervals of time. The inner loop itself runs for a defined period.

For example the outer loop runs for 36 hours (basically it keeps a feed solenoid valve open), then after every 30 minutes in this 36 hrs the inner loop is started (this closes feed solenoid valve and opens backwash solenoid valve for 1 minute).

Now I can keep track of elapsed time for each loop using the elapsed time sub vi but what I am not able to accomplish right now as to how to check for the 30 minute time interval.

Here I have attached a vi inwhich the outer loop runs for 300 seconds and then I check whether the elapsed time is a multiple of 30 seconds or not, if yes and the elapsed time is not zero then switch to the inner loop. But the loop never switches.

Please suggest suitable way out.

0 Kudos
Message 1 of 25
(3,931 Views)

This (homework?) problem sounds very much like one that was discussed here within the last week (or maybe 10 days).  Not sure what you should search for, but I'm 90% certain this was recently answered ...

 

Bob Schor

0 Kudos
Message 2 of 25
(3,914 Views)

I only posted the previous problem but since it did not get resolved I posted again. The solutions given were a little out of my reach.

0 Kudos
Message 3 of 25
(3,909 Views)

@Bob_Schor wrote:

Not sure what you should search for, but I'm 90% certain this was recently answered ...

 


I am 100% sure. 😄

0 Kudos
Message 4 of 25
(3,907 Views)

@kunal7505 wrote:

I only posted the previous problem but since it did not get resolved I posted again. The solutions given were a little out of my reach.


It is incosiderate to simply start a new thread for an old problem. If you don't understand the answer, reply in the original thread and ask for clarification. There is no need to start a new thread for a problem that is already under discussion.

0 Kudos
Message 5 of 25
(3,905 Views)

I didn't mean to be inconsiderate but I didn't want to bother the people with the studpid questions owing to my inexperince with LabVIEW. I apologize!!

Now you have the vi as well. Can you help. Maybe a workaround to the problem. This is just the first phase, I still need to figure out regarding the working with solenoid valves. Once the vi is done I would be able to move to the next stage.

0 Kudos
Message 6 of 25
(3,903 Views)

The key word or the solution given was "state machine", which can be done with less code than what you currently have. Search the forum. look at the LabVIEW tutorials, look at the shipping examples, and look at the design templates that come with LabVIEW.

Message 7 of 25
(3,887 Views)

Thanks for considering my request. I'll try the suggested materials and prepare a vi based on the same and then update. This time on the same post.

0 Kudos
Message 8 of 25
(3,885 Views)

Hi,

I tried to create a state machine, what I have done is defined two cases each for feed valve and backwash valve, within the case structures for each case I have defined while loops which run for the specified time required for each valve to be open. But what I am not able to understand as to how do I make sure that the cases switch based on the time intervals, the tutorial on ni basically switches case based on a manual input of a coin.

0 Kudos
Message 9 of 25
(3,838 Views)

No, you only need the outer loop, but have a case for each possible state. there is no need for inner loops. Keep the state variable (e.g. an enum) in a shift register and initiate transitions to a  new state at the required points in time.

0 Kudos
Message 10 of 25
(3,834 Views)