Quantcast
Channel: Counter/Timer topics
Viewing all articles
Browse latest Browse all 1271

Buffered pulse width measurement on the 6211

$
0
0

Hi All

 

I have a USB 6211 that I am trying to use to measure a pulse width or period.  The input to the timer gate is the A output of a rotary encoder and I need to know the instantaneous speed of this encoder.  The minimum pulse width is 100uS - the maximum is about 10ms.  I want to use the internal 20MHz or 80MHz clock to time these pulse widths.  Using an example I found I have the following C code that works

 


    DAQmxErrChk (DAQmxCreateTask("Pulse Width Measurement Task",&taskCounter));
    CreateChannelName( channelName, deviceName, "ctr0" );
    DAQmxErrChk (DAQmxCreateCIPulseWidthChan (taskCounter, channelName, NULL, 4000, 40000, DAQmx_Val_Ticks, DAQmx_Val_Rising, NULL));

 

I then read the samples with

 

    DAQmxErrChk(DAQmxReadCounterU32 (taskCounter, 1023, 10.0, TimeSamples, 1023, &SamplesRead, NULL));

 

The problem is that if I put the following code into the device I can catch every sample up to 1000Hz.  After that I seem to catch every other period.
I think this is because the code works in the "On Demand" mode.


    DAQmxErrChk (DAQmxCfgSampClkTiming (taskCounter, deviceName, 10000, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 10000));
    DAQmxErrChk (DAQmxGetBufInputBufSize (taskCounter, &bufSize));

 

I have tried to add the above lines to put it into continuous mode but I get an error complaining that I need to select an external clock.  Do I need to configure an output to act as a sample clock for the continous stream? 

 

I am sure I am making a simple mistake here but I have not worked out what it is yet.

 

Any help appriciated.

 

Thanks

 

John


Viewing all articles
Browse latest Browse all 1271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>