Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

daqmx read inside while loop

I would like my waveform graph to update throughout the task, so I put a while loop around my daqmx read.  I am now encountering problems when I try to write the waveforms to the file.  I tried putting it outside the while loop but that didn't work either.
0 Kudos
Message 1 of 5
(3,540 Views)

Greetings,

 

I've looked at the VI that you attached to your post, but was not able to run it because I didn't have the three global VIs that are a part of your main VI.  From your post, I gather that you are having problems related to the Export Waveforms to Spreadsheet File VI. Can you please explain in detail what your expected results are, and what are your actual results?

 

Best wishes,

Wallace F.

National Instruments
Applications Engineer
0 Kudos
Message 2 of 5
(3,523 Views)
The code works fine and the data writes to the file and all when I take out the while loop but then the waveform graph doesn't update continuously.  When I run with the while loop in, the data samples but then the prompt "do you want to replace the write to file path" comes up a million times since it is running in a while loop.  My ultimate goal of this program is to take 3 separate data aquisitions and write the results to 3 different file paths.  Is there a way to do this?
0 Kudos
Message 3 of 5
(3,519 Views)
You have nothing wired to the file path input so of course it will ask for a path each time it is called. You've also got it setup for a new file with each iteration so if you choose the same path, you will be overwriting the old data. You should explain exactly what you mean by 3 separate acquisitions and 3 separate files. If you only want to run the loop 3 times, you need to either use a for loop or compare the while loop's iteration terminal with a number (and not have just a stop button). If you do want to run the loop three times, then you can create an array of paths outside the loop and pass it. Use autoindexing of the array and it will use a different path with each iteration.
0 Kudos
Message 4 of 5
(3,509 Views)

Hello,

 

I understand that when you have the Export Waveforms to Spreadsheet File VI inside the while loop, you continuously get the prompt asking if you want to replace the spreadsheet file.  To fix this, I recommend modifying your code so that you have a file path constant with your desired file path for the spreadsheet file outside of the while loop.  Wire this constant through the border of the while loop and connect it to the file path input of the Export Waveforms to Spreadsheet File VI.  Next, wire a true constant to the "append to file" input of the Export Waveforms to Spreadsheet File VI. You can also use the Write to Spreadsheet File VI, but this requires converting the data from a waveform data type to an array data type.  I added some code in the same while loop just to illustrate the point.  I've attached an image of the block diagram so that you can see the code modifications.

 

Best wishes,

Wallace F.

National Instruments
Applications Engineer
0 Kudos
Message 5 of 5
(3,507 Views)