March 28, 2024, 05:00:18 PM

Sample raw ECG data

Started by Stan12, December 24, 2012, 09:12:58 AM

Previous topic - Next topic

vincent2yui

I have Olimex ECG with the default passive electrode attached to the Arduino UNO. I run the Electric Guru software to view the ECG graph. I tried to get the serial data from the serial monitor (Arduino IDE) and save it to a text file (using Visual Basic). A sample packet data is shown below (in unsigned int16):

165 90 2 177 1 68 1 60 1 50 1 40 1 26 1 17 1

NOTE:
165 - sync0 = 0xa5; 90 - sync1 = 0x5a; 2 - packet version; 177 - packet counter; others - data

I tried to use the data (60,50,40,26,17) ignoring the '1', and graph/chart in Excel with the remaining packet data but the result is different(not a ECG graph) from the Electric Guru. Maybe I should use the '1' but I don't know how. My question is how did you graph the data from your Arduino Due? Or can you kindly show sample data you get from the device? Thank you in advance.

Stan12

#16
Quote from: vincent2yui on March 04, 2014, 05:56:41 AM
I have Olimex ECG with the default passive electrode attached to the Arduino UNO. I run the Electric Guru software to view the ECG graph. I tried to get the serial data from the serial monitor (Arduino IDE) and save it to a text file (using Visual Basic). A sample packet data is shown below (in unsigned int16):

165 90 2 177 1 68 1 60 1 50 1 40 1 26 1 17 1

NOTE:
165 - sync0 = 0xa5; 90 - sync1 = 0x5a; 2 - packet version; 177 - packet counter; others - data

I tried to use the data (60,50,40,26,17) ignoring the '1', and graph/chart in Excel with the remaining packet data but the result is different(not a ECG graph) from the Electric Guru. Maybe I should use the '1' but I don't know how. My question is how did you graph the data from your Arduino Due? Or can you kindly show sample data you get from the device? Thank you in advance.
I don't use sketches suggested by OLIMEX, and I don't use ElecGuru software.
I posted the code I use a while ago (December, 27), raw data is transmitted to ECG-processing application I made.
Here is application screenshot

ECG file is saved as a simple ASCII file, and content looks like this:
436,285
389,285
391,285
432,285
436,285
400,285
405,285
443,285
458,285
420,285
403,285
442,285
457,285
409,285
392,285
434,285
464,285

Second number in each row is the same, this is the minimal value in whole dataset, it is used for scaling the image.

vincent2yui

Thank you so much sir! Really appreciate the prompt response.

iloveinter

Quote from: Stan12 on December 27, 2013, 03:14:13 AM
Here is the code I used for Arduino Due:
//timer based on http://arduino.cc/forum/index.php/topic=130423.15.html
volatile unsigned int ADC_Value = 0;
boolean timer_fired=false;
// Black magic
void startTimer(Tc *tc, uint32_t channel, IRQn_Type irq, uint32_t frequency) {
  pmc_set_writeprotect(false);
  pmc_enable_periph_clk((uint32_t)irq);
  TC_Configure(tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK4);
  uint32_t rc = VARIANT_MCK/128/frequency; //128 because we selected TIMER_CLOCK4 above
  TC_SetRA(tc, channel, rc/2); //50% high, 50% low
  TC_SetRC(tc, channel, rc);
  TC_Start(tc, channel);
  tc->TC_CHANNEL[channel].TC_IER=TC_IER_CPCS;
  tc->TC_CHANNEL[channel].TC_IDR=~TC_IER_CPCS;
  NVIC_EnableIRQ(irq);
}

void setup(){
  // Start timer. Parameters are:

  // TC1 : timer counter. Can be TC0, TC1 or TC2
  // 0   : channel. Can be 0, 1 or 2
  // TC3_IRQn: irq number.
  // 250 : frequency (in Hz)
  // The interrupt service routine is TC3_Handler.
Serial.begin(57600);
  startTimer(TC1, 0, TC3_IRQn, 250);
}

void loop(){
  if (timer_fired)
  {
     ADC_Value = analogRead(0);
     Serial.print("D!");
     Serial.println(ADC_Value);
     timer_fired=false;
  }
}

volatile boolean l;

// This function is called every 1/250 sec.
void TC3_Handler()
{
  TC_GetStatus(TC1, 0);
  timer_fired=true;
}

Hello stan 12,
Thank your for posting this code, i uploaded this code to an ardunio due and used ElectricGuru in order to view the EMG signal but the signal was too slow

Badreddinez

Thank you so much, I wonder in which software or application you are displaying the data?
Is it real time?
I tried to do the same on Matlab but plotting live is delaying which means losing the aspect of real time!
Can you please help me on that?

Stan12

As I mentioned above,
I made my own application for handling ECG data. It can register and store in memory in real time up to an hour of ECG, plus some extra functionality - besides saving/reading from file, exporting to standard formats, annotate, it also allows to convert ECG into HRV (heart rate variability) domain and process HRV data.
The part for receiving a signal initially was written to handle dataflow from cheap hand-held cardio monitor MD100B easily available online (~$150); although this part can be modified to accommodate practically any input device. I even used it for registering extra-fast accelerometer data :)
I don't see any serious advantage of processing ECG data in real-time; all the most interesting methods usually are applied as a post-processing. For monitoring heart activity pulse sensors are way cheaper and convenient; and if you want to look into the shape and fine structure of cardiogram - you will need a professional device and accessories. So I came to conclusion that HRV is the only type of ECG-related data that can be registered reliably with simple hardware we are dealing with.

Badreddinez

Hi again,

After getting this raw ECG, have you used any filters?
I got similar raw ECG but I am trying to make some processing on it if possible to orient me.

MC_Rosu

Hi Stan12,

Tell me please, the ECG signal that you show in your self made GUI it is in analog domain or digital?
As I read in the posted script, I concluded that the raw data are analog; in any case, if you are so kind to send me the script for the GUI you used for displaynd on PC the ECG signal, to adapt for an digital ECG data received wireless.

Greetings.
MC_Rosu

joe50

Hey Stan12, thanks for the nice work! Two questions:

1. which graphical program are you using to display the ECG data?
2. With the code you mentioned: Can I just upload it to the Shield via Arduino IDE to get the data out? Please clarify.

Thanks a lot for an answer