cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

case structure selector

Highlighted

case structure selector

Hi there,

 

I am having an issue with my case structure selector in my vi. I have it wired to select on/off/auto but it will only work after one cycle of my vi. i cannot select the value i want prior to running the vi. i tried attaching my vi but it wouldn't work so i have attached a screenshot.

is it something to do with having a flat sequence within my case structure?

0 Kudos
Message 1 of 5
(451 Views)

Re: case structure selector

We cannot tell from a truncated picture, you don't even show the case labels. Once the code is running inside the inner loop, the case selector will only get read again after the current iteration of the outer loop completes, and this can only happen once the inner loop and all other sequence frames have completed.

 

Judging from your code, you are making some serious beginner mistakes (overuse of local variables and sequence structure, for example). Also your selector should be an integer or preferably an enum. I doubt the "init to default" node is needed.

 

I would strongly recommend to go over the tutorials and learn the basics of dataflow.

 

Look into a simple state machine with a single outer loop containing a case structure, no sequences and no local variables. Attach your code and we'll show you how.


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 2 of 5
(449 Views)

Re: case structure selector

thanks for the reply,

 

Yeah definitely making errors,this is my first exposure to programming so any advice is much appreciated. Unfortunately this assignment was thrown at me without much guidance at all.

0 Kudos
Message 3 of 5
(445 Views)

Re: case structure selector

No problem. we are here to help. what is the program supposed to do? Again, feel free to attach the VI.

 

You can also try to run with execution highlighting while looking at the diagram to see what's happening. What is your LabVIEW version?


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 4 of 5
(442 Views)

Re: case structure selector

From the little bit you show us, odds are you want to use an enum instead of the cotrol you're currently using to select the state.  You'll also want to be aware that reint all values to default also includes the control you're using to select the state.  That means the first iteration will always run the default value.  Until that's done, it'll ignore your selection

0 Kudos
Message 5 of 5
(410 Views)