10-15-2017 05:17 PM
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
10-15-2017 05:55 PM
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.
10-15-2017 05:59 PM
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
10-15-2017 06:13 PM
A case structure will work for you. Each frame handling a different range.
10-15-2017 09:56 PM
This is one of those times I like enums
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)
10-16-2017 05:53 AM - edited 10-16-2017 05:58 AM
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
10-16-2017 06:13 AM
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
10-16-2017 06:14 AM - edited 10-16-2017 06:27 AM
Use the features of the "In Range"
10-16-2017 08:47 AM
@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
10-16-2017 09:10 AM - edited 10-16-2017 09:11 AM
Here is what is inside the VI.
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.