03-31-2017 07:30 PM
Hi,
I have currently developed a code where I have voltage input from two channels on the same device. While I run my program I receive error 200279 on both channels. Additionally, the output to my excel combines both channels as one. Though I want continuous samples, I could have a pause situation where I can get the data in intervals. If that does not work, I can change my while loop wait time (where I would prefer a longer time).
Any help would be appreciated. Thank you in advance. I have also attached my program for viewing.
Thanks again,
Sadia
03-31-2017 10:24 PM
Suggestion -- start simple. There is a lot of stuff going on in your code (which, according to you, doesn't work). Have you tried experimenting with your USB 6009 using MAX? You can tell MAX "Take samples from 2 channels at the same time", which makes your DAQ code really simple. Get MAX to do what you want, then create a 2-channel MAX Task, with the channels, max/min, sampling rate, # of samples, etc. all defined, press Run to see it in action (so you can refine your parameters if necessary), then save it as a Task in MAX. Now you have one "Start Task" function (with, you guessed it, your already-defined Task constant as its input), a single Analog Read, N Channel, N Sample function in the loop (which gives you 2 Channels together, either as an array of 2 Waveforms or a 2D array of Doubles, whichever you choose). Now you have to do something with these data ...
You mention "Exporting data to Excel". Your code shows writing a text file, separating the data with a delimiter character (by default, a <Tab>). This is not an Excel-specific (.xls, .xlsx) file, but a text file that you can read with NotePad or any other Text Editor. LabVIEW calls this a "Delimited Spreadsheet File" -- that word, "Spreadsheet", confuses many into thinking "Excel".
You don't need (and shouldn't have) a Wait function inside your DAQ loop. The DAQ hardware with "clock" the loop much more accurately and precisely than Windows' clock. For example, if your 6009 is set to take 1000 samples at 1KHz, it will take it exactly 1 second to produce these data, and exactly 1 second later, it will have another set of data. So if you have a While loop with only the DAQ Read inside, it will loop at exactly 1Hz. The only thing you can do is to "slow it down" (and potentially miss data samples) by putting more "stuff" (like a Wait) inside the loop.
Have you spent time with the LabVIEW Tutorials (see Getting Started with LabVIEW on the first page of the Forum)? There is an excellent series of videos and papers on DAQmx (do a Web search if you haven't run into them yet).
Bob Schor
04-02-2017 07:06 AM
Thank you for your recommendations. As you stated, starting simple is the route to take. This is why I am currently trying to program/ learn coding with this device because I used MAX originally and was able to output data. From here, I am trying to use the same device and DAQmx so I can potentially use this as a basis for other devices.
You are also correct about my output file which has the ability to open in notepad and excel. The reason I am using this vs the invoke node- Export to Excel File from the waveform itself is that through that method I was (I believe) reading the time data in Hz and this way I was able to see my data in date/time/s.
Thank you for the Wait function input also. I again believe you hit the target on the spot. Yesterday, I took the wait function out but another error (error 200479 or 200278 depending on what I did) pops up. Therefore, could you explain what you mean by the DAQ hardware with clock the loop- are you talking about the sample clock task? Once I took the wait out- my program stopped before even giving me data in the notepad/excel file.
04-02-2017 03:51 PM
I don't happen to have a USB-6009 at home, so I told MAX to make a simulated one for me. I created, in MAX, a Task called Demo-6009 that consisted of two analog input channels (AI0 and AI1) that ranged from -10 to +10 volts, I set the sampling mode to Continuous, the sampling rate to 1000 Hz, and the number of samples to 100. This means that when started, the (simulated) 6009 will take 100 samples from 2 channels simultaneously at 1KHz, and every 0.1 second (100 samples divided by 1000 samples/second) will deliver two channels of 100 points.
Here's the VI that does this, and plots the data as it comes out onto a Waveform Chart.
You'll notice it only uses 3 DAQmx functions (as so much has been pre-defined in the saved MAX Task wired into the DAQmx Start Task VI). I chose to have the data come out as Waveforms, one per channel (hence a 1D Array of Waveform), which the Chart happily "adjusts" to displaying when I wire the array to its input.
When you run this, you'll see a scrolling display that updates every 0.1 seconds and continues until you push the Stop button. Note that there are no "clocks" in the loop -- the DAQmx Read requires exactly 0.1 seconds to give you 100 points at 1KHz, hence by the rules of Data Flow, the entire loop runs at this rate.
Note if you want to do anything else inside the loop, you need to make sure it can be done within the 0.1 second "window", otherwise you may miss data points. A way around this is to take advantage of LabVIEW's ability to have two loops running in parallel, something called the Producer-Consumer Design Pattern, but that's another topic ...
Bob Schor
04-02-2017 11:32 PM
Thank you for all your help!
I have attached the LabVIEW program that is a (I believe) exact copy of yours (except for the Export to Excel node) and am still getting the error 200278. In my original program, I am able to get a finite sample amount without the wait in the while loop now but the continuous is still giving me an error.
04-03-2017 07:47 AM
Well, if I remove your "Export to Excel" node and substitute my Task for yours, it runs fine. I suspect there's an error in your Task. What happens if you open MAX and run the Task from there? Does it work? And why does your plot show three graphs? (Oh, your task has a third channel, right?).
Your error code makes no sense. Could it possibly be -200278? (The signs are important!). If so, this signals trying to read more samples than are available, again pointing to a Task error. Are you using Continuous Mode sampling in your Task? Be sure it is not set to "1 sample" or "N samples".
Bob Schor
04-03-2017 08:32 AM
Yes, my task runs in MAX and it also runs when I use DAQ Assistant in LabVIEW and when I have one channel using DAQmx.
I do not have a third channel- my graph show voltage 0 and dev2/ai3 (which are the same thing) and voltage 1 and dev2/ai2 (which are the same thing).
Yes, thank you for the correction. All the errors I have mentioned so far have the negative sign in front. A further explanation of the error is: http://digital.ni.com/public.nsf/allkb/4159A4241B8A24B3862570EC007AB6B7
And yes, I am using continuous sample.
The one thing I believe that might be causing the error is in the advanced setting in MAX- I have it set as internal clock with a timeout amount. Do you think that might have something to do with the error? If so, what should it be?
Thank you.
04-03-2017 11:03 AM
I'm assuming that the Advanced Timing is set to the default values of Internal Clock and 10 seconds. If 10 seconds go by and noone reads the data the USB-6009 is presenting, then you'll get a Timeout Error. When you get your error, when does it occur? Does it occur immediately, or about 10 seconds after you start the program? [... and what is the value of the Timeout? Did you change it from 10 to, say, 0? I hope not ...].
This is certainly strange.
Bob Schor
04-03-2017 02:01 PM
Default setting is internal clock at 60s timeout time I believe. I changed it from 60 (I believe) to 10 to see what happens to my LabVIEW but it does not make a difference as far as I could tell. The sample rate in the DAQmx Read does though. The only time I see an error in MAX is if I set the timeout to 0.
I get my error in LabVIEW after about 23 seconds.
04-26-2017 09:01 AM
Hi,
Sorry for the late reply. I have gotten rid of that error. Therefore, thank you for all your help- I did a combination of what you had in the example and what started to work.
However, I am still having the problem with both channels being feed as one in the excel/word file. I was also wondering if you know how to output data without it being in an array form? I have attached both my code and the data example that I am getting. It is combining both the channels in one stream and outputting data in an 2X4 array.
Or else do you know how I can convert the time in the waveform to real time or time in minutes? Any of the options above would really help out.
Thank you again,
Sadia