Learning to use an oscilloscope can be daunting!
But... that's okay because I'm here to help!
My name is James and I am the Bald Engineer.
In this AddOhms electronic tutorial,
we'll use an Arduino Uno to learn how to use a scope.
Let's go measure!
(I hand write these! Let me know in the comments if they are helpful...)
If you find these videos helpful,
please consider supporting AddOhms and the bald engineer
on patreon.
Before we get started I need to cover a couple of things:
First, I want to say a big thank you to my friends at
Rhode and Schwarz for sending me this RTM3004.
Now... they did reject my first
idea which was a video called:
"How to sell a new scope on eBay!"
So, I decided to make this video instead.
With that said you do not need to have this specific scope for these measurements.
In fact, you can even use a USB-based scope for most of these tips.
Which brings me to my next point:
These tips and measurements only work on digital scopes.
I am NOT going to cover the older analog types.
And last we need to talk about how to start off in a known state.
So let's go talk about that next.
The RTM 3004 has both a "preset and "auto set."
Preset puts the scope into a known "default setup."
While, "auto set" will check all the signals and auto scale each of the inputs.
On my older Rigol, however,
it only has an "auto" button.
Which does both the preset and Auto-Scale at the same time.
Just make sure you reset your scope before each measurement
Ready to get started?
Let's kick off with a common voltage measurement.
In this case, we will measure the noise of the 5 volt pin on Uno.
Now, some probes can just stick into the hole. but...
for mine I'm going to clip on to these upside-down header pins.
For ground I stuck in this really long
pin into one of the sockets.
Looking at the scope, make sure that your volts per division is set to 5 volts.
This setting determines how much signal is shown on screen.
Let me show you how we can zoom in by going to 2 volts per division.
And we can keep going...
Oh no!!! The signal went off the screen!
Whatever will we do!
Eh! it's actually no big deal. We'll just turn the offset knob down...
...to bring it back on screen.
Now if you keep zooming-in, in this way,
eventually the signal won't come back.
So in that case we have to think about what we're doing with our measurement.
When we measure the voltage rail we are
usually only interested in the noise.
So using the scope we can remove the DC offset from the DC signal.
Going into the channel menu, we can see that there is an option for coupling.
It can either be AC or DC.
Changing to AC coupling puts a series capacitor between the BNC and the analog-to-digital converter.
That capacitor removes the DC offset leaving only the AC component.
Check this out
I'm going to hit AC coupling and then I'm going press the offset knob to zero out the channel.
Now when I turn the volts per division knob , or scale knob,
only the noise gets larger.
Now it'd be nice if we had some automated measurements to measure this...
So let's go talk about how to make measurements next.
But first, I want to change our setup on the Arduino.
You might notice on my screen the grid is very dim.
In the old days we would make measurements by counting the actual grids.
Today I almost always use automatic measurements.
To show how measurements work we're going to change our signal.
We're going to use analogWrite() and pulse width modulation, or PWM, on the Arduino.
First we need a variable for our PWM signal and then we'll set it to OUTPUT.
Real quick: you don't actually need to use pinmode() with analog write.
because analogWrite() will change the pin to OUTPUT.
However I like putting all of my pinmode()s in setup(), so that I can glance at the code...
... to know which pins are being used (and how!)
The last thing we will add is an analogWrite() with a value of 128,
and that should give us a 50% duty cycle.
While that uploads, the way I'm connecting is using the same trick before with upside-down header pins connect it to pin 3.
This time I am going to hit PRESET to put the scope into a default setup,
and then let AUTOSET find the signal for us .
Okay, how measurements get set up will vary depending on the scope.
Let's see how the RTM 3000 does it.
I'll hit measure...
.. to get the measure window,
and then go look at type.
Here we can see that they're grouped by : basic, vertical, horizontal, or count.
It's pretty common for scopes to group measurements by vertical and horizontal, so let's talk about those.
Vertical means vertically on the screen or, more commonly voltage,
and so I can remember that because Vertical and Voltage both start with the letter "V."
We look at horizontal, these are measurements that go across the screen or in time.
Now for this setup I want three measurements.
First I want an amplitude measurement,
and then second I would like to see the frequency of our PWM signal,
and then third I want duty cycle.
Okay, now we can see that the signal has a 5 volt amplitude.
frequency of 490 Hertz, and a duty cycle of 50%.
Even though it's called "analog write,"
there are only two voltages 0 & 5.
The "analog" part comes from the amount of time that the signal is ON or OFF.
Since the duty cycle is 50%, the signal is only on for about half the time.
This is how we can control the speed of a motor or the brightness of an LED.
To demonstrate, let me just change the value that we used to 64.
Okay, 5 volts (and) 490 Hertz -- so those two measurements are the same as before...
...but our duty cycle is 25%
So, analogWrite() is only changing the amount of time that the signal is on.
Now, let's do something a little bit fancy
It's called **Infinite persistence** and it's a display mode!
First, on the Arduino code, I'm going to move the analogWrite() into a for()-loop.
I'm doing this so that we can sweep through all of the values from 0 to 255.
On the scope we can see that the waveform is now kind of like dancing across the screen.
So let's go into display...
... and there's an option called "persistence."
Right now it's set to OFF, which is a little bit of a "lie," or, it's not entirely true.
Modern digital scopes will try to fade the waveform to give it more of a phosphor or CRT look
but, that's another story [for another video]!
I'm going to change it to Infinite, or forever,
which means the signal will stay drawn on screen...
... until I hit CLEAR.
So in this mode, the signal draws in over time.
This is very helpful when you're looking for say... a glitch!
You can see: how often does the glitch occur.
Here we can see that the HIGH and LOW of the waveform happens very often,
because its brightest on the screen.
While the transition area happens rarely, or not as often relative to the rest of the waveform.
Okay, you know I'm starting to think we're getting pretty good with the scope!
What can we do next?
I know! Let's go and talk about triggers.
Using the Uno's RESET circuit, we will learn when to use the Auto and Normal trigger or sweep modes.
I talked about how the reset circuit works in the Pyramiduno turn-on episode,
but basically,
when the serial signal RTS or DTR goes low,
it causes a short glitch that resets the 328p.
The key is a 100 nano farad capacitor.
On the scope, I'm going to use two channels to connect to the reset capacitor.
I know this is the reset capacitor because it's right by the reset enable pads.
I'm going to place channel 1 on RTS, or DTR,
and I'm gonna place channel 3 on the reset signal.
Now you've probably noticed I ran out of hands
so I'm gonna try to hold the probes like this while I go and open the serial monitor.
Wow that was quick did you even notice that the signal flashed on screen?!
Well that sort of makes for a lousy measurement! Right?
The reason it flashed quickly is because the scope is in Auto trigger mode.
That means if it does not see the trigger condition after a set period of time,
it just dumps whatever is in its acquisition buffer to the screen.
This mode is really useful when you're poking around a circuit because the screen constantly updates.
But, in this case we want a stable display for an event that rarely occurs.
So we're going to tell the scope only update the screen when the trigger condition is met.
What is that trigger condition? Let's take a look.
It is watching Channel 1 for a Falling Edge that crosses through 2.8 volts.
The change we'll make is hitting Auto, to make Normal.
At this point, the scope stops updating... ...but that's okay! It's supposed to do that.
This time when I reopen the serial monitor, we get a stable display.
But we can't really see all that much at this point.
The problem is this isn't really showing us a whole lot about the signals.
We can see that they're going active.
So I'm just gonna play with the time-base a little bit,
to make a better display.
Remember if you're using a USB based scope, there are software controls that
can do the same things that I'm doing with the front panel.
From previous measurements, I know I need at least three milliseconds on the screen.
We define the amount of time that gets captured, by changing the time-per-division.
This scope has 12 horizontal divisions.
Which means 12 times 500 microseconds is 6 milliseconds.
Before we move on let me review a few of the settings that I did on the scope.
We already know about the normal trigger mode, I set the time base to 500 microseconds per division,
and I added a delay, or offset, of 2 milliseconds to move our event closer to the left side of the screen.
Now I'm going to re-probe the capacitor, run the scope and,
then open the serial monitor.
Okay, now we get a much more interesting display.
The waveform we get is the glitch that causes reset!
The RTS signal--the signal in yellow--goes LOW as well as the Reset signal. which is on the other side of the capacitor.
It drops to 0 volts and then immediately begins to start charging back up.
By the way, this charging curve is typical for a charging capacitor.
Now I'm going to use cursors to measure how long reset lasts.
The first thing we need to do is look at the ATmega328p datasheet.
For the reset signal it says anything below 0.5 volts is a LOW and anything above 4.5 volts is a HIGH.
These levels only apply to reset. They are not the same levels that GPIO pins use.
I'm going to set my horizontal cursors to 0.5 and 4.5.
Now, I'm going to move the vertical cursors to intersect each of those.
First the LOW...
... then the HIGH.
So, using the cursors, we can see that the reset condition lasts for about two milliseconds.
Now, if you only had one channel, or for some reason one probe...
... you could have still done this measurement by using a reference waveform.
So let's go talk about that next.
A rule for test equipment is that when you add a probe, you change the circuit.
To see how that works, we're going use the Arduino's on-board 16 MHz oscillator,
and watch how it changes by adding a scope probe.
Now, for this measurement, you will need a scope with at least 20 MHz of bandwidth,
and ideally you need 50 MHz (megahertz).
The Uno uses a ceramic resonator for its clock, which is this little IC.
Because this is a higher frequency measurement I am using this ground pin to make my connection.
It provides a shorter path between ground and signal.
For the ground, I'm using a via on the ground plane and then
touch to the termination resistor right, next to the oscillator.
Stopping the scope, I want to save a copy of the waveform so that I can compare it later
Now some scopes put a reference function inside of their math functions.
On the RTM 3000, there is a dedicated Reference menu.
From here we can copy Source 1 into R1.
Now, if I run the scope again, the live waveform is the yellow trace,
and the white waveform is the saved trace.
I have a second probe connected to Channel 3.
However, I am not going to display channel 3 on the screen.
Instead, I am probing the same probe point with the probe tip.
And then, I'm going to say probe one more time.
As the second probe comes in contact notice how the signal changes.
The probes are loading down the signal.
In this case, the loading is very small .
However it is important to remember that whenever you attach a probe,
whether it's like a passive probe, or a DMM test lead, you are changing the circuit
In another video, I'll show some proper scope probing techniques,
why you need them and the different types of probes.
Now is a good time to ask questions about probes in the comments
Ok, let's move on to our last measurement.
It is just a little bit more advanced than the others that we've done so far
On this last measurement your scope does need to have the ability to trigger and decode serial traffic.
If not that's okay, just follow along.
On the Arduino, I'm going to use a Serial.print() to send the word "Hello" inside of a loop.
Now even though serial, or UART, has a transmit (TX) and a receive (RX),
I only need to connect to one of them.
So on the Arduino, I will connect to pin 1, which is the transmit pin.
Setting up the trigger will vary by scope.
On the Rohde & Schwarz, we start by going into the protocol menu...
and changing the bus type to UART.
Then we can go into configuration and set up our channels.
Now remember a second ago I said that I'm only connected to TX on the Arduino,
well on the Rohde, I'm only going to configure RX.
But that's okay because in serial TX and RX is arbitrary.
The reason I'm using RX is because this scope only triggers on the RX channel.
So channel 1 I'll ask it to find the threshold,
and then we can go into the trigger setup and,
here I'm going to ask it to trigger on a pattern,
and I want it to trigger on 48 HEX (aka 0x48).
Why 48 HEX? Well turns out that is the ASCII value for capital 'H'.
So let me change this back to normal
and stop,
then zoom in.
What I wanted to show here: if we look at the serial pattern for this character,
we see the Start bit; then we see our data--which is capital H--and then
we see a Stop bit.
Now if we were using parity we would also see that bit in here as well.
If I Zoom out... then we can see the entire sequence.
Looking at hex values is... okay. It's nice that we can see the whole sequence.
But it would be really nice if we could read it! Which we can!
So I'm going go back into the protocol menu, and then I'm going to display setup,
and them I'm going to select decimal. Okay that's nice but really what I want to see is ASCII.
With ASCII, not only can we see all the letters H-E-L-L-O.
but we can also see the inline carriage return and line feed.
Having UART, decode, and trigger is nice. But I find it really useful for I2C and SPI.
If you get a chance play around with something like an OLED display. It is really cool to see...
the command and data being sent across the I2C bus.
Okay so in this video we use the Arduino to learn how to use a scope.
We looked at voltage measurements, time-based controls, basic triggers,
automated measurements, reference waveforms and finally serial triggering.
Here's the thing that's just the tip of the iceberg.
We didn't get into different display modes like X-Y,
or using FFTs,
or using a built in function generator,
or math functions,
or a whole bunch of other cool stuff you can do on a scope.
Before closing I would like to thank my patrons: J Mike; Mike K; Joseph V; and Paul H.
If you'd like to help support this work please consider joining that list at
patreon.com/baldengineer.
If you would like to learn more stuff on digital scopes or other electronics tutorials let me know in the comments.
Also make sure you are subscribed to know when new videos on scopes get
released check the description for a couple of links. One will take you to our
AddOhms discord and another takes you to the show notes.
There I'll provide links related to this episode.
My name is James, and I am the bald engineer.
You can find us around the internets using the keyword AddOhms.
Remember if your circuit isn't working... grab a scope to see if you need to AddOhms. :)