Instructables

Girino - Fast Arduino Oscilloscope

Featured
Picture of Girino - Fast Arduino Oscilloscope
I am a Physicist and the nicest part of working in this field is that I get to build my own instruments. With this way of thinking, I decided to build a homebrew Arduino Oscilloscope. This instructable was written with the purpose of teaching a bit about microcontrollers and data acquisition. This is an extreme project because I wanted to squeeze out from Arduino as much velocity as I could, I have not seen any other Arduino Oscilloscope as fast as this one.

Some time ago I was working on an Arduino project and I needed to see if the output signal was into compliance with the specifics. Thus I spent some time on the internet looking for Arduino Oscilloscopes already implemented, but I did not like what I found. The projects that I found were mostly composed of a Graphical User Interface for the computer written in Processing and a very simple arduino sketch. The sketches were something like:
void setup() {
    Serial.begin(9600);
}

void loop() {
    int val = analogRead(ANALOG_IN);
    Serial.println(val);
}
This approach is not wrong and I do not want to insult anyone, but this is too slow for me. The serial port is slow and sending every result of an analogRead() through it is a bottleneck.

I have been studying Waveform Digitizers for some time and I know reasonably well how do they work, so I got inspiration from them. These were the starting points of the oscilloscope that I wanted to create:
  • the incoming signal should be decoupled from the arduino to preserve it;
  • with an offset of the signal it is possible to see negative signals;
  • the data should be buffered;
  • a hardware trigger is required to catch the signals;
  • a circular buffer can give the signal shape prior to the trigger (more to follow on this point);
  • using lower lever functions that the standard ones makes the program run faster.

The sketch for the Arduino is attached to this step, along with the schematic of the circuit that I made.

The name that I came up with, Girino, is a frivolous pun in Italian. Giro means rotation and adding the suffix -ino you get a small rotation, but Girino also means tadpole. This way I got a name and a mascot.
 
Remove these adsRemove these ads by Signing Up
hitchcme made it!5 days ago

I Made it, modified it, couple transformers inside an Iomega hard drive enclosure, home etched shield, working with a mega 2650, and..... here's a labview student edition interface, and an XCode Cocoa OpenGL interface =>still in progress. it could be called the Cocoa-O-O-G-G-L-Scope or I don't know.

https://github.com/hitchcme/GirinoScope.git ta da!!!!

Cocoa-O-Scope-Girino-Scope.tiff

If one was working with a Windows machine, it is possible to just copy side by side everything, recreating everything as if you had done it yourself, which... I am happy to share!

I meant a windows machine with LabView.

Kerveros1 month ago

Hello, this is nice work, i have a question, have you full schematics?

snoop9111 month ago

What are your thoughts on displaying the data? Any front-end GUI you like? There seems to be so many open source options for developing GUIs ( Juice, GTK+, wxWidgets, Feathers UI, Chico UI/JQuery, etc)... example, the PulseView logic analyzer software uses sigrok/qt.

On the backend, is the serial protocol to talk to the frontend much different than firmata? Hopefully it's a serial protocol that it's easily ported to any microcontroller with a uart!

arthujt6 months ago
Any help please?
The Huntron(octopus circuit) has been a staple on most test benchs for years(me? >40years)It uses a a transformer to cause a 60hz signal and when fed thru a three resistor network, (google: octopus circuit),then is applied to X,Y (horizontal,vertical direct inputs.) This allows the pinpointing of discrete or IC defects or damaged devices,including resistors,and capacitors.This saves alot of time troubleshooting as the circuit can be tested dead. And the device doesnt have to be unsoldered(incircuit)
I looked at some android apps , and no XY functions. Can you take the timeframing out of the picture and compare two inputs directly to each other ? If you generate a pwm(60hz)send it out and return thru another input, the result can be compared to an internal (60hz) and displayed in a horizontal vs vertical scene., just place the resistors inbetween and some wiring to test devices with and you eliminate the outside source. Or just run two inputs and use the outside coil(transformer)to gen the 60hz.
kooth8 months ago
Awesome Instructables! Very well done!
ivansouza11 months ago
Nice Work!!! Maybe this could help you in this great project... http://www.linuxtoys.org/pscope/pscope.html
Wow, excellently well explained Christiano--I feel I've already learned so much just reading through this in the library, and I haven't even started building! It really ties together the material I'm learning in EE, in a tangible & actionable manner. Keep up the good work!
dinoi1 year ago
Great work, but I have troubles to get it run. Could you please explain the Hardware mapping on your schematic:

