Home > Projects > Metering – Instrument Projects > Quasi real-time oscilloscope using Arduino

Quasi real-time oscilloscope using Arduino

Summary of Quasi real-time oscilloscope using Arduino


This article details the evolution of a low-cost, four-channel oscilloscope built on an Arduino Leonardo board. Leveraging the ATmega32U4's internal PGA and ADC, the design eliminates external operational amplifiers, allowing for rapid prototyping. The project includes three software versions, progressively adding precise timing controls via TIMER1, multichannel sampling capabilities with automatic resolution adjustment, and optimized sampling logic to fix channel mapping errors.

Parts used in the Quasi real-time oscilloscope using Arduino:

  • Arduino Leonardo board (ATMega32U4)
  • LM317 voltage regulator
  • 5 resistors
  • 5 capacitors
  • Prototype board

Recently I was reviewing one of my oldest project, and decided to “refresh” previous design by taking full advantage of the new arduino Leonardo board.  Based on AtMega32U4, which include PGA (programmable gain amplifier), oscilloscope’s  analog front end doesn’t require external OPA this time, end could be build in 1-2 hours on prototype board, using 5 resistors, 5 capacitors and one IC. Short specification:

Arduino Quasi real-time oscilloscope

  • Four channels.
  • Switchable gain settings 1x, 10x, 40x, 200x.

As you can see on drawings above, inputs are AC coupled with caps, and biased with 1.25V generated by LM317. Connector for other two inputs not installed yet.

Software.

Project keeps almost same  structure of commands (CLI – command line interface) as its ancestor, with only two new for channel and gain selection. Read comments, it explains how to use them. One more things, I removed “r” – re-print option from the list of available commands.

Have fun!.

Link to arduino Leonardo sketch:  Oscilloscope_Leonardo.

********************************************* Version 4*********************************************

Well, even posted above sketch has low complexity, and its good for beginning, nevertheless it’s quite limited as measuring device. The most important feature for oscilloscope, except V/div,  is T/div, or timing, that has to be as much precise as possible.   This is why “standard” timing options based on TIMER1 were add to next version of software. There are 9 time settings Time/div (10 samples):

50ms, 20ms, 10ms, 5ms, 2ms, 1ms, 500us, 200us, 100usec

corresponding to

200Hz, 500Hz, 1kHz, 2kHz, 5kHz, 10kHz, 20kHz, 50kHz, 100kHz

sampling rate. You can choose any of of this in the same manner, entering a digit 1-9 and letter d (display). Zero would skip capture, and just do whatever next letter request. Basically, 0 should be used to print channels data from memory. Combination: 9d0i – capture at 100 kHz rate, print chart and info-table,
4c2g7d – select 4-th channel, set gain to 10, select 20 kHz sampling rate and display.

I also add multichannel sampling capability. Commands 2m, 3m or 4m would configure oscilloscope for 2, 3 or 4 channels simultaneously capturing input waveform.   As arduino has only 1 ADC, switching in multichannel mode would reduce sampling rate proportionally to number of channels, and this changes would be reflected in right top corner of the display. What more, arduino would automatically change vertical resolution per channel, to fit all 2 – 4 charts on one screen!

Known caveats:

  • Sampling rate 9, or 100 usec per division (10 usec per sample) could not be selected in multichannel mode, should be in use for single channel only (1m, 1c – 2c – 3c – 4c).
  • There is a “shift” in channel number, signal  presented at input 1 would show up on screen 2, and so on. This happens on time settings 7 (occasionally), 8 and 9 in 4x multichannel mode due delay in MUX registers switching. Shouldn’t be an issue for 2x channel mode, or when you have an “overview” of the signals shape in single channel mode (1m) before switching to 4x, so you would know what to expect at each input port.

Link to arduino Leonardo sketch:  Oscilloscope_LeonardoV4

********************************************* Version 5*********************************************

New updated version. I was thinking how to improve simplest ever oscilloscope, and have made some structural changes in the code, mostly related to sampling in multichannel mode.

Arduino Quasi real-time oscilloscope schematic

First of all, instead of “delay” 2 microseconds, that was used to give a multiplexer (and PGA amplifier) time to “settle” on new channel, I decided not to waste a time (that may be priceless in real-time application), rather start new conversion, than track samples based on the “history” of MUX settings, and store new sample in corresponding two dimensional array box. Now MUX and PGA would have more time,  and consequently I could reduce ADC pre-selector’s clock to get better readings. It solved all the problems with wrong association port number and picture on the screen.

Major Components in Project
Arduino

 

For more detail: Quasi real-time oscilloscope using Arduino

Quick Solutions to Questions related to Quasi real-time oscilloscope using Arduino:

  • How many channels does the oscilloscope support?
    The device supports four channels.
  • Can the gain settings be switched?
    Yes, the gain is switchable between 1x, 10x, 40x, and 200x.
  • What components are required for the analog front end?
    The design uses five resistors, five capacitors, one IC, and an LM317 to generate a 1.25V bias.
  • How do I select specific time divisions in Version 4?
    Enter a digit from 1 to 9 followed by the letter d to choose from nine available time settings.
  • Does multichannel mode affect the sampling rate?
    Yes, switching to multichannel mode reduces the sampling rate proportionally to the number of active channels.
  • Why was the delay removed in Version 5?
    The delay was removed to allow the multiplexer and PGA more time to settle while starting new conversions immediately.
  • Is it possible to capture all four channels simultaneously?
    Yes, commands 2m, 3m, or 4m configure the scope for simultaneous multi-channel capturing.
  • Are there limitations on sampling rates in multichannel mode?
    Yes, the fastest sampling rate of 100 microseconds per division cannot be selected in multichannel mode.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top