05-05-2009 05:04 AM
Hello,
I want to measure a frequency on the analog input but it doesn't seem to work.
I'm trying to get it working using DAQmx with the use of ansi c.
The first step I made was acquiring the information on the analog input. With the use of a simulated device this shows a sine wave on the input.
My next step was to generate a trigger signal for the counter, but this doesn't seem to work.
I don't see how it is possible to connect the trigger on the analog input to the counter.
For the creation of the analog input and trigger I use the following code:
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-3.0,3.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000));
DAQmxErrChk (DAQmxCfgAnlgEdgeStartTrig(taskHandle,"Dev1/ai0",DAQmx_Val_RisingSlope, 0));
For the creation of the counter I am using the following code:
DAQmxErrChk(DAQmxCreateCIFreqChan(taskHandle1,"Dev1/ctr1",
"",1,2000,DAQmx_Val_Hz ,DAQmx_Val_Rising ,DAQmx_Val_LowFreq1Ctr ,1,4,"");
I hope some one could give me a hint.
I have also tried the examples that come with DAQmx but far as I know this are only counter examples using digital inputs.
Thanks in advance.
Solved! Go to Solution.
05-08-2009 08:22 AM
Hi,
You have to use the comparison event output to the counter input. Change this property after the configure channel function.
DAQmxSetChanAttribute (taskHandle1, "", DAQmx_CI_Freq_Term, Dev1/AnalogComparisonEvent);
Regards,
Bas