Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Measure Frequency with Measurement Studio .NET and C#?

What is the quickest/best way to measure an acquired signal's frequency? Example: Let's say I have a acquired a sine waveform with an analog input channel in C# and measurement studio .net. I have assigned the waveform data to a graph and an array variable. Now what? How do I get what frequency it is? I have used LabView for the last 7 years. Measuring frequency is pretty simple in LabView....just wire up the measure frequency VI. This is done without using any counters....etc. Is there a way to do this in measurements studio.....(NationalInstruments.Analysis......????)

I am using Measurement Studio .NET version 7.1 enterprise, MS Visual Studio .NET 2003, PCI-6071E, SCB-100.

Thanks much all,

Jason
0 Kudos
Message 1 of 9
(6,264 Views)
Jason,

There actually is not a single function that measures the frequency of an acquired waveform. You can, however, calculate this quite quickly and easily using functions from Measurement Studio. Since frequency is simply one over the period, you can simply calculate the period and then divide. To find the period, you can use the PeakDetector Class. Using the detect method, you can get the position of two successive peaks using the Detect Method, and can subtract the position of these two to find the period. You can then simply calculate the frequency from this. Let me know if you have any other questions regarding this class or method. Have a great day.

Adam B.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 9
(6,242 Views)
Thanks much, the technique works!!!

Jason
0 Kudos
Message 3 of 9
(6,219 Views)
On using the PeakDetector Class to find frequency, I have a couple question? I have a task to that has 4 AI and outputs a double [,] sampled at 1000 samples/channel. So I get about 4000 samples in data. How do I use the peakdetector class to find the peaks. The example I have on that is not helpful. I have the raw data as a 2 dimentional double array. Let me know if you can help. Thank you
0 Kudos
Message 4 of 9
(6,075 Views)
On using the PeakDetector Class to find frequency, I have a couple question? I have a task to that has 4 AI and outputs a double [,] sampled at 1000 samples/channel. So I get about 4000 samples in data. How do I use the peakdetector class to find the peaks. The example I have on that is not helpful. I have the raw data as a 2 dimentional double array. Let me know if you can help. Thank you
0 Kudos
Message 5 of 9
(6,070 Views)
Since the PeakDetector function only takes 1-D array data, you will need to extract the individual rows of data to pass it on to the PeakDetector function. You can use the ArrayOperation.CopyRow if you are using Measurement Studio 7.1. If you using a prior version, check out this link for information on how to do this in C#.

Hope this helps
Bilal Durrani
NI
0 Kudos
Message 6 of 9
(6,056 Views)
when you call the method arraySubset(data, row) in the code snippet you provided, what value is passed into row?
0 Kudos
Message 7 of 9
(6,052 Views)
You would provide the row number you are interested in. .NET arrays are 0-indexed, so to extract the first row(or first channel in your case) from a 2D array, pass a 0 to the function.
Bilal Durrani
NI
0 Kudos
Message 8 of 9
(6,022 Views)

Peak detection, though, is error-prone when you have multi-tonal signals or the case of low signal-noise. Is there an automated approach using Fourier Analysis (peak of FFT) or auto-correlation built in to Measurement Studio?

0 Kudos
Message 9 of 9
(4,521 Views)