June 3, 2014

Weekly Update #10: Project Presentation

Hello all,
With the term coming to an end, this post will the the last post detailing the progress of this project. In week ten's lab, we presented our project and prototype.

The device we made for this project is now complete. It reads through the user's heart rate, identifies the peaks of the QRS complexes in the ECG signals and from that, calculates the time between each heartbeat. By doing this, the device is able to detect abnormal rhythms in the user's heart and notify the user of such abnormalities. Improvements we've made since last week's project check include adding filtering and debugging the code we had for calculating the time between the peaks in the user's heart rate. We filtered the ECG signals by calculating a moving average of the data from the sensors. This smoothed out the data and helped to ensure more accurate readings.

Though we initially hoped to develop a smartphone application to go with the heart rate monitor, there wasn't enough time for that. Currently, the device is capable of communicating data over Bluetooth. So future work on this device includes developing an app that could send a distress signal to a user's physician or emergency medical services. The inspiration for this was the fact that text-to-911 is something that is expected to be in widespread use in the next few years. Other improvements that could be made include better filtering and using better sensors with more leads. This would improve the device's rhythm abnormality detections. More can be seen about this in our final report (found in the Reports and Documents page).

May 27, 2014

Weekly Update #9: Project Check

There was not much done in lab this week as this lab was spent tweaking things for the project check.

The results of the check has shown us that we need to put in code to filter the ECG signals and read and display heartbeats per minute of the user on the device. We also need to put together a presentation for week 10.

May 21, 2014

Weekly Update #8: Button and Filtering

Hello,
We hooked up the Bluetooth module again to allow the device to communicate with a smartphone or computer wirelessly. We also put a button on the device to act as a kill switch. The button currently restarts the device. We need to change this so that it just stops the functions of the device. Since this is not an integral part of the device, we aren't spending much time on it. Should it not work, it will just be left off of the final deliverable.

We worked on trying different ways to filter the signals as the sensors are not very accurate. We haven't found a way that works well enough to make us want to keep it in the program for the device. This is what most of the remaining time will be spent on with the project.

May 14, 2014

Weekly Update #7: Portability

Hi there,
In week seven's lab, we looked through more sample code to try to get a working program together. The sample code that came with the new sensor contained code for calculating peaks and troughs of a heart rate. We worked on incorporating that into our existing program.

We also decided to switch back to the sensor that straps onto both wrists and leg. While the new sensor seemed to work better in terms of signal clarity, it was too difficult to work with. The old sensor provided better mobility when it was worn and we felt more familiar with it.

We got antistatic bags this week, covered the device in them, and packaged the whole thing in a waist pack. The LCD module is mounted on the outside of the waist pack so the user can see the status of their heart rate. The way that the device is placed in the waist pack also lets the user plug it into a computer without having to open the main pocket.

In the next couple of weeks we hope to complete the program and get the device to detect abnormalities in the user's heart rate. We're also working on a presentation and the final report for week ten.

Project Timeline

Hello all, 
This post is a summary of our progress on the project so far and what we plan to do in the few weeks that remain in this term. 


Weeks 1 - 4 | Literature study and electrical design
In the first four weeks, we focused on learning about how the Arduino works and how everything connects to the Arduino board. We started plugging in all of the components into the Arduino and managed to get each piece working. This included figuring out how the Arduino outputted data from the sensors and getting it to do this through the LCD module. Most of this was done with the help of online sources which can be found in the "Tutorials and Sources" page.

Weeks 4 - 7 | Electrical design and Arduino programming
We connected the Bluetooth module to the Arduino at the end of week four and got the device to output data to a smartphone over Bluetooth connection. A new sensor was also tested out in week six. It was during this time that code was starting to be written for the device. We managed to get the device to detect when there is no heart rate, but there is not yet code for the detection of an irregular heart rate. The sample code that came with the new sensor included code for the calculation of peaks and troughs in a heart rate. We are currently working on using this code to get the device to detect an irregular heart rate. A draft of the final report was written at the end of week six and can be found in the "Reports and Documents" page.

Weeks 7 - 10 | Finishing up and writing the final report
In the last few weeks left in the term, we hope to fix up the code for the detection of irregularities in a heart rate. We also need to work on putting the device together in a way that is portable. The draft of the final report has to be adjusted to include the activities done since week six. And a presentation has to be made.

