Signal Conditioning

cancel
Showing results for 
Search instead for 
Did you mean: 

export all data after the loop terminates executing

I am student and would like to take continuous temperature measurements using thermocouples. I am using anSCXI-1000 chassis, an SXCI 1102-B module, an SCXI-1303 terminal block and the PCI-6034E board.

I am taking the temperature readings using the Cont Acq Thermocouple Samples-HW Timed.vi.

 

My problem is that i would like to see in the front panel a continuous updated waveform, while in the end concentrateall the samples taken in a txt file. If I place outside the loop the export waveform to spreadsheet.vi then I will onlytake the last measurements. If i place it inside the loop, the vi will ask me in each iretation to save the samples.

 

How can solve it?

 

I have also a of question regarding the Cont Acq Thermocouple Samples-HW Timed.vi. Is it necessary first to adjust in MAX  the temperature range that i would like take measures or it is automatically adjusted when I configure therange in the Cont Acq Thermocouple Samples-HW Timed.vi.

 

Thank you in advance

 

Papakonstantinou Georgios

0 Kudos
Message 1 of 10
(7,434 Views)
Message Edited by Online Courses on 07-17-2009 11:11 AM
0 Kudos
Message 2 of 10
(7,417 Views)
Message Edited by Online Courses on 07-17-2009 11:12 AM
0 Kudos
Message 3 of 10
(7,413 Views)
Welcome to NI forums.  In order to continuously write your data to a text file you would need to use the WriteText File VI (located in the File I/O palette) and place this in the while loop with your VI that's reading the thermocouple measurements (I'm assuming a DAQ Read VI).  You will also need the Open/Create/Replace File VI and the Close File VI.  Both of these VI's should not be included in the while loop, and I believe this is the reason you are constantly being asked to save the file everytime the loop iterates. You want to place the Open/Create/Replace File VI before the while loop and the Close VI after.

In regards to your other question, the input temperature ranges in MAX are for if you want to configure the task in MAX and then export it to LabVIEW.  If you are simply using a LabVIEW VI with temperature range controls in it then you can simply change those controls in the VI.  Please let me know if you still have any questions regarding this issue.

Have a nice day,
Message 4 of 10
(7,409 Views)

Thank for your answer and your time Brandon.

 

I did what you told me but other problems arise.

At first I had to add the array to spreadsheet string.vi. Because array to spreadsheet string.vi could not read an 1-D array of waveforms I had to change also the polymorfic DAQmx Read.vi from analog 1D Waveform NChan NSamp (default) to the analog 2D DBL NChan NSamp.

 

Consequently, I got a text file which has 10 columns and under each column tons of data (temperatures).

 

What do I want to do??

 

 

1. I want to build a vi that will take temperature measurements from 5 thermocouples (5 channels). This vi must take finite samples (for example 2000 samples/channel) and then stop .

2. Additionally, I want to see in the front panel a continually updated waveform graph (with 5 plots) depending on the rate that I give in the front panel.

3. Finally, I want to export those samples into a txt file which will have 5 columns (as many as the thermocouples) and as many rows as the samples I have given in the front panel.

 

It must be so easy to build this vi. Nevertheless, no matter what I do I cannot make it work!!!! And believe me I have spend many hours on this vi before I post to the forum. Plus, I do not have anybody else to ask because noone knows how to use labview in the whole university (Greece..).

 

Thank you very much Brandon.

 

P.S.: I have uploaded the vi that I built, as you instructed me with the changes that I told you above and the txt file that it generates.

Download All
0 Kudos
Message 5 of 10
(7,398 Views)

The VI that you have is a pretty good start.  I would say the one thing that you are missing is a Transpose 2D Array VI (found in Programming>>Array palette).  This VI should fix the problem with your colums.  You will want to place this before the Array to Spreadsheet String VI.  Please let me know if you have anymore problems regarding this issue.

 

Have a nice day,

