07-29-2009 05:14 PM
Why does resample.vi (in Sig. Proc toolbox, LV 8.6) sometimes give errors?
Attached VI gives error when input file=sin0.10hz.txt and decimation factor(DF)=6, attenuation=40, BW=0.25.
Error -20076 occurred at NI_AALPro.lvlib:AAL Resample (const to const).vi:2 in NI_AALPro.lvlib:Resample (constant to constant,single -channel).vi:1 in decimation_test.vi.
Possible reason(s): Analysis: The resample point cannot be calculated with the signal behind that of the input.
Whether or not an error occurs depends on the input file (at least its length), and the value of DF, attenuation, and BW. Examples, with attenuation=40, BW=0.25 if not specified:
Input file=sin0.10hz.txt: Error when DF=6,7,8. (other DFs from 1 thru 10 OK)
Input file=sin0.001hzlong.txt: Error when DF=6,8,9.
Input file=either, DF=6: Error when BW=0.25, no error when BW=0.35.
resample.vi can be called with anti-aliasing turned on or off. Errors seem to occur only when anti-aliasing is turned off. The help indicates the attenuation and BW parameters affect how anti-aliasing is done. Why then does occurence of errors depend on the values of parameters that are supposedly ignored when anti-aliasing is off?
Is this a bug? Thanks for your help.
Solved! Go to Solution.
07-31-2009 03:21 PM
Hi WCR,
This was reported to R&D (# 181556) for further investigation. Thanks for the feedback!
Regards,
Stephen S.
07-31-2009 05:00 PM
Thank you Stephen S.
Another example of resample VI behaving badly is attached.
The example is slightly different than before. An error does not occur, but I think the results are incorrect and inconsistent with the documentation. When I run the attached vi, decimate_test_whileloop.vi, with input file sin0.01hz3x.txt (3 cycles of a 0.01 Hz sine wave), and with the parameters dec.factor=10, atten=40, BW=0.01, I get a resampled array with 10X fewer points than the original. So far so good. The original sampling rate=1 Hz, new sampling rate = 0.10 Hz. This is all correct and the output display confirms this. However, the resampled signal has NOT been anti-aliased as requested or as the documentation states. (Note that anti-aliasing is turned on on the block diagram.) I have specified minimum attenuation of 40 dB and normalized bandwidth = 0.01 times the new rate, in other words a passband of 0.001 Hz (new rate * 0.01). The signal is at a frequency 10 time higher (0.01 Hz) so it should be attenuated, presumably by a factor of a hundred (40 dB) or more. It is hardly attenuated at all. If I try changing the attenuation factor from the initial value of 40 to 30, 20, 10, 5, the output signal doesn't change. It should. If I increase the attenuation to 60 or 80 dB, the output actualy gets a little bigger, instead of smaller as it should do.
Can you forward this followup info to R&D, # 181556?
Thank you.
08-03-2009 01:23 PM
Hi WCR,
Thanks for the further information. I have put your information into Corrective Action Request #181556.
Regards,
Stephen S.
08-05-2009 01:47 AM
Hi WCR,
Resample VI has many checks to avoid invalid memory access. However, one of the checks seems too strict, so that in some cases, when correct result could be delivered, Resample VI actually returns error. We will fix this in future release. Thanks for reporting this!
Your second poster involves the concept of resampling.
http://ccrma-www.stanford.edu/~jos/resample/ describes the main concept of resampling in details.
In theory, we can recover the bandlimited analog signal from its discrete samples, according to Shannon's sampling theorem, by using sinc function.
However, the sinc function extends from -Inf to Inf. So in practice, we need to truncate it and window it. This process can be regarded as passing sinc function through a low-pass filter. Attenuation, normalized bandwidth, and anti-aliasing are used to describe the low-pass filter.
If you increase the attenuation from 40 to 80 dB, the designed filter is more like an ideal low-pass filter, so the VI gives better resampling result - closer to original signal. If you use 40 dB, which means you use a "poor" low-pass filter in resampling, so the result is not good - deviate from the original signal.
Since low attenuation results in poor resampling result, Resample VI will automatically adjust this value if the input attenuation is too low. So you will see the result is the same for attenuation being 40, 30, 20, 10, 5.
Hope this helps.
08-06-2009 02:14 PM
Thank you, DSPmchen.
I understand from your reply and from looking at the guts of Resample.vi and its sub-VIs that if an attenuation of less than 48 dB is specified, the attenuation will be automatically increased to 48 dB. I suggest that this fact be noted in the help for Resample.vi to avoid confusion. This does not explain 2 other questions which I asked. Both questions relate to results which cn be observed when running decmation_test_whileloop.vi, with input file sin0.01hz3x.txt and decimation factor=10 and BW(normalized, or fractional)=0.01.
1. When attenuation is changed from 50 dB to 100 dB, the output (resampled signal) amplitude increases. Shouldn't it do the opposite?
2. When attenuation is 80 dB, the resampled signal amplitude, whose frequency = 0.01 Hz, is essentially the same as the input signal amplitude. Since its frequency is ten times higher than the frequency indicated by the "normalized bandwidth", I would expect it to be attenuated. (Help file for Resample.vi says "normalized bandwidth specifies the fraction of the new sampling rate that is not attenuated." In this case, norm.BW=0.01, new sampling rate=0.1 Hz, so the actual bandwidth should be 0.001 Hz.)
Files decimation_test_whileloop.vi and sin0.01hz3x.txt were attached to earlier message so I will not resend.
Thank you.
08-09-2009 10:31 PM
Hi WCR,
We will update the help in future release to avoid confusion. Thank you!
According to Shannon's theory, if you want to recover the signal at a certain time stamp x(t0), all the input signal samples will contribute to x(t0) by multiplying the sinc function. Sinc function also is regarded as ideal lowpass filter. In practice, resampling is using certain lowpass filter to replace the sinc function.
1. The frequency response of an ideal lowpass filter is a "rectangle" in frequency domain. When the attentuation is changed from 50dB to 100 dB, this means you use a filter more similar to the "ideal lowpass filter". Thus the resampled signal is closer to the original signal. So you see the output amplitude increases.
2. When anti-aliasing is TRUE, the normalized stopband is 0.5. So the normalized transition band is from 0.01 to 0.5 (or 0.001Hz to 0.05Hz). The input signal is 0.01 Hz, which falls into the transition band. However, the frequency response of the filter in Resample VI does not drop very fast in transition band, since most resampling applications want to keep the orignal signal spectrum. So in your case, the input signal does not attenuated much.
08-09-2009 11:33 PM
I think about the first question again and check the code.
Since the passband is 0.01, stopband is 0.5, so the transition band is dominant. When the attenuation changes from 50 to 100 dB, the frequency response increase a little bit at first and then drops sharply in the transition band. And 0.01Hz happens to be in the first part of transition band, so the output amplitude increases.
08-10-2009 08:34 AM
Thank you, DSPmchen. I agree with your analysis.
08-19-2010 01:00 PM
CAR 181556 has been resolved in LabVIEW 2010. To look for other bug fixes please review the LabVIEW 2010 readme.