LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically changing case structure

Hello

The vi I have been building has a case structure inside a for loop. I was wanting to have the case structure change every time the loop completes. For example I was wanting to use a string selection input, if the case names are ABCDE and I type in the string input ABCDE could I get the case structure to go A B C D E? Is this possible or any other way I can do this.

0 Kudos
Message 1 of 8
(4,663 Views)

Let me see if I understood your question correctly:

You have a case structure with multiple states (A, B, C, D and E) and you have a string that has an order of letters in which you want to execute the cases.

What you could do is use the 'String subset'  function, with the 'i' counter as the starting position and a length of 1.

For 'N' you should take the length of the string.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 8
(4,659 Views)

I'm a university student and quite new to Labview. That is my plan as how it is to work. If it is at all possible could you post a basic vi of this working.

 

Thanks

Craig McMillan

0 Kudos
Message 3 of 8
(4,653 Views)

What kind of code do you have at the moment?

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 8
(4,641 Views)

The vi i have built below is what i am wanting to use. The two array constants are what i intend to put in a case state. Then have other cases. As you can see the graph will display other letters that are in the different cases, well that is the idea. So if i have a string input i would like it to output a word on the X-Y graph.

 

Thanks

Craig McMillan

0 Kudos
Message 5 of 8
(4,635 Views)

Forgot to post Vi

0 Kudos
Message 6 of 8
(4,634 Views)

First of all, you have way too much code:

 

There is no reason for the local variable. Just branch the wire to enforce execution order.

There is no reason for the sequence structure once you get rid of the local variable.

The small FOR loop does not do anything useful, right?

There is no reason for the built xy graph express VI monster. Use complex data.

 

What you could do:

 

Create a lookup table of small complex arrays, one for each desired letter.

(Since the arrays have different length use a cluster array. You might even append a NaN+NaN to each letter in case you want to ever show more than one at a time, This way you get a gap).

Index into the lookup table to get the desired character.

 

Here's a very quick draft to give you some ideas (LV 2010). This example toggles between E and F, depending if the iteration is even or odd. Modify as desired.

 

Download All
Message 7 of 8
(4,627 Views)

Would it be possible if you would show me how to use a lookup table in this situation or a NaN+NaN? Not sure how to work either.

 

Thanks

Craig McMillan

0 Kudos
Message 8 of 8
(4,617 Views)