09-13-2012 12:39 PM
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..
09-13-2012 12:46 PM
@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?
09-13-2012 12:50 PM
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.
09-13-2012 12:51 PM
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.
09-13-2012 01:31 PM
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)
09-13-2012 01:38 PM
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?
09-13-2012 01:43 PM
it is like vehicles coming from 4 directions..( the traffic is like a plus sign..)
09-13-2012 01:50 PM
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
09-13-2012 02:03 PM
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:
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.