06-15-2011 12:34 PM - edited 06-15-2011 12:36 PM
Hi:
Let me explain my situation and then ask questions.
I need to aquire a voltage trough a DAQ and perform a numeric integral of this signal. When this integral surpases a certain value, I need to change an output on the DAQ. Its crucial to change the output as soon as the integral of the signal reaches a certain value.
I am having trouble deciding wich are the best sample rate and sample/channel settings. The ideal solution would be to get one sample at the highest posible sample rate and summ it to the integral value, and keep doing this until it reaches the predetermined value, but as you may all know when I try this type of combination*(low sample number and high sample rates) I encounter an error saying, "Attempted to read samples that are no longer available....".
So lets say I use 10khz sample rate and 1000 samples per channel. The problem is that maybe with the first value of the buffer the integral exeeds the predetermined value, and instead of changing the output in that instant, I will have to wait for the other 999 samples to be read and then sent to the computer to make the change. If I were reading a single value at 1khz I wouldnt have to wait for any other values to be read.
The other parameter is the reading mode, would it be better to use an external trigger and ask for one sample, or maybe fix the sample number to 1, I really dont know.
What I am really asking is, What is the best configuration for what I am looking for? (regarding sample rate, smaples per channel and mode)
My project is in c# Vs2010 using the NIDAQmx driver dlls.
Thanks.
Fernando
06-16-2011 12:32 PM
Hi Fernando,
Thanks for posting. Let me make sure I understand what you are trying to achieve here. You are reading data from your DAQ card and calculating a running integral of the samples, adding each additional sample to the collection of previous samples and monitoring the integral. As soon as the integral reaches a threshold, you want the task to change from acquisition to generation. Your question is how to set up the acquisition so that you can make that change as fast as possible.
The way you have tried is giving you an error saying that samples in the buffer have been overwritten. If I am correct, then I would suggest trying a DAQmx Read Property called ReadRelativeTo and set it to "Most Recent Sample". This way, you should be able to specify reading one sample and not have that error thrown. Let me know if this works!