Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

pwm measurment

How can i measure a duty cycle & frequency of a PWM Signal with a 6014PCI usinf traditional  NI-Daq functions.
I need to measure the pulse and the pause to calculate the PWM in percent.
0 Kudos
Message 1 of 2
(3,457 Views)
What you'll need to set up is called "semi-period measurement" and you may need it to be a buffered measurement.
 
However, the last I knew, this was a little quirky under trad NI-DAQ with DAQ-STC counters.  Specifically, there was no way of specifying or knowing whether the measurement started with a high time or a low time.  So when a real signal has a duty cycle of 25%, your program had no way of knowing whether it's measuring 25% or 75%.  Sometimes you may have special knowledge of your PWM signal that will help you know which is more sensible, but other times you're just plain stuck.
 
Frequency is easy enough though -- just take the reciprocal of the sum of two adjacent semi-periods.  Any two adjacent semi-periods sum to 1 whole period, and the reciprocal of that is frequency.
 
DAQmx provides some additional capabilities (including triggering) that *may* help.  I vaguely recall a thread here that suggested a DAQmx bug in a particular version that would have caused a similar ambiguity -- ah yes, here it is.   It references a different type of counter, so I'm not sure if the workaround applies to your board.
 
I haven't used DAQmx much for DAQ-STC counters -- I've mainly been using the 6602 and an M-series board which use different timing chips that sometimes work a bit differently than the DAQ-STC.  Nevertheless, here's a basic concept thay might also work.  As far as I know, this approach also requires DAQmx because trad NI-DAQ doesn't support triggering on DAQ-STC counters.
 
You would need to configure 2 counters to be triggered by the same signal (to guarantee simultaneous start), both measuring your PWM signal.  However, one would do buffered semi-period measurement (where polarity might be ambiguous) while the other does buffered period measurement (where polarity won't be ambiguous).  If your period measurement is set to measure rising edges, then you'll be able to examing the semi-period data to determine whether that rising edge corresponds to the 1st or 2nd entry in the semi-period data.  This in turn resolves the polarity ambiguity.
 
Note that even though you only need the 1st value in the buffer, the period measurement still needs to be buffered to make sure that the period measurement starts at the trigger signal.  In unbuffered mode, period measurement starts at the first active edge of the PWM signal after the trigger.
 
-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 2
(3,448 Views)