A simple Digital CRO (exaggeration)

A simple Digital CRO using Arduino
Idea behind this simple concept is to use Arduino’s serial communication and MATLAB’s serial port function to draw a signal on your computer.  So for generation of signal, I simply use a photo resistor that will vary input voltage according to light incident on it. Arduino code is as below..
Arduino code:
//This code is used to generate a signal and then signal in converted into digital using sampling...
/* Simple Digital CRO using MARTLAB to draw signals. This signal will be sent on com11 pot where MATLAB will read it and plot it..
----------------------------------------------------

           PhotoR     10K
 +5    o---/\/\/--.--/\/\/---o GND
                  |
 Pin 0 o-----------

----------------------------------------------------
*/

int SensorPin = 0;  //define a pin for Photo resistor


void setup()
{
    Serial.begin(9600);  //Begin serial communcation
   
}

void loop()
{
    Serial.println(analogRead(SensorPin)); //Write the value of the photoresistor to the serial monitor.
  
}

MATLAB code:
clear all
clc

arduino=serial('COM11','BaudRate',9600);

fopen(arduino);

x=linspace(1,100);
  
for i=1:length(x)
    y(i)=fscanf(arduino,'%d');
end
   
fclose(arduino);
disp('making plot..')
plot(x,y);

Results:

Some other results:

A servo motor input from controller mapped in simple DCRO
Pulse train


Limitations: 
This is not very precise 'cause we are just using digital pins of ARDUINO, if we use analog pins, and sampling with baud rate of 9600 can give us even more precise output. 

These results were tested when input is no more than 5 volt (Maximum Voltage arduino can bear), if we wanna make it to test for any voltage we need some circuitry to limit current and voltages just as we use in Multi meter. 

Possible errors:


Solution:
Don’t use any device that uses serial pin on which arduino is connected. Like don’t open serial monitor of  ARDUINO IDE like this..
Also take care of  baud rate and  also select correct port both in Arduino IDE and MATLAB code. You  can check port number where arduino is connected using device manger.




No comments:

Post a Comment

Thank you for your response.