Personal tools
User menu

Simple USB Oscilloscope

From Francois Louw

Jump to: navigation, search

Back To All Projects Page

Back To Main Page


A Simple/DIY USB Oscilloscope

I have at many times wished that I had an oscilloscope. Given the prices, and shipping costs they are a bit too expensive for just hobbyist jobs. I have looked at USB oscilloscopes that are currently available, but starting at around $50 for one, that has a bit too high claims of sensing speed and accuracy, I realised that it will be a good weekend project to create a DIY USB Oscilloscope.

Note: This is not a high speed high precision replacement for a professional oscilloscope. This is meant for hobbyists who don't want to spend $50+ on something that is worth only $5. If you need professional quality readings, then get a proper oscilloscope.

Simple USB Scope.jpg

It's not pretty but it works!


The goal was to create an Oscilloscope that is good enough for my ECU prototyping. Here are a list of the specifications for what I wanted.

  • USB Interface (NOT a USB-Serial interface, but proper libusb/winusb interface)
  • 10KHZ+ Sampling rate
  • 8bit Accuarcy
  • 2 Channels
  • USB Powered
  • Cheap
  • -15V to +15V input
  • Qt Based Windows interface (Can be ported to Linux/Android)
  • Portable
  • Weekend Project

Ok, well, all of that is good, except, as most projects go, the timeframe of just weekend didn't work, so in the end it took me 5 days to get it sorted. There are still a few minor bugs in the Windows code, and inefficient coding. But it works 100%!

Hardware and Schematic

The following is a bill of materials of what I used:

  • Microchip PIC32MX220F032B
  • 20MHz Crystal
  • USB Cable
  • 3.3V Low Drop Off Regulator
  • 3mm LED
  • ICSP Header
  • 2x 10uF Capacitor
  • 1x 100nF Capacitor
  • 2x 10nF Capacitor
  • 1x 4.7K Resistor
  • 1x 1.0K Resistor
  • 2x 1.8K Resistor
  • 2x 2.5K Resistor
  • 2x 8.2K Resistor
  • Crocodile Clamp Cables
  • Prototyping board (strip board)

Note: Do not use the prototyping bread boards, where you can plug in and out the wires. They are horrible and especially with USB should not be used. They are basically and array of tiny antennae in there that picks up noise the whole time! If you use them and this doesn't work, then don't blame me! When using Strip Board, make sure to cut the tracks as short as possible on the underside to prevent noise.

Here is the schematic.


There are no PCB layout or gerber files, this is simple enough so that anyone can implement their own PCB. Or just use strip board.

The analog input part is a simple offset and divider circuit. It divides the input voltage into a range of 3.3 Volts and offsets it to allow negative input voltages.

The voltage regulator is a simple linear low drop off regulator from ST Microelectronics. Any other regulator can also be used to drop the voltage to 3.3V.


To create the firmware I used MPLabX 1.60 with Microchip XC32 V1.20 Compiler. This was programmed with the ICD3 programmer/debugger. I also used Microchip's Application Library 2013-02-15 USB Stack. The USB mode used is the LibUSB Generic Driver.

NOTE: The USB VID and PID that I use are Microchip VID and an arbitrary chosen PID to differentiate between my other projects. I am not licensed to use that PID. Do not use that PID! I have requested a PID from Microchip, but have not yet received a response.

The firmware is very simple. There are two 3kB circular buffers, each for one channel. The PIC samples the A2D every 4000 cpu ticks. The PIC is running at 50MHz, meaning every tick is 0.02uS and 4000 ticks are 80uS. This gives a sampling rate of 12500 samples per second, or 12.5KHz. Every read gives a value for both channels.

The LED is used as an indicator of when the buffers are full. (Used to show if your computer is reading it too slow)

The main loop is used to send the channel data alternating between channel 1 and 2, emptying the buffers. Timer1 is used to interrupt the main loop, sample the data and add data to the buffer.

USB Packet structure is done first by writing the endpoint 0x81, then the packetsize, then the channel number followed by samples. This results in a max of 61 bytes of data (61 samples) per packet to be sent to the computer.

Windows Software

This part is a bit more difficult. I have used Qt 4.7, with MinGW, and QWT 6.1.0rc3. Qt can be found here with MinGW. QWT for Qt can be found here. Follow the QWT Installation instructions to the letter! Please don't contact me if you cant get QWT to work, search on the internet and on forums.

You also need LibUSB-win32 that you can find here.

After compiling and loading the firmware on the PIC, plug it into the computer and then Windows will search for drivers. Point windows to the drivers found in this projects download section. Or alternatively if you have changed the PID value, then you need to uncompress the LibUSB-win32 and in the bin folder you need to run inf-wizard.exe to create a driver set for your device.

The Qt software links dynamically to the libusb driver. Ensure that the driver is installed successfully and that you have a LibUSB-win32 device in device manager.

When running the Qt Interface application there are two calibration values. The first value is the offset, and the second is the full range divider. To calculate these values, connect the input signal to the ground wire and adjust Cal1 until the graph displays 0. Then connect the input signal to the 3.3V regulated voltage of the PIC. Adjust the Cal2 value unitl it shows 3.3V. Do not use the USB 5V as a reference. The USB voltage is 5.1-5.2V most of the time and not precise 5V. Remember this device uses 5% or 10% resistors, meaning that the calibration is not perfect. Some nonlinear effects may be observed.

The Windows application sets up the display, and then generates a thread to read the USB. This separate thread is necessary because the QWT display routines are blocking and slow. Without the separate thread the USB reading is too slow and the PIC buffers will overflow.

Global circular buffers are used to read the data periodically then display them. The display updates at 10Hz. More display updates slows down the system. Due to the nature of Qt and QWT libraries the QWT display needs to run in the main application thread.

The USB reading can be optimised further, I was just lazy and this works. If anyone updates it and improves send me the code then I will integrate it or I can link to your site!

Here is a screenshot of both channels reading signals

Simple USB Scope Screenshot.jpeg

Everything Together

When you add everything together, you have a simple but effective USB oscilloscope that is good enough for everyday projects. As a Checklist remember to do the following (preferably in order)

  • Install MPlabX and XC32
  • Program Firmware on PIC
  • Download and uncompress libUSB-win32
  • Create driver set
  • Install drivers
  • Install and configure Qt and MinGW
  • Install QWT
  • Compile Windows software

I hope that you enjoy the scope! I am very interested in people using this or improving it. Let me know if you use this then I will add a link to your implementation!

Here is a small Youtube Video of the USB Oscilloscope in action! I connected the headphone output of the computer to the two channels (left and right) and played music. There is no audio because no audio came out of the computer.

As stated before, the software has major room for improvement, and maybe someday I will get round to do it. But in the meantime, feel free to use this and improve! Remember to link to this site and share your design!


Everything here is provided under the Gplv3 licence. Do not claim this as your own, do not make money from this, release your version also as open source. Give back to the community.

Precompiled Firmware, drivers and Windows software. This is the complete binary package, you don't have to install Qt, QWT, MinGW or compile anything.

MPLabX Firmware. This is just the firmware for the PIC. Note that this already includes the Microchip USB Framework files needed.

Windows Executable Source. This is the Qt Source code for the Windows Executable. Note that you need Qt, MinGW and QWT to compile this!