ECG Circuit
We designed a functional ECG made from an instrumentation amplifier, which increased the gain of our circuit, a low-pass filter, which only let in lower frequency values, and a notch filter, which will attenuated frequency at 60 Hz. In order to do this, we built each part separately using given equations to calculate the resistor values, and choosing our own values for capacitors and what we wanted the gain of our circuit to be. We then tested each part separately, then connected it and ran a simulated and human ECG. Our results were consistent with what we expected, although our gain was not as high as we wanted. It successfully amplified and removed noise from the simulated ECG and plotted the human ECG, although this was still noisier than desired. We can conclude that our device did work as expected, but longer trial and error would have provided us with more accurate amplification, a less noisy human ECG, and an exact BPM value.
Supplies
General
- Function Generator
- Positive and Negative Power Supply
- Connecting wires
- Breadboard
Instrumental Amplifier
- 1 1000 ohm resistor (Brown Black Red)
- 2 82,000 ohm resistors (Gray Red Orange)
- 2 1500 ohm resistors (Brown Green Red)
- 2 10,000 ohm resistors (Brown Black Orange
- 3 Operational Amplifiers
Notch Filter
- 4 0.15 µF capacitors (154)
- 2 1100 ohm resistors (Brown Brown Red)
- 1 270,000 ohm resistor (Red Purple Yellow)
- 1 Operational Amplifier
Low-Pass Filter
- 1 13,000 ohm resistor (Brown Orange Orange)
- 1 820 ohm resistor (Gray Red Brown)
- 1 1000 ohm resistor (Brown Black Red)
- 1 Operational Amplifier
Build the Instrumentation Amplifier
Construct the instrumental amplifier according to the shown LTSpice schematic. Once it can be confirmed that the output of the amplifier is about 1100, obtain the supplies for the instrumentation amplifier section. Then, beginning building the circuit on the breadboard. This can be achieved by using both the schematic and the image of the already build circuit. Make sure to connect the op amps to their respective side columns. For all operational amplifiers, pin 4 should have a wire connecting it to the column on the far left side that will correspond to the negative voltage supply. Pin 7 should be connected to the column on the far right that will correspond to the positive voltage supply. Another one of the columns should be connected to the ground on the power supply.
Using a function generator set to a sine wave with the lowest possible peak to peak voltage (ideally 10-20 mV) and an oscilloscope, connect the input to the input wire of the INA and connect the output to pin 7 of the op amp. After connecting these to the function generator and oscilloscope, it should be verified that your gain is around 1100, as shown in the above image.
Build the Notch Filter
Build a notch filter in LTSpice using the above LTSpice schematic that is given. This can be verified by running the program and plotting the voltage of the output node. This should result in a cutoff frequency of about 60Hz. Once the numbers and circuit are verified on LTSpice, begin building it on the breadboard below the INA. Using the same columns from earlier, connect pin 4 on the op amp to the negative power supply and connect pin 7 to the positive supply.
Using the function generator and oscilloscope, test the output from pin 7 of the op amp. When the frequency is set to 60 Hz, the magnitude of the voltage should drop to 0 or very close to 0.
Build the Low-Pass Filter
Build a low-pass filter in LTSpice using the above schematic. This can be verified by running the program and plotting the voltage of the output node. This should result in a cutoff frequency of about 150Hz. Once this is confirmed, begin building the circuit on the breadboard below the notch filter. Using the same columns from earlier, connect pin 4 on the op amp to the negative power supply and connect pin 7 to the positive supply.
Using the function generator and oscilloscope, test the output from pin 7 of the op amp. The magnitude should begin decreasing as frequency in increased and should reach about 0.7*Max value when the frequency is set to 150Hz.
Connect the 3 Stages
To connect the three stages of the circuit, take the output from the INA (pin 7 on the op amp) and connect it to the input of the Notch Filter. Then, take the output from the Notch Filter (pin 7 on the op amp) and connect it to the input of the Low-Pass Filter.
In order to verify that the connections were made correctly, run a pulse from the function generator through the circuit. It should result in an image on the oscilloscope that is extremely similar to the one shown above.
Arduino
After obtaining the Arduino, hook up the connections based on the images above. The input should go into A0 and the ground is GND. Then, paste the following code into Arduino and run the code.
int UpperThreshold = 140; //Thresholding of where to read "beats" based on your signal input
int LowerThreshold = 160;
int reading = 0;
int BPM = 0;
bool IgnoreReading = false;
bool FirstPulseDetected = false;
unsigned long FirstPulseTime = 0;
unsigned long SecondPulseTime = 0;
unsigned long PulseInterval = 0;
void loop(){
reading = analogRead(A0);
// Heart beat leading edge detected.
if(reading > UpperThreshold && IgnoreReading == false){
if(FirstPulseDetected == false){
FirstPulseTime = millis();
FirstPulseDetected = true;
}
else{
SecondPulseTime = millis();
PulseInterval = SecondPulseTime - FirstPulseTime;
FirstPulseTime = SecondPulseTime;
}
IgnoreReading = true;
}
// Heart beat trailing edge detected.
if(reading < LowerThreshold && reading > 2){
IgnoreReading = false;
}
BPM = (1.0/PulseInterval) * 60.0 * 1000;
//Serial.println(A0);
Serial.print("BPM = ");
Serial.println(BPM);
delayMicroseconds(3900);
{
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue;{
// read the input on analog pin 0:
//int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
// print out the value you read:
Serial.println(voltage);
};
// print out the value you read:
Serial.println(voltage);
}
}