Showing results for 
Search instead for 
Did you mean: 

Possible bug in sv_Harmonic Distortion and

Go to solution



I have run into what I believe to be a bug in sv_Harmonic Distortion and


I am calling this VI through a higher level VI which is part of the Sound & Vibration toolkit (SVT SNR without Harmonics (time) (1ch).vi


What happens is that I will occasionally get error 0xFFFFB1A3 (-20061):


Error -20061 occurred at NI_MABase.lvlib:Sine >> NI_MABase.lvlib:ma_Trap Fgen Parameter
frequency must be <= sampling rate/2

Possible reason(s):

Analysis:  The selection is invalid.


This error is actually generated within sv_Harmonic Distortion and by one of it's subVIs (svc_Extract Single Tone Information (complex).vi) although I am not able to enable debugging for this VI so I can not dig any deeper. 


What seems to be happening is that for certain fundamental frequencies that result in a higher order harmonic that falls very near to Fs/2 you get the error.  I have attached a waveform and a simple VI that produces the error.  From my debugging it seems that the error is occurred when the code tries to extract the harmonic at  5119.53Hz.  Fs/2 is 5120Hz so this should be valid but produces an error.





0 Kudos
Message 1 of 8

Hi Phreezer,


Could you please attach the Tokenize from the File Access - Load Waveform - Multi - ASCII  I would like to look into this but I am unable to run the attached VIs.  

Jim Schwartz
0 Kudos
Message 2 of 8

Ok the new zip file should include that sub-vi as well.  Sorry about that.



0 Kudos
Message 3 of 8

Hi Phreezer,


I have added a VI build from yours but adding in simulated data - the only difference is that the noise levels are much lower on the simulated data.  I believe the noise could be causing the error.  I was able to make the error go away on your program by using a lowpass filter at sample rate/2.  We are going to look into this a little more.  Let me know what you think.

Jim Schwartz
0 Kudos
Message 4 of 8

Hi Jim,


Thanks for working on this.  It is interesting that putting a filter on the waveform removed the error but I feel this may just be coincidental.  To me it seems a little odd that noise in the signal would be the cause of the problem since part of calculating the SNR is to measure how much noise is in the signal.  My signal is cerainly not perfectly clean but if I had a perfect signal then I wouldn't care about SNR. 


 I think trying to put in an ideal sine wave of the same frequency was a good idea to try and find out if there is an error in the code somewhere but when I was playing with your modified version I could never get it to detect quite the same f0 with the simulated data as it did with my data (you might need to increase the number of digits shown to see this).  As a result it might again just be a coincidence that the simulated data works because it doesn't result in the exact same f0 and corresponding harmonic frequencies.


The waveform I have provided probably has a fair amount of phase noise which I could see making the algorithm have some added error detecting the precise fundamental, but when I was tracking where the error origionated it looked like it was coming from the (svc_Extract Single Tone Information (complex).vi) sub-vi when it was told to extract the amplitude of the bin at 5119.53Hz.  Since this bin should be less than Fs/2 it seems like this sub-vi should have been able to extract this value but instead it throws an error saying the requested frequency is > than Fs/2.


If for some reason the extract tone VI should in fact be throwing this error with this input frequency and waveform, then it seems like the higher level VI (SVT SNR without Harmonics (time) (1ch).vi) should be removing this frequency from the list of harmonics that it wants to extract levels for.







0 Kudos
Message 5 of 8
Accepted by topic author Phreezer

Hey Matt,


I have talked to R&D and the source of this issue is that we are detecting a peak at exactly the Nyquist Frequency for the 127th harmonic, while this should work, we are getting the false error. As a workaround, you can specify the Frequency Range from 0-126 harmonics as seen in the picture below.  Having one less harmonic shouldn't be a big deal as the 127th harmonic is in the noise anyway.  R&D is now aware of the issue and looking into it.   Thanks!



Jim Schwartz
Message 6 of 8

That will work for me, thanks for your help!



0 Kudos
Message 7 of 8

I upgraded LabVIEW code from version 2013 to 2017.  At the higher levels are are no changes in the code, but I am getting a different result for the exact same spectrum.

I have followed the signal as far as I can.

A vi called svc_Extract Single Tone is password protected.

On two different versions of LabVIEW I am passing it the exact same spectrum data and settings.  The calculated peak is different by 4Hz, and the amplitude calculated is different as well.  The setting used is -1, -1 for frequency of interest and advanced span.  


Bug report 416096 says that there was a fix in LabVIEW 2014 that affects advanced span wide value.  But I am not certain that is my case or not.  Because, while I may use a wide range for general use.  For diagnostic purposes, while supplied a fixed signal to two versions of LabVIEW I tried specifying the exact frequency of interest and a narrow band.  

0 Kudos
Message 8 of 8