ADC:1 is Analog 0 on Arduino,
PWM:1 is Analog3

but where to go with AnalogComparator:1 and Threshold:1?

Thanks a lot
Dinoi
I did something similar, I sent out sensor values to serial port in csv formate, I used GTK term, and logged the data in a file, that file was read at the same time by KST (an awesome plotting software) to plot the data. It has a good gui and many other options, I'm trying to make a plugin for kst that will make this process simple.
Nanico1 year ago
Can you explain how to use dual channel? What is the best way to switch from 1 ch to other
Caffeinomane (author)  Nanico1 year ago
Well if you want to use two channels at the same time the acquisition rate will go down, probably more than a factor of 2.
Given that the Arduino has only one ADC you must alternatively feed to the ADC your signals. This means that you have to use the multiplexer (see step 8). At each iteration you have to:
- Read Ch 1 with the ADC
- Switch to Ch 2
- Read Ch 2
- Switch back to Ch 1
Plus doubling the number of channels you halve the amount of available memory, because you have to store two numbers at each iteration.
konsumer1 year ago
Very informative. I am the maker of arduinoscope, which is one of the Processing scopes you mentioned. Although, the original goal of that project was to make it extremely accessible to non-tech people (I used it for teaching electronics and hardware hacking.) I think we could add some of these features to that project (especially the Arduino firmware.) I don't really like Processing (or java, which arduinoscope is written in) and would be happy to switch to something else, if it could remain fairly easy for a non-programmer/electronics newb to get their hands on and modify. I started work on node.js to make a simple GUI, but Python also seems like a good candidate. I have moved the simple serial Arduino backend (sort of similar to the code pointed out, but you are exaggerating a bit, at least in my case) to use Firmata, to get myself out of the business of maintaining the firmware, and introduce new users to the awesome Firmata library. I'd be happy to move to a more performant Arduino firmware, especially if you want to maintain that part, and offer your Girino as a "fancy" version, in terms of hardware. Do you have speed stats? How much of this can be done without adding custom hardware, so people can do it all in soft/firmware?
Caffeinomane (author)  konsumer1 year ago
Thank you for your offer! Right now I am in the middle of the writing of a thesis, so I can not dedicate time on this project. When I am done with this thesis I will surely contact you to start this collaboration.
sweet!
MGreatwolf1 year ago
I am somewhat new to this so forgive the question. I was reviewing your code and found the following line in it:
ADMUX |= ( ADCPIN & 0x07 );
unfortunately I am unable to locate ADCPIN in the datasheet or any of the source files provided by the Arduino developers. I like your solution and would like to dig into it a little deeper. Could you please provide some additional detail regarding ADCPIN? What it refers to and so on...Thanks for what appears to be a lot of work documenting this instructable.
Caffeinomane (author)  MGreatwolf1 year ago
Do not worry. If you look at the header file Girino.h you can see the definition:
#define ADCPIN 0
It refers to the ADC pin number that I used for the data acquisition.
aspify1 year ago
is the source code done in the arduino sketch editor or was it done in C++ code on another compiler? Just curious...thanks
Caffeinomane (author)  aspify1 year ago
Well I usually code with VIM so I basically wrote the code with VIM and then opened and compiled it with the arduino IDE.
a.flux1 year ago
Thank you very much for this project! That's exactly what I was looking for. I think I will write the Qt/Qwt interface as soon as I'm done with the soldering.

Any recent update to the schemes?

a.f
Caffeinomane (author)  a.flux1 year ago
Thank you!

No, there have not been any updates so far. I was planning to work more on this project, but some work problem denied that and are still denying.

