LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Find values in an array using math

I've been using LV for a while now but I still don't understand arrays and autoindexing. I"ve got an array of voltage and current levels and I want to find a threshold where current jumps up from micro amps to milliamps. My little test vi is basically the same except I'm using the random number generator for my array and looking for the first number that is over 2. Seems pretty basic but I can't figure it out.

0 Kudos
Message 1 of 16
(2,771 Views)

Hi R.,

 

do you need a suggestion like this?

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 16
(2,769 Views)

Consider also looking at the Threshold Detector and Peak Detector built-in vis.

0 Kudos
Message 3 of 16
(2,740 Views)

I already tried them. I'm not getting what I want out of them. I want to do my own searching.

Thanks

0 Kudos
Message 4 of 16
(2,728 Views)

This is a more realistic version. It's a piece of much larger code that I don't wish to share. I think you can see the trip point where the numbers on the right represent the current and you can see where it jumps from 1.013e-3 to 931e-6. That's the trip point or threshold I'm looking for. I need to be able to do this ramping up or down and it must be accurate.Capture.JPG

0 Kudos
Message 5 of 16
(2,722 Views)

I see two columns. The left column ramps up twice from 10 to 18. The right column has two steps in it one from about 20e-3 to 30e-3, another from 30e-3 to 35e-3. Do you want to count the steps or peaks or threshold one of these?

 

You'd need to use the other unbundle for unnamed cluster elements in your example. Dunno if that is a hang up or not.

 

image.png

0 Kudos
Message 6 of 16
(2,715 Views)

It appears the data didn't transfer over properly. It ramps from 5V down to 0V And there is only one transition point as I said before. The number in the left column with the red arrow is what I'm looking for based on the current jump on the right. I've tried both unbundles. I don't understand the problem

Capture.JPG

0 Kudos
Message 7 of 16
(2,709 Views)

OK. Maybe your hang up is just the unbundle, in which case I've used the correct unbundle inside. I've attached code though that finds all the transitions from high to low and low to high. Keep in mind the indexing gets weird because your reverse the array. Also, the build cluster array in this example doesn't seem super necessary. I assume you put it in since that better simulates what you have. I had to make up my own numbers since the ones in the VI didn't demonstrate what you wanted.

0 Kudos
Message 8 of 16
(2,697 Views)
The point of this is to find the value on the left based on changes on the right side of the array. There's only 1 change that I'm interested in and that's the numbers on the right change a significant amount or order of magnitude. The numbers on the right should be some quantity of xe-6 and the rest xe-3. The point where xe-3 changes to xe-6 or the reverse, is what I'm looking for. It's a single trip point. One of the problems I have is determining which side of the array I'm looking at. It seems to automatically be looking at the right side and this is correct but I don't know why. I want to return the corresponding value on the left side. I long for VB
0 Kudos
Message 9 of 16
(2,651 Views)

It seems like maybe you're just having trouble understanding how to index your arrays? You start out with 2D array. The indexes are hidden on that array (you can show them by right clicking the array on the front panel > visible items > index display OR on the block diagram by right clicking the icon for the control > properties > show index display. If trying to click on the front panel, make sure to right click the border of the array and not one of the elements or you'll get the context menu for the properties.)

 

Now, why I show you this is that if you increment the first index, you'll notice that you are scrolling through rows (starting at 0). And then if you increment the second index you'll see you're scrolling through columns (starting at 0). This is important: If you want a specific ROW, you index the FIRST INDEX. If you want a specific COLUMN, you index the SECOND INDEX. Your data is in column format, so to get an array of either column, you index using a value of 0 or 1 on the second index in the index array vi. You seem to understand that because your code uses this but your explanation seems like maybe you stumbled upon it.

 

Anyways, I went ahead and changed the code a bit to get the value of the first column after a transition in the second column. Let me know what you think.

 

 

0 Kudos
Message 10 of 16
(2,644 Views)