I own a cheap oscilloscope Hantek DSO4102C. It's rated bandwidth is 100 MHz, and sample rate is 1 GSa/s. Some info about the tool can be found here: http://hantek.com/en/ProductDetail_3_4163.html
Now I have an Atmega328P MCU running from an external quartz at 16 MHz, without any code it it (chip erased by usbasp), only CKOUT fuse bit is set. So I supposed to see a square wave at PB0 pin, but my scope shows it quite distorted:
MCU's datasheet doesn't mention a pin rise time, which was a big surprise to me, so I cannot check if measured 9.5 ns is a valid value. But judging by Pk-Pk voltage exceeding 6 volts (and even going below zero for a good 560 mV), I believe there's a problem with the scope. Am I right?

ADDED LATER, AFTER GETTING SOME ADVICE I've assembled everything on a breadboard, rather then using Arduino Uno. I've connected ground clip from the scope to the ATMega's ground pin with a wire through breadboard. I'm measuring directly at the output pin (see photo of my layout below). Now I'm getting better results, also with 20 MHz oscillator. 16 MHz 20 MHz Layout on the breadboard Obviously, Pk-Pk values are now more close to reality, as well as signal shape. So thanks everybody for the help!

  • 5
    \$\begingroup\$ Are your probes compensated correctly? Also, can you try with a different probe? \$\endgroup\$
    – Steve G
    Commented Aug 30, 2019 at 14:52
  • 3
    \$\begingroup\$ Could you add a photo of how you're probing the signal? That is, how exactly your probe is connected to the circuit. \$\endgroup\$
    – marcelm
    Commented Aug 30, 2019 at 16:59
  • 6
    \$\begingroup\$ Make sure your probe is in the x10 position, compensation adjustment is done and the ground lead is connected to a plane very close to the MCU ground. You can also run probe wizard and self cal routines. \$\endgroup\$ Commented Aug 30, 2019 at 17:27
  • \$\begingroup\$ You MUST do what Spehro says before you start to wonder about what the 'scope is doing to the signals. 1. Connect ground clips from probe to a system ground point as near as possible to the signal point. 2. You probes have an adjustment screw. Usually acccessible through a hole on the side of the probe. Adjust this until waveform appears "most square". Note that this MAY not be optimum if the waveform isn't square but it's a good start in this case. || Even given the pints raised in the good advice from others, I'd not be surprised if you could achieve a squarer result than you are seeing. \$\endgroup\$
    – Russell McMahon
    Commented Aug 30, 2019 at 23:48
  • 1
    \$\begingroup\$ One can never generate a perfect square wave, since the wires, etc. always have some (small) capacitor and inductor effect. \$\endgroup\$ Commented Aug 31, 2019 at 15:31

4 Answers 4


I believe there's a problem with the scope. Am I right?

Don't think so. Overshoot is a perfectly normal phenomenon when measuring a fast-edge signal with a high-impedance probe. (Also, these signals look about as sharp as I'd expect them to be.)

There's many tutorials on sensing high-speed signals: this is the perfect time to read one!

Oh, and there's Gibb's phenomenon, which says that any band-limited observation of a theoretical perfect (or far less band-limited) edge will have some 9% of overshoot; to understand that, I'd recommend looking at the cosine series representation of the square wave and consider what you'll cut off when you get rid of anything above 5× 16 MHz (=the fundamental frequency of your square wave).

  • 1
    \$\begingroup\$ On OP's measure function: I'd believe 16.00MHz frequency (these 'scopes use a crystal time-base). But 9.500 ns risetime? That's suspect, especially with 1ps resolution? And 6.16V Pk-Pk often goes through the entire sample record to find the maximum extent...(I make out about 5.2V, after settling). So Marcus' verdict is reasonable - more careful probing likely gives different results - learn to trust some measure functions, dis-trust others. \$\endgroup\$
    – glen_geek
    Commented Aug 30, 2019 at 15:18
  • 1
    \$\begingroup\$ The statement about Gibbs phenomenon and overshoots is only true if whatever limits the bandwidth does introduce frequency-dependent phase shifts as well as frequency-dependent gain. It is possible to trade off overshoot against rise time (or slew rate) for example. \$\endgroup\$
    – alephzero
    Commented Sep 1, 2019 at 0:18
  • 1
    \$\begingroup\$ @alephzero : Or to express this in more general concepts, the shape of a band-limited wave as compared to its unlimited ideal form depends on exactly how that the band-limiting is accomplished. The "classic" Gibbs phenomenon is only the case for a perfect-cutoff ("brick wall") filtering method that zeroes out all harmonics above a threshold frequency while perfectly retaining those below. This, itself, is an idealization of real filers, and no real filter behaves this way. \$\endgroup\$ Commented Sep 1, 2019 at 4:09
  • \$\begingroup\$ @The_Sympathizer: Indeed, it is possible to design filters in ways that are guaranteed not to produce overshoot. Probably the simplest example is a series-R parallel-C filter. In many cases, tolerating a certain amount of overshoot will make it possible to have a wave shape that more closely follows the input wave, but in some applications it may be more important to avoid overshoot (e.g. because the signals of interest are much lower than the cutoff frequency, and it's necessary to allow the output to reach full scale). \$\endgroup\$
    – supercat
    Commented Sep 1, 2019 at 17:40

Keep in mind that if you have a 100MHz brick-wall filter (ideal case) with a perfect 16MHz square wave in, the only harmonics you'll see are 1 (16MHz), 3 (48MHz) and 5 (80MHz). That's an ideal case, but if you do the calculations, you'll see the result isn't too far from what you're seeing.

In the nonideal case, of course, probe loading and compensation will have further distorting effects, and the waveform isn't going to be perfectly square to start with.

  • 9
    \$\begingroup\$ I simulated this in LTspice, with a bit of phase delay and reduced amplitude at the higher frequencies, and produced a waveform almost identical to the questioner's. \$\endgroup\$ Commented Aug 31, 2019 at 0:59

Marcus Müller mentions Gibbs phenomenon, which produces ringing artifacts in a bandwith-limited signal, and Cristobol Polychronopolis mentions that your 100 MHz bandwith will be reducing the amplitude of harmonics past the third in your 16 MHz signal.

For simplicity and just to get a sense of what's going on with waveforms, we can graph Cristobol's ideal case of just the first three harmonics:

sin(x) + sin(3x)/3 + sin(5x)/5

Note that this is what a perfect scope with a perfect 100 MHz brick wall filter would show, if given a square wave. So no, your scope is not broken when you see ringing in the waveforms: it's displaying what it sees after distortion introduced by the probes and analogue front end and imperfect filtering before digitisation.

This is something you need to learn to deal with: any time you examine a circuit with an oscilloscope it changes (hopefully not too much) the waveforms at that point in the circuit and then further distortions occur between the tip of the probe and the oscilloscope's display. Since you can't avoid this, a good understanding of what distoritions are likely to be happening is essential when using a 'scope, particularly on relatively high-frequency circuits.


In addition to what was said about probe compensation and probe choice, a 16MHz signal from an IC running at nominal speed will not always be so fast in risetime as to appear as a perfect squarewave. To achieve that, you would have to use output stages that would be perfectly capable of handling signals in the 100MHz range. Designing an IC like a MCU to be as fast-rise as possible would only waste power and create EMC problems.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.