Saipraveen Durairaman
Published © CC BY

ChipoScope

Poor Mans oscilloscope using Digilent Chipkit Uno 32.

IntermediateFull instructions provided712
ChipoScope

Things used in this project

Hardware components

Chipkit Uno 32
×1
Chipkit Basic IO Shield
×1

Hand tools and fabrication machines

Laptop with MPIDE installed
Laptop with MPIDE software installed

Story

Read more

Code

ChipoScope

C/C++
A simple oscilloscope implemented on the OLED display on the Digilent Chipkit Uno 32.
#include <IOShieldOled.h>

#define  OLED  IOShieldOledClass
#define height 32
#define width 128
#define switc 2

OLED  oled;

int val;
int value;
int values[width];
float zoom;

void setup() 
{
oled.begin();
oled.setCursor(0, 0);
oled.putString("Welcome..!!");
oled.setCursor(0, 2);
oled.putString("Enjoy CHIPOSCOPE");
oled.updateDisplay();

delay(5000);

zoom = 3.0f;

pinMode(switc,INPUT);
}

int getY(int val) 
{
return ((height - val/ 1023.0 * ((height - 1))));
}

int getValue() 
{
value=analogRead(A0);
return value;
}

void pushValue(int value) 
{
for (int i=0; i<width-1; i++)
{
values[i] = values[i+1];
}
values[width-1] = value;
}

void drawLines() 
{  
int displayWidth = width / zoom;
int k =  128- displayWidth;
int x0 = 0;
int y0 = getY(values[k]);
for (int i=1; i<displayWidth; i++) 
{
k++;
int x1 = i * (width-1) / (displayWidth-1);
int y1 = getY(values[k]);
oled.moveTo(x0,y0);
oled.drawLine(x1,y1);
oled.updateDisplay();
x0 = x1;
y0 = y1;
}
delay(60);
oled.clearBuffer();
}

void drawGrid() 
{
int sw=digitalRead(switc);
if(sw==1)
{
oled.moveTo(0,height/2);
oled.drawLine(width,height/2);
oled.updateDisplay();
}
}

void loop()
{
drawGrid();
val = getValue();
pushValue(val);
drawLines();
}

Credits

Saipraveen Durairaman

Saipraveen Durairaman

4 projects • 4 followers
A robotics and Electronics Enthusiast.

Comments