[Help Needed] Oscilloscope/Arduino Issue: Overshooting and Ringing - Page 1
Forum section: electronics / beginners

author: Ratents0
author_rank: Newbie
timestamp: June 16, 2023, 04:43:37 am
content: Hello everyone,I'm a newbie to the world of electronics and oscilloscopes, and I am currently facing a peculiar issue with my new Siglent SDS1202X-E oscilloscope and an Elegoo Uno R3 board. I'm generating a square wave with the Arduino, but I'm seeing a significant amount of overshooting/undershooting and ringing. This happens regardless of the frequency of the square wave, and the deviation is quite noticeable (~3V off a 5V signal on both the rising and falling edge).I've tried various troubleshooting steps including updating the oscilloscope's firmware, compensating the probes, calibrating the scope, and more. I've even tried using a different board (Elegoo Mega 2560 R3) to no avail. I'm at a loss as to what's causing this issue.Here's the code I used to generate the square wave:Code:#define REFRESH_RATE 60void setup() {pinMode(12, OUTPUT);}void loop() {unsigned long period = 1000000 / REFRESH_RATE; // total period for one cycleunsigned long halfPeriod = period / 2; // half periodunsigned long start = micros();digitalWrite(12, HIGH);while (micros() - start < halfPeriod); // delay for half period while HIGHdigitalWrite(12, LOW);while (micros() - start < period); // delay for remaining half period while LOW}I've also posted this question on Stack Exchange and provided a more detailed explanation of the problem there, along with some images of the waveform, and my oscilloscope probe connection to the Arduino. Here's the link to the post:https://electronics.stackexchange.com/questions/670233/why-does-my-square-wave-signal-from-an-elegoo-uno-r3-have-3v-overshoot-undershoo.I would greatly appreciate any insights or suggestions that you might have to help resolve this issue. Is this a common issue when generating square waves with Arduino boards, or could there be a specific issue with my setup?Thank you in advance for your help!

author: radiolistener
author_rank: Super Contributor
timestamp: June 16, 2023, 04:53:58 am
content: Quote from: Ratents0 on June 16, 2023, 04:43:37 amit depends on the load impedance connected to output port. If there is overshoot and ringing it means that there is impedance mismatch. For example unloaded port.It doesn't depend on arduino. It depends on what you're connected to the digital port.

author: David Hess
author_rank: Super Contributor
timestamp: June 16, 2023, 04:57:45 am
content: Need to see a picture of how you used the ground spring. The problem sure looks like the ground connection is too long. The photo shown with the ground clip would definitely cause overshoot.What is the 10x probe bandwidth?

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 16, 2023, 05:56:34 pm
content: The oscilloscope pictures you posted on stackexchange look perfectly normal.When you are measuring with the crocodile GND clip, you can't expect a measured bandwith of more then 20MHz and extending your GND lead with the grey "dupont" cable makes it even worse. You've got yourself a nice 200MHz scope.Also, if you move the GND wire or hold it in a fist (without disconnecting the wire) you will see the amplitude of the ringing changing. That is a clear indication that this ringing is caused by the GND wire.Now repeat that measurement, but instead of the long GND lead, use small GND clip. The ringing will be (nearly) gone.The crocodile GND lead is much more convenient to use, and I usually combine it with using a 20MHz bandwidth limit on my oscilloscope.

author: tggzzz
author_rank: Super Contributor
timestamp: June 16, 2023, 06:12:57 pm
content: EasyThe ringing is caused by the inductance of that long ground lead (~1nH/mm) resonating with the probe tip capacitance.FFI about theory, practice, and how to improve the issue, seehttps://entertaininghacks.wordpress.com/2015/04/23/scope-probe-accessory-improves-signal-fidelity/As aseparateissue, such resonances occur elsewhere, e.g. flying leads and circuit input capactiances. That's why long leads on solderless breadboards are a bad idea. For alternative construction techniques, seehttps://entertaininghacks.wordpress.com/2020/07/22/prototyping-circuits-easy-cheap-fast-reliable-techniques/.BTW, it is good that you tested, observed, and thought. Not everybody does thatBTW it is also good that you noticed the phenomenon iscompletely unrelatedto your waveform'sfrequency/period. That's because the issue is solely related to your waveform'stransition time. You are now innoculated against the incorrect statements about your "scope needing 5 samples per clock period" and related nonsense. FFI about why, seehttps://entertaininghacks.wordpress.com/2018/05/08/digital-signal-integrity-and-bandwidth-signals-risetime-is-important-period-is-irrelevant/

author: james_s
author_rank: Super Contributor
timestamp: June 16, 2023, 06:41:24 pm
content: You should read Jim Williams' comments about probing techniques in app note 47.https://www.analog.com/media/en/technical-documentation/application-notes/an47fa.pdfJim was one of the true greats in analog design and his application notes are fantastic.

author: Infraviolet
author_rank: Super Contributor
timestamp: June 16, 2023, 06:52:23 pm
content: If this rippling is problematic in some application, or you fear that the highest point on the ripple could be a large enough voltage to threaten to shorten the life of anything sensitive wired on to it... have a look at some simple low-pass filter circuits to somewhat slow the rise time of that edge.

