08-06-2014 03:33 AM
Hello,
I got a Signal in my NI USB 6009 analog input. Now I have to average this Signal and send it to the analog output. I continuously aquire the signal. The Signal in my input looks like the following Signals:
I think the input signal is a ~ 280 - 300Hz Signal.
Which sample rate I have to take for this 280 - 300 Hz Signal? And how do you averge this signal?
DAQmxErrChk (DAQmxCreateTask("",&taskHandle1));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle1,"Dev2/ai0","FunktionEingang1",DAQmx_Val_Cfg_Default,0,10.0, DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle1,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,100000));
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle,"Dev2/ao0","",0,5.0,DAQmx_Val_Volts,""));
[...]
// DAQmx Read Code
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle1,100,-1,DAQmx_Val_GroupByChannel,dataread,1000,&read,NULL));
[...]
// DAQmx Write Code
DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle,4,1,-1,DAQmx_Val_GroupByChannel,datawrite,NULL,NULL));
08-08-2014 03:22 AM
Hello,
The sample rate should be greater than 2*f_max (ca. 600 Hz) as it is said in the Nyquist Theorem.
In the real life, it is better when the samplerate is greater than 10*f_max.
If you want the average of the signal, you have to sum up all values of the read-Array and divided by the number of the samples.
You get the number of samples with the function arraySizeInSamps and you should sum up all values with a for loop.
The C Reference Help for Daqmx could help you:
http://digital.ni.com/manuals.nsf/websearch/6A79EF4F9F30AFC086257A4400600861
Bye,
Janina