Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

analog input generating trigger on the counter gate to measure frequency

Solved!
Go to solution

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,"":smileywink:);

 

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.

0 Kudos
Message 1 of 2
(6,472 Views)
Solution
Accepted by topic author Teun

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

0 Kudos
Message 2 of 2
(6,436 Views)