12-16-2014 06:05 AM
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.
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).
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!
12-16-2014 06:48 AM
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.
12-16-2014 06:53 AM - edited 12-16-2014 06:55 AM
Hi alex,
to simplify your "1st and last array element" you can go like this:
or even this way:
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?
12-16-2014 07:58 AM
HI, GerdW, thanks for your reply!
Your code worked great on my random array, but it failed on data I try to aquire with a Local var.
So, it seems the problem is in my Local var and they way I use it.
Here is the output of 2 arrays:
Array is a random, Array 2 is a voltage, provided but the power supply.
The 2nd array starts from the 1 number on 0 position, than it shows a pair of 2 number on 1 and 2 positions, and so on.
At last it displays only the last data of the array in all the positions.
I've attached the file to make it more clear.
The main purpose of the project - is to catch the Voltage, when S.S.R. (solid state relay) works and stops.
So, that's why I needed the first and the last values.
P@Anand, 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.
12-16-2014 08:01 AM - edited 12-16-2014 08:02 AM
Hi alex,
could you please attach your VI in LV2011?
The 2nd array starts from the 1 number on 0 position, than it shows a pair of 2 number on 1 and 2 positions, and so on.
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…
So, it seems the problem is in my Local var and they way I use it.
Definitely YES. 🙂
12-16-2014 08:06 AM
Yes, I thought about the 'loop', but could not manage it any way better.
LV2011 attached, sorry
12-16-2014 08:24 AM
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…