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

Counter with external Timing stops after a few measurements

$
0
0

Hello everyone!

 

This is my first project using Nidaqmx and I've run into a problem:

I want to measure the incoming signals with respect to a timing signal I create with the following code:

 

    DAQmxCreateTask("timing", &task_timing);
    DAQmxCreateCOPulseChanFreq(task_timing, timing_ctr, "timing",DAQmx_Val_Hz, DAQmx_Val_Low,0.0,hz,0.5 );
    DAQmxSetChanAttribute(task_timing, "timing", DAQmx_CO_Pulse_Term, timing_slot);
    DAQmxCfgImplicitTiming(task_timing,DAQmx_Val_ContSamps,1);
    DAQmxStartTask(task_timing);

 

This seems to be working as intended, but in my counter there seems to be a mistake:


    DAQmxCreateTask("counter", &task_ctr);
    DAQmxCreateCICountEdgesChan(task_ctr,counter_ctr, "counter", DAQmx_Val_Rising, 0, DAQmx_Val_CountUp);
    DAQmxSetChanAttribute(task_ctr, "counter", DAQmx_CI_CountEdges_Term, counter_slot);
    DAQmxCfgSampClkTiming(task_ctr, timing_slot, hz, DAQmx_Val_Rising, DAQmx_Val_ContSamps, hz);

 

or in the function responsible for reading from the counter:

 

    while (true)
          {
            DAQmxReadCounterU32(task_ctr, -1, 10.0, data, hz, &read, NULL);
            for (u = 0 ; u<read; u++)
            {  delta_t++;
                if (data[u] > cnt)
             { cnt=data[u];
              cout<<  delta_t << '\t' << cnt;
                 delta_t = 0;
            }
        }
   }

 

Shouldn't this function write a continuous stream as such:

    1000   1

    1000   2

        ...

        ...

        ...

 

Instead it stops after 2 or 3 lines.

 

Thank's in advance!

Markus

 

 


Viewing all articles
Browse latest Browse all 1271

Trending Articles



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