May 13, 2014

Project Budget

Hello,
This post is just going to be the breakdown of the costs of the project.


Arduino
This category consisted of only the Arduino Uno board which we are using to record and analyze data from the sensors

Sensors
The sensor used was a small pulse sensor that clips onto the user's ear. More details on this sensor can be seen on our week six blog post. We also tested out a sensor that strapped onto the user's arms and legs. Each of the sensors cost about $25, but only one was used in the final design so only one's cost was factored into the budget. 

Connectivity
We used a HC-06 Bluetooth module to allow the device to connect to smartphones and computers wirelessly. 

Peripherals
Since the main purpose of the project was to notify users of heart rate abnormalities, we needed a way to convey an alert message to a user. We used a LCD display module and a simple speaker for this. 

Miscellaneous
This category included all the wires and the breadboard used to connect all of the components. We also bought a pack of switches for the kill-switch function on the device. Since the device is meant to be carried around, we needed a rechargeable battery pack to keep the device wireless. We also got antistatic bags to protect the device when the user is wearing it. Mike's dad was kind enough to give our group a waist pack (fanny pack) to carry our device around in. 

May 6, 2014

Weekly Update #6: New Sensor

Hello all!

We got a new ECG sensor to play with this week. The new sensor can be worn on the fingertip or clipped onto someone's earlobe. The signal from the new sensor is clearer than the signals we were working with before. After connecting the new sensor, we worked on filtering the signals we got from it. The signals we got from the new sensor were erratic and all over the place at first. After we wrote code to filter the signals, the new sensor worked better than the previous one we used in terms of portability and signal clarity. We are now looking through the software that came with the new pulse sensor to find a way to calculate the peaks and troughs of the signals.



We also started writing the final report draft in lab. We hope to finish the report and have the heart monitor able to find the peaks and lows of a heart rate by the end of this week. If we have time this week, we will work on the app and get the device to detect irregularities in a user's heart rate.

April 30, 2014

Weekly Update #5: Fixing the Week 4 Code

Hi there,

Week five of the project has just started, but we've made a lot of progress with the heart monitor. We worked on the code that previously crashed the device and got it stop overloading the Arduino. Mike pinpointed the section of the code that caused the failure and fixed how the Arduino was storing and processing data.

Before the code was fixed, the Arduino was storing data in an array. It was constantly moving every value in the array up a position in the array and adding a new value to the end of the array. It was trying to do this over a hundred times per second. The code now has the Arduino processing just one data point at a time, lessening the load on the device.

So far, the Arduino can detect when there is an absence of the wearer's heart rate. When we tested the device, sudden removal of the sensors resulted in the notification sounds and message to go off. The device can't detect an irregularity in the wearer's heart rate yet. There has been code written for it, but it doesn't work quite right. Hopefully, it will be worked out in week six. We are also going to be working on the cell phone app in week six.

April 25, 2014

Some Technical Stuff: Fun with Bluetooth

Hi everyone,

Since I recently got Bluetooth communication working with the Arduino board, I'll be sharing the details of my progress. Before sending any data over a Bluetooth connection, I first had to connect the Bluetooth module to the board. A quick Google search brought me to a tutorial (http://makezine.com/projects/connect-an-arduino-to-a-7-bluetooth-serial-module/), which explained that digital pins 0 and 1 on the Arduino correspond to TX and RX (transmit and receive), respectively. This meant that, with the corresponding pins on the Bluetooth module connected to the board, the data sent over a USB connection would be the same as that sent over a Bluetooth connection. Therefore, using Serial.print() within the code would send the same data over both types of connection.

Here's a diagram of how the Bluetooth module was wired:

Now, after powering the Arduino, the LED on the Bluetooth module started flashing, indicating that it was receiving power. I then attempted to connect to the device using my computer's Bluetooth connection. It quickly located the device, and was able to establish a connection.

