LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to measure the pulse duration of a TTL signal using AI?

Hi there.
 
I would like to know how to measure the pulse duration of a TTL signal using an Analog input.
These TTL signals comes from an ultrasonic sensor's output. The pulse width of the signal is
proportional to the distance of the object the sensor detected.
I have tried using the example "Measure Pulse Width.vi" which uses a counter to measure the
pulse duration instead. It provides me with correct results.
However, i will like to know how can i do it using the AI instead.
I tried it by using the example "Acq&Graph Voltage-Int Clk.vi" which i modified by including a
timing and transistion measurement vi. Pulse duration was selected as the output. A graph indicator was also added at the output of the pulse duration to monitor the incoming TTL signals.
However, everytime the TTL signals was detected on the graph indicator, the numeric indicator always produce a "zero" reading.
 
I have attached my vi for your reference.
Can anybody advice me what i have done wrongly?
 
Regard.
 
0 Kudos
Message 1 of 12
(7,389 Views)

How fast is the TTL pulse? ms, us, ns?

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 12
(7,368 Views)
The pulse width is ranging from 0.7msec to 5.6msec.
The frequency of this pulse width appearing is 0.25sec.
That is to say the sensor will sense and update the numeric
indicator about 4 times every sec.
 
Regards.
0 Kudos
Message 3 of 12
(7,358 Views)

Hi Paul,

Today i tried using 2 different methods to read the pulse duration of my sensor signal.

Both methods use "Acq&Graph Voltage-IntClk" vi as a guide.

Method1:

Add a filter vi(lowpass/bandpass) and a timing and transition measurements vi.

Pulse duration is selected as the output. With some numeric conversion, a centimeter

reading indicator was created. However, the reading always remains as "zero"

 

Method2:

Add a Mask and Limit Testing vi and a timing and transition measurements vi.

By adjusting my upper and lower limits, i manage to "filter" a single pulse out from the actual signal.

However, like the earlier case, the cm reading still remains at "zero"

I have attached both the methods resulted waveforms for your reference.

Are there anything that you can advice on?

 

Regard.

 

 

 

0 Kudos
Message 4 of 12
(7,340 Views)
jj6206,

I have an idea about how to measure the pulse using AI.  Do you want to calculate the pulse duration on the fly or is this going to be an after the fact calculation?  In any case I would monitor the signal and if it goes above a threshold (~1.5 in your case) take a time measurement.  Then when the signal goes below the threshold, take another time measurement.  Subtract those two time points and that value is your pulse duration.  If this does not work, then I would suggest posting a VI with some data saved in the graph (Edit » Make current values default) so that when you reopen the file some data is there.  This would be helpful for those trying to test out potential solutions!

Thanks!
Andy F.
-----------------------------------------------------------------
National Instruments
0 Kudos
Message 5 of 12
(7,306 Views)

sorry for the slow reply, you can use an analog collection with a analog trigger.  Acquire a signal as long as the longest expect pulse but shorter than the retrigger rate.  if you use pretriggering you can collect additional information on the edge jitter and slew rate.  Vis are provided of determining logations of edges rising and falling of a wave form as well as any other metric which should be important.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 6 of 12
(7,296 Views)

Hi Andy,

I have tried the method you suggested. But i got an error msg after running the vi.

Error: 20309 occurred at timing and transistion measurement.

Analysis: The amplitude of the waveform is zero, so the histogram method cannot be used.

I have attached my vi for your reference. Can you please see if it is correct?

Any other advices will be much appreciated.

Regard.

0 Kudos
Message 7 of 12
(7,268 Views)

Hi Paul,

Thankyou for the suggestion.

But i don't really understand what you mean.

Is there any examples that explain the steps u adviced?

 

Regard.

0 Kudos
Message 8 of 12
(7,239 Views)
One quick question, why are you not using a counter to measure the pulse widths?  This seems like the best method since you dont care about the pulse heights (all TTL logic levels).  I was simply providing a possible method for analog analysis of a signal.   The counting method will give yo the ability to do high resolution analysis on your signal continuously and with an all digital process will greatly simplify the programming logic.  I guess the only downfall is that there is no very high channel count counter system but I dont know how many signals you are looking to analyze.
 
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 9 of 12
(7,230 Views)
Hi Paul,
 
Thankyou very much.
I have already tried using counter to measure my pulse width.
The results indeed  is very good.
However, i am using PCI-6025E, which has only 2 counters available.
I used one as i/p to measure pulse width and the other to generate PWM signal.
I am able to control part of my system by doing so.
As i need to duplicate my design for another set with the same capability, i thought
of using 2 analog inputs to measure my TTL signals and use the 2 counters to
generate PWM signals instead.
I apologize for didn't explain my full system requirements clearly.....
 
 
0 Kudos
Message 10 of 12
(7,228 Views)