Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Duty cycle measurement with 6036E device

I'm trying to measure duty cycle using either counter 0 or 1 but I'm getting inconsistent results. With a function generator sending 70% duty cycle signal, I randomly get 30%. Looking at the buffer, it looks like device is starting the counter while the signal is low and not high. Is there a way to configure the card to always start measurement when there's a transition from low to high? Here's my code in VB6 showing how I'm configuring it.

    er = GPCTR_Control(m_uiDeviceNumber, ND_COUNTER_0, ND_RESET)
    er = GPCTR_Set_Application(m_uiDeviceNumber, ND_COUNTER_0, ND_BUFFERED_SEMI_PERIOD_MSR)
    er = GPCTR_Config_Buffer(m_uiDeviceNumber, ND_COUNTER_0, 0, 22, Buffer&(0))
    er = GPCTR_Change_Parameter(m_uiDeviceNumber, ND_COUNTER_0, ND_SOURCE, ND_INTERNAL_100_KHZ)
    er = GPCTR_Change_Parameter(m_uiDeviceNumber, ND_COUNTER_0, ND_SOURCE_POLARITY, ND_LOW_TO_HIGH)
    er = GPCTR_Change_Parameter(m_uiDeviceNumber, ND_COUNTER_0, ND_GATE, ND_PFI_9)
    er = GPCTR_Change_Parameter(m_uiDeviceNumber, ND_COUNTER_0, ND_GATE_POLARITY, ND_LOW_TO_HIGH)
    er = GPCTR_Change_Parameter(m_uiDeviceNumber, ND_COUNTER_0, ND_INITIAL_COUNT, 0)
    er = GPCTR_Control(m_uiDeviceNumber, ND_COUNTER_0, ND_PROGRAM)

Any help would be appreciated. Thank you.
-Dom
0 Kudos
Message 1 of 6
(4,016 Views)

I know this once was, and maybe still is, an issue with E-series boards under traditional NI-DAQ.   I only program LabVIEW, but it appears to me that you had the right idea by trying to specify Gate polarity.  Way back I was trying to do this with E-series boards too, and I found that it simply didn't matter what I specified for Gate polarity, the values would start buffering on the first transition of *any* polarity.  So it just came down to 50-50 chance.

The work-around I found was for cases where I could start my acquisition before the duty cycle signal started.  In such cases, I would parallel wire the signal to a digital input pin and simply query the initial state.  You can't get good hardware level timing between this digital input query and the counter measurement, so this method really can't be used to measure a continuously-running duty cycle signal.  Later I just ran the app using a counter from a 6602 board which *did* respect my specified Gate polarity as the starting polarity.

I don't know if you're using traditional NI-DAQ or DAQmx, though the syntax inclines me to suspect traditional.  If you haven't tried DAQmx yet, you might give it a try.  I don't know for sure if it'll work, but I'd give it better odds than traditional NI-DAQ.

Note: the expected behavior for "Low-to-High" polarity setting should be an initial value representing time from starting the counter task until the first Low-to-High Gate edge occurs (whether or not any High-to-Low edges occur in between).  All subsequent values would be ordered as High Time, Low Time, High Time, Low Time, ...

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 6
(4,004 Views)
Thank you for clarification on this. I am using traditional NI-DAQ driver and I'm measuring a continuous signal at "random" time. Unfortunately, I'm also working on a software that was written to use traditional driver so I'm not sure how feasible it would be to change to DAQmx, since I have a deadline for this.
0 Kudos
Message 3 of 6
(3,998 Views)

One other simple trick if the duty cycle changes slowly.  Configure one counter to measure high pulse widths and the other to measure low pulse widths.  If you're careful, you can start the tasks up at nearly the same time.  The data won't quite be the truth since the arrays won't be perfectly aligned with respect to time, but you might get "good enough" results.

Also, I never tried doing an unbuffered semi-period measurement.  Perhaps for unbuffered measurement, the polarity setting might be respected?

Good luck,

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 6
(3,993 Views)

hello every body, please i have a question in this context , can i mesue the '' duty cycle "" with (((NI usb-6210 ))), i need a response please , i need it to do my graduate project , thanks of all 

0 Kudos
Message 5 of 6
(3,233 Views)

Hi Satouani,

 

The USB device that you have has two counters. You can use the counters to measure duty cycle. Please refer to the following example: Measure Duty Cycle - Buffered - Finite.

 

Best Regards,

Jignesh

Best Regards,
Jignesh Patel
Principal RF Software Engineer
0 Kudos
Message 6 of 6
(3,198 Views)