12-04-2011 11:14 PM
I am tring to get multichannel analog input (data) through DAQmax (NI 9215 with BNC) and after that I would like to save that data into a file (text/binary).
Could you advise me how can I write data into the file?
I can see the mutichannel signal on seperate waveform in LabView but I could not able to save that data into file.
For,example, if I use 4 channel then in the text file, I hope I can get 4 column of respected data.
I am at the beginner for LabView.
Your help is highly appreciated.
05-16-2012 05:20 PM
I had a problem similar to the one the OP had, I am using a NI 6225 and have mage a block diagram to write an analog input to a text file, I orignially used the Write Measurement to File function but it wrote the data to an excel readable file with the data barely legible. I thereafter looked at the examples in labview and modified the block diagram. Now the issue I'm having is when the program runs, It stops and tells me that there is no input and then stops the execution. I am attaching my file, and would really appreciate any feedback.
The problem lies in the second case structure form the top.
05-17-2012 05:13 PM
Could you provide more details on the specific error you are seeing (Code, Explanation, Trace)?
I downloaded your code, and noticed a few changes you should make.
(1) On both your Sample Clock and DAQmx Read, you should wire a value to samples per channel. In your case, you wish to read 100 Samples per second, and read 10 times a second. So you are reading 10 samples each iteration. Wire a 10 constant to both the Sample Clock and DAQmx Read.
(2) Because you are asking the DAQmx Read for 10 samples, you can remove the Wait Until Next ms Multiple inside the while loop. The read operation is blocking, and will take 100ms. Adding a wait function is redundant.
Because you are doing File IO every loop iteration, if this adds too much overhead and the loop cannot execute the DAQmx Read function quickly enough, then you can run into errors. You are not writing a very large amount of data each iteration, so you will probably not need to worry about this. However, you should keep in mind that File IO is very slow, especially if you wish to increase the amount of data you are writing. To avoid this, you can store all of the values in memory (in an array or queue) until you finish the loop, and then do one large write outside the loop.
Let me know if you still see the error after making these changes.
05-18-2012 11:38 AM
Thank you so much for your helpful advice. I made some modifications to my block diagram by removing the redundancies like you said. The program runs now but another problem has arisen.
The goal of my program is:
(1)To generate a triangular voltage signal which will be used to control a pressure transducer (Presure increases at the same rate the voltage does).
(2)Then, I plan on getting a voltage reading from the transducer and write that reading to a text file (two columns: relative time from start of data acquisition and voltage reading).
The writing to a text file loop is working great, but the moment I activate the Input channel, the output channel stops ramping up the voltage and remains at a constant state, and resumes ramping up the voltage only after I turn off the input channel and stop the while loop that writes data to file. The resultant data is two columns of time and the same voltage at different times.
Presently I am testing the program by using the generated output voltage directly as the input voltage which needs to be written to the text file. I am using the loop counter as the relative time because the data I need is voltage reading and time with respect to the begining of data acqiusition. I replaced the Wait till next ms Multiple with Wait 1000 ms
Attached is the modified LabView file, Please help me identify the problem. Thank you so much for taking the time to do so
05-18-2012 03:02 PM - edited 05-18-2012 03:04 PM
Your problem is quite simple to understand. You have a while loop that runs until your clcik the stop data acquisition button or you have an error. While that loop is running, nothing else can run. You can simply place the generation task inside the acquisition loop.
p.s. Why would you want to use the 1Chan 1Samp mode for the generation? If you were to use NSamp, your generation would be hardware timed. You also removed the set timing function and did not specify the number of samples to read. You got good advice about it but ignored it. Do you have any idea how many samples per second you are acquiring now?
05-21-2012 02:33 PM
Thank you for your brutally honest response; it was carelessness on my part.
What I did to fix that issue was remove the acquisition loop from that VI and create another VI only for that purpose.
I was under the impression (I'm probably wrong..) that the while loop ran at intervals set by the Wait till next ms function. Since I set it to read 1Chan 1 Sample, I thought the loop would take one sample every 200 milliseconds. But I removed it as Jared suggested and I have put a sample clock and specified 5 samples per second and that I want to write the same to a file.
I also wanted to expand this to take samples from multiple channels and display respective charts at the same time. I changed the physical channel field to Dev1/ai0ev1/ai4 but was unable to figure out how to get separate charts for the waveforms and record the respective data to a single text file.
I thought a fix to this issue would be to add multiple separate channels and record data from them separately. This was not a good idea because the data that is being recorded is garbage (i.e it is recording 10.6 V from every channel even though the max was set to be 10V. It is no longer varying with the input provided rather staying at a constant).
So my queries are:
1) Is it possible to condense the attached VI to record 5 samples every second form each of the channels at the same time and also generate separate charts for the respective channels? If so, how?
2) Is the approach I used remotely sensible? If not, is it at least apparent what I'm trying to do?
05-21-2012 02:35 PM - edited 05-21-2012 02:36 PM
that smiley face is not supposed to be there, it turned my ' : ' and ' D ' into that , I was trying to mention a range of physical channels