LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array problems

I made this program to run a calibration of a LISN, but there is a problem with how the data is handled that I can't seem to find.

I made a duplicate .vi that replaced all of the equipment control/data acquisition sub.vis with random number generators to simulate the execution. (attached)

 

Execution of the program is very simple, there is a menu ring with 3 items, and you need to select each one (in any order) and click queue event.  A message will pop up, just click "ok" and then do the next one.  Once you have queued all 3, click stop and the file should be made.

 

On the block diagram:

The first "insert into array" places data into row 1, 2, or 3, depending on which menu-ring item you have queued (50 ohm, test sample or EMI out).  The problem does not lie in the incrimented integer that tells which row to use (I have placed an indicator there and it does display the correct 1, 2, or 3 value) and it is not an issue of wiring it to the column instead of the row, I have tried this as well.

 

The second "insert into array" that is located inside the case structure puts frequency values into the array at row 0, and is only supposed to run once, when you que the 50 ohm data.  This feature works just fine.

 

The string constants that make up the header also only runs once, when you que the 50 ohm data, and works just fine.

 

The problem lies in the data.  As you can see in the other attachment, the program sucessfully builds the frequencies, but that is all.  It places 0s into (excel) columns B and C, and leaves column D entirely blank.  Those 3 columns represent the raw data.  The last 2 columns come out of the final "Math" sub.vi (also attached) and are also left blank (possibly due to the blank EMI out column causing the math to fail).

Download All
0 Kudos
Message 1 of 22
(2,879 Views)

Forgot to mention:

 

I am running LabVIEW 8.5, in case you want to send me a .vi

0 Kudos
Message 2 of 22
(2,877 Views)

Hi Lars,

 

I would suggest to use BuildArray instead of ReplaceArraySubset. It's a common misconception to construct arrays by insertion, appending (or prepending) rows is much more intuitive (or should be...)!

 

Also I suggest to do your math the standard way:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 22
(2,864 Views)

I am using insert into array and not replace array subset, but if I made them build arrays, I couldn't designate which row I wanted it to go into, no?  I need to make sure that the data goes into 3 seperate rows instead of 1 giant list.

0 Kudos
Message 4 of 22
(2,859 Views)

You start with an empty array, then try to insert a new row at an index that depends on the measurement selection. This will not work. For example you cannot insert at row 3 in an empty array.

 

It seems you want to replace the data in one of three rows depending on the measurement selection, so you should initialize the shift register with an array of correct size and use "replace array subset" to place the new data in the right place.

 

See how far you get.

0 Kudos
Message 5 of 22
(2,857 Views)

Hi Lars,

 

- as you only want to insert at certain rows you could also append new rows.

- in the case structure you want to insert row "0" which is basically the same as prepending a row using BuildArray

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 22
(2,855 Views)

Really?  That suprises me, I thought that was the point of initializing everything to 0 when you use the initialize array, that you don't have an empty array but an array full of zeros.

I'll try it out though, thanks for the tip.

0 Kudos
Message 7 of 22
(2,853 Views)

@LarsUlrich wrote:

I am using insert into array and not replace array subset, but if I made them build arrays, I couldn't designate which row I wanted it to go into, no?  I need to make sure that the data goes into 3 seperate rows instead of 1 giant list.


You are still not understanding the difference between the two functions. You definitely don't want "insert into array", because each successful operation will grow your array. For example if you insert at row 1, the existing row 1 will move to row 2, row 2 will move to row 3, etc. and the array will grow with each insertion.

Message 8 of 22
(2,852 Views)

@LarsUlrich wrote:

Really?  That suprises me, I thought that was the point of initializing everything to 0 when you use the initialize array, that you don't have an empty array but an array full of zeros.


You have an array of size 0x0 full of zeroes, so there is no room to replace data. Initialize with the correct size by wiring the size inputs of initialize array.

Message 9 of 22
(2,849 Views)

Thanks Altenbach, I'll play around with it some.  As a quick fix, reversing the order which builds the arrays (frequency case first, then data) it allows the program to run if and only if the menu-ring is queued in order.  This will work as a bandaid but I'll try your suggestions and see what I come up with.

0 Kudos
Message 10 of 22
(2,841 Views)