الکتروکاردیوگرام یا به اختصار ECG ، دستگاهی است که بر اساس اندازه گیری سیگنال های الکتریکی حاصل از انقباظ قلب ، منحنی فعالیت قلب را نمایش می دهد . ECG ها کاربرد فراوانی در صنایع پزشکی دارند . به طور مثال از ECG ها جهت گرفتن نوار قلب استفاده می شود یا دستگاه هایی که علائم حیاطی بیمار را چک می کنند . ماژول AD8232 یک ECG ارزان قیمت است که می توانید آن را به آردوینو یا MCU مختلف متصل کنید . AD8232 در واقع یک آمپلی فایر است که سیگنال های دریافتی از پد های تماسی را تقویت می کند . به همراه این ماژول پد های ECG وجود دارد که آن ها را بر روی سطح بدن چسبانده و سپس الکترود ها را به آن متصل می کنید . پد های eCG یکبار مصرف می باشند که می توانید آن ها را از داروخانه ها تهیه کنید . از این ماژول می توانید علاوه بر کای های پزوهشی و آزمایشگاهی ، در ماربرد های عملی نسز استفاده کنید .
در تصویر زیر پین های ماژول AD8232 نشان داده شده است :
3.3V و GND پین های تغذیه ماژول می باشند .
OUTPUT سیگنال آنالوگ خروجی مازول می باشد .
پین های LO جهت تشخیص اتصال درست الکترود های می باشد .
SDN جهت خاموش کردن ماژول است .
راه اندازی ماژول AD8232 با آردوینو :
برای راه اندازی این ماژول با آردوینو می توانید از واحد ADC استفاده کنید . همچنین پین های LO را نیز به آردوینو متصل کنید تا در صورت تغییر سطح این پین ها ، قطع شدن اتصال الکترود ها تشخیص داده شود .
Serial myPort; // The serial port
int xPos = 1; // horizontal position of the graph
float height_old = 0;
float height_new = 0;
float inByte = 0;
int BPM = 0;
int beat_old = 0;
float[] beats = new float[500]; // Used to calculate average BPM
int beatIndex;
float threshold = 620.0; //Threshold at which BPM calculation occurs
boolean belowThreshold = true;
PFont font;
void setup () {
// set the window size:
size(1000, 400);
// List all the available serial ports
println(Serial.list());
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[2], 9600);
// don't generate a serialEvent() unless you get a newline character:
myPort.bufferUntil('\n');
// set inital background:
background(0xff);
font = createFont("Ariel", 12, true);
}
void draw () {
//Map and draw the line for new data point
inByte = map(inByte, 0, 1023, 0, height);
height_new = height - inByte;
line(xPos - 1, height_old, xPos, height_new);
height_old = height_new;
// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
background(0xff);
}
else {
// increment the horizontal position:
xPos++;
}
// draw text for BPM periodically
if (millis() % 128 == 0){
fill(0xFF);
rect(0, 0, 200, 20);
fill(0x00);
text("BPM: " + inByte, 15, 10);
}
}
void serialEvent (Serial myPort)
{
// get the ASCII string:
String inString = myPort.readStringUntil('\n');
if (inString != null)
{
// trim off any whitespace:
inString = trim(inString);
// If leads off detection is true notify with blue line
if (inString.equals("!"))
{
stroke(0, 0, 0xff); //Set stroke to blue ( R, G, B)
inByte = 512; // middle of the ADC range (Flat Line)
}
// If the data is good let it through
else
{
stroke(0xff, 0, 0); //Set stroke to red ( R, G, B)
inByte = float(inString);
// BPM calculation check
if (inByte > threshold && belowThreshold == true)
{
calculateBPM();
belowThreshold = false;
}
else if(inByte < threshold)
{
belowThreshold = true;
}
}
}
}
void calculateBPM ()
{
int beat_new = millis(); // get the current millisecond
int diff = beat_new - beat_old; // find the time between the last two beats
float currentBPM = 60000 / diff; // convert to beats per minute
beats[beatIndex] = currentBPM; // store to array to convert the average
float total = 0.0;
for (int i = 0; i < 500; i++){
total += beats[i];
}
BPM = int(total / 500);
beat_old = beat_new;
beatIndex = (beatIndex + 1) % 500; // cycle through the array instead of using FIFO queue
}
نحوه اتصال پد ها بر روی بدن :
موقعیت پد ها بسیار مهم است و در صورتی که در قسمت های دیگری چسبانده شوند خروجی ماژول ممکن است بسیار ضعیف باشد . پد ها را بهصورت تصویر زیر بر روی بدن نصب کنید :
Red: RA (Right Arm)
Yellow: LA (Left Arm)
Green: RL (Right Leg)




