From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Count number of rising edges in 1D array

Solved!
Go to solution

Hello,

 

I wanted to measure the frequency of a pulse signal using an MCC DAQ through ULx libraries in Labview. I have two methods to do this:

 

1. Use analog input:

Since the DAQ has only 1 ADC, I have to use a common acquisition VI for all channels and create a multi-dimensional array with different channels in rows 0-15. Then split them using "Index Array" function.  I believe this splitting will remove the "time" parameter from the waveform, since it is now a 1D array. But I already know that it will have 1000 samples every 100 ms. All I want to do now is to count rising edges using some function and divide it by the 0.1 to get frequency in Hz, but I don't know how. Can someone help?

 

2. Use counter frequency input:

Since I can't use the DAQ assistant, I have to use the CI Frequency -> Counter 1D DBL 1ChanNSamp in the ULx library. There's no reference to take help from and I'm not sure if this method is right. I have no way of knowing since I don't have a signal generator. Plus it doesn't work so far.

 

Please help.

 

Thanks!

 

0 Kudos
Message 1 of 19
(5,363 Views)
Assuming the pulsed signal.is basically TTL levels with nice rising and falling edges, and no overshoot or undershoot, a counter input is always the best way to go. Analog measurements, even in the best of circumstances, will mess up your timing since the sample rate directly impacts the time resolution of your measurements.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 19
(5,334 Views)

First we should establish the correct DAQ design before trying to tackle software implementation questions (such as how to handle the waveform and array data or how to use the provided library).

 

What are the characteristics of the signal(s) that you are working with?

What information are you trying to extract from these signals?

What DAQ hardware do you have?

 

 

Assuming that you have some value that is being carried as the frequency of a high frequency square wave, using a hardware counter should be the correct design for acquisition.



0 Kudos
Message 3 of 19
(5,329 Views)

I forgot to mention that the input amplitude and frequency is both proportional to the RPM. I am only concerned with frequency, and am ready to use a 0.15 V threshold value for distinguishing between a noise and proper signal.

 

This is because the RPM pickup is a magnetic type and voltage is induced without an external power supply. The data sheet suggests that it's not really good below 100 RPM, but I'm not concerned because my working RPM is above 1000.

 

How does this information change my actions?

 

Please find the part of the counter input code attached and suggest if I'm doing it right..

 

EDIT:

 

I'm using a Measurement computing DAQ (USB 1608G) which can take upto 250kS/sec analog inputs. Counter input is 32 bit.

 

0 Kudos
Message 4 of 19
(5,309 Views)

With that kind of sensor you must use an anolog input. The varying amplitude and frequency usually implies an approximately sinusoidal waveform, at least at lower speeds.  The counter requires clean logic level transitions at its input or it will almost certainly give poor results.

 

We need more information: What is the maximum speed? How many cycles per revolution does the sensor produce? What are the amplitudes at the lowest and highest speeds of interest? What speed resolution do you require?

 

With that information we can determine the sample rates required, estimate how fast you can update, and determine the resolution you will achieve in the speed measurement.

 

Lynn

0 Kudos
Message 5 of 19
(5,291 Views)

Hello,

 

Here's the information:

 

Maximum speed: 2500 RPM,

Sensor produces 60 pulses/revolution, which means a maximum frequency of 2500 pulses/sec

Amplitude at lowest speed of interest: 0.15 V at 100 RPM, but the lowest detectable speed can go as high as 200 RPM, i.e., 0.3V

Amplitude at highest speed of interest: 3.75 V at 2500 RPM,

Resolution should preferably be 1 RPM.

 

 

0 Kudos
Message 6 of 19
(5,286 Views)
Solution
Accepted by topic author prafullashahi

Thank you.

 

I note in your first post that is appears you want to get speed readings about 10 times per second. To get a 1 Hz resolution by direct frequency counting you need to get at least 2500 counts in one counting interval at the highest frequency. That means you need to count for at least one second. Period measurements are another option.

 

Some preliminary calculations:

 

Period at 2500 RPM = 2500 Hz is 400.000 us.

Period at 2499 RPM = 2499 Hz is 400.160 us.

 

So you need to be able to resolve a period difference of 160 ns. To do this directly requires a 6.25 MHz sampling rate.  This is 25 times faster than your DAQ board can sample.

 

What other options are there? Consider Extract Single Tone Information.vi. It uses Fourier transform techniques and interpolation to find the frequency of a signal. I put together a quick test VI to check this. Using a sampling rate of 10 kS/s and 1000 samples per read (ten readings per second) it easily has frequency resolution below 0.1 Hz at both ends of the speed range and largely independent of the amplitude.  This is the way to go.

 

Lynn

Message 7 of 19
(5,258 Views)

Thanks a lot! 

I'll try it out and let you know how it worked!

0 Kudos
Message 8 of 19
(5,256 Views)

First thing I would say is that you need to be thinking about some external signal conditioning to turn the varying amlitude into a constant amplitude with good rising and falling edges. How much noise is there on the signal?

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 9 of 19
(5,247 Views)

@mike

 

Noise is less than 0.2% at all times.

I don't really know how to convert incoming signal to constant amplitude.

0 Kudos
Message 10 of 19
(5,239 Views)