author: tggzzz
author_rank: Super Contributor
timestamp: June 16, 2023, 09:15:04 pm
content: Quote from: Infraviolet on June 16, 2023, 06:52:23 pmMany digital logic outputs have configurable "strength" parameters which limit the output current. The first benefit is to reduce ground bounce (i.e. the voltage induced across the ICs internal lead inductance). The second benefit is to increase the transition time, thus reducing EMI.Beyond that, the best technique is to use appropriate interconnection practices, as described in many textbooks and application notes.

author: james_s
author_rank: Super Contributor
timestamp: June 16, 2023, 10:56:08 pm
content: Quote from: tggzzz on June 16, 2023, 09:15:04 pmI don't think the atmega used in the Arduino does though. In this case I suspect the ringing is largely due to probing technique though and is not actually there otherwise. That said, arduinos are often rather carlessly connected to peripheral devices to the point that sometimes it's remarkable that the circuits ever work at all and yet they usually do.

author: tggzzz
author_rank: Super Contributor
timestamp: June 16, 2023, 11:22:29 pm
content: Quote from: james_s on June 16, 2023, 10:56:08 pmQuite likely, definitely, and rather than "ever work at all", I'd encourage the OP to think of such circuits as "working well enough that you can persuade yourself the intermittent failures aren't really happening".The OP isn't falling into the lazy way of not-thinking, though, which is an excellent start

author: LukeW
author_rank: Frequent Contributor
timestamp: June 18, 2023, 03:49:25 am
content: You really want a reliable, consistent connection between the thing that you're trying to measure, and the scope. Ideally, hands-free and with as low stray inductance as possible, and without mechanical intermittency.I would use a female SMA connector with two very short (<10mm) pigtails of wire soldered onto it, and soldered onto the DUT. (Just tacked in place is fine, as long as it's a reliable solder joint.) Solder it onto the pads on the bottom of your Arduino board, in this case.Then I would use a SMA male-to-male cable and a SMA-to-BNC adapter to connect it to the scope.You now have a completely consistent, reliable connection to the scope, you don't need to hold it, with low stray inductance, with no mechanical intermittency.Much easier way of working IMHO, even if it seems like more work at first.Those "breadboard jumper" wires with the round pins and the moulded black rubber part are the worst. I suggest throwing them away. They're even more crap than usual "DuPont" jumper wires.(Relatively high resistance, very thin core, low quality soldering, relatively high inductance, intermittent connections.)

author: BillyO
author_rank: Super Contributor
timestamp: June 18, 2023, 04:45:11 am
content: Your ground connection is way too long for the rise time being measured. Try to reduce it to about 1 cm. Your Siglent probes would have come with little spring grounds. Use one of those.

author: David Hess
author_rank: Super Contributor
timestamp: June 18, 2023, 12:51:42 pm
content: One method I like is to use a probe tip to BNC adapter to attach a short RG-174 pigtail which can be soldered into place. This is more useful with switching power supplies where the coaxial pigtail reduces interference from magnetic flux. The disadvantage is added capacitance but length is seldom a problem below 100 MHz.

author: james_s
author_rank: Super Contributor
timestamp: June 19, 2023, 06:38:55 pm
content: Jim Williams discusses all these techniques in the app note I referenced.For poking around an arduino circuit it's probably sufficient to just use the shortest possible ground on the probe tip, but various other techniques have their place.

author: tggzzz
author_rank: Super Contributor
timestamp: June 19, 2023, 10:51:09 pm
content: Quote from: james_s on June 19, 2023, 06:38:55 pmFor too many decades I've liked HP10020 probes: 1.5GHz with a tip capacitance of <0.7pF, interchangeable 1:1, 5:1, 10:1, 20:1, 100:1 resistive divider tips.They are difficult to find,but you can make your own(unlike mis-named passive "high impedance" probes).

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 19, 2023, 11:04:29 pm
content: I'm sure all these comments are well meant, and have their place, but for probing around in "arduino circuits" or on breadboards, just use the covenience of the crocodile clamp ground lead and use the 20MHz internal filter of the scope. That's plenty plus good for most measurements, but of course it does not hurt to get to know more "advanced" probing techniques and learn about when they are useful to apply.

author: David Hess
author_rank: Super Contributor
timestamp: June 20, 2023, 01:00:35 am
content: Quote from: Doctorandus_P on June 19, 2023, 11:04:29 pmThe danger with such a low bandwidth is that it can conceal double clocking in most modern logic.

author: tggzzz
author_rank: Super Contributor
timestamp: June 20, 2023, 07:37:24 am
content: Quote from: Doctorandus_P on June 19, 2023, 11:04:29 pmThat's the equivalent of looking at the world through rose-tinted spectacles or Zaphod Beeblebrox's sunglasses .If you filter out problematic behaviour, then of course you won't see problems. Digital hardware inputs interpret the analogue waveforms to infer digital signals, and the nanoseconds can matter - e.g. dynamic hazard glitches, or hold times, or ground bounce, or random interference. Having said that, orange sunglasses do allow you to see more of a cloud's structure, and hence help find thermals and avoid being forced to find a suitable field

author: james_s
author_rank: Super Contributor
timestamp: June 22, 2023, 08:56:51 pm
content: But you already know there's going to be problematic behavior, in most cases that isn't what's actually causing the problem though. When I've worked on projects like this what I'm usually interested in seeing is whether my code is doing what I expect it to be doing with the IO, I'll concern myself with signal integrity after I've confirmed that the code is behaving as expected and the thing is still not working. I've found that most devices are remarkably robust and can work properly with all sorts of noise and garbage. It's just toy hobby projects, not avionics or life support hardware.