Using the Tera Term software (available at http://ttssh2.sourceforge.jp/index.html.en), I attempted to receive data from the Arduino (which would simply be the ECG data that I had set up earlier to be sent over the USB connection). Instead, the terminal simply showed a jumble of random characters.

Another trip to Google revealed a manual for the HC-06 Bluetooth module that we are using (http://makezineblog.files.wordpress.com/2014/03/hc_hc-05-user-instructions-bluetooth.pdf). Reading through, I saw that the default rate of communication for the module is 9600 baud (or symbols per second). In the code, the value for serial communication had originally been set to 57600 baud, using Serial.begin(57600). I changed this value, re-ran the software, and finally got the same output I had been receiving with the serial monitor in the Arduino software.

The next step was to see if this same output could be communicated to a smartphone. Searching through the Google Play Store revealed an application called "Android Bluetooth Terminal," which I determined would be sufficient for testing purposes (app available here: https://play.google.com/store/apps/details?id=arduino.bluetooth.terminal). I connected to the device using my phone's Bluetooth connection, ran the app, and successfully received the output.

Now that the device is set up to send a Bluetooth signal to a smartphone, development of the Android application can begin. Before getting started on this, however, the group plans to first complete an initial version of an algorithm for detecting irregularities in the ECG signal. This is already in progress, so look forward to my upcoming post detailing the specifics of the math and programming that are going into it.

Anyway, that's all I've got for now!

April 23, 2014

Weekly Update #4: Bluetooth & Analyzing Heart Rate

Hello all,

During our fourth week lab meeting, we managed to connect the Bluetooth module and transmit data from the Arduino to both a computer and a cell phone using the wireless connection. The data we got on the computer through USB was the same as the data we get now through bluetooth. The device can now be connected to either a computer or a cell phone. The data output can be seen on a cell phone with an "Arduino Android Terminal" app we found on the Google Play Store.


With the Bluetooth module connected, we started working on a way for the device to detect irregularities in a user's heart rate. We used the math we worked out in week three to write code for the device to run through data and find any deviations. We started by writing some pseudocode.


Currently, when the code is run, it stops the device from working. We think it may cause the device to calculate too many things at once. We will work on this in week five and hopefully have a working program for the heart monitor by week six.

April 15, 2014

Weekly Update #3: Planning for Data Analysis

Hi there everyone,

Week three of our project has come to a close, so here's some of the stuff we got done in the past week. Hardware assembly is nearing completion, as we have connected the LCD display, speaker, and ECG shield. The only things left to connect to the device are the Bluetooth module and a kill switch. This is next up on the task list for our group in terms of hardware.

This is our heart monitor device so far:


We exported data from the device into Microsoft Excel to create a spreadsheet and graph of the electrical signals.


We are now looking into ways to analyze the data to find irregularities. To start, we are using one set of data (about a thousand data points) and doing statistical calculations by hand and with Excel. We need to find ways to calculate the average middle, peak, lows, and time between peaks in the data.

Week three has been a bit slow compared to previous weeks, but look forward to our progress!

April 11, 2014

Some Technical Stuff: ECG Shield and Peripherals

Hi everyone!

In taking the lead role in hardware assembly and programming for the ECG device, I'm going to mostly be talking in more technical terms and discussing specifics.

Anyway, after receiving the initial order of parts, I quickly got to work by attaching the ECG shield to the Arduino board. I looked through the shield's manual, loaded the manufacturer's sample code onto the Arduino, and ran their PC software to analyze the output from the shield with the probes attached to myself (documentation, sample code, and ElectricGuru software can all be found at https://www.olimex.com/Products/Duino/Shields/SHIELD-EKG-EMG/).



With the Arduino connected to my computer, I was able to identify a regular heartbeat. This indicated that the shield and probes were functioning properly.

I then decided it was time to connect the LCD screen to the Arduino board. This was to be done using the breadboard and the wires included with it. I quickly realized, however, that the LCD did not have pins attached to it. This resulted in a trip to the local RadioShack, where I obtained soldering tools. I soldered the 16 leads of the LCD to the pins it came with, and then wired it to the Arduino with the assistance of an online tutorial (http://arduino.cc/en/Tutorial/LiquidCrystal). Deviating slightly from the guide, I decided to forego using a potentiometer (which allows for control of the display's contrast) and wired two additional pins to allow for the screen's backlight to be powered. I soon was able to write a "hello world" program (as demonstrated in the tutorial), and show my own output on the display.

At this point, I decided that I needed to understand how the shield outputted data. Searching the internet, I found a very useful post on the shield manufacturer's forums (https://www.olimex.com/forum/index.php?topic=572.0#msg2180). The user Stan12, providing sample code, demonstrated usage of the analogRead() function. Using this, I was able to have the Arduino output a value of 0-1023 (based on electrical signal) over the serial port. I then had the Arduino software's serial monitor receive this data, and exported it to Microsoft Excel to create a graph.


This graph resembles a normal heartbeat, like the one obtained using the ElectricGuru software earlier. This indicates that the numeric output reflects the user's heartbeat.

Now, for debugging purposes, I used the analogRead() function along with the print() function to create a live output of the numeric value outputted by the ECG shield onto the LCD. Of course, the rate at which the shield outputs numbers is much faster than the refresh rate of the LCD, so the number on the screen updates very rapidly - faster than one can read it. However, by lowering the sampling frequency within the code, the number on the LCD becomes human-readable (although making the ECG's outputted data less accurate).


Playing around a bit more with the LCD, I also coded a loading/splash screen that displays while the device is starting up.


Finally, since our finished monitor will feature, in addition to Android device communication (a time permitting feature), both audio and visual notification of irregular heartbeat, we needed a way for it to create sound. Enter: the speaker. I connected the speaker we had ordered on Amazon to the Arduino board, and attempted to use the tone() function to create a beep sound. Initial attempts at this failed, and the speaker produced no sound no matter how I changed the code or wiring. I began to suspect a defective speaker, and took another walk to RadioShack to purchase another. Lo and behold, after attaching the new speaker to the breadboard and running my code, there was sound!

I decided to play around with the tone() function a bit, and got the device to play a familiar sound.


Anyway, that's it for now. Next up from me will be discussion about code for detecting an irregular heartbeat, starting to write the Android application, and Bluetooth communication between the devices.

April 9, 2014

Weekly Update #2: Hardware Assembly

Hello, all!

In the second week of our project, we focused on putting together all the parts we got for the ECG device.

We connected the ECG shield to the Arduino board, and using the manufacturer's sample code and software, we could detect a regular heartbeat and display it on a computer.


The software provided with the ECG shield gave us a way to check that the sensors worked and would give us useful data output. The end goal of this project is to make a device that can detect irregularities in a person's heartbeat. To do this, we needed to output the data in numbers so that code can be written to analyze it to find any patterns that are out of place. We found out how to use the analogRead() function to get the Arduino to output a number between 0 and 1023 based on an electrical signal.

The main function of our device is to let a user know about possible irregularities in their heart rate. We decided that a monitor and a speaker would be our best choices in notifying the user. An LCD display module was hooked up to the board; we got it display a splash screen and a live output of the electrical signal that the sensors picked up. The buzzer was tested by programming the Arduino to play the NBC chimes. We did this by finding the three notes (G3, E4, and C4) and translating these to frequencies (196, 329.63, and 261.63 Hz respectively) that the device can understand.


We also played around with LEDs. In an attempt to attach LEDs onto the board, someone forgot a resistor and blew up one of the lights. A couple others were shorted. We started with 60 LEDs and are now down to 57.


That's all for our week two activities and progress.

April 1, 2014

Weekly Update #1: Assembling the Pieces

Hello there, this is Steven!

A Little About Us
We are a group of three Drexel University first-year engineering students. Mike is a computer engineering student, while Kat and myself are in materials science and engineering.

This blog's purpose is to report and inform anyone interested on what we're doing in our freshman engineering design lab.

The Project
The task given to our group is to create a wearable ECG monitor using Arduino technology to measure and record heart rate.

Our idea is to have the heart rate monitor interface with the user's smartphone via Bluetooth, becoming capable of not only informing the wearer of any irregularities in heartbeat but also call the police if the signal is ignored for an extended period of time, which would potentially imply distress and distraction while wearing the heart monitor.

Materials Gathered
By the end of week one, we have collected a few of the necessary parts including an Arduino Uno board, an Arduino-compatible EKG shield, wearable electrodes, a blue 16x2 backlit LCD display, a Bluetooth wireless transceiver, a breadboard for the electronics, a small Arduino speaker, and a set of buttons.

EKG Wearable Electrodes
EKG Arduino-Compatible Shield

Bluetooth Transceiver
16x2 Blue-Black LED Screen



Buttons!
Breadboard and Pins




The blog will be updated with basic facts and information about our work, information about the group members, and other fun things as time passes.

This has been Update #1, look forward to our progress!