Signal Generator Square Wave and Aliasing? - Page 1
Forum section: electronics / testgear

author: ssashton
author_rank: Frequent Contributor
timestamp: September 29, 2021, 07:38:42 pm
content: I'd like to understand more about how digital signal generators (proper ones like R&S, Keysight, not a PC) produce square waves? Would someone with a good quality bit of kit be willing to post an FFT (logarithmic please) of a 10KHz square wave?I watched a youtube video about aliasing, Nyquist and square waves etc..https://youtu.be/bg6bOVShU-wThe video showed that if you use the tone generator in Adobe Audition and create a square wave it results in significant aliasing distortion in the waveform. Basically it uses a mathamatical function to create a square wave (at unknown bandwidth?) and then down-samples to the working project sample-rate without anti-aliasing filters.To me that seems wrong, as I think it should apply anti-aliasing to whatever the generator outputs to give a 'realistic' (analog?) representation of a band-limited square wave.I'm very curious how a proper dedicated signal gen does this same task? Does it also kick out lots of alias products, or does it band-limit before interpolation?If there is a good reason for not applying anti-aliasing to the generator output, what is it?Please help me understand.I'm sure we all know that a square wave consists of odd harmonics, so a 10KHz square wave should have only 10KHz, 30 KHz, 50KHz, 70KHz etc.. I *assume* if I got a high bandwidth square wave such as from a switching transistor and recorded it in to my audio interface ADC I would not have all these extra distortion products thanks to the input filtering and ADC digital filter? I've got to try it now!

author: bdunham7
author_rank: Super Contributor
timestamp: September 29, 2021, 07:59:45 pm
content: Quote from: ssashton on September 29, 2021, 07:38:42 pmThis is a common issue when people generate 'illegal' audio files--those that violate the input rules--by either disregarding the need to filter digitally generated files or by using improper recording techniques. This is often used to 'demonstrate' that digital audio is inferior to analog. A 10kHz square wave generated by a typical AWG or DDS is going to indeed only have the harmonics you expect. As you approach their sampling limits, the results may vary with the cheapo ones, but all decent ones will have analog and/or oversampling filtering of the output.Does Adobe Audition allow you to manually apply brickwall anti-aliasing filter?

author: ssashton
author_rank: Frequent Contributor
timestamp: September 29, 2021, 08:32:42 pm
content: I realised I can easily test what happens with a square wave recorded by my audio interface. I used the digital output pin of an Arduino Uno and switched it at 10KHz. I don't know how clean it switches, but I guess with audio bandwidth sampling it won't really matter?The results are interesting!As expected, the aliasing products are significantly lower than those of the digitally generated square wave.On the other hand I am surprised they are as high as they are! In both cases the highest amplitude alias products are about -25dB (sorry I didn't normalise the files to 0dB). I thought the brick wall digital input filters in the ADC would be more effective.Note the frequency axis scale changes in these graphs.

author: ssashton
author_rank: Frequent Contributor
timestamp: September 29, 2021, 08:34:22 pm
content: Quote from: bdunham7 on September 29, 2021, 07:59:45 pmThanks for the info.There is no option to apply filtering to the waveform generator. You can of course filter after generation, but by then the aliasing products are already baked in to the waveform.If you re-sample a file there are options about filters and for bit depth change there are dithering options. So I think it's a bit of an oversight to miss it from the tone generator.

author: TurboTom
author_rank: Super Contributor
timestamp: September 29, 2021, 09:43:17 pm
content: ...and that's what a 10kHz 0dBm fundamental square wave from a rather crappy arbitrary waveform generator (integrated AWG of a DS2000A-S o'scope -- all the better ones are in the basement lab and I don't bother to go and get one) looks like on an entry level spectrum analyzer (logarithmic frequency scale, 1kHz~1MHz). The LO/1st IF feedthrough on these simple devices makes looking at lower frequencies pointless.All half-way decent lab signal generators have high-order (usually 7th or 9th) reconstruction filters installed right after the DAC that will virtually eliminate all aliasing products form the output by cutting off everything above approx. 0.8 Nyquist frequency. And the sampling frequency of these devices is in the hundreds of megahertz to gigahertz ballpark, so not at all comparable with the usual audio converters. On the other hand, your screenshots show that the input of the audio ADC is probably un-filtered, resulting in a whole bunch of mirror frequencies below the fundamental that are the result of harmonics above Nyquist of the ADC passing through to the sampler input. Some of the sampling aliases of the generator signal of your first test may also contribute.I hope this somewhat helps to shine some light on your questionsCheers,Thomas

author: ssashton
author_rank: Frequent Contributor
timestamp: September 29, 2021, 10:16:49 pm
content: Thanks for the plot!The video creator replied to my message and I have asked if I can reproduce it here.He basically explained that Audition apparently uses wavetable synthesis. He pointed out that the samples themselves are a 'square wave' - i.e. samples go '00001111'. Essentially it is producing square samples, not a square wave.

author: ssashton
author_rank: Frequent Contributor
timestamp: September 29, 2021, 10:25:10 pm
content: Quote from: TurboTom on September 29, 2021, 09:43:17 pmThe ADC itself is theAKM AK5385which has a digital LP filter when operating at 192KHz. It says stopband 106KHz (which is above 1/2 fs!) and 100dB attenuation. I'm sure there is also some soft analog filtering for RFI rejection etc..I guess the aliasing products we see in my plots are from whatever creeps in between the 96KHz upper limit of the 192KHz sample-rate and the 106KHz stopband.

author: ssashton
author_rank: Frequent Contributor
timestamp: September 29, 2021, 10:32:35 pm
content: Oh no cocked up! The first waveforms I posted from Audition were wrong. I must have had a modulator enabled. I'll edit the first post if I can.Here are the correct results.The point is still valid - aliasing products are there.