Oscilloscope

Build, use, and understand your own oscilloscope

OSCAR and OSCARET grew out of a simple idea: build a computer-controlled oscilloscope using simple hardware and open-source software.

The goal is not just to display a signal, but to experiment with data acquisition, analog-to-digital conversion, triggering, digital signal processing, spectral analysis, and effective resolution.

Arduino UNO Tcl/Tk Signal acquisition DHT CA3306 DSO183

The project is part of the work behind the book Arduino, Tcl/Tk osciloscopio, although both the source code and the executable applications are available free of charge.

Project page View source code View the book

Different themes


OSCAR: an Arduino UNO and two wires

The easiest way to get started is probably also the most surprising.

All you need is:

  • an Arduino UNO
  • a USB cable to connect it to your computer
  • two wires to connect the signal you want to measure

That’s it.

The ATmega328P’s built-in ADC digitizes the signal, while the computer displays and analyzes it.

In this way, an Arduino UNO can become a small digital oscilloscope controlled from your PC.

The key idea

Arduino acquires the samples, while the computer provides the display, graphical interface, and much of the processing.

This keeps the hardware extremely simple and moves many of the features into software.

What can you do with it?

Among other things, you can:

  • display signals in real time
  • measure voltages
  • measure frequency and period
  • use different triggering modes
  • analyze the acquired samples
  • explore a signal’s frequency spectrum
  • export captures for later analysis

And above all, you can experiment.

OSCAR is not intended to replace a professional oscilloscope. Its purpose is to show how much can be achieved with extremely simple hardware and to help you understand what actually happens inside a digital measurement instrument.

An important limitation

If you use an Arduino UNO directly, the signals must remain approximately within this range:

$$ 0\text{ V} \leq V_{in} \leq 5\text{ V} $$

Arduino is not designed to accept negative voltages or voltages higher than its supply voltage directly.

This means you must be careful about which signals you connect.

Even with that limitation, it can be a surprisingly useful tool for digital signals, sensors, small electronic circuits, PWM, appropriately conditioned low-level audio, and many laboratory experiments.

If you don’t have a development environment set up, I’ve also provided an executable so you can try it out.

Genuine Arduino UNO boards and clones

The application is designed to work with a genuine Arduino UNO.

You can also use a clone, but you’ll need to specify its serial port in the serial_port.txt file. For example: COM8.

I recommend using a genuine Arduino UNO because, in my experience, clones can have serial communication issues and may even stop sending data to the application. I’ve never encountered that problem with a genuine board.

Taking it a step further

If you want to go further and measure AC/DC signals at different amplitudes, here are some ideas for expanding the hardware:

Voltage divider voltage divider

Gain variable gain

Buffer amplifier buffer amplifier


Not a black box

One of the project’s main strengths is that you can study how it works.

OSCAR is much more than a program that draws a waveform on a screen.

It lets you experiment with topics such as:

Sampling rate ADC Quantization Triggering Buffers Serial communication Window functions Noise SINAD ENOB

You can also explore digital signal processing and spectral transforms.

That makes it both an instrument and a learning platform.

You can modify the code, run tests, make mistakes, and see what happens.

OSCAR in action

OSCAR running at 150 ksps

OSCAR using new spectral windows


What if you want something closer to a conventional oscilloscope?

That’s where OSCARET comes in.

The philosophy remains the same: use the computer to provide acquisition, visualization, and processing capabilities normally associated with far more complex instruments.

The next step, however, is to add a proper oscilloscope analog front end and an external ADC such as the CA3306.

OSCARET

OSCARET builds on OSCAR’s philosophy but expands the hardware to behave much more like a benchtop oscilloscope.

voltage divider

Using a DSO183 as an analog front end

DSO183 DSO183

The DSO183 is a small, inexpensive standalone oscilloscope.

It can already display signals on its own, but its hardware can also serve as a starting point for something more interesting.

