LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interrupting a Loop

How to interrupt a loop and jump control to another loop. When the subroutine terminates, it should return to the original loop. suggest ideas to perform this LabVIEW..

0 Kudos
Message 1 of 9
(2,800 Views)

@vidhya_1309 wrote:

How to interrupt a loop and jump control to another loop. When the subroutine terminates, it should return to the original loop. suggest ideas to perform this LabVIEW..


Use the STOP terminal? Smiley Frustrated

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 2 of 9
(2,796 Views)

If you call a subVI from within a loop in the main VI, it should return to that loop (mainVI) after the subVI has completed.  There is nothing special required.

0 Kudos
Message 3 of 9
(2,792 Views)

Let me guess, you normally work with a text based language right?

 

what is wrong with both loops running in parallel?  Take a look at the templates for Producer Consumer loops.


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 9
(2,791 Views)

Our actual project is "Traffic Light Controller with Ambulance detection". It is a basic traffic light control for the four roads meeting at a junction and in addition, if an ambulance arrives in any one of the four roads, then the traffic should should go green in the respective road and al the other should go red. So, we have designed a basic traffic light control system using a while loop with timings for red amber and green for each of the 4 roads(I have attached our vi). Now when an ambulance arrives ( which we have planned to show by clicking a button), the traffic should go green in that road and red in all the other 3 roads. Our idea is to set a button saying "ambulance" and when it is clicked, the execution of the while loop should stop and the control must be transferred to other loop where the traffic will go green in the corresponding road for a certain timing. When the execution of this loop is done, the control should again be transferred back to the original while loop. How to do this?

(we are new to LabVIEW)

0 Kudos
Message 5 of 9
(2,783 Views)

Your logic is not correct as written regardless of an abulance being present or not. Only one direct ever gets a green light. Shouldn't both directions be green when an ambulance is not present?



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 9
(2,779 Views)

it is like vehicles coming from 4 directions..( the traffic is like a plus sign..)

0 Kudos
Message 7 of 9
(2,777 Views)

Few notes here.

 

In what country does the light go Red->Yellow->Green?  It should go straight from Red to Green.

 

You really should have a state machine.  In fact, I'm going to tell you to look up a CLD practice exam.  The sprinkler one should be a good reference (timer halts when it rains).  The sample exams can be found here:https://lumen.ni.com/nicif/us/ekitcldexmprp/content.xhtml


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 8 of 9
(2,774 Views)

Scratch your code with all these parallel operations and implement a simple state machine. All you need is one while loop with a shift register and a case structure. Look at the state machine templates that ship with LabVIEW.

 

States are:

 

  1. North-South green, East-West red
  2. North-South red, East-West green
  3. North-South yellow, East-West red
  4. North-South red, East-West yellow
  5. ...(you can easily expand with more states)

If an ambulance comes in one of the directions, you simply switch to the appropiate states (e.g. if the other direction is green, you probably still need to go to yellow before going red before setting the ambulance direction to green. Once the ambulance has passed, you go back to the regular programming.

0 Kudos
Message 9 of 9
(2,770 Views)