Recently i made shield for arduino which can measure ECG, respiration, eventually after some changes in PCB and code, EEG and EMG. Big advantage of this shield is possibility to make it easily at home. The shield is equipped by display to show you measured signal real-time. Shield is based on AFE integrated circuit ADS1292R. You can use this shield for many application - acquiring your vital signs (or further operations with those signals - filtering, analysing etc.), modify shield for your own application, or just do it for fun with home PCB design and soldering:)
Important note:Don´t have your computer connected to the mains, when you acquire signal from anybody! This can´t be used as a diagnostic device, if you´ll see any abnormalities on your ECG its probably because me or you did some mistake during design this shield:)
- arduino UNO
- ECG arduino shield (instructions below)
- ECG cable (or any cable with crocodiles)
- ECG electrodes
- Display LCD 2.2" SPI 176x220 (e.g. https://github.com/Nkawu/TFT_22_ILI9225)
Step 1: PCB Design - ECG Shield
For design of PCB I used great freeware SW CircuitMaker. Advantage of CircuitMaker is that all released PCB design are freely available, so you can use scheme and PCB. I designed and modify it exaclty for your purposes or ideas. My PCB desing is available here http://circuitmaker.com/User/0FAA9686-2FCB-4D39-8F... . During PCB design i came out mostly from datasheet and user guide. PCB has prepared button and one programmable diode waiting for your ideas:)
What wasn´t best idea is connector for display. I draw some paths on top layer, so its really hard to solder those paths to connector, when you have 2 layers PCB made at home. I would recommend to change PCB design or to use some extension between top layer and connector. Other thing suitable for improving would be connector for ECG cables:) I solder ecg cable, but maybe somebody would prefer removable connector.
I tried to do PCB as simple as possible to allow make it at home. I did that one on picture on CNC but I am sure you can use some other way mentioned here on instructables. Of course, it would be much better for signal noise if it would have more layers but that wouldn´t be that much fun:)
If you decide to change PCB desing, really important thing is to preserve analog part of circuit as clean as possible, try to keep bottom part without any paths needed.
I attached gerber data I used for making PCB on CNC machine.
Step 2: Soldering
Soldering ADS1292R by hand could be quite tricky. If you solder ICs with that kind of package, its really important to prepare PCB properly. You should clean pads and put little solder on them. If you use lot of a solder wire you wont be able to solder all pins of ADS1292R. Most important part is placing IC exactly on pads. You can also use hot air to solder IC, but as you can see it can be done using soldering iron:) My recomendation is to start soldering with ADS1292R.
After soldering you should check that you have all pins soldered properly by magnifiying glass or USB microscope (I was almost sure that all pins are soldered properly but after seeing it in USB microscope there were 2 pins which weren´t attached to pads.)
Step 3: Programming ADS1292R With Arduino
During writing code i came out mostly from datasheet, also as an inspiration I used some things I found on GitHub and so on. I wrote code without using any libraries, because I know you can easily understood meaning of code when everything is written step by step. If you prefer well-arranged code, you can move lot of things to libraries. Some parts of code are referenced to datasheet page to better understood why there has to be that part. To better understanding of the code I strongly recommend you to read up all important part in datasheet ADS1292R (http://www.ti.com/lit/ds/symlink/ads1292.pdf).
The benefit of using ADS1292R is presence of testing circuits which can be programmably set up. I guess this should be your next step. If you can acquire square test circuit, you can be sure that your circuitry work well and you can communicate with ADS1292R. I would recommend you not to rely on showing test signal, and ECG signal on display and use e.g. Serial port (simply copy those data and display them in some SW). For setting up test signal you have to write to registers CONFIG2 value 0xA3 and to register CH2SET value 0x05. You can see video of test signal on display in attached files.
After you succesfully see test signal, you are ready for acquiring ECG signal.
I attached all code - with this code you can acquire, display, filter data (sorry for using that stupid variables:D)
Step 4: Acquiring ECG Signal
For acquiring ecg signal it is important to place electrodes on right place. You can find many literature eg http://www.nursecom.com/ECGprimer.pdf. To suppress noise in the signal, you can activate Right-Leg circuitry - see datasheet.
For acquiring your ecg you have to change CONFIG2 and CH2SET again to original values. Important thing is that using channel 2 for acquiring ECG is not coincidence. As you can see in datasheet channel 1 can be used for acquiring respiratory signal (and for that you have to use different capacitor that means you cant acquire ECG with channel 1), so use always channel 2 for ECG or solder proper capacitor to channel 1:)
You don´t have to use medical ECG cable as I did, but when I compared cable I used with unshielded cable with crocodiles, using ECG medical cable resulted in less noisy signal. I attached video where you can see acquired ECG signal.
I repeat my recommendation - as you can see there are no optical isolators in PCB so always unplug your computer from mains when using this shield for acquiring your vital signs.
Step 5: Signal Processing
As you can see on video the ECG signal is quite noisy. That is caused mainly because following reasons: I used only simple IIR filter with two coeficients. If you want get better results, you should use FIR filters and/or median or averaging filters. Other thing is that ADS1292R has stunning resolution (24bit) but if you want to display acquired signal to 176x220 pixels display, you are loosing like 99% of resolution - Also I used the simplest method to get into proper range of display (Subtraction and division). Other recommendation would be not to show every point of data as I did, but do an average of like 5 points and display it.
When you are into signal processing (filtering, QRS detector, heart rate monitoring) you won´t use display at all. Thing is that arduino is not exactly DSP so when you would like to do some processing, you should use more suitable SW like Matlab, or use DSP instead of Arduino. Combination of well-chosen filters in Matlab, acquiring signal with ADS1292R can result in that kind of ECG you are used to (as you can see on picture). I think this should be the main usage of this shield - further analysis of acquired signal. You can apply filters, algorithms you create on real data.
Step 6: Further Use of Shield
When you look to the datasheet you´ll find that acquiring ECG is not the only thing ADS1292R or its multi-channel version ADS1298R are suitable for. I am sure that when you modify PCB from circuitMaker just a little you will be able to acquire EEG and EMG signal as well. ADS1292R can acquire respiratory signal as well. When you change the code to activate channel 1, you should be able to read respiratory data. To be honest I wasn´t so fascinated by data I get. I am not sure whether it was caused by "home-made" PCB or some SW issue. Hopefully, you´ll get better results:)
On PCB you can also find button (pin A0) and programmable LED (pin D7). I did not find use for those but maybe you get more lucky:)
I really hope you will have fun with ECG arduino shield, and you´ll get me some feedback. Also if you would have any problem with realization of ECG arduino shield, don´t hesitate to contact me:)