Hantek HDG2102B square wave not so square - Page 1
Forum section: electronics / testgear

author: tkamiya
author_rank: Super Contributor
timestamp: March 27, 2021, 07:53:49 pm
content: I have a Hantek HDG2102B function generator. This unit is spec'd 100MHz sine wave and 30MHz square wave.However, using short 50 ohm coax (output impedance is 50 ohm) and 500MHz scope with 50 ohm input impedance, "squaredness" of the signal is only maintained to around 10MHz. At 20MHz, there is significant rounding, and at 30MHz, it is a sine wave.I have experienced something like this before with all function generators including HP. If anyone has this unit or ones similar, would you be so kind to check yours and possibly take a photo?Thanks.

author: Fungus
author_rank: Super Contributor
timestamp: March 27, 2021, 10:29:45 pm
content: Quote from: tkamiya on March 27, 2021, 07:53:49 pmThose numbers don't add up. To show a decent 30Mhz square wave you need about 300Mhz output bandwidth on the device.Quote from: tkamiya on March 27, 2021, 07:53:49 pmSounds about right. With 100Mhz output bandwidth you can show a 10Mhz square wave with five harmonics.

author: tkamiya
author_rank: Super Contributor
timestamp: March 27, 2021, 10:35:46 pm
content: Well.... that's what Hantek claims in its literature. But I tend to think some of these "facts" are overly optimistic. I wanted to compare notes with owners of this device just to verify. It's incredibly difficult to maintain square shape of "square" waves....

author: gnuarm
author_rank: Super Contributor
timestamp: March 27, 2021, 11:23:22 pm
content: Quote from: tkamiya on March 27, 2021, 10:35:46 pmYou realize this is a "duh" moment? Hantek is not HP and pretty much anything they build is overrated in every sense of the word.

author: tkamiya
author_rank: Super Contributor
timestamp: March 27, 2021, 11:29:29 pm
content: No, not really....If it's rated at 30MHz, I'd expect some resemblance of square waves - heavily distorted maybe. What I am seeing here is, a complete sine wave.Again, I'm looking for someone who actually own this gear.... I have all the theoretical stuff.

author: TimFox
author_rank: Super Contributor
timestamp: March 27, 2021, 11:31:13 pm
content: Is there a spec for the rise time? If so, compare it to the period. Otherwise, the usual rule is that (rise time) x (bandwidth) = 0.35. If the sinusoidal bandwidth is 100 MHz, that implies 3.5 ns rise time, and your 30 MHz square wave has a half period of 16 ns, so two rise/fall times take up almost half that.The third harmonic is most (but not all) of the difference between a 30 MHz sine and square wave, and phase shifting the harmonics has a large effect on the temporal waveform.

author: tkamiya
author_rank: Super Contributor
timestamp: March 28, 2021, 12:22:43 am
content: Default amplitude is 200mV p-pRise time is < 10nS for sine....We are not even taking an account for slew rate.That explains it doesn't it?

author: tautech
author_rank: Super Contributor
timestamp: March 28, 2021, 03:37:13 am
content: Quote from: tkamiya on March 28, 2021, 12:22:43 amNo !Both square wave and pulse waveforms should have a specified risetime and any AWG without these run a mile !

author: tkamiya
author_rank: Super Contributor
timestamp: March 28, 2021, 04:38:17 am
content: I'm attaching a manual here. (found the spec for square wave)On page 26, it defines square wave. Leading edge and trailing edge time is defined. Now, go all the way down to appendix... page 98, towards the bottom, square wave rise/down is specified. <10nS....One cycle is made up of rise and fall. So 10nS one way means 20nS both ways to complete a cycle. f = 1/t to find a frequency of what this represents.... 1 / (20x10^-9) = 50,000,000 = 50MHz. So the cut off derived from rise/fall is 50MHz. So at 30MHz, there is enough bandwidth to generate fundamental sine wave, but not the required second, third.... harmonics.So one will only get sine wave at 30MHz.Is there something wrong with my reasoning?

author: gnuarm
author_rank: Super Contributor
timestamp: March 28, 2021, 04:49:19 am
content: Quote from: tkamiya on March 28, 2021, 04:38:17 amThe relation between rise time and bandwidth is the product equals 0.35. The way you are calculating 50 MHz would be valid if the limitation were slew rate and not bandwidth. Bandwidth is defined as the -3 dB point on the frequency response curve, so with a 10 ns rise time it would be 35 MHz. To form a square wave the odd harmonics need to be present in the amplitudes of 1/3, 1/5, 1/7... etc. of the fundamental. This is a 20 dB/decade drop off as in a 1 pole filter. So a 30 MHz square wave should be possible if the response does not drop off any faster than this."Cut off" is an unfortunate term to use with bandwidth. It implies a step response where frequencies on one side of the cutoff are passed and on the other side they are not. Frequency response doesn't work like that.