I am still considering the idea of putting this project somewhere like Sourceforge.
Nanico1 year ago
Great work Caffeinomane!!! I love your project.
Can I use a LCD T6963c and use with girino? I have one and it run at 6 Mhz, and i want to make your project portable. Can you help me with the code for that? My ideia is to have 2 channel, but not every time.
Thank you
privatier1 year ago
For an alternative implementation of an oscilloscope, which uses an Arduino for data acquisition, please have a look at LXARDOSCOPE, available from Sourceforge. There is also a section on an investigation into the accuracy of the ADC; it includes schematics for a preamplifier which works from the same 5V supply as the Arduino.
Redsic1 year ago
Hello

This scope is great, my question though is…
This Oscilloscope is only able to read 0 -5v ? Is there anyway to Increase this ?
I know adding a resistor can make this go up to like 0-48+volts but reduces it's accuracy.

This beats the other Arduino scopes I tried hand's down.
I think this is the best DIY scope out there,
On IDE maybe you could steal the IDE from lxardoscope on Sourceforge.
I get what your saying on the power it can be powered from 12v, but you RECOMMEND 5 Volts as that's what the Ardino uses...

I really like this, not because it is a really great and simple scope with a really small footprint space wise...
but simply because of it's growth potential...

Just an Idea... for most people growing an Interest in the field.. space and initial hardware outlay cost's are an issue...

I was recently lucky enough to win a great old oscilloscope, function generator multimeter and regulated power supply for pretty cheap... second hand
and when I say cheap... I mean a few hundred pounds...
and they pretty much take up almost Half my workbench space wise.. even stacking the power supply and function generator on-top of the Oscilloscope.

This Scope is set to be the cheapest and smallest space wise...
You could combine more into this, with an Arduino mega maybe for more inputs you could build in a simple Function generator... a Multi-meter, and design to put in your own regulated power supply....
all with one credit card sized board, with a bread board and some components, you could make a PCB CNC design layout and sell them for great profit, and great value saving the average enthusiast beginner hundreds of pounds, and ton's of desk space, so they can take their projects from the garage workbench to the study desk...
then to add on a Raspberry PI 25£ credit card PC with a customized distribution with Arduino IDE etc. or a cheap 7” android capacitive touch pad with apps.
You now have an entire workbench with a design IDE, with all the tools capable of operating off a 12 volt battery... powered by wall/solar panels, and all fit in one little box smaller than your average Oscilloscope able to fit on any desk, small enough that the wife does not throw it out !
The applications could be endless...
But this project has a lot of room for Growth... and If you highlight it's growth potential... there will be a lot more interest... and a lot more people building these, and making cut's with components able to be sourced cheaply in many countries...
Man...
You will have a following and be set for life.
Schools/Universities will want this, what better way to learn than to build your own test equipment…
Not to mention cost saving’s, Saving each school from forking out thousands per each lab desk, to a mere hundred or so pounds, making education affordable !
but keep it open source please, and make the commission of donations and official branded boards, Which people will want to have...
anyway.
If your keen to go down that Path, I am keen to help.
From a Automation/Integration/Programmer/IT specialist dabbling in electronics
Redsic Redsic1 year ago
Merge,

Grinoscope

Simple Logic Analyzer
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1223530321

Multimeter
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1266030815/7

Waveform Generator
http://www.instructables.com/id/Arduino-Waveform-Generator/

Voltage Regulator
http://www.arduino.cc/playground/Main/RegulatedPositiveVoltageBooster

All in the same box, with say a Raspberry PI, Touchscreen/LCD, and a Lead acid Battery, = Super low cost full lab in one little box, Ideal for starters and beginners.
womai2 years ago
Two ideas to make the code more efficient (run faster):

The calculation

ADCCounter = ( ADCCounter + 1 ) % ADCBUFFERSIZE;

involves an integer division which tends to be time consuming (at least on a Microchip PIC - I do not know Atmel as well). Instead, try

if (++ADCCounter >= ADCBUFFERSIZE) ADCCounter = 0;

Second, you can completely avoid the time required to evaluate

if(wait)

and live without the wait variable if you simply set stopIndex to a value that the counter never reaches, as long as you aren't yet in the post-trigger phase. I.e. during initialization (when starting a new sweep) set

