Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

When exactly do pulse width measurements start?

I am using a PCI-6601 to measure pulse width and period of a PWM signal in LabView (DAQmx).

 

I use ctr0 for the period and ctr1 for the pulse width. The period is measured between falling edges. As I am interested in the high pulses, the pulse width measurement is configured to start with a rising edge.

 

I do a buffered measurement with continuous samples.

 

I use a common start trigger (ArmStart) for both tasks.

 

Everything works just fine, but one thing puzzles me:

My start trigger can occur at any phase of the PWM signal, so I expected the first measurements to be invalid. This is true for the period measurement, but the pulse width is always correct. It doesn't matter in what phase my trigger occurs, the first reading of the pulse width is always correct.

 

Can someone tell me why?

 

 

 

0 Kudos
Message 1 of 3
(3,946 Views)

This is speculation, but it's probably just that NI decided to follow slightly different rules for pulse width measurement than for some of the other counter measurements.

 

I've done triggered period and semi-period measurements before, but don't know that I've done triggered pulse width or frequency measurements.

 

For the two former cases, I know that the counter will start counting time immediately after the trigger edge.  The first measurement represents the time from the trigger to the first active edge period (or semi-period) edge.  It is often meaningless as you anticipated.  For pulse widths, I suppose NI simply decided that the trigger will arm the counter but you also need the pulse's leading edge before you start counting to measure pulse width.  So the first measurement is a true measure of pulse width and is never meaningless.

 

If this is true, then it may be tricky to sync / correlate the data in simultaneous measurements.  For your particular app, you could get away with performing a single semi-period measurement and then calculating the periods and pulse widths.  In other apps, it could get more difficult.

 

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

Thanks for your answer, Kevin.

 

Unfortunately I can't use semi-period measurements, because I need the common start trigger to start other measurement tasks (2x voltage, 1x angle) at the same time as well.

 

I.e. if I use semi-period measurements I can't differentiate between high and low pulses.

 

I did some experiments and you are right with your assumption. The pulse width measurement needs to see a leading edge (in my configuration) before it starts counting. I.e. it doesn't store a result in the buffer at the first falling edge, if there was no leading edge before it.

 

I have only one idea to sync the data. I'll drop period[0] anyway, because it's invalid. If width[0] is smaller than period[0] I will drop it as well. I.e. the start trigger occurred during a low pulse.

 

There is a certain risk by doing that, but as the PWM signal is static at the beginning of the measurement I think it's ok.

 

 

0 Kudos
Message 3 of 3
(3,923 Views)