OlimexShield-ECG

Hi,

I need some help with something I am working on. I have bought an Olimex Shield and attached it to an arduino atmega2560 to read an ECG signal and plot it in Matlab. I am a newbie in arduino and don’t know very well how it all works yet.

The thing is that I am getting in matlab just a few samples - around 20 samples/s- which is pretty low, so I am missing some PQRS. How could I increase the sample rate? Am I missing something?

The code I am using in arduino is this:

#include <compat/deprecated.h>
#include <FlexiTimer2.h>
#define SAMPFREQ 256 // 
#define TIMER2VAL (1024/(SAMPFREQ))                        
volatile unsigned char CurrentCh=0;   .
volatile unsigned int ADC_Value = 0;
char answer[3];

void setup() 
{
 noInterrupts();  // Disable all interrupts before initialization
 FlexiTimer2::set(TIMER2VAL, Timer2_Overflow_ISR);
 FlexiTimer2::start();

 // Serial Port
 Serial.begin(57600);

 interrupts();  // Enable all interrupts after initialization has been completed
}

void Timer2_Overflow_ISR()
{
        ADC_Value = analogRead(CurrentCh);
        sprintf(answer,"%04d",ADC_Value);
        Serial.print(answer);
}

void loop() 
{
 __asm__ __volatile__ ("sleep");
}

Thanks in advance