Breadboard ECG

by katrielle in Circuits > Sensors

1815 Views, 3 Favorites, 0 Comments

Breadboard ECG

Final ECG wave.jpg

Welcome to our awesome Instructable, where you will learn how to create an ECG on a breadboard using simple circuitry! This ECG is made up of 3 parts: an instrumentational amplifier, a low pass filter and a notch filter. To begin you simply need a computer, a breadboard, an oscilloscope, a power source, two 9 Volt batteries and an assortment of wires, resistors, capacitors and op-amps.

Supplies

- Breadboard

- Miscellaneous assortment of wires

- Assortment of different resistors

- Five op-amps

- Two 0.1 microfarad capacitors

- One 0.2 microfarad capacitor (can also use 2 .1 microfarad capacitors in parallel)

- One 33.3 nanofarad capacitor

- One 68 nanofarad capacitor

- Two 9V batteries

- Oscilloscope

- Power supply

- Computer

- Three ECG leads and patches

- An arduino (for the optional part)

Create Your Simulations

INA amp.jpg
Low pass filter diagram.jpg
Notch filter diagram.jpg

To start building your ECG, the first (and very important) step is to create simulations of the components of it. As previously mentioned, an ECG is made up of three components: an instrumentational amplifier (INA), low pass filter and notch filter. A simulation needs to be made for each component so that the components can then easily be built irl.

The circuit modeling software that we used is LTSpice. This is very handy for quickly making circuits online and simulating their output. If you are new to LTSpice, I recommend doing a quick google search to find the software, and possibly watching some youtube videos to find how to use it. It's pretty simple, and you'll be simulating your own circuits in no time!

The final circuit diagrams for LTSpice are shown above, with the expected output. Once you create the circuit you can run a 'decades sweep', which will test the circuit at range of different frequencies, allowing us to see the circuit's frequency dependent response. It is important to make sure that each simulation is working as expected before moving on to building the actual circuit.

Simulating Your INA Amplifier

INA amp.jpg

Again, simulating the circuit components is a very important part, because once you know that they're built right virtually you can just connect components in real life! The first component that we made was an instrumentational amplifier. This component takes the signal sent from your heart and amplifies it to an amplitude big enough to be visualized on an oscilloscope or computer. The INA that we used has a gain of x1000, so the amplitude of a signal input into it will be muiltiplied by a thousand, up to a maximum and minimum value determined by the V+ and V- voltages input into the op-amp.

Create Your Notch Filter Simulation

Notch filter diagram.jpg
ECG with components labeled.jpg

The next step is to create a simulation for your Notch filter. This Notch filter filters out signals at a frequency of 60 Hz, while letting other frequencies pass. This is important because 60 Hz frequencies are a common source of interference, as a 60 Hz frequency comes from your power lines. You don't want any interference due to power sources messing with your final results!

Create Your Low-Pass Filter Simulation

Low pass filter diagram.jpg

Finally, a low pass filter is needed to only let smaller frequencies through. This is because the frequency coming from your heart is low - if your heart beats at 60 beats per minute, that's one beat per second, or 1 Hz! The low pass filter gets rid of any high frequencies so that only the lower ones that are relevant are displayed. Our low pass filter shown above has a cutoff frequency of 150 Hz.

Make Your Circuit Components!

ECG with components labeled.jpg

Now that you're (finally) done simultating your circuit components, you can start building your ECG! Follow your circuit diagram and build each component separately on your breadboard. Once you've done this we suggest testing each component of your circuit to make sure that it does what you expect it to.

For the low pass filter:

Try a few lower frequencies and a few higher frequencies, and a lot of frequencies around your cutoff frequency (150 Hz). To make sure that it's working you can graph the output voltage divided by the input voltage against the frequency in excel. The graph should look similar to the one output in LTSpice!

For the instrumentational amplifier:

Be sure to connect 9 V batteries to the V+ and V- terminals to create the amplification effect! Then you can input a sine wave to the INA from a function generator and check to make sure that the amplitude of the sine wave is increasing by a factor of around a thousand (up to 9 Volts)

For the notch filter:

Test your notch filter at different frequencies to make sure that it only gets rid of the 60 Hz frequency and lets the others pass. We suggest testing a few low and high frequencies, and a lot around 60 Hz. You can graph the output voltage divided by the input voltage against the frequency in excel to visually check that it's working correctly.

Put It All Together

ECG with connections labeled.jpg

This step's the really easy part! After you're done with the individual testing and know that each component of your circuit works, take the output from your INA and set it as the input to your Notch filter. Once you've done that take the output from your Notch filter and set it as the input to your Low pass filter. The output from your Low pass filter will be the final output that you can visualize either with an oscilloscope or through an arduino (using an arduino is really tricky though and we do not recommend it).

See Your ECG!

Final ECG wave.jpg

Last step! (Unless you want to use the Arduino, but still, exciting)

Take three patches and stick them to both of your ankles and your right arm. Then take an lead wire and connect it to your right ankle. Use an alligator clip and connect the other end of the lead wire to the ground on your circuit. This will let your reference point be the voltage from your right ankle. Next, take a lead wire and connect it to your left ankle. This will be your positive electrode, and can be input to one of your input op-amps on your INA filter. Your final lead wire connects to your right wrist, which is your negative electrode. You then connect the lead wire to your other input op-amp on the INA filter.

If you forget which of the two input op-amps the positive and negative lead wires go to you can either try to figure it out from your circuit diagram or just guess. If you guess wrong the waves on the ECG will be upside down - just switch which op-amp you send each input to and it'll be fixed!

Shown above is my ECG, ran through our circuit!

Full Set Up

ECG

Here's a short video showing our set up! Because I moved my phone to record the video I wasn't staying still, so the ECG readout isn't perfect. A better example of our final ECG readout is the picture shown in the previous step, which is from the same set up but taken by my lab partner while I was holding still :)

Optional Step: Visualize on an Arduino

Arduino Code 1.jpg
Arduino Code 2.jpg
Arduino Code 3.jpg

This is an optional step because, full disclosure, we didn't get the Arduinos to work with our ECG signal. They work in theory.....yeah. To test whether or not your Arduino is working, hook it up to a function generator and run a simulated ECG signal through it. The input to your Arduino should go to pin A0 and make sure to ground it using the ground pin. Use a frequency of 1.2 Hz, which corresponds to a heartbeat of 72 beats per minute. Set the voltage amplitude to be around 1 Volt - although the amplitude from a real heartbeat is a lot smaller, remember that you're just testing using the function generator and so not amplifying your signal with the INA. Finally, plug your Arduino into your computer.

Using the code above, you should be able to see an ECG and a BPM readout! If you want, you can try to hook it up to yourself and visualize your ECG on the comforts of your own computer.

Also, here's the code if you want to look at it not in picture form:

int UpperThreshold = 50; //Thresholding of where to read "beats" based on your signal input
int LowerThreshold = 90; 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 setup(){ Serial.begin(9600); }

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); } }