From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, 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: 

Problem with LED and Comparision.

Solved!
Go to solution

Hi everyone, I have trouble with this application, so i hope someone could give me some advice. Im going to explain as better as I can....

 

So in this VI, I have 4 signals that I need to compare, from them, i need the smallest and the largest value , so i used a Case Estructure to do so. I make 2 groups to compare and then the result of each one gets another comparision to get the values I want. My problem is, for the largest value of all 4, I need a LED to indicate which one is the largest, and, the closest thing I have is in my attachment. I take my first group of two and put 2 LEDs, so when the comparision happens, one turns ON and the other turns OFF, (indicating that the one ON is the largest and the other one is the smallest), and I repeat the same in the other one. But as you can see, when executes I have two LEDs indicating in each comparision who is the largest, but I need only one LED turn ON when that value is present. and the other three OFF. I know that working in this way, thats the result I´m going to get, but I can figure out how to continue from this step to the result I need.  

 

As far as I know, there is no way to compare more than 2 signals at a time, so i tried to merge signals, but that didn´t help me at all (maybe is something that I dont get with how merge works, so if someone has an specific example on how do it right, i´ll check it ).

 

All the data is Dynamic, from a NI 9237, but since its from a Lab, I cant get a lot of time to try different solutions, so I made a TDMS file from a test and change the DAQ Assistant to a Read from Measurement File, but the rest is the same.

 

 

Download All
0 Kudos
Message 1 of 4
(2,947 Views)

You need to step away from Express VIs. You're over-using them and you code would be a lot easier to comprehend without them. You can convert your dynamic data to a more manageable datatype using a conversion node. You're over-using case structures as well. Take a look at the Comparison palette and get familiar with the comparison operators. These would elminate all of your case structures I believe.

 

Please include a Snippet of your code, or attach your VIs, so that we can better assist you. We are here to help, but won't spend all day recreating your code from scratch. When you do this, create a constant on your block diagram of your data so that we don't have to load a TDMS file.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 4
(2,938 Views)

Thanks for the advice, i really appreaciate it. Its my first step in how to code better, also sorry for the delay on answer it.

So here is what i got. I change all the Express VI and make my comparisions with Select, Less and Greater.

For the last part, I did it like I was on text code. I made something like this:

If(a>b){
    print(a,1);
           (b,0);
           (c,0);
           (d,0);
   else if (b>c)
     print(b,1);
            (c,0);
            (d,0);
            (a,0);
    else if (c>d)
      print(c,1);
            (a,0);
            (b,0);
            (d,0);
    else:
      (d,1)
}

 

 

 

last.png

 

And I got it work doing it with Cases inside one when it get false, but maybe I dont need all that Cases.

 

 

0 Kudos
Message 3 of 4
(2,849 Views)
Solution
Accepted by topic author johncgh22

Use 'bundle array' to build an array of your 4 control values. Use 'array max and min' to return the index of the max and min elements. From there it should be a snap to indicate the corresponding controls.

0 Kudos
Message 4 of 4
(2,829 Views)