Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
test-and-measurement:analog-discovery-studio:ecg-demo:start [2022/09/12 19:56] – changed forum.digilentinc.com to forum.digilent.com, and some type-o's Jeffrey | test-and-measurement:analog-discovery-studio:ecg-demo:start [2024/04/16 21:00] (current) – title case Arthur Brown | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== DIY ECG with Analog Discovery Studio and LabVIEW ====== | ||
+ | {{ reference: | ||
+ | **Note:** //This is NOT a medical device. Should be used for educational purposes only.// | ||
+ | ---- | ||
+ | ===== Overview ===== | ||
+ | <WRAP group> | ||
+ | This demo uses the Analog Discovery Studio' | ||
+ | </ | ||
+ | ---- | ||
+ | |||
+ | ===== Inventory ===== | ||
+ | === Software === | ||
+ | <WRAP group> | ||
+ | * A computer with the latest version of [[software: | ||
+ | * WaveForms VIs (check this guide: [[test-and-measurement: | ||
+ | * [[https:// | ||
+ | * {{ reference: | ||
+ | </ | ||
+ | |||
+ | === Hardware === | ||
+ | <WRAP group> | ||
+ | * [[https:// | ||
+ | * Analog parts and wires (all found in the [[https:// | ||
+ | * 1 x [[https:// | ||
+ | * 2 x [[https:// | ||
+ | * 1 x 47 nF capacitor (473) | ||
+ | * 4 x 4.7 KΩ resistor (yellow-purple-red-gold) | ||
+ | * 1 x 10 KΩ resistor (brown-black-orange-gold) | ||
+ | * 2 x 20 KΩ resistor (red-black-orange-gold) | ||
+ | * 3 x 100 KΩ resistor (brown-black-yellow-gold) | ||
+ | * 1 x 150 KΩ resistor (brown-green-yellow-gold) | ||
+ | * 2 x 470 KΩ resistor (yellow-purple-yellow-gold) | ||
+ | * Jumper wires | ||
+ | * 3 x Alligator clips | ||
+ | * 3 x Surface electrodes | ||
+ | |||
+ | **Note:** //The ECG design can still be viewed and run in software without all of the hardware, through the use of an imported data file. See //Testing Without External Circuitry//, | ||
+ | </ | ||
+ | ---- | ||
+ | |||
+ | ===== Setup and Use Instructions ===== | ||
+ | |||
+ | ==== Circuit Setup ==== | ||
+ | <WRAP group> | ||
+ | This section will go through each stage of the ECG circuit. There is a diagram of the completed circuit, as well as a wiring diagram made in Fritzing, at the last step, if you wish to skip to that step. | ||
+ | </ | ||
+ | |||
+ | <WRAP group> | ||
+ | === Building the Amplifier Circuit === | ||
+ | <WRAP column half> | ||
+ | The amplitude of the potential difference on the skin is just in the millivolt or microvolt range, so it has to be amplified. To amplify the signal an instrumentation amplifier is built using OP482. The gain is set to 500 (A = (1 + 2 * R2/R1) * R3/R4). The **+** input should be connected to the right leg, above the ankle, the **-** input to the right hand, on the wrist. Between the surface electrodes and the inputs of the instrumentation amplifier 100 kΩ resistors are connected to limit any current circulating towards the body (in case of faulty operation). | ||
+ | </ | ||
+ | {{ reference: | ||
+ | </ | ||
+ | <WRAP group>< | ||
+ | The output of the amplifier can be visualized with the help of the // | ||
+ | </ | ||
+ | {{ reference: | ||
+ | </ | ||
+ | |||
+ | <WRAP group> | ||
+ | === Filtering Out the Common Mode Signal === | ||
+ | <WRAP column half> | ||
+ | It can be seen, that the measured signal is too noisy, the heart signal can't be recognized. To correct this, the common mode signal from the output of the first amplifier stage is amplified and inverted using the fourth operational amplifier in OP 482 (A = - R6/R5). The amplified and inverted common mode signal (**G**) is connected to a current limiting resistor, then to the left wrist. Two antiparallel diodes are connected between the **G** surface electrode and the device' | ||
+ | </ | ||
+ | {{ reference: | ||
+ | </ | ||
+ | <WRAP group>< | ||
+ | The signal becomes periodic and less noisy, but it has a large offset. | ||
+ | </ | ||
+ | {{ reference: | ||
+ | </ | ||
+ | |||
+ | <WRAP group> | ||
+ | === Eliminating the DC Component === | ||
+ | <WRAP column half> | ||
+ | The offset of the signal can be easily eliminated using a small decoupling capacitor between the output of the instrumentation amplifier and the oscilloscope probe. | ||
+ | </ | ||
+ | {{ reference: | ||
+ | </ | ||
+ | <WRAP group>< | ||
+ | On the power spectrum of the signal the DC component disappears. As the 50 Hz sine signal from the mains can be found on the skin, high power spectral components appear at multiples of 50 Hz. However, these can be eliminated easier using high order digital filters in LabVIEW, than with analog filters. | ||
+ | </ | ||
+ | {{ reference: | ||
+ | </ | ||
+ | |||
+ | <WRAP group> | ||
+ | === Wiring diagram in Fritzing === | ||
+ | <WRAP column half> | ||
+ | In the picture to the right, the wiring diagram of the same circuit is presented, but built in Fritzing, in case that is easier to follow. | ||
+ | </ | ||
+ | {{ reference: | ||
+ | </ | ||
+ | ---- | ||
+ | |||
+ | ==== User Interface ==== | ||
+ | <WRAP group>< | ||
+ | Download, unzip and open the ECG VI attached at [[# | ||
+ | |||
+ | Below the control elements, a plot pane is placed, where the electrocardiograph signal is displayed. Below the plot pane, a slider and a numeric indicator shows the calculated heart rate, the slider being green when the heart rate is considered normal (between 50 and 100 bpm) and red otherwise. On the right part, a column is placed, where all the data acquired from the ECG feature extractor block is displayed (see: [[http:// | ||
+ | </ | ||
+ | {{ reference: | ||
+ | </ | ||
+ | ---- | ||
+ | |||
+ | ==== Data Flow ==== | ||
+ | === Data Aquisition === | ||
+ | <WRAP group>< | ||
+ | The block diagram of the ECG VI is divided at six parts with different decorational elements and structures. The first two parts are responsible for initializing the // | ||
+ | |||
+ | Acquisition mode of the scope is set to sampling with a 1000 sample rate for the time specified with the help of the control element on the front panel. After the initialization, | ||
+ | </ | ||
+ | {{ reference: | ||
+ | </ | ||
+ | |||
+ | === Postprocessing === | ||
+ | <WRAP group>< | ||
+ | The acquired signal is still as noisy as seen on the // | ||
+ | |||
+ | After proper filtering, the maximum point of the data set is acquired and, with a peak detector, all the data points above 75% of this maximum and 10 ms wide are found (the P - preceding QRS - and T - proceeding QRS - signals of the should not reach that amplitude). The location of these points are multiplied with the time derivative of the signal and summed with the starting time to get the exact time of each peak. Time between two consecutive peaks is calculated and converted to frequency, then multiplied with 60 to get the number of beats (peaks) per minute. | ||
+ | </ | ||
+ | {{ reference: | ||
+ | </ | ||
+ | |||
+ | === Results and Cleanup === | ||
+ | <WRAP group>< | ||
+ | The filtered signal is connected to the plot pane and to the ECG feature extractor to visualize the signal itself as well as the data about it. The calculated heart rate is also visualized with the help of the slider, but also evaluated and if it is lower than 50 bpm, or higher than 100 bpm, the fill color of the slider is changed to red (otherwise it is green). | ||
+ | |||
+ | The while loop is exited only if the stop button is pressed or if there is an error, but in both cases the current data acquisition is finished first. After exiting the loop, the // | ||
+ | </ | ||
+ | {{ reference: | ||
+ | </ | ||
+ | ---- | ||
+ | |||
+ | ==== Testing ==== | ||
+ | <WRAP group>< | ||
+ | To test the device, build the circuit on the Breadboard Canvas, turn on the Analog Discovery Studio and connect it to a PC. Open the ECG VI. Place one surface electrode on the inner side of your left wrist, one on the inner side of your right wrist and one on the inner side of your right ankle. With the alligator clips, connect the circuit to the electrodes, as shown in the image to the right. Start the VI with the play button. If you stay still for a few seconds, you will see on the plot pane your ECG signal and the estimated heart rate. | ||
+ | </ | ||
+ | {{ reference: | ||
+ | </ | ||
+ | {{ reference: | ||
+ | </ | ||
+ | |||
+ | --> Testing Without External Circuitry # | ||
+ | <WRAP group>< | ||
+ | If you don't have the necessary hardware for this project, you can still test the VI, using Analog Discovery Studio and an other Test and Measurement Device (called transmitter in the following). Connect the transmitter' | ||
+ | </ | ||
+ | {{ reference: | ||
+ | </ | ||
+ | <-- | ||
+ | ---- | ||
+ | |||
+ | ===== References ===== | ||
+ | <WRAP group> | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | </ | ||
+ | ---- | ||
+ | |||
+ | ===== Final Notes ===== | ||
+ | For more guides and example projects for your Analog Discovery Studio, please visit its [[test-and-measurement: | ||
+ | |||
+ | For more information about how to use the software featured in this demo, please visit its respective guide: [[test-and-measurement: | ||
+ | |||
+ | For technical support, please visit the [[https:// | ||
+ | |||
+ | {{tag> |