Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

pulse width measurment error vs no error measuring period

Solved!
Go to solution

Hardware:

 

NI Cdaq 9172 with one ni 9422 in slot 5 of the 8 slot rack

The Task is to accurately measure pulse width or semiperiod.

 

Using NiDaq and visual studio c++, language.

Code samples were acquired from National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Counter\Measure Period or Pulse Width

 

The problem is simply this.

 

A 1000 hz square wave is applied to counter one (or counter two, tried both) at the proper teminal of the 9422. The square wave is generated by an Agilent 33220A and is the signal verified by scope, and appears to very accurate in period, amplitude and duty cycle (50%).

 

Using the Nidaq code examples, and making 10  period measurments using the DAQmxCfgImplicitTiming function returns 10 very accururate period measurments.  When performing a measurment on the same signal using the DAQmxCreateCISemiPeriodChan function, the two results returned

for each measurement add up to the 1000 micro second period, however the results returned are approximately 586 micro seconds and 414 micro seconds.  This also occurs  when trying to measure pulse width using the DAQmxCreateCIPulseWidthChan function. Using the DAQmx_Val_Rising

parameter and 586 uS measurments are retuned. If the parameter  DAQmx_Val_Falling is passed the measurments are 414 uS.

 

Do I have some bad hardware --> the 9422?

I tried changing the signal amplitude from +10V peak to +23Volt peak and the measurements do not change? (period is still accurate)

It appears that the system is having trouble seeing the falling edge of the signal!

Am I missing a ground connection somewhere?

 

Any suggestions?

 

 

 

0 Kudos
Message 1 of 10
(7,329 Views)

One thing you can do to check the hardware is verify in measuement and automation explorer if your PFI lines are counting edges correct.  Create a test panel for the counter I/O of the NI 9422 and count edges your known signal slowed down so that you can verify it is counting correctly.  Also, what counter are you using on the module and which PFI line are you wired into to take the pulse width and period measurments?

 

TESTING MULTIFUNCTION DAQ PFI LINES IN THE MEASUREMENT & AUTOMATION EXPLORER (MAX):  http://digital.ni.com/public.nsf/allkb/4790E23458D698E086256DCD00543C3D?OpenDocument

 

Regards,

Isaac S.

Regards,
Isaac S.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 10
(7,289 Views)

Issac,

 

Thanks for the reply!

 

Removed all hardware in the cdaq9172 except the NI9422, that's located in slot five.

Slowed down the arb to a 1 hz square wave and then ran the test panel for the 9422.

The rising edge detection works fine and updates the edge count every 1 sec.

 

The system appears very capable of seeing the rising edges!

The signal from the arb is connected to pin 2 of the 9422 and the signal ground is connected to pin3 of the 9422.

PF1  

 

 

Returned freq to 1000 hz, 50% duty cycle, verified with scope... signal is very clean with very fast rise and fall times.

 

The function:

DAQmxCreateCIPeriodChan(taskHandle,"cDAQ1Mod5/ctr0","",0.0001,0.010000,DAQmx_Val_Seconds,DAQmx_Val_Rising,DAQmx_Val_LowFreq1Ctr,0.000100,4,"");

returns 0.001000 seconds for period

 

The function:

DAQmxCreateCIPeriodChan(taskHandle,"cDAQ1Mod5/ctr0","",0.0001,0.010000,DAQmx_Val_Seconds,DAQmx_Val_Falling,DAQmx_Val_LowFreq1Ctr,0.000100,4,"");

returns 0.001000 seconds for period

 

 

The function

DAQmxCreateCISemiPeriodChan(taskHandle,"cDAQ1Mod5/ctr0","",0.0001,0.001,DAQmx_Val_Seconds,"");

returns 0.000593 and 0.000407  

 

 

The function

DAQmxCreateCIPulseWidthChan(taskHandle,"cDAQ1Mod5/ctr0","",0.0001,0.001,DAQmx_Val_Seconds,DAQmx_Val_Rising,"");

returns 0.000594

 

 

This should be real straight forward stuff, measuring a pulse width.

I'm overlooking something... but what!

 

Any additional suggestions.  

0 Kudos
Message 3 of 10
(7,271 Views)

Your wiring seems correct, however just to verify you may want to look over the counter input section of the cDAQ-9172 user guide.  There doesn't seem to be any issues as you appear to be connecting your signal source to the gate of counter 0 on the NI-9422.  Are you able to compare this behavior to another module?

 

 

NI cDAQ-9172 User Guide and Specifications: http://digital.ni.com/manuals.nsf/websearch/D0435486A31A3B038625743900690AEE

 

 

Regards,

Isaac S.

Regards,
Isaac S.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 10
(7,237 Views)

Isaac,

 

Two different modules were tested and they both have the same issue.

Tried both slots, 5 an 6, same issue.

The 9422 is specified, I believe, up to 4Khz, but as the freq of the signal approaches 4khz, the pulse width error becomes larger and larger.

Conversely,  at very low freq. the error appears less!

One would think that 1kHz would be OK on a device specified for 4khz!

No success yet!

I'll dig through the 9172 manual, looking for applicable info!

 

0 Kudos
Message 5 of 10
(7,231 Views)

Hello

0 Kudos
Message 6 of 10
(7,182 Views)

Hello,

 

Nothing in the 9172 manual to suggest anything wrong, with connections or software.

I believe that the 9422 is not capable of connecting a clean signal to the 9172 counter system, to make an accurate pulse width measurement! 

 

Can someone confirm this. I do not want to waste any addtional time trying to use the 9422 is it's not capable of this.

 

Any insight/suggestions?

 

Thanks!

 

0 Kudos
Message 7 of 10
(7,181 Views)

No real insight as I'm not familiar with your particular hardware.  In general though and by analogy to the hardware I *am* familiar with, I find your observations highly unexpected & surprising as well.  The particular quantization you see for semi-period measurement doesn't seem to break down as a possible off-by-1 type of issue, which is about all I could think to look for.

 

As to suggestions, you've tried period and semi-period.  What happens when you measure pulse width, either high time alone or low time alone?

 

-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 8 of 10
(7,169 Views)
Solution
Accepted by topic author dachenba

Hello,

 

The 9422 specificaitons indicate "Input Delay Times" on page 14:

 

Input delay time

OFF to ON..................................250 μs max, 4 μs typical
ON to OFF..................................250 μs max, 130 μs typical

 

 

It seems that it is typical for the module to have a 126 us discrepancy between its detection of rising and falling edges.  This discrepancy would explain the measurements you have reported (a period measurement is the difference between consecutive rising-rising or falling-falling edges, whereas a pulse width measurement is the difference between consecutive rising-falling or falling-rising edges).

 

 

Best Regards,

John Passiak
Message 9 of 10
(7,156 Views)

Thanks for the info.

 

It seems a contradiction to spec the device speed at 250us or 4000 hz but then spec an input delay at 130us.

But that detail explains the issue!

 

Thanks again!

 

0 Kudos
Message 10 of 10
(7,142 Views)