6. A Poor-Mans Oscilloscope

Background

The AVR’s ADC hardware peripheral will be used to measure the voltage generated from an LDR. It will be displayed on a computer, thereby creating a poor-mans oscilloscope.

Who needs the Arduino Serial Monitor? Not me!

The Theory

We’ll configure the ADC to run in free-running mode. We enable this by enabling auto-triggering mode. When an ADC conversion completes, this is the trigger to begin a new ADC conversion. This repeats infinitely.

Hardware Connections

8 LED’s with current-limiting resistors connected on PORTB.

A voltage divider consisting of LDR on upper leg and a 10k on the bottom leg. The halfway point connects to PC0.

The Software

The project consists of two files. The complete source code is available in the GitHub repository.

  1. main.c

We configure ADC for free-running mode, self-triggering. Results are transmitted via UART.

2. serial_scope.py reads the serial port and plots the values

    Expanding on Poor-Mans Oscilloscope

    Let’s add some X-Factor to the project, both of these introduce a visual upgrade made possible due to matplotlib. 2 extensions of Poor-Mans Oscilloscope is available:

    1. serial_scope_timestamped.py adds timestamps. The graph is continuously refreshed as new readings arrive over serial.
    2. serial_scope_to_csv.py writes the values to a .csv in case you would like to interpret the data and store it.
    serial_scope_timestamped.py adds a timestamp

    The Showcase