Showing results for 
Search instead for 
Did you mean: 

Writing and Plotting Data from a Measurement File

As mentioned above, the Express VIs can be a bit of a pain to use once you start trying to customize your application.  If you are looking for a way to replace the Write to Measurement File VI, you can take a look at an example here.  You will have to do a bit more work to get it to handle the multiple waveforms from the DAQ Assistant but it should give you a start.
Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 21 of 52

Okay, another question. I'm trying not to use the ExpressVIs to avoid dynamic data types.  So, I am using the DAQmx VIs to acquire my temperature from 3 RTDs with a NI9217 and acquire flow and CO2 concentration levels on using an NI9215. First, I cannot get the DAQmx VIs to read in the RTDs at all.  It gives me an error, Error 200077, about selecting external excitation and says I should use internal. However, when I double clicked on the create channel and selected internal and ran it again, it gives me the same error.


I also tried using the DAQmx to read in the flow and CO2 concentration readings. I can read them in.  However, it seems as though the timing information is lost. I need that timing information to plot the trend data after the experiment is over.

0 Kudos
Message 22 of 52

Are you using the 9217 to provide excitation to your RTDs?  Try running the RTD examples in the Example Finder under Hardware Input and Output»DAQmx»Analog Measurements»Temperature and verify that these are not working with the different excitation settings.


The reason you are losing timing information is because you have the top DAQmx Read VI set to read data into a 2-D array of doubles.  Choose the 1-D array of waveforms which contains timing information. You can also get rid of the conversion steps as the array of waveforms can be wired directly into the Write to Measurement File VI-you will just have to change your indicator type.

Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 23 of 52

Okay, I've got a majority of the system working. However, I am getting Error 0 saying that it cannot connect to GPIB driver or device, but I do not have a GPIB interface. What do I need to do to correct this error. Also,the data is getting logged in a strange way. It is writing 6 measurements for each channel in a cell before creating a new row. How do I correct this?



Download All
0 Kudos
Message 24 of 52

The Error 0 code should also have an explanation for LabVIEW.  Read that portion of the error and see if it makes more sense.


The reason you are getting 6 measurements in a cell is because you are converting an array of values to a string and writing it to the file.  You need to index your arrays to get single values.  


Also note that the Write Characters to File VI is deprecated and you should be using Write to Text File.  I also recommend using the Array to Spreadsheet String VI to group your data and have it do the formatting for you instead of manually adding tabs and carriage returns.  Both of these are in the community example I linked to in my earlier post.

Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 25 of 52

Okay, I got rid of the Error 0 and figured out how to measure RTDs and the other analog inputs at the same time and writing all the data to one data file. I have put the program in a producer/consumer design as referred before, and now I'm back to the original question about how to log data to 12 files only when selected by the program and read the files to plot the trend data as the program is running.  Below I give a full explanation of what exactly I need help doing.




I am building a system that is measuring the CO2 content of 12 vessels but only 1 CO2 gas analyzer. So, my system has a series of valves that only lets one valve open at time so that only one vessel is being measured at a time.  What I would like to is have a measurement file for each vessel so I don't have to worry about determining which data came from each vessel in one large data file. Also, I only want to write measurements to each file whenever its corresponding valve is turned on. The third thing I would like to do is to be able to read the data file and plot the trend data as the test is running.  These test will run for 14 days.  So what would you recommend to do this? Would you recommend using a Write to Measurement File Express VI, Write to Spreadsheet, Write to Text File, Write to XML? 


Requirment Summary

1) File for each vessel

2) Only write data to file when corresponding valve is selected

3) Ability to read the data files and plot the trend data over time for the 14-day test.




I am using a Consumer/Producer design with two consumer loops one for processing and writing the data and the other to control a pump for a waterbath that was made inhouse.



0 Kudos
Message 26 of 52
Store your 12 filenames in an array of file paths.  It looks like you already have code to determine which item is active.  Use that to index out the appropriate filename from the array of filenames.
0 Kudos
Message 27 of 52

Well, on the previous version of my system I used something similar to your suggestion. I had 12 Write to Measurement File Express VIS and I used the enable pin on the Express VI to write the data, and the setup worked.  However, I am trying not to use the Express VIs, plus I would like more control over the way the data is stored than what an Express VI will allow. I'm trying to use the same enable logic in the producer/consumer design of my program, and right now I have indicators to show the enable signals.  The first one lights up, but it gets stuck on 1 and never moves to 2 and so on.  Does this have something to do with the queue?


I've attached my old program (Composting System Control) along with the new program with a producer/consumer setup (Producer-Consumer from Scratch 2).

0 Kudos
Message 28 of 52

Twelve Express VI's!!!???  That is a ridiculous amount of work.  And it makes the VI file size unnecessarily large.


Did you notice that the Express VI has an input for filename?  Use that.


Here is an example how to use the array of filenames and select the appropriate file name based on which element in the boolean array is true.

I have no idea about your queue and your light getting stuck on 1.  I'm not trying to figure out the logic of your code.  Things have been touched here and there across numerous message threads.   It seems like you are trying to solve a half dozen different problems at once and are bouncing between them among the different threads rather than trying to fix one thing at at time then move on. (By the way, it's about time to name your VI something more meaningful than "Producer-Consumer from Scratch2"Smiley Wink)

Message 29 of 52

Thanks for the tip! I've put it into the program and it works. However, I discovered today I was wrong about the problem that I mentioned about the trigger getting stuck on valve 1.  What is happening is for some reason there is a delay in the queue for the T/F cluster-array. I put indicators before and after the queues for both the acquired data and the triggers.  The analog data is getting passed to the data acquistion loop with virtually no delay.  However, there is a 20 second delay between when valve 2 is triggered and when the indicator in the consumer loop triggers the data file for valve 2.  Then the delay grows to about 40 seconds between when a valve is triggered and the corressponding data file is triggered.  Why do you think this is happening and how can I correct this? Can I put the T/F cluster on the same queue as the acquired data? If so, how do I put them on the same queue?



0 Kudos
Message 30 of 52