This widget could not be displayed.

Dynamic Signal Acquisition

cancel
Showing results for 
Search instead for 
Did you mean: 

automatic low frequency with labview 2010 and agilent 35670a

Solved!
Go to solution

Hello er_10_1999

 

What your code currently does causes "race conditions". Essentially there is no way to say which of your write loops will execute first. In addition, you will encounter an error if you try to open a file that is already open. You don't need to open and close the file twice, you just need to open it once and append each column one at a time. 

Jonathan L.
Technical Support Section Manager
National Instruments
0 Kudos
Message 31 of 56
(6,555 Views)

Hello Jonathan,

 

 

Thank you for the information. However, I can't seems to find a way to open it once and append each column one at a time, would you have any suggestion about how I proceed about it. My code from the February 9th post(see below), has a "Excel Get Last Row.VI"  and "Append Table to Report.VI" which allows insertion and appending of data in the 1st column only, but the issue here is that it doesn't allow any additional setting to allow insertion and appending of other set of data in a separate column of the same excel worksheet.

I understand you strategy of "open it once and append each column one at a time"; however which VI would allow this stragety to work. 

Would you have any recommandation of we could proceed about it

 

Thanks

 

Eric 

0 Kudos
Message 32 of 56
(6,549 Views)

Hi Eric, 

 

Typically when dealing with repeatedly writing to a file, you will have a loop and write repeatedly in the loop, and outside of the loop you can open and close the file. This example shows one way of doing this, however since you're not using a text file, you should instead just use the report generation VIs. 

 

http://digital.ni.com/public.nsf/allkb/F55FD21DFEF0C3C1862571F500023123

 

Another way to do it would be to store the file reference in a functional global varaible (http://labviewwiki.org/Functional_global_variable) and have functions for open/write/close and call them when necessary. This option cleans up the block diagram a bit more, as there doesn't have to be a file reference running across the entire code, but it is a little bit more difficult to implement. 

 

Hope this helps.

 

-N

National Instruments
Staff Certification Engineer
0 Kudos
Message 33 of 56
(6,544 Views)

Hi Jonathan,

 

Thank you for the information. I was thinking about another way to possibly address the situation, I don't know if it is implementable. In this other version of my block diagram code(see attach picture) I have a loop for the all code and at each iteration, Y-axis and X-axis data are saved and appended into two seprate text file.

Do you think they could be a way of let says once all my loop program has finished executing, with all Y-axis and X-axis data saved and appended into the two seprate text file, to have a function or an additional block diagram code that would extract the Y-axis data from the 1st text file and import it into the 1st column of an excell worksheet, and then have the X-axis data from the 2nd text file imported into the 2nd column of the same excell worksheet. If that is feasible that would probably avoid to deal with iterating and saving on an excel file each time.  

 

What do you think, would you have any suggestion ?

 

Eric 

0 Kudos
Message 34 of 56
(6,534 Views)

Hi Eric, 

 

Better yet, you could just form it into a single large array and write it all to the same text file. If you wire something to the edge of a for loop, it will auto-index and automatically build an array of the values. You may have to change the auto-indexing mode for the 2-D array, you can do this by right-clicking on it and selecting the auto-indexing option. 

 

After the loop iterates, you can use the build array or Insert into Array functions to combine the x and y columns and then write them all to a text file. 

National Instruments
Staff Certification Engineer
0 Kudos
Message 35 of 56
(6,526 Views)

 

Hi Nathanael,
 
Yes that's a good solution, but unfortunately it will not allow me to have all he data in an excel file, which is what I want at the end. Basicaly I'm looking for a way to have those data saved in an existing excel file, I've tried different approach, but they are either fail on allowing insertion of data in separate columns, or prevent from having some of the column of the excel worsheet set with formulas. 
Here is what I'm aiming at, I've my loop that performs measurement over separate decade at each iteration and generates 400 Y-axis values, and 400 X-axis values each iteration. I want to save those data at each iteration in the 1st and 2nd column of a preexisting excel file where say the 3rd and 4 th column of that excel file have been set with formulas to manipulate data that are in 1st and 2nd column. On my previous post, as stated I've tried different excel solution using generation toolkit, but somehow they seems so far not to be able to perform what I'm looking in terms of insertion, appending, and setting formulas on columns to manipulate inserted data.
Would you have any sugesstion.
 
Thanks
 
Eric
0 Kudos
Message 36 of 56
(6,522 Views)

Hi Nathanael,

 

Just to be more precise on some of the issues I'm facing, I've attached one of the code that I implemented to give you an idea of the problem with insertion in different columns. 

In that code I'm saving the same data in 2 separate excel files, just to test if I can perform insertion in 2 files but in different columns, unfortunatelyt it doesn't work, because if I set the MS office parameter in "Append to table VI" to a specific value(say column to 5), my other "Append to table VI" will also be set to the same value, regardless to the fact that I'm using separate "Append to table VI". In my understanding if I'm using two different "Append to table VI" I should be able to set the MS office parameter of one to says (row=0,column=0), and the other one (row=0, column=2), and when I run the program I should have my data in one file save in the 1st column, and in the other file saved in the 2nd column, but it looks like, you can't configure that settings. 

 

As usual waiting for you insight regarding insertion and appending in separate columns

 

Eric

 

0 Kudos
Message 37 of 56
(6,511 Views)

Hi Eric, 

 

You need to fill out the 'MS Office Parameters' input of the Append Table to Report.vi. Please see the detailed help for more information. http://zone.ni.com/reference/en-XX/help/371361J-01/lvreport/append_table_to_report/

 

-Nathanael

National Instruments
Staff Certification Engineer
0 Kudos
Message 38 of 56
(6,506 Views)

 

Hi Nathanael,

 

Thank you for the answer, that exactly what I'm doing, and for strange reason, whenever you fill out the 'MS Office Parameters' input of one of the Append Table to Report.vi, that automatically set the other 'MS Office Parameters' input of the other Append Table to Report.vi to the same input parameters, which cause a problem because it doesn't alllow different settings of 'MS Office Parameters' for different Append Table to Report.vi in the same block diagram.

Besides using Append to table report VI, would have any idea of another way I could proceed in order to insert and append data in an existing "excel file" with the data inserted in separate columns. 

 

Thank you

 

Eric 

0 Kudos
Message 39 of 56
(6,503 Views)

Hi Eric,

 

Try doing them in serial rather than parallel. It is probably only opening up a single session to Excel and both values are being applied, but only the latter takes effect on the data being written. 

 

-Nathanael

National Instruments
Staff Certification Engineer
Message 40 of 56
(6,501 Views)