From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple if else if statement to load different images into 2D Picture

Hi All

I come from a c# background and am struggling with labview

i want to load a specific image onto my front panel depending on the output of my algorithm 

The output of my algorithm ranges from 0-360 

I want to implement a conditional statement like

If (0 < x > 45)

     load image from path a;

else if (45< x > 90)

     load image from path b;

else if (90 < x > 135)

     load image from path c;

.......

 

Could anyone give me some direction? 

Thanks in advance

 

 

0 Kudos
Message 1 of 13
(3,432 Views)

Use In Range and Coerce.

 

What happens if the value is exactly 45, or 90, or greater than or equal to 135?

In Range and Coerce has right click options to determine whether the upper or lower limits are included in the range.

0 Kudos
Message 2 of 13
(3,417 Views)

The LabVIEW Tutorials available on the Web (or on the first page of this Forum) will tell you about LabVIEW Structures (such as the Case Structure), Comparison Functions (such as Less Than), Boolean functions (such as And), and an interesting one, "In Range and Coerce".

 

If you are familiar with C and its variants, you know about the Switch statement.  The Case Structure is a more intelligent version of Switch (there is no "fall-through" to unmatched Cases).  Note that you can also use the Case Statement without needing to use the Comparison and Boolean functions, but I'll let you learn about that from the Tutorials (or the LabVIEW Help on the Case Structure).

 

Bob Schor

0 Kudos
Message 3 of 13
(3,415 Views)

A case structure will work for you.  Each frame handling a different range.

else.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 4 of 13
(3,406 Views)

This is one of those times I like enums

Capture.png

Capture1.png

Those enums make it easy to extend functionality when the number of pictures change during development.  (use a  Ring instead if you may need to have programmatic control.  Like reading a list of paths from a configuration file)


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 13
(3,378 Views)

Hi Jeff 

 

I tried your solution out but i think i made a balls of it 

can you take a look at my vi and see where im going wrong 

i just want to display a specific image between certain values of "angle of sail" indicator

 

thanks

0 Kudos
Message 6 of 13
(3,340 Views)

im also unable to attach both fuzzy logic files 

but the output of the angle of sail file should be 0 and 360

and that is the value i want to determine which image is displayed

0 Kudos
Message 7 of 13
(3,328 Views)

Use the features of the "In Range"

Range.png

Labview 4.0, 5.0, 6.1, 8.6, 2009, 2011, 2012, 2014
If you do not know something, ask me.
0 Kudos
Message 8 of 13
(3,327 Views)

@macfernan wrote:

I tried your solution out but i think i made a balls of it 

 


Sorry, I haven't (yet) (re-)installed LabVIEW 2017 (it took out two of my machines, forcing me to reformat and reinstall Windows + everything else), so I can't look at your code.  But you do realize, I hope, that Jeff's picture shows a single case Statement, one Case having the selector 1..45 (meaning numbers 1 through 45), and a Case called "Default" that catches all the other 2^32 - 360 numbers that you haven't explicitly specified.  So it's one Case structure with a half-dozen or so Case "elements".

 

Bob Schor

0 Kudos
Message 9 of 13
(3,308 Views)

Here is what is inside the VI.

 Sailboat_BD

 

Why did you type in "60 to 120"?

 

It should say "60..120"

 

And the comparisons inside are just redundant.

 

Just use the In Range and Coerce function.

0 Kudos
Message 10 of 13
(3,302 Views)