LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Frequency measurement

Hello,

 

I am trying to measure the frequency of an input square wave signal using "Tone Measurement VI". The frequency measurement is correct and I can only see a output graph using "waveform chart". However, I need a graph where x-axis is the time and y-axis is the measured frequency.

 

I have tried various ways to do but couldnt get x-axis working. The sampling rate is 50kHz so i would like to see x-axis increasing from 0 with ms intervals. 

 

I will then need to perform a FFT on this signal but I am stuck on how could I get this time vs measured freq waveform.

 

I have attached the VI I am working on so hopefully it is clear.

 

Many thanks,

 

Yang

0 Kudos
Message 1 of 8
(3,655 Views)

Hi Souken,

 

so you want to display frequency over time? Plot the waveform on your chart and enable time formatting of the x axis:

check.png

 

The problem here is some overuse of ExpressVIs and DDT wires: both hide elementary information from the programmer - in the end you don't gain from using them a lot.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(3,650 Views)

Hi GerdW,

 

The fisrt graph i want is time vs measured frequency. I expect this "time" is in milliseconds starting from zero rather than HH:MM:SS format.

 

The second graph is the FFT results based on the results from the previous step. However, this FFT cannot be plotted at the moment and I suspect the time axis isnt correct.

 

I have tidied up the VI and attached. 

 

Thanks, 

 

 

Download All
0 Kudos
Message 3 of 8
(3,626 Views)

Hi Souken,

 

I expect this "time" is in milliseconds starting from zero rather than HH:MMSmiley FrustratedS format.

Then you need to format the x axis to float numbers - and adapt the x axis scaling (multiplier) to match your sampling rate (or better: loop iteration rate).

 

However, this FFT cannot be plotted at the moment and I suspect the time axis isnt correct.

The whole FFT is wrong right now: why do you try to apply a FFT an the ToneMeasurement result?

Why not take the FFT from your simulated signal?

(THINK DATAFLOW!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 8
(3,611 Views)

Hi GerdW,

 

Thanks for the first one. I will work on that to see how should I convert it to the milliseconds.

 

The second one is a bit tricky. The concept is to find out the frequency variation over time. e.g. frequency variation over 120 seconds. I should then be able to plot this variation in time domain. Since this frequency variation is caused by a capacitance sensor, I would like to see at which frequency the capacitance changes the most. Here are two plots I have from manual plotting using excel but i would like those to be automatically plotted by LabView.

Time vs measured frequencyTime vs measured frequencyFFT of (Time vs frequency)FFT of (Time vs frequency)

 

 

 

 

 

 

 

 

 

 

 

 

 

The figure on the right is what I am after but I have to get the one on the left in order to perform FFT.

 

I am thinking to rebuild a waveform using measured frequency as y-axis but struggling on what should I use for x-axis (I know this can be achieved using the timestamp, but again, i want to see either second or millisecond).

 

Many thanks,

 

0 Kudos
Message 5 of 8
(3,607 Views)

Hi Souken,

 

The figure on the right is what I am after but I have to get the one on the left in order to perform FFT.

Right now you calculate the main frequency using ToneMeasurement. You need to collect the tone result in an array (or waveform) and apply the FFT on that collected array. Right now you apply a FFT on only one sample delivered from ToneMeasurement: which kind of result do you expect from an FFT working with just one sample?

 

Again: NOT using ExpressVIs and DDT wires will make your life (a lot!) easier. You will learn basic LabVIEW concepts as collecting data in arrays, storing data in shift registers, differences of arrays and waveforms…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 8
(3,584 Views)

Hi GerdW,

 

Many thanks pointing out.

 

I have now received a Frequency vs time graph and exported to .txt file. I have also spaced them to be 0.05 sec along x-axis.

 

I now try to implement a FFT on this signal and unfortunately i have received no value...This time, I have used the very basic FFT block but no luck. 

Capture.PNGCapture1.PNG

Any advice?

 

Many thanks,

 

 

 

0 Kudos
Message 7 of 8
(3,564 Views)

Hi souken,

 

advice:

- what's the error output of fft?

- do you use charts or graphs?

- why don't you attach your VI?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 8
(3,556 Views)