0
\$\begingroup\$

I have encountered a problem in my ECG/EKG design.

I am trying to make an ECG using an Arduino as a microcontroller to send/retrieve heart rate measurements via Bluetooth (JY-MCU.)

I know my circuit is working because when I place an LED in op-amp output and its ground, I get a slight dimming of the light if I gently put my hand on the leads. I know the issue is with my code. I have been working on this project for a while and still can't find a solution.

Here is my schematic:

enter image description here

Here is my code that I think is incorrect. The code is just the bare minimum.

// External variables
const int  signal = 8;    // Pin connected to the filtered signal from the circuit
unsigned long time;   
unsigned long frequency;
char freq[3];

// Internal variables
double period = 2000;
double starttime = 2000;
double input = 0;
double lastinput = 0;
unsigned long death = 0;

// initialize the library with the numbers of the interface pins

void setup() {
pinMode(signal, INPUT);
Serial.begin(9600);
}

void loop() {
delay(500);

time = millis();
input = digitalRead(signal);

 period = time - starttime; // Compute the time between the previous beat and the one that has just been detected
 starttime = time; // Define the new time reference for the next period computing
 death = time;
 frequency = 60000/period;
 freq[0] = frequency/100+48; // Sort the hundreds character and convert it in ASCII
 freq[1] = (frequency/10)%10+48; // Sort the thents character and convert it in ASCII
 freq[2] = frequency%10+48; // Sort the units character and convert it in ASCII
 Serial.println(freq);
}

All I'm getting is either 120 or 119 as my value. It fluctuates between those two. I tried changing my resistors out but that didn't do anything. I also completely took the wire between pin 8 and the breadboard out, and it still fluctuated between 119 to 120. I don't have any idea what is going on here! I would appreciate it if someone could help me out here.

\$\endgroup\$
5
\$\begingroup\$

That amplifier will simply not give you an ECG signal. There's nowhere near enough gain, and the common mode rejection is very bad. You need to get a grip on your data acquisition using some sort of test signal that you can use without your amplifier. After you get that working, then you can work on a working amplifier. You'll get nowhere fast trying to work on every aspect of your problem at the same time.

Looking at your code, you seem to be calculating the time between your SAMPLES (which is why you're getting something near constant), which has nothing to do with heart rate. Somehow, you need to process a VALID ECG signal to yield heartrate.

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ Ok Scott, got it. I got a hold of an electrocardiogram program on my computer and I am using that to display a graph. Here's the issue though. I am not getting my heart rate readings. When I completely take my hand off, I am getting nothing. When I put my finger on the leads, I am getting 60 Hz noise only. Funny thing is this doesn't happen when I don't place my fingers on the leads, which is when I expect it to happen. Is it because the leads I am using not sensitive enough? I am using 25 ft speaker wire for the leads. I also used 3-4 inch jumper wire, but that made no diff either. \$\endgroup\$ – Rohodude Jan 24 '15 at 20:47
  • \$\begingroup\$ Oh, and almost forgot. I used an opamp and found out my gain is about 214. I used a low pass filter to filter off any noise above 38 Hz. It works somewhat, as I can see some of the data being compressed, but I still can't see my own heart rate. I'm a total beginner at this so I seriously need some help. Thank you. \$\endgroup\$ – Rohodude Jan 24 '15 at 20:59
0
\$\begingroup\$

Your speaker wire is an antenna that picks up the 60Hz from electricity that is all around you. Your + input pin 3 on the opamp has no bias voltage that should be about half the 5V supply. If you look at ECG Amplifier in Google then you will see an instrumentation amplifier (with 3 opamps inside it) so that it has differential inputs and any noise on the patient is fed back to the right leg out-of-phase to cancel the noise.

ECG circuit

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.