231a-aj Project2More

From CSclasswiki
Jump to: navigation, search

Cyberpunk bracelet

Idea

The idea for the cyberpunk bracelet partly came from my contact Melissa Choyse. She wanted a costume piece that looked like a cybernetic arm from cyberpunk novels and at the same time did something. We discussed this for a while and came up with was a bracelet that light up a number of LEDs depending on your pulse. The original idea was to have a vibration sensor on the wrist to measure the pulse. But it was later discovered that an LED and an LDR might be a better choice for this.

To involve Assembly in an interesting way, I decided that the computer would record your preformance as well as do an on the fly testing against previous exercise rutines and what your pulse should not be above based on your weight and age. The user would have to enter this information before putting the bracelet on. If the wearers heartbeat goes above the recommended maximum for that particular weight and age, a LED on the bracelet will light up and warn the wearer of this.

The best would be if this could be wireless, but that require extra hardware such as a battery pack and bluetooth for the arduino.


Background

Pulse or more precisely heart rate is how many times your heart beats per minute. In a adult human the resting heart is somewhere between 60 and 100 beets per minute. The equation for the maximum heart rate is most commonly written as 220 - age.

Heart rate can be measured using a LED/LDR set up because the capillaries in the fingertip or the ear lobe expand or contract in time with the heart rate. The LED/LDR will see this as small but detectable differences in the skin contrast.

Links

Ideas for Design: LED/LDR heart rate monitor

Example of a heart rate monitor that uses the LED/LDR method

Heart Rate basics

Goal

  1. To make a low budget heart rate monitor that can easily be used in costumes
  2. Have some sort of visual feed back that can be worn together with the sensor
  3. Record the heart rate and compare against previous recordings and calculated estimates of the maximum heart rate.

Constrains

  1. Budget (Smith CS department are providing us with $20)
  2. Size (the bracelet can not be too big)
  3. Connection to computer
  4. Time (needs to be done and tested before 12/08)
  5. Sampling Frequency

Cost

Budget from Smith CS department: $20

Cost of hardware:

LDR (1) + shipping ~$6 ([http://www.bidflex.com/storefrontprofiles/processfeed.aspx?sfid=49414&i=238496182&mpid=120&dfid=1 Bidflex.com ])

LED (12) ~$2.50 (American Science and Surplus)

Wire(100ft way more than I need, anybody wanna team up?) ~$4 (American Science and Surplus)

Shipping from American Science and Surplus ~$6

Total: $18.50

Other things needed: 1 inch Piece of PVC tube - from the engineering workshop? Resistors - from the CS department?

Code

Assembly: Estimate the maximum heart rate based on the user's age. Compare the heart rate from the Arduino against this and previous testing. Send warning to the Arduino if the user is too close to the maximum heartrate and also how many of the 'lightshow' LEDs to light up at any point. Record the heart rate over the entire run.

Arduino: Take the input form the LDR and calculate the heart rate and pass this on to the Assembly. Run all the lightening up of the LEDs depending on feedback from the Assembly.

Hardware

The main part of hardware used in this project will be the Arduino. The Arduino board used is a Diecimila board.


Other hardware

The pulse sensor.

The implementation of this that seems to be the best for this experiment is one using a LED and a LDR. They are set up in the way of the picture below. 231a-aj HeMon2.jpg

(From the HeMon project by Keith Wilson) The part that would be implemented would be the part inside the blue box.

231a-aj fullschem.jpg

231a-aj schem1.jpg

(Slightly modified from Keith Wilson's schematics)

The light display

A series of LEDs, each lit individually. Each of them connects to a seperate pin on the arduino and to gnd.

231a-aj schem2.jpg

(from Limor's tutorials)

Testing of Hardware

First I tested the hardware to make sure it is all hooked up to the arduino correctly.

During testing I found that the best resistors to use was two 120Ohm in parallel for the high intensity LED and a 10K Ohm for the LDR. This gave a much brighter LED and much better numbers for the LDR (see calibration) I used a arduino sketch to test my hardware and it can be found here

What this sketch does is simply turn on the all the LEDs when the value the LDR reads is high.


Calibration

The main part of the calibration was about the calibrating the LDR to measure the heartbeat. As of today, 12/16/08, full calibration have yet to be obtained.

During testing we decided to go with a much higher resistor with the LDR, because we found that the LDR I am using at the best conditions I could create it had a resistance of ~40K Ohm. These conditions were blocking as much light as we could and measuring the voltage drop using an voltmeter. To even out the numbers a bit we went for a 10K ohm resistor..

The arduino project used to for calibration looks like this

Time: 1
Avg: 191
Max: 197
Min :187
 
Time: 3
Avg: 192
Max: 198
Min :188
 
Time: 4
Avg: 194
Max: 199
Min :190
 
Time: 6
Avg: 194
Max: 199
Min :190
 
Time: 7
Avg: 194
Max: 199
Min :190
 
Time: 9
Avg: 194
Max: 199
Min :190
 
Time: 10
Avg: 194
Max: 199
Min :191

As we can see here there clearly is some difference between the min, max and the average. However the numbers you get out running this sketch under different light conditions vary drastically. These numbers here were in a what I consider a decently lit room at night time, but they are still far lower than what I got when I ran the same sketch in day time. (the numbers then were in the 800 range). It also varies with how you hold your head and so on.

After much testing and discussion with D.Thiebaut I decided to let the calibration rest and instead work on my assembly program. Because of this the assembly program is using a fake heart beat

Software for the Final Presentation

finalProject.asm

serialFin.c

sketch.pde


Both serialFin and sketch are mostly code we have gotten in class, mainly from lab7, with some few things added on for this project.

finalProject is the main part of the project and where most of the sophisticated calculations are done.

Final Thoughts

This is just a prototype. There is still a bit left to go with this project, but for now I feel like I have accomplished a lot.

Much of the little details that were dropped where dropped due to time constraints.

The most challenging thing in this project is a toss up between calibration and working under time constraints. The calibration and building the hardware took up most of my time for the early part of the project, a large part of this was that I was really unsure what I was doing. Because of that I had very little time to write and debug my code, on top of this this happened on top of me also having to study for exams. For me the most challenging part was to be calm enough to actually work efficiently. There was also some challenges working with floating points.