LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a time delay between two counters that start at the same time?

Solved!
Go to solution

I have the follow VI that I am using to calculate duty cycle. When I use a function generator for the input signal it calculated the duty to within .1%. However, when I use a signal from an encoder attached to a motor, so not a perfect wave, the duty cycle jumps anywhere from 2% off up to almost 20% off. When the signal is attached to an oscilloscope the duty cycle is +-1% of change at most. The only thing I can think of is that the timing between the two counters in not simultaneous, and so the pulse width measurement isn't correlated to the period measurement. That also would explain why with a function generator that is would work, since the signal does not change in anyway.

 

Is my assumption correct that they are not synchronized, or is there something else that would cause that?

0 Kudos
Message 1 of 6
(3,186 Views)

I'm still on LV 2016 and can't look at your 2017 code (unless you use File-->Save for Previous Version, hint, hint).

 

1. Syncing two counter measurement tasks is possible but not obvious or trivial.  Odds are your tasks aren't sync'ed.

 

2. Dunno what board you're using, but you can avoid sync issues by doing your measurement with a single semi-period measurement task (or possibly a pulse measurement task if you have an X-series board that supports that measurement mode).

   By setting the input signal polarity for the semiperiod task you control whether the first valid interval in the buffer (see caveat below) will be a high time or a low time.  From there it's easy enough to figure out any timing relationship you want -- high and low pulse width, duty cycle, frequency, you name it.

 

*Caveat: the meaning of the first value in the buffer might vary from one board type to another.  On older boards, you'll get a time from task start until the first edge of the specified polarity.  This is not generally a valid interval time.   On newer X-series boards, the first value in the buffer should be a valid full interval but offhand I can't say whether a rising edge polarity spec leads to an initial buffer value of high time or of low time.

   The old behavior created some confusion, but the new behavior isn't perfect either.

 

 

-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
(3,161 Views)

Here is a version for 2016, and also a snippet for the duty cycle. I'm using a 6341 daq.snippet.png

0 Kudos
Message 3 of 6
(3,156 Views)

@randomguy77 wrote:

Here is a version for 2016, and also a snippet for the duty cycle. I'm using a 6341 daq.snippet.png


I am the same page as Kevin.

 

If you change your acquisition to return a "Waveform" instead of "1D DBL", you MAY be able to see a difference in the "t0" for the Waveform data.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 6
(3,151 Views)

Can you combine the two counters into a single task, then use a single start function?

 

I know you can for analog channels where you can add individual channels in a series of "creates" or within a loop.  I don't mess with DAQ counters, so I don't know if the philosophy applies.  But the DAQmx Read does have a Multiple Channel option in it.

0 Kudos
Message 5 of 6
(3,144 Views)
Solution
Accepted by topic author randomguy77

I made mods in place to convert to a single counter doing semi-period measurement.  I don't have hw here to test so it's possible I have the high times and low times swapped due to misinterpretation of the "starting edge" parameter.  Fix as needed.  Otherwise, this should help you get all the pulse params you care to measure.

 

 

-Kevin P

 

New Duty Cycle Tester - modKP.png

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