top of page

Raspberry Pi Based Oscilloscope


(Only for visual representation)


This project can be of great use to an electrical/electronics engineer as it shows how to make one of the most important instruments which will be of use throughout: an OSCILLOSCOPE.

The oscilloscope is an electronic test instrument that allows the visualization and observation of varying signal voltages, usually as a two dimensional plot with one or more signals plotted against time. Today’s project will seek to replicate the signal visualization capabilities of the oscilloscope using the Raspberry Pi and an analog to digital converter module.


PROJECT FLOW:

PROJECT REQUIREMENTS:

Hardware requirements


  1. Raspberry pi 2 (or any other model)

  2. 8 or 16GB SD Card

  3. LAN/Ethernet Cable

  4. Power Supply or USB cable

  5. ADS1115 ADC

  6. LDR (Optional as its meant for test)

  7. 10k or 1k resistor

  8. Jumper wires

  9. Breadboard

  10. Monitor or any other way of seeing the pi’s Desktop(VNC inclusive)


Software Requirements

The software requirements for this project are basically the python modules (matplotlib and drawnow) that will be used for data visualization and the Adafruit module for interfacing with the ADS1115 ADC chip.

This tutorial will be using the Raspberry Pi stretch OS.


P.S. If you have issues with any of this, there are tons of Raspberry Pi Tutorials on this website that can help.


CIRCUIT DIAGRAM:


ADS1115 and Raspberry Pi Connections:

VDD – 3.3v

GND – GND

SDA – SDA

SCL – SCL


Install Dependencies for Raspberry Pi Oscilloscope:

1. Enable Raspberry Pi I2C interface

2. Update the Raspberry pi

3. Install the Adafruit ADS1115 library for ADC

4. Test the library and 12C communication.

5. Install Matplotlib

6. Install the Drawnow python module


For detailed explanation on how to do this, visit: https://circuitdigest.com/microcontroller-projects/raspberry-pi-based-oscilloscope


Python Code for Raspberry Pi Oscilloscope:


import time import matplotlib.pyplot as plt #import numpy from drawnow import * # Import the ADS1x15 module. import Adafruit_ADS1x15 # Create an ADS1115 ADC (16-bit) instance. adc = Adafruit_ADS1x15.ADS1115()

GAIN = 1 val = [ ] cnt = 0 plt.ion() # Start continuous ADC conversions on channel 0 using the previous gain value. adc.start_adc(0, gain=GAIN) print('Reading ADS1x15 channel 0') #create the figure function def makeFig():     plt.ylim(-5000,5000)     plt.title('Osciloscope')     plt.grid(True)     plt.ylabel('ADC outputs')     plt.plot(val, 'ro-', label='Channel 0')     plt.legend(loc='lower right') while (True):     # Read the last ADC conversion value and print it out.     value = adc.get_last_result()     print('Channel 0: {0}'.format(value))     # Sleep for half a second.     time.sleep(0.5)     val.append(int(value))     drawnow(makeFig)     plt.pause(.000001)     cnt = cnt+1     if(cnt>50):         val.pop(0)


To fully test your oscilloscope, you can connect an analog device like a potentiometer to a channel on the ADC and you should see the data change with each turn of the potentiometer. Or you can input Sine wave or square wave to test the output.


For a detailed version and more such projects, visit: https://circuitdigest.com/microcontroller-projects/raspberry-pi-based-oscilloscope


Taken from: circuitdigest

370 views0 comments

Recent Posts

See All
bottom of page