LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

dinamic case selector value

Is it possible to connect the case selector value up to a user input that is set by the front pannell?  If so, how, if not, is there any other way to do dynamic case selection?
0 Kudos
Message 1 of 9
(3,538 Views)
What kind of user input are you talking about? You can connect a case statement to a ring control, an enum, or even a combo box. The values in these must be defined and you cannot add new cases. What exactly are you tring to accomplish and how dynamic does it need to be?
0 Kudos
Message 2 of 9
(3,531 Views)
I want the user to be able to enter 3 numeric values on the front pannell.  Then I want the case structer to be connected to the increment of a for loop and from 0 to value1 be the first case, value1 to value2 be the second case and value2 to value3 be the third case.
Does that make sence?
0 Kudos
Message 3 of 9
(3,527 Views)
Not really but it's Friday and it's been a long week. You want to have three separate numerics on the front panel? You want the output of the case structure wired to a single for loop? As I said, you cannot change the values handled by each case at run-time. I'm sure there is a work-around but I need some more details on why you want this.
0 Kudos
Message 4 of 9
(3,522 Views)
I don't think you need/want a case structure. 



Naturally, you will want some kind of error checking to make sure that value1<value2<value3


Message Edited by jasonhill on 05-19-2006 02:34 PM

0 Kudos
Message 5 of 9
(3,516 Views)
Here is another approach (LV8). Like jasonhill's, it does no error checking.

Lynn
Message 6 of 9
(3,508 Views)

Thanks for your help, this is really good.  As I was working this demo into my existing code, I relized that there were more complications.  I attached a VI that modified your code to do what I needed it to do.  I must worn you first off that I am not proficient at writing code so it may be rather convoluted.  Due to this let me explain in detail my desired outcome:

If you look at the Case execution array created after the program has ran I want it to have case 1 for the number of times that is specified by the user in Numeric, then I want it to have case 2 once.  I want it to repeat this pattern of case 1 and case 2 for the amount of times in Numeric 2.  Then I want it to have case 3 once.  I want this repeated for the duration of the loop. 

For example.  If Numeric=3 and Numeric 2=2.  The array will be 111211123111211123111211123...until stop is pressed. 

The code almost does this, except when case 3 is asserted it clobbers the following case 1.

So for the previous example instead of the desired output above I get.  1112111231121112311211123... 

In other words I want an extra case 1after case 3 where the _ is: 111211123_11211123_11211123...

Do you know how I could mod my code to do this?  If not, is there different code that would get the desired results?

0 Kudos
Message 7 of 9
(3,488 Views)
I can think of two ways to do what you want. You logic seems to be something like this:

Set LoopCounter1 = 1
Set LoopCounter2 = 1
Loop until Stop
Case1
Case 1 code
If LoopCounter1 < Numeric Then
Set LoopCounter1 = LoopCounter1 + 1
Repeat Case1
Else
Set LoopCounter1 = 1
Go to Case2
Case2
Case 2 code
If LoopCounter2 < Numeric2 Then
Set LoopCounter2 LoopCounter2 + 1
Go to Case1
Else
Set LoopCounter2 = 1
Go to Case3
Case3
Case 3 code
Set LoopCounter1 = 1
Set LoopCounter2 = 1
Go to Case1
End Loop



One involves nested loops. It also requires queues, local variables, or global variables to get the current "Case Executing" value to the fornt panel indicator.

The second is a state machine. This is a while loop with a case structure inside. The next state is passed via a shift register. The State Machine architecture is very versatile and highly adaptable. I strongly recommend that you become familiar with it.

Lynn
Download All
0 Kudos
Message 8 of 9
(3,474 Views)

thanks

That is very helpful

0 Kudos
Message 9 of 9
(3,467 Views)