From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Write to specific array locations (into file) without overriding every time

So I am trying to capture some data from an Agilent Multimeter and record it into an array of 16R x 8C. I have everything pretty well set up, I have initialized a file with some appropriate headers for the file, and need to write some measurements to specific locations in the array. I have accomplished this, yet everytime I run the VI, it initializes my new array with all (Zero's) and replaces the desired "Zero" with the measurement. Problem is it overwrites all prior data to all Zeros everytime. How do I keep the previous data, and only overwrite a desired location. Any help would be appreciated

 

Side Note: I am pretty new to LabView, so take it easy on me , haha

0 Kudos
Message 1 of 6
(2,503 Views)

Well, looking at your image, you seem to constantly write your results in the same array element i.e. row 0, column 2. I'm assuming that you want to populate the array with ALL you measurment results, and if thats the case, you simply use the while loop index (that little blue "i" on bottom left of your while loop) as your "row" position. And if you also want to increment the column, you just create a shift register that increments by 1 and feed that into your column position. 

 

But again, lookingat your image, you seem to run the "Process 1" state only once, and then it goes back to idle. So maybe just the row index would do. 

0 Kudos
Message 2 of 6
(2,489 Views)

Well, the terms "specific location" and "without overwriting" seem to contradict each other. If you are writing to the same location, overwriting the existing value is the only possibility. 😄

 

Maybe you could attach the actual VIs and explain in more details what the program should do.

 

It is not a good idea to write to file after the loop completes. Why not add a new state that saves the data in the 2D array, then goes back to idle?

0 Kudos
Message 3 of 6
(2,477 Views)

Basically what I am doing, eventually is using a bunch of different Instruments to log data, I will use multimeters, dc power supplies, signal generators, oscilloscope & a VNA. I currently writing seperate VI's to call in instrument individually and will eventually compile all into one VI and into an .exe.The one attached is specifically for the Agilent, I will be taking an impedance measuremetn on 2 components and recording them in the first row, and column 3 & 4 respectively. Lets say I run VI, it asked for the file name to be initiated, along with the appropriate header attached. Then I take the gate impedance measurement. It records in the right spot, then stop the VI, then run again and want to take Drain Impedance, it overwrites both array locations with zeroes. I want to be able to keep the previous information. What I was thinking was to have a master file that it gets initialized with, then read in a file with previously recorded information and only place the desired measurement ... Im kinda confusing myself on this one. been a long day

 

PA
#
S/N Gate Impedance(Rg)
KOhm
Drain Impedance(Rd)
Ohm
TP2 (Rd)
KOhm
TP1 (Vg)
V
Gain
@ … GHz
dB
Gain
@ ….GHz
dB
1              
2              
3              
4              
5              
6              
7              
8              
9              
10              
11              
12              
13              
14              
15              
16              

 

 

0 Kudos
Message 4 of 6
(2,442 Views)

Hi,

 

If I understand correctly, you write all the data (the entire array) at the end of the VI. You initialize it with all zeros, and then update only the row and column that you need. The zeros in the array are actual values; when you write this data to the file, the zeros are written over the previuos data. You have two options if you want to change only a few bytes:

1. Read the data from the file, change only the row/column you want, write it back. This will preserve the previous data.

2. Open the file, use the Set File Position VI to to set to the bytes you want, and write only these bytes (not the whole array). don't forget to close the file afterwards. Assuming that the file format is constant, this would work best for you as it is more efficent than the previous solution.

 

Good luck!

"Wisdom comes from experience. Experience is often a result of lack of wisdom.”
― Terry Pratchett
Message 5 of 6
(2,418 Views)

Without going into the best practices to improve your program (maybe state machine, QMH or Producer/consumer templates seem good for this type of program), you keep replacing the old values because you keep writting to the same row and column locations. You need to control that through shift registers so that your column and row location increments and do not become the same from the previous run. 

0 Kudos
Message 6 of 6
(2,411 Views)