LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Does labview have a "GO TO" function?

When I took Fortran in college many years ago, there was a feature where you could call a sub-routine by using this command "GO TO" and the complete syntax was something like "GO TO 100" and that would take you to line 100 and start executing line 100 and beyond (pardon me if I am not remembering it exactly correct).

 

I have a flat sequence structure and in the 3rd frame, I have three TRUE/FALSE case structures, of which, only one can possibly be TRUE at any time.  If case 3 of the cases is TRUE, I'd like to be able to go immediately back to the 1st frame of the Flat sequence structure, and that reminds me of a "GO TO" command.  How do I accomplish this with Labview?

 

Thanks,

Dave

0 Kudos
Message 1 of 34
(11,275 Views)

You need a state machine. You will be able to get rid of the flat sequence all together and go back to any state you would like at any given time. Also, if only one boolean can be true at any given time you don't need multiple case structures. You can do something like what is shown in Figure 3c in the link I have provided.

Message 2 of 34
(11,269 Views)

Here is an image of a slight modification to figure 3c to show you how to have only 1 case structure which will have the code you want to execute in each case depending on which boolean is true. You would have cases for 0, 1, and 2. Now, if you have stuff in the false cases of your case structures you would have to modifiy this. I am making the assumption you execute code in your true cases, and do nothing in your false cases.

 

Edit: oops, wait (ms) should be outside the case structure.

 

.

Message 3 of 34
(11,263 Views)
0 Kudos
Message 4 of 34
(11,234 Views)

Hi Greg,

Thanks for the input.  Actually, I had already built a state machine, and it works fine.  But, I got stuck when I was creating a sequence, and I don't know how to convert the output into integers to call a single case structure.  Instead, I have 3 TRUE/FALSE case structures, which is not desirable. So, how do I do that?

 

I am measuring voltage and putting the values into three boxes, LOW, MID, and HIGH, pretty straightforward.  Then, depending on which range the voltage falls, I want to call either case 1, case 2 or case 3.  Once I do the comparison (less than, greater than, in range and coerce, etc.) I get a Boolean output.  But, I can only find Boolean to 0,1.  I need to convert the boolean outputs to 1,2,3, and would like even higher cases too.

 

I see the code in 3c.  What is that function with the True/False input and the Build Array feeding into it?  What is that function?  I was reading that article last week and studied it over and over again, but, I couldn't understand that picture 3c because they don't

offer any naming of the various functions used to build it.

 

Thanks a lot!

 

Dave

0 Kudos
Message 5 of 34
(11,194 Views)

Search 1-D array.  It is searching the arry to find a True.  It will return the index of the first element that is true, or -1 if no element is True.

0 Kudos
Message 6 of 34
(11,179 Views)

If you already have a state machine why are you using a sequence frame? The state machine can do everything you need. Within you state include the logic to chose the next state. It sounds like you already know what conditions will drive your decisions. If you find that you are using the same logic in determining the next state in several places this can be made into a subVI. I strongly recommend that you abandon using the sequence structure especially if you already have a state machine.



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 7 of 34
(11,176 Views)

It might speed things a bit if you can post your code (ID'ing what flavor LabVIEW it is in).

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 8 of 34
(11,160 Views)

Escuse me, but could you show me how to make the blue "structure" please (with "next", "state" ...)

Sorry for mistakes, I'm french ^^

0 Kudos
Message 9 of 34
(10,879 Views)

The blue constant is an Enum, when wired to a case structure it automatically uses the Enum names.

/Y 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 34
(10,872 Views)