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!