By connecting it to the system developed in this project, you can turn it into a kind of computer-controlled benchtop oscilloscope.

The advantage is that you can combine its input electronics with software capabilities that the original DSO183 lacks but OSCAR and OSCARET provide.

A capture is no longer just a curve displayed for a few seconds on a small screen.

It becomes a dataset that you can save, analyze, compare, or process later.

OSCARET sampling at 5 MS/s

OSCARET sampling at 5 MS/s


Spectral analysis

One feature I find particularly interesting is the ability to observe a signal in both the time domain and the frequency domain.

An oscilloscope lets you study how voltage changes over time.

Spectral analysis answers a different question:

What frequencies make up this signal?

This lets you experiment with:

  • sine waves
  • square waves
  • harmonics
  • noise
  • PWM
  • distortion
  • filters
  • aliasing

The project uses a Discrete Hartley Transform (DHT) for this analysis.

It’s not simply a matter of adding an attractive graph to the application. Implementing these features helps you understand many of the concepts behind a digital spectrum analyzer.

Spectral analysis of a square wave Spectral analysis of a square wave


Your data, your choice: CSV export

Acquired samples can be saved as CSV files.

This allows you to analyze them later with virtually any tool:

LibreOffice Calc Excel Python GNU Octave MATLAB R

And, of course, with your own programs too.

This is particularly useful for teaching and experimentation: you can capture a signal, save the samples, and then study exactly the same data without having to repeat the experiment.

CSV in Excel CSV in Excel


Free and open-source software

All the code developed for OSCAR and OSCARET is available free of charge.

The idea is that you can:

  • use it
  • study it
  • modify it
  • experiment with it
  • build your own version

An executable application is also provided, so you don’t need to know Tcl/Tk or set up a development environment just to try the oscilloscope.

If you’d like to dive deeper, you can always download the source code and see how it’s built.


The book

Book Book

This entire project also provided the foundation for my book, Arduino, Tcl/Tk osciloscopio.

If you find the project useful and would like to support its development, one way to do so is by buying the book.

And if you want to understand how everything was built, reproduce the experiments, and follow the journey from the first samples acquired with an Arduino to a complete acquisition and analysis system, you’ll probably enjoy the book as well.

The book is not simply an installation manual for OSCAR.

It gradually explains many of the design decisions, experiments, mistakes, and solutions involved in trying to build a digital oscilloscope from scratch.

Along the way, it covers topics such as:

  • signal acquisition
  • Arduino programming
  • how the ADC works
  • increasing the sampling rate
  • communication between the microcontroller and the computer
  • building a graphical interface with Tcl/Tk
  • waveform display
  • triggering
  • digital signal processing
  • spectral analysis
  • window functions
  • noise and effective resolution
  • SINAD and ENOB
  • the real limitations of the hardware

I also try to explain why it works, where its limits lie, and what happens when we push simple hardware beyond what it was originally designed to do.

View the book

One Arduino, two wires, and a question

One of my favorite things about this project is how simply it can begin:

The starting point

Arduino UNO + computer + two wires.

From there, questions start to arise:

  • How can I sample faster?
  • Why does the waveform change when I increase the frequency?
  • What does ADC resolution really mean?
  • Why do frequencies appear that weren’t present in the original signal?
  • How much information am I losing?
  • Can I calculate the spectrum?
  • Can I improve the hardware?
  • Can I turn it into a real instrument?

OSCAR and OSCARET are, to a large extent, the result of trying to answer those questions.

And there are still plenty more to explore.


More information

Article on Hykrion

About the names

I thought the names were fun because:

  • OSCAR: OSCiloscopio ARduino (Arduino oscilloscope)
  • OSCARET: OSCiloscopio ARduino ExTendido (extended Arduino oscilloscope)

And also because I have two friends with those names :-P


Contact

If you have any suggestions or questions, you can reach me at:

tdso112a at hykrion com