Message 6 of 10
(7,372 Views)

Thank you very much Brandon and sorry for the delay. We are almost done!!

 

It worked although i could not quite understand why the 2D array should be transposed.

 

Another thing that I would like you to help me is how to get this vi to take finite measurements while the waveforms update constantly, because this vi keeps running until i press the stop button.

 

For example I would like this vi to take 2000 Samples/channel at a rate of 100Hz as I described you in the previous message. As a consequence this vi will run 20 seconds and I will be able to watch the the waveforms updating until the vi finishes. I hope that you understood my problem.

 

I would not be able to solve it in another 20 years if it weren't you. Thanks again!

 

 

0 Kudos
Message 7 of 10
(7,349 Views)

Hello ginos,

 

The array needed to be transposed because of the way LabVIEW was trying to format the spreadsheet file.  LabVIEW was putting the channels in the rows and each sample was a different column.  By transposing the array, you basically flip that around so now each column is a different channel and each row is a new sample.

 

As for being able to take finite samples, the most common practice is to set your DAQmx Timing VI to Finite Samples, rather than Continous Samples as you have it set now, and then specifying the number of samples you would like to read.  This method does not use a while loop because it runs through one time, reads the specified number of samples, and then stops.  A good example of finite sampling can be found in the NI Example Finder under Hardware Input and Output>>DAQmx>>Analog Measurements>>Voltage>>Acq&Graph Voltage-Int Clk.vi.  Since you already have a while loop in your program, an easier method for you would be to just insert another stop condition for the while loop.  You are acquiring 10 samples per channel each iteration of the loop, and you want 2000 samples per channel total, so you would like your loop to stop after 200 iterations.

 

I've included a screenshot of what this will look like.  You want to use the Compound Arithmetic VI (found in the Numeric palette) along with an Equal? comparison VI.  Once the loop iteration count reaches 200 you want the while loop to stop. While loops are a little tricky though because the loop will always iterate one time initially before it begins counting.  Because of this, you will actually want to set your comparison to one less than the total iteration count you are looking for (in this case 199).  I hope this answers your question and please let me know if you run into anymore problems.

 

Have a nice day,

0 Kudos
Message 8 of 10
(7,342 Views)

Hello Brandon, thank you very much for the help. I followed your instructions and I made a couple of similar vi's. The first one is made with a while loop and the second one is with made with a for loop. Please take a look at them and tell me which of this is best. In my opinion it is better to use the one with the while loop.

 

I have two questions although we have come up to a solution. At first, I think by setting the DAQmx Timing.vi to take continuous measurements and setting the Read.vi to take 10 Samples per iteration I lose some measurement. Am I right?

Finally I have not quite understood what does the timeout parameter do in the Read.vi

 

Thanks again for the solution

 

I won't be able to answer earlier than Monday because I won't have access to the internet. 

 

Have a nice weekend!

 

0 Kudos
Message 9 of 10
(7,329 Views)

Ginos,

I looked over your VIs, and in the one that uses a For loop, I think you will end up getting 10 times as many samples as in the one with the While loop.  (You should divide the Samples per channel by the number of samples you are acquiring each iteration, and then wire that to the iterations terminal of the For loop.)  However, aside from that, I think that I agree with you about using the While loop rather than the For loop.  That VI has the advantage that you can stop it before it finishes, if you need to, and also it will stop iterating if there is an error. 

To answer your questions: you should not be losing any measurements because you set up the task to be hardware timed.  The Samples per iteration just sets the size of the buffer that the samples are read into.  The Timeout parameter sets the amount of time in seconds that the read VI will wait for the samples to be in the buffer.  So, in your case, if the DAQmx Read VI has been waiting 10 seconds and 10 samples (the number of samples to read) are not in the buffer then the code will produce a timeout error. 

Let me know if this clarifies things, or if you have further questions.

 

-Christina

0 Kudos
Message 10 of 10
(7,309 Views)