stopIndex = ADCBUFFERSIZE + 1;

and when the trigger event happens then just do as you did so far, but without the boolean wait variable:

ISR(ANALOG_COMP_vect)
{
// Disable Analog Comparator interrupt
cbi( ACSR,ACIE );

// Turn on errorPin
//digitalWrite( errorPin, HIGH );
sbi( PORTB, PORTB5 );

stopIndex = ( ADCCounter + waitDuration ) % ADCBUFFERSIZE;
}

and the ADC ISR routine becomes

ISR(ADC_vect)
{
if (++ADCCounter >= ADCBUFFERSIZE) ADCCounter = 0;

if ( stopIndex == ADCCounter )
{
cbi( ADCSRA, ADEN );
freeze = true;
}
}
Caffeinomane (author)  womai1 year ago
Thank you very much womai for your precious advices!
This period is very though for me but I am planning to modify the project according to your suggestions.
hoppy7772 years ago
Build an adruino signal generator. It ought to be easy to generate different wave forms.

Hoppy
womai2 years ago
One thing to be careful about: If you supply the op-amp with +/-12V it can drive almost as much into your Arduino - which will most likely kill the latter! Would be a good idea to add a series resistor after the last op-amp stage, and behind that two clamping diodes (Schottky type) going to 0V and 5V, respectively.
womai2 years ago
You can build a simple analog signal generator with an Arduino driving a R-2R resistor network (google the term and you'll get plenty of hits) from an 8-bit port. Use 1% resistors and you'll get almost 8 bits of resolution. You can the scale an buffer the signal with an op-amp stage. Just a few cents worth of parts apart from the arduino.

Here is such a project that uses an AVR, ready to be copied:
http://www.myplace.nu/avr/minidds/index.htm
womai2 years ago
To the circuit itself:

The third op-amp stage isn't really needed. Did you try to run without it? (make sure the unused op-amps inputs are tied to VCC and VSS, respectively, to avoid oscillations).

Second, to protect the input stage against overvoltage I'd add clamping diodes to VCC and VSS, respectively, right at the place where the 1 MOhm resistor is. Good, cheap, fast, low-capacitance diodes would be e.g. 1N914.
womai2 years ago
Just a general comment - and it doesn't affect the content of what you say, you did a very nice Instructable! - what you have in your circuit is called an op-amp "follower" or a "buffer", not an "emitter follower". An emitter follower would be a single transistor (with suitable resistors), not a full-blown op-amp. In fact, your op-amp could have FETs in the output stage (not BJT = bipolar junction transistors), and FETs have source, drain, and gate, but no emitter whatsoever.
intructable2 years ago
Amazing, great job!
For a GUI you could use Qt which is free and coded in C++.
Check my instructables to get an overview of what Qt could do.

Good luck
Caffeinomane (author)  intructable2 years ago
Thank you!
I was actually thinking about using the Qt with Qwt.
You will also need a serial library, try the qextserialport library.
Here some information about that :
http://www.instructables.com/id/Control-your-arduino-from-your-PC-with-the-Qt-Gui/

For Qwt, take a look at this :
http://www.instructables.com/id/Make-graphs-on-Qt-and-plot-your-arduino-measuremen/

As you are a physicist (like me) you could find Qwt very useful to develop your applications.

cheers
Caffeinomane (author)  intructable2 years ago
I will surely take a look at those instructables. Thank you!
JakeTobak2 years ago
For the GUI, you might be able to do something with MATLAB and its ArduinoIO package.
Caffeinomane (author)  JakeTobak2 years ago
I guess that that could be an option. Unfortunately, even though Matlab is a wonderful instrument, it is too expensive and the GUI would not be available to everybody. I would like to use an open source tool to give the result to the community.
You could also try Octave (http://www.gnu.org/software/octave/) which is a kind of open source Matlab. Although the language structure and syntax are similar, it isn't as simple as just dropping Matlab code in and running it.

That said, you seem to be in the position of writing new code, so this probably wouldn't matter.

Oh, did I mention the learning curve? :)

BTW - Really nice project. Well done.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!