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.
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.
02-17-2019 03:26 PM - edited 02-17-2019 03:32 PM
Hi, I want to extract the fundamental waveform from a single cycle of a square waveform. But using square waveform VI I am not getting the correct fundamental waveform.
I thought maybe because since the waveform is not completing a full cycle at t=10 by jumping back to 1. So I had increased the no. of samples by 1 to make the waveform complete, but I am still not getting correct results.
Please help with this problem.
02-17-2019 03:46 PM
What do you expect the answer to be?
I think you are confused about what a frequency of square wave is and what a fundamental frequency is. A square wave does not consist of one frequency. It is a sum of multiple frequencies that goes on infinitely. Do an FFT on your square wave and you'll see what I mean. You are using single tone extraction which is returning the strongest frequency of all of those individual sine waves.
If you want the frequency of a square wave, you need to take the period of the square wave signal and then the inverse of that.
02-17-2019 04:06 PM
You are correct that the single tone extraction fails in this edge case and gives you the first harmonic instead. This is most likely due to limitations of the algorithm, after all, it applies a window function before doing the FFT. (The extract single tone is a VI, so you can see how it does it :D). It does work correctly of you have two or more periods.
02-17-2019 04:15 PM
To paraphrase RavensFan's (correct) response to your question. using some wisdom I learned as a Freshman in College, "Answer Analysis reveals that the Question is Wrong".
You have a single cycle of a Square Wave (which one assumes will continue squarely-oscillating "forever"). If you have any kind of signal and repeat it cyclically at a certain frequency, you should expect that the dominant frequency of the spectrum should be ... the repetition frequency = the reciprocal of the signal's Period (here 10 seconds, for a frequency of 0.1 Hz).
Your "Extract Single Tone Information" function (whose behavior I haven't studied, don't know its algorithm, so can't comment on whether it is just flat-out wrong, which I hope is not the case, or whether you are mis-using it somehow) is returning an estimate of the "Single Tone" that is twice the fundamental. If you know anything about signal theory, you'll know that a Square Wave consists of odd multiples of the Fundamental, with all the even harmonics being 0, so if there were a "second harmonic", it would have a magnitude of 0, hence would not be the "Single Tone" present in the signal.
Have you tried running this algorithm where the input signal is not a single cycle, but (say) 10-100 cycles of something, even a square wave? Do you still get the same (obviously-wrong) result? [I could do the experiment myself, but I'm not really interested in the answer to this question -- I am, however, interested in your learning something about Signals, LabVIEW, and learning how to "explore on your own" to figure things out, which is what Engineers are supposed to do ....].
Bob Schor
02-18-2019 12:01 AM
I have noticed the following things after analyzing the working of extract tone VI:
I think the extract tone VI need at least 2 cycles of the waveform to calculate the correct values. But in my program, I need to calculate the fundamental only with a single cycle of the square waveform. Is it possible?
02-18-2019 12:11 AM
Try using the pulse measurements VI. You should be able to detect your pulse time and therefore be able to detect the frequency.
02-18-2019 12:39 AM - edited 02-18-2019 12:45 AM
If you know it is a exactly a single cycle, there is nothing more to measure. The answer is already there, given the time axis.
AsI said, "extract single tone" applies a window function because it cannot assume that you have an integer number of cycles. You use of it is not as intended.
Can you give some background on the purpose of all this?
02-18-2019 06:39 AM
Yes with the only single cycle I can calculate the fundamental frequency which is obviously the signal frequency itself and there is no need of 'extract tone VI'. But here I want to measure amplitude as well.
My application is related to MMF waveform of a distributed winding of an electrical machine.
When the number of poles in the machine is two, I need to generate a single cycle of the square wave.
When many such square waves are displaced from one other with some angle then the resultant waveform resembles a sinusoidal wave with very fewer harmonics. For making a reference sinusoidal wave, I need to extract the fundamental from the resultant and then plot it.