06-07-2012 09:40 AM
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).
06-07-2012 09:41 AM
Forgot to mention:
I am running LabVIEW 8.5, in case you want to send me a .vi
06-07-2012 09:50 AM
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:
06-07-2012 09:53 AM
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.
06-07-2012 09:54 AM
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.
06-07-2012 09:56 AM
06-07-2012 09:57 AM
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.
06-07-2012 09:58 AM
@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.
06-07-2012 10:00 AM
@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.
06-07-2012 10:14 AM
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.