Another Arduino Oscilloscope / New user

Hi all,

For my first Arduino project i got hold of the S65 shield and turned it into an oscilloscope. Resolution-wise i get to around 7.7kHz, wich isn’t too bad. Since i am mostly into audio processing it still would be nice to get that a little higher, is there any suggestions on how to get the sample rate higher ?

Thanks, Mason

---
#include <S65Display.h>
#include <SDcard.h>

#define FASTADC 1

// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

S65Display lcd;

#define ANALOG_IN4 4
#define ANALOG_IN5 5

int count = 3;
long previousMillis = 0;
char string[8];
int diff;
int mem4[129];
int mem5[129];
   
void drawBox(void)
{
  lcd.drawLine(2,2,130,2, RGB(255,255,255));
  lcd.drawLine(2,2,2,130, RGB(255,255,255));
  lcd.drawLine(130,2,130,130, RGB(255,255,255));
  lcd.drawLine(2,130,130,130, RGB(255,255,255));
  lcd.drawLine(2,66,130,66,RGB(255,255,255));
  lcd.drawLine(130,2,132,2,RGB(255,255,255));
  lcd.drawLine(130,66,132,66,RGB(255,255,255));
  lcd.drawLine(130,130,132,130,RGB(255,255,255));
  lcd.drawLine(130,33,132,33,RGB(255,255,255));
  lcd.drawLine(130,99,132,99,RGB(255,255,255));
  lcd.drawLine(130,16,131,16,RGB(255,255,255));
  lcd.drawLine(130,49,131,49,RGB(255,255,255));
  lcd.drawLine(130,82,131,82,RGB(255,255,255));
  lcd.drawLine(130,115,131,115,RGB(255,255,255));  
}

void setup() {
  int start ;
  int i ;
  
#if FASTADC
  cbi(ADCSRA,ADPS2) ;
  sbi(ADCSRA,ADPS1) ;
  sbi(ADCSRA,ADPS0) ;
#endif

  //init LCD  
  lcd.init(2);

  //clear screen
  lcd.clear(RGB(0,0,0));
  drawBox();
  pinMode(3, OUTPUT);   
}

void loop() {

  int val4 = analogRead(ANALOG_IN4);
  int val5 = analogRead(ANALOG_IN5);
  int data4 = (int)(val4 / 16.0f);
  int data5 = (int)(val5 / 16.0f);
  
  lcd.drawPixel(count,66,RGB(255,255,255));
  lcd.drawPixel(count,66-mem4[count],RGB(0,0,0));
  lcd.drawPixel(count,66-data4,RGB(0,200,50));
  lcd.drawPixel(count,129-mem5[count],RGB(0,0,0));
  lcd.drawPixel(count,129-data5,RGB(0,50,200));
  
  mem4[count] = data4;
  mem5[count] = data5;
  
  if (count < 129){
    count = count +1;
  }
  else
  {
    count = 3;
    diff = millis()-previousMillis;
    itoa(diff, string, 10);
    lcd.fillRect(140, 60, 175, 60+10, RGB(0,  0,  0));
    lcd.drawText(140, 61, string, RGB(  255, 255, 255), RGB(0,  0,  0));
    
    itoa(val4, string, 10);
    lcd.fillRect(140, 30, 175, 30+10, RGB(0,  0,  0));
    lcd.drawText(140, 31, string, RGB(  0, 200, 50), RGB(0,  0,  0));
    
    itoa(val5, string, 10);
    lcd.fillRect(140, 92, 175, 92+10, RGB(0,  0,  0));
    lcd.drawText(140, 92, string, RGB(  0, 50, 200), RGB(0,  0,  0));
    
    previousMillis = millis();
  }
}

great first project! I like it.

nice :slight_smile:

Oops, had a dead link in previous post, see here for pictures http://traegerwelle.blogspot.com/2009/08/arduino-oscilloscope.html