Sie sind auf Seite 1von 4

technology workshop craft home food play outside costumes

Arduino oscilloscope
by BramMylemans on February 6, 2016

Table of Contents

Arduino oscilloscope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro: Arduino oscilloscope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1: Adding voltage dividers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

http://www.instructables.com/id/Arduino-Oscilloscope/
Intro: Arduino oscilloscope
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:

A 5V arduino
2 crocodile clamps
a 0.1F capacitor (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;

File Downloads

scope.ino (1 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'scope.ino']

http://www.instructables.com/id/Arduino-Oscilloscope/
scope.pde (7 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'scope.pde']
Step 1: Adding voltage dividers
The circuit show above consists of:

On the left: a 1:4 voltage divider between the probe and A1

This will bring the voltage down to 1/4 of the input voltage. The analog pins can handle 5V, so this will allow for voltages up to 20V.

Note that there are 2 input channels in the picture of the breadboard. Adding an extra channel slowed down the sampling rate dramatically (because continuous mode
can't be enabled on the ADC), so I decided to leave it out in the final code.

On the right: a switched voltage divider between 5V and the Analog Reference (AREF) pin
You can use the switches to set the measuring range: 5V, 6.64V, 10V of 20V

How this works:

If configured to 'external reference', the ADC compares the voltage of the analog inputs with AREF, instead of 5V.
Here's an example: suppose the probe is measuring 5V. The voltage on the A1 will be 5V/4 = 1.25V

If both switches are off, the voltage on the AREF pin is 5V.
The ADC will read 1.25/5 = 25%
If switch 1 is off and switch 2 is on, the voltage on AREF is 2.5V
The ADC will read 1.25/2.5 = 50%
If switch 1 is on and switch 2 is off, the voltage on AREF is 1.66V
The ADC will read 1.25/1.66 = 75%
If both switches are on, the voltage on AREF is 1.25V
The ADC will read 1.25/1.25 = 100%

The second pole of each switch is connected to a digital input. We can read this pin to automatically adjust the voltage scale.

A capacitor between the probe and ground


Might not be necessary, but for some reason some pc's measure a lot of noise without it. The capacitor will solve that, but may slightly affect the signal when measuring
high frequencies.

Be careful:
If the analog reference is set to internal (default) while you are supplying voltage to the AREF pin, the arduino could get damaged. I did that, and it didn't damage
mine, but better be safe and upload the proper code before connecting AREF.
the analog inputs can't handle negative voltages.
Don't exceed 5V on the arduino pins. It's probably a good idea to test the circuit with a voltage below 5V, so
you don't damage the arduino in case the voltage divider on A1 was wired incorrectly.

The arduino code was loosely based on this excellent article:

http://meettechniek.info/embedded/arduino-analog.html

Good luck!
Bram

Image Notes
1. I was experimenting with a second channel here. It didn't work well, so you
can omit this part.
Image Notes
1. Input voltage divider (1:4)
2. AREF voltage divider
3. filter gound noise from usb port
4. filter gound noise from usb port
5. the other pole of the switches is used to read the switch position, so we can
adjust our voltage scale

http://www.instructables.com/id/Arduino-Oscilloscope/
Related Instructables

How to make an Arduino -


Arduino Chiposcope by Oscilloscope LinkIt One - Oscilloscope OFFscope -
oscilloscope (poor man's offline
saipraveen How To by Oscilloscope by
probe by LightBug Oscilloscope) oscilloscope
durairaman amandaghassaei
NeoRecasata by RuiSantos (Arduino + SD
card fast
logging) by
brajomobil

Advertisements

Comments
3 comments Add Comment

tttapa says: Feb 8, 2016. 7:33 AM REPLY


Great Instructable!
It may be a good idea to add a 5.1V zener diode on the Arduino's inputs, or even an op-amp buffer, just in case ...

alexpikkert says: Feb 8, 2016. 4:30 AM REPLY


Hi Bram,
Nice instructable !
You refer to an article at the end of your story, but the link is missing. Can you add the link please, thanks !

BramMylemans says: Feb 8, 2016. 4:46 AM REPLY


Added the link. Thanks!

http://www.instructables.com/id/Arduino-Oscilloscope/

Das könnte Ihnen auch gefallen