Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Ground Controller Lvl 1
Message 1 of 1

Sampling Rate Timecode Problem Arduino-ECG

Hi, I am new in GitHub. I use Arduino UNO Rev.3 and MySignals HW (eHealth Medical Development Shield for Arduino) to measure heart rate. I have a problem with the sampling rate: I have a sampling frequency of 500 Hz, which means data should come at the rate of 2 milliseconds (ms). But this is not the case I see in csv. file, the difference between one sample to the next upcoming sampling is not always 2 ms and also it keeps changing throughout my log (sometimes the time stamp is identical but nevertheless the voltage changes, sometimes the time value duplicated and triplicated).
E.g.
time (hh:mm:ss.ffffff), voltage,
13:14:16.341084;1.92;
13:14:16.341585;1.94;
13:14:16.341585;1.86;
13:14:16.341585;1.76;
13:14:16.342087;1.72;
13:14:16.342087;1.77;
13:14:16.342588;1.87;
13:14:16.342588;1.94;
13:14:16.343090;1.92;
13:14:16.343090;1.82;
13:14:16.343591;1.74;
13:14:16.343591;1.74;
13:14:16.343591;1.73;


#include <MySignals.h>
#include "Wire.h"
#include "SPI.h"
void setup()
{
Serial.begin(115200);
MySignals.begin();
}
void loop()
{
float ECG = MySignals.getECG(VOLTAGE);
//Serial.print("ECG value : ");
Serial.println(ECG, 2);
//Serial.println(" V");
// wait for a millisecond
delay(1);
}

This will cause problems as I will try to have trigger points in data, to measure the time difference between the trigger point and one previous R peak. When there is more than one time stamp, it is not possible to measure.

My question is:
How can I get one sample in every millisecond (1000Hz) ? What I eventually need to see is something like this:
time (hh:mm:ss.ffffff), voltage
13:14:16.341585; 1.94;
13:14:16.342087; 1.72;
13:14:16.343090; 1.92;

Thank you very much in advance!