06-06-2011 09:59 PM
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
06-06-2011 11:49 PM - edited 06-06-2011 11:53 PM
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.
06-07-2011 12:04 AM - edited 06-07-2011 12:07 AM
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.
.
06-07-2011 03:12 AM
Do not use Flat Sequences!
06-07-2011 01:32 PM
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
06-07-2011 02:09 PM
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.
06-07-2011 02:13 PM
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.
06-07-2011 04:23 PM
It might speed things a bit if you can post your code (ID'ing what flavor LabVIEW it is in).
06-12-2012 06:11 AM
Escuse me, but could you show me how to make the blue "structure" please (with "next", "state" ...)
Sorry for mistakes, I'm french ^^
06-12-2012 06:22 AM
The blue constant is an Enum, when wired to a case structure it automatically uses the Enum names.
/Y