Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring continuously counter edge separation

Solved!
Go to solution

Dear all,

 

I'm trying to measure continuously the separtion between pulses on a pulse train coming from a measurment device.

For that I'm using the source "ctr0" (physical channel PFI8) of my NI pcie 6351 card (X serie). The train amplitude is around 3V with an aproximate frequency of 500Hz.

I wrote a C++ program using the DAQmx library and everything is fine on that front, I don't get any error when calling any DAQ function.

here is the related part of my code :

error = DAQmxCreateTask("", &coTask);
DAQErrChk (error, "coTask DAQmxCreateTask");

error = DAQmxCreateCITwoEdgeSepChan(coTask, "dev1/ctr0", "", 10.0e-8, 1, DAQmx_Val_Seconds,
                                        DAQmx_Val_Rising, DAQmx_Val_Rising, NULL);
    DAQErrChk (error, "coTask DAQmxCreateCITwoEdgeSepChan");

error = DAQmxCfgImplicitTiming (coTask, DAQmx_Val_ContSamps, 1000);
    DAQErrChk (error, "coTask  DAQmxCfgImplicitTiming");

error = DAQmxStartTask(coTask);
        DAQErrChk (error, "coTask DAQmxStartTask");

 error = DAQmxReadCounterScalarF64(coTask,1 ,&data,0);
    qDebug()<<data;

I linked the

DAQmxReadCounterScalarF64

function to a button callback so I can check at reguler interval the last measurement. the problem is : there is no measurement. Each call to the measure function hit the time out.

I also tried to measure the train pulse frequency with no success whatsoever.

I'm starting to think that the amplitude of the pulses is too low (~3V) and the task is expecting a classic 5V TTL but I haven't find any method allowing me to define the amplitude of the pulse.

I tried:

 DAQmxSetDILogicFamily(coTask, "dev1/ctr0", DAQmx_Val_2point5V)

but apparently, this method doesn't apply for counter.

The weird thing is that I can count the number of pulses in the train.

Any help would be welcome!

many Thanks in advance

 

0 Kudos
Message 1 of 5
(3,776 Views)
Solution
Accepted by topic author Olivier.Blanc

3V isn't as high as the board would like (and this is not software configurable), but the fact that you can count edges on the pulse train suggests that the other measurements should also be able to work.

 

I think this boils down to a mismatch between where your signal is physically wired and where the task config expects it to be.  I'd recommend that you configure your task(s) to identify the PFI terminal for your signal explicitly.  When you don't do that, each counter has default pins it looks to for various measurements.  Apparently, you're physically wired to the place your counter looks to for edge measurement but not the other types.

 

As a LabVIEW-only guy, I don't know the C++ API syntax for designating these terminals explicitly, but I know for certain it can be done.  Note also that 2-edge separation expects 2 distinct physical signals -- an edge on one signal starts the timer and an edge on the other one stops it. 

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 2 of 5
(3,755 Views)

Thanks for your answer!

Yes I finaly made progress, you were right the card was expecting two signals, the first on PFI10 and the second on PFI9. So I manage to configure the card to do the measure on a single physical channel (PFI9) but you can not measure the interval between 2 rising edges but one rising and one falling. So you end up either measuring your pulse width or the pulse interval. I'm fine with the later since my pulses are constant.

Would you know of any other method to measure the rinsing edge to rising edge of a pulse?

thanks again

0 Kudos
Message 3 of 5
(3,749 Views)

Rising edge to rising edge of the *same* signal is known as Period measurement.  (You can also configure for falling edge to falling edge measurements.)

 

Rising edge of signal A to rising edge of signal B is known as Two Edge Separation measurement.  The polarity of each signal can be chosen independently, but the time always starts at the next active edge on A and ends on first active edge on B that occurs *after* the edge on A.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 5
(3,743 Views)

ok I see! Thanks for your help!

0 Kudos
Message 5 of 5
(3,725 Views)