author: tkamiya
author_rank: Super Contributor
timestamp: March 28, 2021, 05:13:25 am
content: If rise time is 10nS, rising edge will take 10nS to go from 10% to 90%, correct? 30MHz signal alternates every 33nS. If it took 10nS to go up and another 10nS to go down, at best, there is 10nS of "flat top". In bandwidth limited condition like this, there won't be a flat top.When I think of a "square wave", I'd expect fairly sharp rise and drop with plenty of flat response at both ends.Isn't it?

author: gnuarm
author_rank: Super Contributor
timestamp: March 28, 2021, 05:46:47 am
content: Quote from: tkamiya on March 28, 2021, 05:13:25 amIsn't what?

author: tkamiya
author_rank: Super Contributor
timestamp: March 28, 2021, 06:54:28 am
content: Is my understanding correct? I think you were trying to tell me I'm thinking incorrectly before. Where did I go wrong?

author: Fungus
author_rank: Super Contributor
timestamp: March 28, 2021, 07:48:15 am
content: Quote from: tkamiya on March 28, 2021, 04:38:17 am10ns is only enough for about a 30MHz sine wave.Can the device output a 100Mhz sine wave with no voltage loss? (is peak to peak voltage still the same as at 10MHz?)

author: Fungus
author_rank: Super Contributor
timestamp: March 28, 2021, 07:51:19 am
content: Quote from: tkamiya on March 28, 2021, 05:13:25 amNot really. A square wave is a sine wave with harmonics at 3x, 5x, 7x, .... the base frequency. If the harmonics are being lost then you only see the sine wave.

author: tkamiya
author_rank: Super Contributor
timestamp: March 28, 2021, 08:10:33 am
content: Appreciate all the inputs.I'd like to go back to original query, and ask for anyone who has Hantek HDG2102B to chime in.... in these price range in T&M equipment, I am not expecting lab quality accuracy and precision. I don't necessary trust spec sheet either. I've seen plenty of overly enthusiastic ones. So I'd like to compare apple to apple.Question here is, Hantek HDG2102B, square wave, 30MHz, what does it look like? I'm looking at a sine wave on mine.Or... does anyone have Siglent SDG1032X? what does 30MHz square wave look like?

author: tautech
author_rank: Super Contributor
timestamp: March 28, 2021, 08:16:55 am
content: Quote from: tkamiya on March 28, 2021, 08:10:33 amWas going to do just that for you but sold our last this morning however I do have a SDG6022X out but that would be a little unfair with its 1ns rise times.Maybe I should unbox a SDG2042X...............Gimme a bit.

author: tautech
author_rank: Super Contributor
timestamp: March 28, 2021, 09:11:35 am
content: How square a square wave looks is always about its risetime and if slow it can look like a sinewave however when we increase the timebase to inspect a HF square wave its risetime at the faster timebase appears more noticeable to the point we suspect it's a sinewave we are looking at....it has always been this way for the inexperienced as we overlook the critical part of a square wave spec... its risetime !SDG2042X on Ch 2, risetime spec 9 ns max to 25 MHzSDG6022X on Ch 4, risetime spec 2.4 ns max to 80 MHzAll that matters is they meet or better datasheet spec.SDG1032X offers a 4.2 ns max risetime.

