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

20 Comments

  1. Pingback: Merry Christmas and a Open New Year | Open Electronics

Leave a Reply

Your email address will not be published. Required fields are marked *