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: 

Array Subset misunderstanding

Hi, I'm trying to get the 1st and the last values of an array with Array Subset function as it's shown on pic below.

 1.PNG


And it works as a part of my project, but not inside it, when I use a Local variable instead of a random (pic below, and I simply put those Subsets it in a SubVI).

 

2.PNG

 

 

The format of both arrays seems to be identical, but subset works only in 1st example. 

The Local var comes from the power supply unit and provides the Voltage' value at the moment.

What's wrong?

Any help required, thank you!

0 Kudos
Message 1 of 7
(3,063 Views)

To be honest I am not able to understand completely what is your issue here. You have problem with the Array subset primitive?

What is there in the sub vi? The same code which the image 1 shows? You want the 1st and the last element of an array then why are you using the array subset? If you want the values out of array you must be using the index array. 

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 7
(3,039 Views)

Hi alex,

 

to simplify your "1st and last array element" you can go like this:

check.pngor even this way: check.png

 

To comment on your "local variable in a loop" image:

That loop runs x times in a VERY short amount of time, so the variable will probably not change while the loop runs. What kind of results do you expect when getting the first and last element of the array generated by the loop?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 7
(3,030 Views)

HI, 

 

, I thought it was Array Subset issue, but now I suppose I was wrong. 
The SubVI contains the same code as shown on 1st image, yes.

0 Kudos
Message 4 of 7
(3,012 Views)

Hi alex,

 

could you please attach your VI in LV2011?

 

Meanwhile: This should be related to your "funny" creation of that "loop" counter. Each call incrments this loop counter by one and so your array contains one more element…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 7
(3,010 Views)

Yes, I thought about  the 'loop', but could not manage it any way better. 
LV2011 attached, sorry 

0 Kudos
Message 6 of 7
(2,998 Views)

Hi alex,

 

what is the purpose of the "loop" variable? Why do you even need it?

 

- Again: your FOR loop used to read "Voltage, V" is senseless without proper timing.

- Please explain what to code in the surrounding while loop (the loop reading the NI-DMM by ExpressVI) is supposed to do! What do you want to do with all those IndexArray and comparison functions? Why do you use InsertIntoArray to append an element to your array? Why not use a simple BuildArray?

 

The whole code is not clear to me…

Best regards,
GerdW


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