Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Measure duty cycle with a counter?

I'm trying to measure duty cycle 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 so I end up being off by one semi period but I have no way of determining that. Is there a way to configure the card to always start measurement when signal is high?

Here's the 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 2
(3,536 Views)

Duplicate thread, answered here.

-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 2 of 2
(3,530 Views)