LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparison of values in an array

Solved!
Go to solution

Hi,

 

So, I have an array comprising of 16 values, and I would like to compare the first 14 values (using the Array Subset vi) of the array, and when they are all within a specific distance of each other, start a timer.

 

Since we are measuring temperature with each one of these inputs in this array, once, and only once, they elevate past about 100 degrees Celsius, I would like to start comparing them amonst each other. Once they all are within 20 degrees celsius of each other, this timer should start. I already have the timer set-up, but I'm missing this comparison.

 

I'm really new to Labview, so the only way I can think of right now, would be extracting every single value, and comparing them with each other inside a while loop, but there has to be a better way, right?

 

Thanks in advance!

0 Kudos
Message 1 of 14
(2,772 Views)

If you were only working with three temperatures, say 10, 25 and 40 degrees then I am assuming this does not meet the criteria?

10 is within 20 degrees of 25

25 is within 20 degrees of 40

10 is not within 20 degrees of 40 (so no go).

 

If I understood the above correctly you should be able to take the min and max of the array subset and if these are within 20 degrees of each other all the others have to be also...

 

Message 2 of 14
(2,766 Views)

I thnk you're on to something!

Sound so simple that I'm actually a bit skeptical, hahah.

 

I'm going to try it out later, and I'll let you know how it goes.

 

Thanks!

0 Kudos
Message 3 of 14
(2,759 Views)

Hi Eduardo,

 

what about this:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 14
(2,756 Views)

Hi Gerd,

 

So, I actually did almost the same thing as you suggested, but I still have some questions.

Timer.PNG

 

- Since this is just a small part of my vi, I still have several other things going on, in the same part of the flat sequence structure that's encompassing the rest of the program. Should I have this entire part I just added, timer and the trigger for it (or just the trigger), inside of a new while loop, or is there something better/simpler?

- The temperatures, the values that are coming from the array, are going to be constantly changing, and it's crucial that the timer stay running, even if the condition of them not being more than 20 degrees from each other is not true anymore. How can I tip off a trigger like that, so that I just have to have these initial conditions be true once for the timer to start running? Should I put the timer in an event structure?

 

Again, thanks for the help, guys!

0 Kudos
Message 5 of 14
(2,716 Views)

Hi Eduardo,

 


it's crucial that the timer stay running


 

I think the ElapsedTime is still running! The point is: your indicators for time and progress are inside the same case and so will only update, when the case is selected...

 


Should I put the timer in an event structure?


That depends on your overall programming scheme. As you talked about (flat) sequence structures I guess there's a lot to improve...

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 14
(2,710 Views)

So I tried creating a separate VI, with just this timer and the two conditions. It will initially execute as it should, when the temperatures pass 100, and when they are within 20 degrees of each other. But, when I manually change one of those conditions to false, the case is no longer true, and the timer stops running, which it shouldn't.

 

Not sure I'm making myself clear, but like, the timer is not suppposed to run before those two conditions are true, and it should not stop running once they aren't true again. Not familiar with event structures though, so that's why I'm not sure I should be using that instead of a case structure.

0 Kudos
Message 7 of 14
(2,694 Views)

Hi Eduardo,

 


the timer is not suppposed to run before those two conditions are true, and it should not stop running once they aren't true again


 

You have to define your logic carefully! What happens the second time the conditions become true?

 

Get rid of the case structure:

check.png

The timer gets resetted when both conditions become TRUE (by help of rising edge detection), else the timer just runs up...

 

If you really insist on "timer is not suppposed to run before those two conditions are true" you have to include some more boolean functions like here:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 14
(2,686 Views)

Minor note on word usage: You have misused the word "comprising".  Any of the following would be correct:

... 16 values comprising an array ...

... an array composed of 16 values ...

... an array consisting of 16 values ...

0 Kudos
Message 9 of 14
(2,659 Views)
Solution
Accepted by topic author Eduardo.R10

TimerW.PNG

(by the way, this is just a separate simulation I'm running from the actual program, so that's why the array and some other stuff is different)

 

There we go!

Just made it pick up from where it left off from in the False Case, and told it to not start (or just reset) if the present time was 0, which it would have been if the True Case had never been set off before.

 

Only real problem now is that the Present (s) doesn't reset to its default value of 0 after I press stop, but since this would only be fired up once, and then the program would be shut down, and restarted a different day, it won't be a problem. And a friendly warning to remember to write 0 on the control if they were to start it again would also go a long ways. All in all, I'm satisfied.

 

Thanks for the help!

0 Kudos
Message 10 of 14
(2,653 Views)