กลับไปหน้ารวมไฟล์
diy-arduino-oscilloscope-56d4c0.md

A very basic and easy to make Arduino PC oscilloscope.

Features:

  • 50K samples/second(actually it can go up to 110K but the signal will become noisy)
  • Auto trigger
  • Frequency counter
  • Reasonably accurate voltage readings (depending on the accuracy of the resistors used for the voltage dividers)
  • Optional: selectable voltage range: 5V, 6.6V, 10V, 20V

You'll Need:

  • An Arduino Leonardo or Arduino Micro
  • 2 crocodile clamps
  • a 0.1µF capacitor (optional)
  • a 5.1V zener diode (optional)
  • a pc with Processing

For the voltage dividers (optional, if you want to measure than 5V or want selectable range):

  • 2 two-pole dual throw switches
  • two 3K resistors
  • two 1.5K resistors
  • one 1K resistor
  • a small perfboard or breadboard

If you only need to measure op to 5V, you can skip the voltage dividers and connect the probes directly to GND and A1. You'll have to modify the code a bit:

In the Arduino code, replace:

ADMUX =  B00000000;         // select external reference and port 5 (A0)

with:

ADMUX =  B01000000;         // select internal reference (Vcc - 5V) and port 5 (A0)

In the processing code, replace:

// read switch position & set voltage range boolean switch1=((buffer[writeIndex*2]&(byte)8)==8);                                                  boolean switch2=((buffer[writeIndex*2]&(byte)4)==4); if (!switch1&&!switch2) voltageRange=20; if (!switch1&&switch2) voltageRange=10; if (switch1&&!switch2) voltageRange=6.64; if (switch1&&switch2) voltageRange=5;

with:

voltageRange=5;

🛠️ เจาะลึกเบื้องหลังการทำงาน (Deep Dive / Technical Analysis)

A real digital storage oscilloscope costs $500. The DIY Arduino Oscilloscope requires zero external sensors, zero shields, and zero extra cost. It exploits the raw speed of the ATmega328P's internal Analog-to-Digital Converter (ADC), turning your computer monitor into a diagnostic window showing the invisible flow of electricity.

Maximum Speed Analog Conversion

By default, the analogRead() function in the Arduino IDE is artificially throttled. It is terribly slow.

  1. Direct Register Manipulation (ADC Prescalers): To capture a high-speed audio wave or a PWM motor signal, you must speed up the chip.
  2. You modify the ADCSRA register in C++: ADCSRA = (ADCSRA & 0xf8) | 0x04;
  3. This highly advanced command drops the Prescaler from 128 down to 16. It forces the ADC to sample the voltage of the ping millions of times faster, taking it from 9,000 samples per second up to 76,000 samples per second!
  4. It reads the incoming voltage (e.g., 2.5V) and blasts it over the USB cable instantly.

The GUI Visualizer (Serial Plotter vs. Processing)

Once the high-speed data hits the computer, you have two choices.

  • The Shortcut: Simply open the "Serial Plotter" built into the Arduino IDE (Ctrl+Shift+L). The IDE will natively graph the 0-1023 numbers as a beautiful rolling wave!
  • The Professional Route: You write a custom Processing (Java) application for your PC.
    • The Java app reads the Serial numbers.
    • It draws a gorgeous green grid (just like a real oscilloscope). It scales the numbers from 0-1023 to calculate 0-5.0 Volts.
    • It plots the coordinates smoothly, allowing you to hit "Pause," zoom in, measure the wavelength (Period) of the signal, and diagnose if a capacitor is discharging properly!

Lab Bench Setup

  • Arduino Uno/Nano (No external electronics needed).
  • Computer running the Processing IDE or the native Serial Plotter.
  • (Warning: The Arduino ADC strictly measures 0-5 Volts! If you poke a 12V motor wire with the physical test probe, you will permanently destroy the microcontroller chip instantly! A voltage divider must be used for higher readings).

ข้อมูล Frontmatter ดั้งเดิม

title: "DIY Arduino Oscilloscope"
description: "A digital device that visualizes analog signal."
author: "Ameduino"
category: "Lab Stuff"
tags:
  - "analog"
  - "digital"
  - "diy"
  - "electronics"
  - "arduino"
  - "oscilloscope"
views: 46295
likes: 22
price: 1999
difficulty: "Intermediate"
components:
  - "1x Arduino UNO"
  - "1x Resistor 10k ohm"
tools: []
apps:
  - "1x Arduino IDE"
  - "1x Processing"
downloadableFiles:
  - "https://projects.arduinocontent.cc/373b1a04-4dff-4c6d-aae0-77c8e2c732e3.ino"
  - "https://projects.arduinocontent.cc/e2469e74-752d-4e9e-b0e3-1e54ea96b3ee.pde"
  - "https://projects.arduinocontent.cc/373b1a04-4dff-4c6d-aae0-77c8e2c732e3.ino"
  - "https://projects.arduinocontent.cc/e2469e74-752d-4e9e-b0e3-1e54ea96b3ee.pde"
  - "https://projects.arduinocontent.cc/27e7e0de-3c49-4eed-adb9-a67fc7630394.pde"
documentationLinks: []
passwordHash: "b6fcdfcce76bfbd1fec243c639cc9a9ca9665a9df4ca85dc28e0eace89ab992b"
encryptedPayload: "U2FsdGVkX1//LoudLKEZxnrWb1Io8racraDlh2VlTXX2bmyd4LypbeWHZKnxFutFMEy5ZK9+F+UondOU+3dJF80o8+yfK1GOCwKZQaNqAf68FFFeeYKClxTnYU0db9M+"
seoDescription: "Build a DIY Arduino Oscilloscope to visualize analog signals. A simple digital project for makers and electronics hobbyists."
videoLinks: []
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/diy-arduino-oscilloscope-56d4c0_cover.jpg"
lang: "en"