LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple ifcase in LabVIEW

Solved!
Go to solution

Hi Friendly Smart Labview Community,
I'm student of Engineering and I try to make interface for my assigments but I have gotten a problem with LabView. With my case, I already write code to receive string from labview and control led. But I saw that the respone time too low and i cant send string in case 3. Any one can explain and give me some advices. Thank you so much.

0 Kudos
Message 1 of 7
(1,296 Views)
Solution

You have three booleans, meaning you can have 8 possible cases, but you only deal with four. (default,1,2,3)

For example if only combine=true, the value would be 4, triggering the default case.

 

If only one switch should be true at any given time, use a radiobutton control instead.

Message 2 of 7
(1,278 Views)

Good evening, sir!

I already change to use Enum control and its right. 
Thank you so much for your help. Have a nice week, sir.

0 Kudos
Message 3 of 7
(1,268 Views)

Here's how you might want to do it. Only two cases and eliminate all that duplicate code. 

 

altenbach_0-1707322897091.png

 

You should probably put the VISA write in the default case. Makes little sense to write empty strings.

 

 

Note that in your case the selector value is the same as the first numeric output, so this would be equivalent. My solution above is more general, of course because you have flexibility about the values for each state, the array values can be chosen freely!.

 

altenbach_0-1707323251769.png

 

0 Kudos
Message 4 of 7
(1,261 Views)

Thank you sir so much. I'm going to take more time to think your idea and revise suitable with my requirement.
Thank you sir so much again.

0 Kudos
Message 5 of 7
(1,251 Views)

Good morning Sir.
I'm understand your idea and I already did it well.
But It occured new problem. I try to replace value in that position but I couldn't see the method to do it. Value in Flat Sequence  will be continously send in 5s. Then change value and will be continously send in 5s or 6s....
The picture below is my idea.
Do you mind if you can give me some advices

My ideal.png

0 Kudos
Message 6 of 7
(1,148 Views)

Your code makes no sense in terms of dataflow. You cannot wire three different sources to the same input, of course. Also 15 seconds to complete a case is way too long. Why is there an indicator inside the case structure?

 

What you need is a simple state machine that spins the loop at a reasonable rate and switches state and output data as a function of selection, time, and user input.

 

Can you explain the functionality in more detail? Should the selector reset after one operation or continue forever until a different mode is selected? Should the "combine" case really go 1, 2, 1, 1, 2, 1, 1, 2, 1, ...  with 5 seconds between or should it do a single 1, 2, 1, cycle? Why is the visa write not inside a case? It seems pointless to write an empty string 10x per second when nothing is selected. Does the instrument really need that?

 

Also you have again all that duplicate code. For example you really only need a single instance of that format string, right? At this point, remove the instrument input and just use a string indicator until all the logic is worked out.

0 Kudos
Message 7 of 7
(1,107 Views)