A PC and an Arduino: here’s your DIY Oscilloscope

By on June 3, 2014

Web site:

http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_type=project&item_id=3888

Project Summary:

We have designed an Oscilloscope using PC and Arduino Board. The signal is first of all fed to the Arduino Board where the analog signal is converted to a digital signal by the ADC which is then serially outputted to the PC and is read by the MATLAB software via the COM ports. Here the signal is read in the form of digital data but then is converted to analog one by using the resolution of the ADC used by the Arduino Board. The MATLAB software was then used to plot the signals.

Full Project:

Oscillo

The input to be plotted is given to one of the five analog pins in the board. The software used for interfacing the board with the PC is Matlab R2012a. The compiler Arduino 1.0 has been used for uploading the codes to the board. The MAX 232 Line Driver and ATmega328 Processor has been used. The various components used in this designing has been illustrated briefly in the coming sections.

 

Full project in PDF: DESIGNING A PC OSCILLOSCOPE

Circuit diagram:

our ckt

Bill of Materials:

Arduino Board

LM358 IC

RESISTORS:
3PCS 1Mohm

CAPACITORS:
2PCS 0.01 µF

Firmware:

Oscillo2

MATLAB CODE FOR SERIAL INPUTTING AND PLOTTING OF WAVEFORM

clear all;clc;close all;
 
arduino=serial('COM6','BaudRate',9600);
 
fopen(arduino);
 
x=1:100;
   
for i=1:length(x)
    y(i)=fscanf(arduino,'%d');
end
t = y/1024*5;
A = y;
count=zeros(0,1023);
for k=1:1024
count(k)=length(find(A==(k-1)));
end
m = max(count);
in = find(count==m);

fclose(arduino);

disp('making plot..')
figure('Name','The Digital Values From Serial Port');
subplot(2,2,1)
plot(x,y);
title('Serial Port Data');
ylim([0 1023]);
xlabel('From Serial Port');
ylabel('Digital Voltage');


subplot(2,2,2)
plot(x,t);
title('The Analog Plot Of Voltage');
ylim([0 5]);
xlabel('From Serial Port');
ylabel('Analog Voltage');

fprintf('%d is found toh be maximum count of %d ',in-1,m);

subplot(2,2,3)
t = 0:1023;
plot(t,count),title('Frequency Count');
xlabel('Digital Value');
ylabel('No Of Occurences');
xlim([0 1023]);

subplot(2,2,4)
d = count/length(A)*100;
plot(t,d);
title('Digital Values Frequency Percentage');
xlabel('Digital Value');
ylabel('Percentage of No Of Occurences');
xlim([0 1023]);

 Arduino Board codes

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(100);        // delay in between reads for stability
}

Software & Code Snippets:


About prem_ranjan

  • MinasMazar

    I think the best way to connect Arduino board to PC is with https://github.com/austinbv/dino enjoy Ruby powa! ;-)

  • Emna Mechri

    nice project ! Arduino, Matlab *_*

  • diex

    100 ms delay? is it a lot, isn’t it?

  • Dave Stansbie

    I’ve logged in but I can’t see any of the project. Am I missing something?

  • vish

    Hi… check out this project
    http://www.element14.com/community/groups/internet-of-things/blog/2014/06/23/building-your-own-iot-oscilloscope-for-less-than-25
    No additional software needed….works from your browser…even from your tablet or smartphone.

  • Joy V. John

    Can this be accomplished using raspberry pi?

    • Glen Duncan

      ANYTHING an Arduino can do, the Pi can do.

      • Yo Joe

        Disagree. They have their strengths and weaknesses and are really completely different. Pi has no where near the same amount of I/O as the Arduino’s (open ended, i’m gonna assume Mega, or Due)

      • Jim Myers

        The Raspberry Pi and the Arduino are designed for entirely different uses. The Raspberry Pi is much slower at processing IO because it must rely upon a full OS for operation. The Pi also suffers from a dearth of GPIO ports. The attached graphic gives a basic comparison between an Arduino Uno and a Raspberry Pi model B.

        The Raspberry Pi is aimed at software applications while the Arduino is aimed at hardware applications. The Arduino is superior at briding the hardware/software gap as compared to the Pi.