author: Fungus
author_rank: Super Contributor
timestamp: March 28, 2021, 09:51:16 am
content: Quote from: tautech on March 28, 2021, 09:11:35 amNote that the pink wave above looks like the second wave in this image:That means that only the first two sine waves that make up your "square" wave are getting through, and even the second one is looking slightly attenuated there.(Image randomly chosen from:http://www.aaronscher.com/Course_materials/DSP/DSP_Lab1.html)

author: gf
author_rank: Super Contributor
timestamp: March 28, 2021, 12:01:40 pm
content: The HDG2102B seems to be a regular DDS generator. AndDDSrelies on band-limited reconstruction of a discrete signal. Given a sampling rate of 250MSa/s, the theoretical bandwidth of the generated analog signal cannot exceed 125MHz, and in practice it has to be even lower (say 100MHz) due to limitations of the analog reconstruction filter. For a 30MHz square wave, only the fundamential and the 3rd harmonic can be retained within 100MHz bandwidth, and 5th, 7th,... harmonics are gone. But the abrupt truncation of the fourier series leads toGibbs effect, and the result won't look like a square wave either, suffering from overshoot/ringing (see diagrams posted by Fungus). The overshoot can only be eliminated (or reduced) by renouncing rise time, by applying a low-pass filter with a smooth roll-off, starting at an even lower cut-off frequency. It's eventually a trade-off. Only a higher sampling can really help, or you must not use DDS to generate a square wave (directly), but a different method.

author: gnuarm
author_rank: Super Contributor
timestamp: March 28, 2021, 06:56:18 pm
content: Quote from: tkamiya on March 28, 2021, 06:54:28 amShould I assume your post is addressed to me? Your mistake is thinking frequency response is binary, frequencies passed or frequencies not passed. Don't over simplify the situation. Don't over complicate it either.

author: TimFox
author_rank: Super Contributor
timestamp: March 28, 2021, 07:16:30 pm
content: Gibbs' phenomenon is very interesting. See the usual source of all knowledge:https://en.wikipedia.org/wiki/Gibbs_phenomenonWhen you generate a square wave by adding harmonic sinusoids (which must be coherent to the fundamental), as you add higher and higher harmonics, the rise and fall become more vertical, but an overshoot appears at the end of the rise and fall. With more and more harmonics (not truncation), the overshoot peaks become higher, but the area under the peaks decreases, so the sum of sine waves is still a good fit (in the least-squares sense) to the desired square wave. This is a direct mathematical result of approximating an ideal square wave with a Fourier series.

author: gnuarm
author_rank: Super Contributor
timestamp: March 28, 2021, 07:27:28 pm
content: Quote from: Fungus on March 28, 2021, 09:51:16 amWhile the overall shape of the magenta waveform may look like the second waveform qualitatively, if you do a quantitative measurement you will get a different result. The ripple in the high and low levels is in the ball park of the seventh harmonic, not the third. However, this is not the waveform of adding the seventh and first harmonics. So the output is most likely the result of a slew rate limitation rather than a bandwidth issue. They are not the same thing.

author: TimFox
author_rank: Super Contributor
timestamp: March 28, 2021, 08:12:04 pm
content: If you want to exploit the fine frequency resolution of a DDS to make square waves, you need to take the reconstructed sine wave (after the LPF driven from the DAC) and square it (Schmitt trigger or similar). Thereafter, you have problems with bandwidth, slew rate, and rise time from the output circuits. Especially at high frequencies that are non-simple ratios of the clock frequency, the digital word applied to the DAC is not itself a good source for the square wave.

author: gf
author_rank: Super Contributor
timestamp: March 28, 2021, 10:41:34 pm
content: Quote from: gnuarm on March 28, 2021, 07:27:28 pmTo me the magenta waveform looks basically like fundamental + 3rd harmonic, but with a lower amplitude for the 3rd harmonic. The presence of other (even smaller) components can hardly be judged by eye, but FFT were necessary. I rather do not see obvious signs of non-linear distortion due to a slew-rate limit.

author: gnuarm
author_rank: Super Contributor
timestamp: March 29, 2021, 01:24:00 am
content: Quote from: gf on March 28, 2021, 10:41:34 pmIt's an oscilloscope display. It's easy enough to measure the period and frequency. My measurement came up with about 6.something ns, so 160 MHz, far from the 3rd harmonic. Not so far from the 7th. BTW, the fundamental measures 24 MHz in that image, not 33 MHz matching the 30 ns that has been discussed.

author: tkamiya
author_rank: Super Contributor
timestamp: March 29, 2021, 01:43:29 am
content: So.... if the magenta trace is 25MHz with 9nS rise time, it makes sense that 30MHz at 10nS will be rounder than that.Confirmed. Thanks everyone!

author: tautech
author_rank: Super Contributor
timestamp: March 29, 2021, 01:49:28 am
content: Quote from: tkamiya on March 29, 2021, 01:43:29 amNo not round as the rising edge of a square wave should always be straight even when it is slow.

author: tkamiya
author_rank: Super Contributor
timestamp: March 29, 2021, 06:09:42 am
content: I think this is a language issue. The magenta trace shows what I call a "rounding." Even the straight part, there is a definite slope and slight inflection. I got the answer I was looking for. Thank you very much!

author: gf
author_rank: Super Contributor
timestamp: March 29, 2021, 06:11:38 am
content: Quote from: gnuarm on March 29, 2021, 01:24:00 amAttached is a plot oft = (0:1:99)/100;x = sin(2*pi*t) + 1/6 * sin(2*pi*3*t);plot(t,x);I.e. fundamental + 3rd harmonic (no 5th or 7th).Relative peak and valley positions on the timeline basically correspond to the magenta trace.EDIT: And for comparison, the 2nd plot (plot-1+7.png) shows how fundamental + 7th harmonic looks like (-> sin(2*pi*t) + 1/6 * sin(2*pi*7*t))

author: gf
author_rank: Super Contributor
timestamp: March 29, 2021, 06:24:25 am
content: Quote from: tkamiya on March 29, 2021, 01:43:29 amBasically yes. At least at/near the limit you rather need to compare frequencies in ratio to the sampling rate. I.e. you rather need to compare the 24 MHz @300MSa/s from the SDG to 20 MHz (not 30) @250MSa/s from the HDG.The SDG has a clear advantage, though, in this regard. It has the higher sampling rate.And besides that, its 4x interpolation/oversampling capability certainly relaxes the requirements for the analog reconstruction filter.(Don't know if the oversampling is used for anything else - the docs don't seem to reveal that.)