Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

get each time step of a waveform

Hallo,
I have created a VI that acquires an Analog Input from 2Chan and saves the Data from both Chan. and in a third column saves the time.
With the values I use for sampling I read the data once per sec.I expected to see in the column of time sth like
0.001  xxxx
0.002  xxxx
0.003  xxxx
but this is not happening.Instead, if the sampling rate is 1000Hz i get 1000 values of 0 then 1000 values of 1.3 and so on.
 I tried some other ways of solving this prob,which i saw in this forum, but didn't work.Please find my Vi attached and a copy of a txt file that i get from a test.

Thank you in advance for your time

Kind regards,

Dimitris

Download All
0 Kudos
Message 1 of 4
(3,158 Views)
Hello Dimitris,

I took a look at your code and noticed a few things that I wanted to comment on. The buffer
size is set to '0'. The buffer size is the number of samples the buffer can hold for each channel in the task. Zero indicates to allocate no buffer. Use a buffer size of 0 to perform a hardware-timed operation without using a buffer. Is this what you would like to do in your application? In not then you don't need to use the Configure Buffer VI, the DAQmx driver will determine the buffer size you need from the rate and number of sampling data you supply.

In your code, when setting the sample clock you had it set at a sampling rate of 1000Hz and 1000 samples per channel. Since you are setting the sample mode as Continuous Samples, DAQmx uses this value to determine the buffer size. Only in Finite Sample mode does it specify the number of samples to acquire or generate for each channel in the task.

I recommend that you remove the configure buffer vi. In your while loop the DAQmx read should be configured similarly with something like the following: Analog>>Multichannel>>Single Sample>>1D Waveform. Remove the 1000 sample constant on the sample clock. Do you need the wait 500ms in your while loop?

Give these suggestions a try. Let me  know if you are running into any difficulties.

Regards,
  Sandra T.

Applications Engineer | National Instruments


0 Kudos
Message 2 of 4
(3,146 Views)
   Dear Sandra,

thank you for your reply. The reason it took me some time to reply is that we purchased and waiting for the new LV.

 I tried everything you suggested but sth  strange happened...
The first time I run the VI the time stamps were ok, that is 0.001....0.004 and so on, but an error occured (200279 occurred at DAQmx Read ).
Then I did some new tests with the VI changing only the sampling freq. and the time stamps were again zero 😞

Also i noticed something else,the above VI does not work at high sampling freqs. Attached you can find an older VI of mine for the same purpose but much more complicated.If you could some time checking it, it would be great..


Thank you again for your time.

D.
0 Kudos
Message 3 of 4
(3,112 Views)
Hello Dimitris,

The error code "200279 occurred at DAQmx Read" is given when your buffer is getting overwritten. This occurs when you are writing data to the buffer and not reading the data off the buffer fast enough. Take a look at the following KnowledgeBase on this issue, there are recommendations on how to fix this.

(DAQmx) Error -200279 During a Continuous, Buffered Acquisition


You mentioned that the new VI doesn't appear to work when you change the sampling frequency to a much higher value. Were you getting an error?
What value did you set it at? When you changed the sampling frequency were you still with in the spec. of the DAQ device? If you set the value to that of something outside the range of the card, you get an error message.

Is there a reason why you are reverting back to the older code? Are you also getting the same 200279 error when you use this code?
Your code looks similar to that of your previous code with a few exceptions when writing to file. I also noticed you aren't writing the time stamp information in this vi. Perhaps stick with one version and continue developing that one.

Regards,
  Sandra T.

Applications Engineer | National Instruments
0 Kudos
Message 4 of 4
(3,081 Views)