EEVblog Electronics Community Forum

Products => Test Equipment => Topic started by: tkamiya on March 27, 2021, 07:53:49 pm

Title: Hantek HDG2102B square wave not so square
Post by: tkamiya on March 27, 2021, 07:53:49 pm
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.
Title: Re: Hantek HDG2102B square wave not so square
Post by: Fungus on March 27, 2021, 10:29:45 pm
I have a Hantek HDG2102B function generator.  This unit is spec'd 100MHz sine wave and 30MHz square wave.

Those numbers don't add up. To show a decent 30Mhz square wave you need about 300Mhz output bandwidth on the device.

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.

Sounds about right. With 100Mhz output bandwidth you can show a 10Mhz square wave with five harmonics.
Title: Re: Hantek HDG2102B square wave not so square
Post by: tkamiya on March 27, 2021, 10:35:46 pm
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.... 
Title: Re: Hantek HDG2102B square wave not so square
Post by: gnuarm on March 27, 2021, 11:23:22 pm
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....

You realize this is a "duh" moment?  Hantek is not HP and pretty much anything they build is overrated in every sense of the word.
Title: Re: Hantek HDG2102B square wave not so square
Post by: tkamiya on March 27, 2021, 11:29:29 pm
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. 
Title: Re: Hantek HDG2102B square wave not so square
Post by: TimFox on March 27, 2021, 11:31:13 pm
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.
Title: Re: Hantek HDG2102B square wave not so square
Post by: tkamiya on March 28, 2021, 12:22:43 am
Default amplitude is 200mV p-p
Rise time is < 10nS for sine.... 
We are not even taking an account for slew rate.

That explains it doesn't it? 
Title: Re: Hantek HDG2102B square wave not so square
Post by: tautech on March 28, 2021, 03:37:13 am
Default amplitude is 200mV p-p
Rise time is < 10nS for sine.... 
We are not even taking an account for slew rate.

That explains it doesn't it?
No !

Both square wave and pulse waveforms should have a specified risetime and any AWG without these run a mile !  :scared:
Title: Re: Hantek HDG2102B square wave not so square
Post by: tkamiya on March 28, 2021, 04:38:17 am
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?
Title: Re: Hantek HDG2102B square wave not so square
Post by: gnuarm on March 28, 2021, 04:49:19 am
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?

The 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. 
Title: Re: Hantek HDG2102B square wave not so square
Post by: tkamiya on March 28, 2021, 05:13:25 am
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?
Title: Re: Hantek HDG2102B square wave not so square
Post by: gnuarm on March 28, 2021, 05:46:47 am
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?

Isn't what?
Title: Re: Hantek HDG2102B square wave not so square
Post by: tkamiya on March 28, 2021, 06:54:28 am
Is my understanding correct?  I think you were trying to tell me I'm thinking incorrectly before.  Where did I go wrong?
Title: Re: Hantek HDG2102B square wave not so square
Post by: Fungus on March 28, 2021, 07:48:15 am
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....

10ns 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?)
Title: Re: Hantek HDG2102B square wave not so square
Post by: Fungus on March 28, 2021, 07:51:19 am
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?

Not 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.
Title: Re: Hantek HDG2102B square wave not so square
Post by: tkamiya on March 28, 2021, 08:10:33 am
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?
Title: Re: Hantek HDG2102B square wave not so square
Post by: tautech on March 28, 2021, 08:16:55 am
Or...  does anyone have Siglent SDG1032X?  what does 30MHz square wave look like?
Was 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.
Title: Re: Hantek HDG2102B square wave not so square
Post by: tautech on March 28, 2021, 09:11:35 am
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 MHz
SDG6022X on Ch 4, risetime spec 2.4 ns max to 80 MHz

All that matters is they meet or better datasheet spec.
SDG1032X offers a 4.2 ns max risetime.
Title: Re: Hantek HDG2102B square wave not so square
Post by: Fungus on March 28, 2021, 09:51:16 am
SDG2042X on Ch 2, risetime spec 9 ns max to 25 MHz
(https://www.eevblog.com/forum/index.php?action=dlattach;topic=275214.0;attach=1204114;image)

Note that the pink wave above looks like the second wave in this image:
(https://www.eevblog.com/forum/testgear/hantek-hdg2102b-square-wave-not-so-square/?action=dlattach;attach=1204120;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 (http://www.aaronscher.com/Course_materials/DSP/DSP_Lab1.html) )
Title: Re: Hantek HDG2102B square wave not so square
Post by: gf on March 28, 2021, 12:01:40 pm
The HDG2102B seems to be a regular DDS generator. And DDS (https://www.analog.com/media/en/training-seminars/tutorials/MT-085.pdf) relies 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 to Gibbs effect (https://en.wikipedia.org/wiki/Gibbs_phenomenon), 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.
Title: Re: Hantek HDG2102B square wave not so square
Post by: gnuarm on March 28, 2021, 06:56:18 pm
Is my understanding correct?  I think you were trying to tell me I'm thinking incorrectly before.  Where did I go wrong?

Should 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.
Title: Re: Hantek HDG2102B square wave not so square
Post by: TimFox on March 28, 2021, 07:16:30 pm
Gibbs' phenomenon is very interesting.  See the usual source of all knowledge:  https://en.wikipedia.org/wiki/Gibbs_phenomenon
When 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.
Title: Re: Hantek HDG2102B square wave not so square
Post by: gnuarm on March 28, 2021, 07:27:28 pm
SDG2042X on Ch 2, risetime spec 9 ns max to 25 MHz
(https://www.eevblog.com/forum/index.php?action=dlattach;topic=275214.0;attach=1204114;image)

Note that the pink wave above looks like the second wave in this image:
(https://www.eevblog.com/forum/testgear/hantek-hdg2102b-square-wave-not-so-square/?action=dlattach;attach=1204120;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 (http://www.aaronscher.com/Course_materials/DSP/DSP_Lab1.html) )

While 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.
Title: Re: Hantek HDG2102B square wave not so square
Post by: TimFox on March 28, 2021, 08:12:04 pm
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.
Title: Re: Hantek HDG2102B square wave not so square
Post by: gf on March 28, 2021, 10:41:34 pm
While 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.

To 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.
Title: Re: Hantek HDG2102B square wave not so square
Post by: gnuarm on March 29, 2021, 01:24:00 am
While 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.

To 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.

It'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.
Title: Re: Hantek HDG2102B square wave not so square
Post by: tkamiya on March 29, 2021, 01:43:29 am
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!
Title: Re: Hantek HDG2102B square wave not so square
Post by: tautech on March 29, 2021, 01:49:28 am
So....  if the magenta trace is 25MHz with 9nS rise time, it makes sense that 30MHz at 10nS will be rounder than that.
No not round as the rising edge of a square wave should always be straight even when it is slow.
Title: Re: Hantek HDG2102B square wave not so square
Post by: tkamiya on March 29, 2021, 06:09:42 am
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!
Title: Re: Hantek HDG2102B square wave not so square
Post by: gf on March 29, 2021, 06:11:38 am
While 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.

To 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.

It'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.

Attached is a plot of

t = (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))
Title: Re: Hantek HDG2102B square wave not so square
Post by: gf on March 29, 2021, 06:24:25 am
So....  if the magenta trace is 25MHz with 9nS rise time, it makes sense that 30MHz at 10nS will be rounder than that.

Basically 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.)