LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Put the same indicator in different cases in a case structure?

Solved!
Go to solution
Is this possible? I don't seem to be able to do this. I want a single indicator to display a different value depending on the case, but in block view I can only put the indicator in a single case.
0 Kudos
Message 1 of 12
(2,162 Views)
Solution
Accepted by topic author achb

There are a lot of different things you could do but without seeing any code it's hard to say which would be best. You could always put the indicator after the case structure and pass out the value that you want written to it.

Matt J | National Instruments | CLA
Message 2 of 12
(2,145 Views)

What if the indicator is inside various loops in the case structure. And it is difficult to bring it out of the case structure? 

I came across this issue when I used a waveform chart in different cases of the case structure. The chart itself is inside a for loop and a while loop in each case. Any ideas/ suggestions is highly appreciated. Thank you.

0 Kudos
Message 3 of 12
(328 Views)

You could use local variables, but you have to be real careful of race conditions.

0 Kudos
Message 4 of 12
(325 Views)

Hi pclab,

 


@pclab wrote:

The chart itself is inside a for loop and a while loop in each case.


Sounds like you used a wrong code architecture!

Why not use one while loop with a case structure inside instead of a case structure with a while loop in each case?

 

Even though you were asked to provide some (example) code you still only provide very little information on your VI.

Please provide an example VI!

Another useful suggestion in such cases is: Instead of asking for "how to improve my current code" you should ask for "what do you want to achieve"!

Best regards,
GerdW


using LV2020 on Win8.1+cRIO
0 Kudos
Message 5 of 12
(320 Views)

Well.

 

I am trying to move a linear stage motor in different fashions and acquire the energy of laser (from an energy meter) transmitting through a sample placed on the stage motor.

In the first case (no Ebar, TRUE case): I need to move the stage 80 mm and as it moves I need to record the energy simultaneously till the motor reaches the endpoint (i.e 80 mm). Then it should return to its home position and would need to repeat itself for the 2nd scan. The total number of scans (scan count) would be requested by the user.

In the second case(with Ebar, FALSE case): The motor needs to move 250 micrometer wait there till 10 shots (shot count) of laser is recorded, averaged, find standard error, and further move 250 um, 10 shots recorded, and so on until a total of 80 mm is moved.

The recorded data has to be plotted in a waveform chart for both the case, and I need it to be plotted on that same waveform irrespective of what case is chosen. (The second case would be a plot with error bar)

I am upgrading a very old program that was made by our seniors. So some ideas are very old and retained here. Any suggestions for improvements are highly appreciated. The VI is attached.

Using: LabVIEW 2010 SP1, Windows 10 Pro, locally made stage motor connected via serial port and energy meter connected via GPIB.

P.S. This is not my original post, but I thought it might be of some help to people who would visit this post.

0 Kudos
Message 6 of 12
(316 Views)

Hi pclab,

 


@pclab wrote:

I am upgrading a very old program that was made by our seniors. So some ideas are very old and retained here. Any suggestions for improvements are highly appreciated. The VI is attached.

Using: LabVIEW 2010 SP1, Windows 10 Pro, locally made stage motor connected via serial port and energy meter connected via GPIB.


I suggest to start over from scratch! (There are very questionable code constructs in your VI like that stop button completely in the wrong place!)

 

I would implement a proper statemachine: only one (1) big loop, with only one (1) case structure inside. Each case is one state, like "initialization", "cleanup" and all those measurement steps in between…

I also suggest to replace those old GPIB functions by VISA functions: handling devices on GPIB port becomes the same as handling devices on serial port!

Best regards,
GerdW


using LV2020 on Win8.1+cRIO
0 Kudos
Message 7 of 12
(311 Views)

Is it possible to use visa serial port to communicate with instruments connected via gpib?

0 Kudos
Message 8 of 12
(255 Views)

Hi pclab,

 

why do you want to use a serial port for GPIB communication? That's something completely different...

Best regards,
GerdW


using LV2020 on Win8.1+cRIO
0 Kudos
Message 9 of 12
(239 Views)

I mean "functions". You asked me to replace gpib with visa functions.

0 Kudos
Message 10 of 12
(223 Views)