Introduction: Pulse of the City

About: I run Neal's CNC in Hayward, CA, an expert CNC cutting and fabrication service, easily findable by Google search. I'm a founding member of Noisebridge, a hackerspace in San Francisco, and Ace Makerspace (forme…
My friend George Zisiadis was heading up an interesting project for the UP! Urban Prototyping Festival last fall.  He and another friend, Matt Ligon, were working on a circuit to sense a user's pulse, and translate it into music.  They wanted a beautiful and user friendly case for the electronics and sensors, and asked me to help.  After a couple of meetings and discussions, and moving from a fingertip sensor to one that requires both hands to grip it, we ended up with this.

Update: Some excellent people in Bristol, UK, built a similar device inspired by this one.  Check theirs out, it is gorgeous.

Here's how we built ours.

Step 1: Sensing the User's Pulse

Background

The core of this project is to reliably detect a user's heartrate.  The method used by PotC is through a simple EKG or Electrocardiogram.  The EKG works on the principle that the heart's electrical activity can be detected through measuring voltage differences produced across the body.  A medical EKG uses many measurement points, but our system will rely on only two, the voltage between the left and right hands.

This two lead EKG is the basis behind common consumer heart rate measuring devices such as those used on treadmills, which embed the sensors in the treadmill rails.  There are also pulse sensing watches where the user wears the watch on one wrist, and must touch a pad on the watch with their other hand to complete the measurement.

Performing a reliable EKG measurement is in practice quite difficult to do under uncontrolled conditions.  In a medical EKG, the leads have a good electrical connection to the body through the use of conductive gel.  In the pulse sensors used in exercise equipment, the measurement is made much easier due to the fact that the user is sweaty and has a heart that is beating strongly.

The voltage produced across the heart is very small, and the body and equipment will pickup interference from ambient EMI, mostly from emitters like power lines and fluorescent lights.  The signal must be heavily filtered in order to get a signal that can be used reliably to measure heartrate.

The PotC team decided to base the project on the "Olimex MOD-EKG" development board.  This is an inexpensive development board that is based on a Texas Instruments design which was developed as an application example for their MSP430 microcontroller.  The dev board utilizes the built in op-amps of the MSP430 to condition the signal, and performes digital filtering on the signal to reduce interfering signals.

Phew, ok anyway to make a long story short, it's quite a pain to reliably measure pulse.  I'd like to try some alternative boards to compare.  Since this thing was really designed to be an example for the microcontroller, I'm inclined to think that the analog front end could have been more sophisticated. 

Connections to the MOD-EKG

We need to make some connections to the MOD-EKG as well as modify the code that comes with it.  The software is included in this instructable. 

Links to Useful Documentation:
MOD-EKG Documentation
TI App Note (The MOD-EKG is based off of this)

1. Power Wires
The MOD-EKG runs of of 3.3V.  I soldered some speaker wire to the power pins of the mod EKG.  These will get soldered to the 3.3V regulated supply on the Arduino

2. Sensor Leads
These are the wires that connect the sensor pads on the MOD-EKG to the copper handles.  The system is very sensitive to interference so I cut up an old USB cable to use for this connection.  A USB cable has a nice shield that helps prevent interfering fields from generating signals on the lines.  The shield should be connected to the ground of the circuit board.

3.  Signal Leads
There are two signal wires that indicate pulse information to the arduino. 

One is the contact indicator.  It goes logic high when contact is detected (the user grabs the handles).  The way this works is that the noise level increases when the user grabs the handles and if the noise is above a certain threshold, then the contact indicator signal is held high. 

The other is the pulse indicator signal.  I spent a decent amount of time messing with serial I/O before I decided to just make a bit that flips every time a pulse is detected.  This prevented me from having to make the MOD-EKG and the Arduino talk over serial which was giving me a bit of a headache with a deadline fast approaching so I took the lazy way out. 

Step 2: Electronics

The guts of Pulse of the City perform the following functions
1.  Records the users heartrate
2.  Indicates that the pulse is being sensed
3.  Visually displays flashing light to the users's pulse
4.  Generates Music in time with the pulse

Bill of Materials

Microcontroller/Programmer
Olimex MOD-EKG
MSP430 JTAG Programmer
Arduino Mega 2560 R3

Audio
Audio Amplifier
Fluxamasynth Shield
Speaker

Lighting:
Total Control Lighting Simple Shield
Total Control Lighting Pixel Strand

Power
5V Li-Ion Battery Pack
Battery Pack Charger

Step 3: Producing Light

The indicator LEDs on the front of the unit have three different patterns.

1.  Waiting
The LEDs are white and fade slowly in and out

2.  Recording
When contact is detected, the system records pulse times for 8 seconds.  The lights incrementally turn on from bottom to top.

3.  Playing
The lights flash with the heartbeat of the user

The LEDs used for this project is a product called Total Control Lighting.  Each of the RGB LEDs in the strip is individually addressable so we can produce arbitrary displays with them. 

The system works through a communications prototcal called SPI.  The product shown in the picture is the Total Control Lighting shield which is an arduino shield that connects the arduino SPI lines and power to the LED strip.  It turns out that the Arduino Mega 2650 that I used has its SPI lines on different pins than a standard Arduino so I ended up having to solder wires between them. 

TCL Shield <-> Arduino Mega 2650
SPI Lines
11 -> 51
13 -> 52

The 5V and GND are hooked up to the 5V and GND on Arduino.

I could have just directly connected the TCL wires to the Arduino but I had already bough the shield anyway. 

Step 4: Producing Music

The fluxamasynth shield has a single chip synthesizer on it, the ATSAM2195.  It plugs right into the arduino. 

I found most of the instruments to sound pretty strange or downright bad but it's decent considering it's a single chip.  It got the job done for our prototype, but a future improved version would hopefully have a more capable synthesizer. 

The audio cable connects the jack of the shield to the mini audio amplifier which then connects to the speaker at the front of the unit. 

Step 5: Power

Power is provided by a 5V regulated Li-Ion Battery Pack.  Since the Urban Prototyping exhibition was only a day long installation, I got a battery pack with sufficient capacity to last the day to avoid having to plug the thing in somewhere.  An additional advantage is that because we weren't hooked up to mains power, there was less nasty 60Hz interference. 

This battery pack is nice in that it has a 5V regulated output.  Therefore I could plug it straight into the arduino 5V rail and power everything from it.  I assume that it has a DC/DC converter in it instead of a linear regulator so it should be more efficient than using a non regulated battery pack and relying on the arduino linear regulator.

Step 6: Hook Everything Up

The Fluxamasynth shield brings out the arduino pins.  We can solder all our power connections to the shield

MOD-EKG
Hook Up the power lines to 3.3V rail.

Communication:
MOD-EKG -> Arduino
Port 1 Pin 1 -> Pin 22
Port 1 Pin 3 -> Pin 23

TCL Shield
Power
Hook up the power lines to 5V rail.

Communication:
TCL Shield -> Arduino
11 -> 51
13 -> 52

Amplifier
Hook up the power lines to 5V rail.  Connect the audio line.

Battery Pack
Plug the battery pack into the 5V rail.

Notes about the arduino power system
This is a bit of an aside since I was pretty confused about how the arduino power system worked at first and what was the proper way of getting power to the thing.

There's 3 ways to get power into the device.
1.  DC power jack - 6-20V( max ).  This connection is for a DC power supply.  The 5V rail is generated from a linear regulator hooked up to this supply.  Since there's some drop in the regulator, putting 5V directly into the DC jack wouldn't yield 5V out of the regulator.  Also, if we hook up say a 12V supply here, most of the power would be wasted in the regulator.
2.  USB.  The 5V from the USB passes through what appears to be an electronic fuse.  That's a device that shuts off the circuit if the current is too high.  Presumably this is to prevent a USB port from being damaged by a short circuit but I'm not sure. 
3.  Directly connecting to 5V rail - By doing this you're directly powering the arduino 5V rail.  The power isn't traveling through a regulator or through a fuse so this allows you to get the most power into the 5V rail.  This isn't really important for this project since it doesn't use much, but it's good to know for other projects.  Just don't put too much voltage on this line or you might blow something up. 

The 3.3V rail is regulated down from the 5V regulator.  It's also a pretty tiny regulator so don't plan on putting anything that draws a lot of current on this rail. 

Step 7: Program the Chips

Here is the code for the Arduino and for the MSP430 on the MOD-EKG.

It's simple to get the code onto the arduino.

The msp430 is a little more involved.  First of all you need aprogrammerwhich at 74USD is a lot more than the EKG board itself. 
You also need the MSP430 IDE.  That's a link to the free version which may or may not work with the code, (there's a 4kb) limit in the free version.  You can find free alternatives on the web too.

Step 8: Case Design

The device was to be installed outdoors, so it needed a case that was at least somewhat waterproof, and of course it had to withstand a day of people actually using it.  It needed to be able to open, to install the electronic parts, and get attached to some part of the landscape so as not to wander off.  Possibly most importantly, it had to be obviously interactive, and immediately clear how; we did not want anyone to have to read instructions!

I immediately though of a "fat, friendly, shiny red heart" as a base shape.  It matched well with the concept we were working with, the heartbeat, and it would encourage interaction if it did not look too industrial or dark.  I'm still, however, most proud of the idea of putting handles on the sides, with the pulse sensors.  Handles are a super clear, wordless, invitation to grab on!

Since the internal circuit needed a bit of time to sense the user's pulse sufficiently, we also decided to have the embedded LEDs behave differently depending on the state the device was in: waiting for a user, detecting a pulse, or playing pulse music.

I decided to construct the heart out of layered cardboard covered with auto body putty.  Layered cardboard is an incredibly quick way to turn a CAD drawing into a rough 3-d object that you can then mess around with to refine.  The painted putty would give it a hard, shiny, good looking and tough shell in which to embed the LEDs, speaker, and sensors.

Tools and materials were simple and readily available:
* computer with CAD programs, Moment of Inspiration and 123D Make
* regular paper printer, and paper
* scissors & tape
* cardboard reclaimed from boxes, refrigerator box is nice if you can get it
* spray adhesive
* exacto knife
* scroll saw (optional but saves a bit of time)
* hot glue
* auto body putty (off-brands smell a lot worse, I recommend Bondo brand)
* plastic wrap
* popsicle sticks or tongue depressors
* 2 pc 4" copper tubing - I used a hacksaw to cut up a piece from the plumbing department of Home Depot
* ok, maybe a hacksaw, if you can't find 4" tubing pre-cut
* drill with metal bit, 1/16"
* a couple feet of medium gauge insulated wire
* soldering iron and solder
* sandpaper
* coat hanger
* spray paint & primer
* drill with 1/2" bit

Step 9: CAD and Basic Structure

I used a CAD app called Moment of Inspiration to design a basic 3-d heart shape (most CAD software could be used).  I used Autodesk's 123d Make to slice it into crosswise layers and render the layers as a series of PDF files printable on 8.5x11 paper.  I printed this all out (there were about 30 pages) and cut and taped until I had all the layers in paper.  Next I got some large pieces of reclaimed cardboard, not too squashed, and used spray adhesive to attach all the paper heart shapes.

I then simply had to cut (again) and stack.  I started out with an X-acto knife but switched to a scroll saw pretty quickly.  It wasn't much faster, but it was a lot easier on my hands!  I used the X-acto to cut reasonably sized chunks, and then the scroll saw to do each individual piece.

Since I wanted a hollow heart to contain the electronics, and I had solid pieces, I then cut the middle out of most of the pieces (except the smallest ones that comprised the front and back of the heart).  Had to do this with the X-acto, but it could be sloppy so it wasn't as troublesome!

Note: the last two files on this step are the PDF of the sliced heart, and the 3dm format file of the basic heart shape.  Feel free to use them.

Step 10: Cardboard Construction

With a pile of cardboard heart shapes in varying sizes, I had to stack them all together appropriately.  The layering program, 123d Make, conveniently printed an outline of the next shape up, when the next shape up was smaller, so placement of half the heart was easy.  Placement of the bottom half wasn't really hard, either, though; I just eyeballed it.  When the piece was in the right place, I hot glued it.  Before I started, though, I hand-cut a circle in the front stack, the size of the speaker we planned to use, or just a hair larger.

I did need a way to get inside the heart after it was completed, to add the electronics.  I decided to make the rearmost 5 or 6 layers a kind of lid.  When I reached the layer just below the lid layer, I glued it down very carefully just at the edge, then sliced a thin line around a half inch inside that layer's edge.  Making sure the inner part wasn't glued down, I added glue on top to just the inner, loose layer.  Then I placed the next layer on top of that glue, to start a second section, which fit precisely into the first.  The pictures should show this more clearly.

Step 11: Handles

The pulse rate sensors were two copper tubes, formed into handles attached to the sides of the heart.  I first wrapped each tube in blue tape, ending where I wanted the putty line to be.  I drilled a small hole in each end of each tube, threaded stripped ends of my conducting wire through, and soldered, for a solid join.  I threaded a couple strands of armature wire (non-conducting) through each tube, and poked the ends through the cardboard sides where I wanted the handles to sit.  I bent the armature wires on the inside so they wouldn't pull out, and threaded the conductive wire ends through at the same point, for later connection to the circuit board.

Lastly, I wrapped the armature wires with paper, partly for fill to support the putty, and partly to prevent them touching the copper, as even non-conducting metal conducts a LITTLE bit!

Step 12: Body Fill

To give the body strength and finish, I slathered auto body putty (bondo) all around the outside.  This is a 2-part mixture, a lot of grey filler putty plus a tiny bit of red-dyed hardener.  It hardens up in about five minutes so I had to work in small batches, and each mixture was slightly different, so in the unpainted pix you will see a variety of grey & pink shades depending on the exact proportions of the mix.  The technique is just, take a popsicle stick and get as much putty on as possible before it starts to cure and stops being spreadable.

Once you have the whole thing covered with cured putty, sand down the rough spots.  You'll need to do at least one, and probably two or three, filler rounds to bring up low areas that you discover after sanding.  Use a power tool if you can.  I used a drill with sanding pads, and a dremel for the small-curve areas of the handles.  Once it's all rough sanded, do a couple rounds of finer and finer grit.  Bondo can be wet sanded, which is nice as it minimizes the dust, but since I was working with a cardboard base I decided not to risk water.  Use a dust mask or respirator!  In the pix you will see that the bondo on the heart body has undergone a round of rough sanding prior to the speaker and lid edge work.

I had three problem areas: the handles, the speaker hole, and the lid.  The handles I just needed to do careful shaping, and I found that working the bondo under plastic wrap, like sculpting with my fingers, was the best way to go.  Everything sticks to bondo when it's wet, but plastic wrap easily comes off again after curing has started so it's a good barrier material.

For the speaker hole, I needed the bondo edges to align smoothly with the speaker itself, without getting bondo onto the speaker.  I wrapped and taped the speaker with plastic wrap, slapped some wet bondo around the edges of the hole, and pressed the speaker into place, pushing the wet bondo around so it fit precisely, and then holding it until it cured.

To handle the lid edges, I first puttied the top of the lid out as far as I thought it should go, with the lid off of the heart.  Once that was cured, I wrapped the lid in plastic wrap and replaced it.  Then I put bondo on the heart up to the lid edges, matching what was there as well as I could.  After it cured I used a knife to trim the edges, unwrapped the lid, and replaced it.  It also could have used more tidying up, but it actually fit tightly enough that I did not use any further fastenings.  It actually had to be pried off with a screwdriver each time we needed to open the case.  Again not totally ideal but functional.

Step 13: More Body Work

There was to be a ring of LEDs around the outside of the heart to work as indicators (see step 3).  I made a paper template, drew a line on the sanded bondo surface, and marked where the LEDs should all go.  I drilled out half inch holes (the LEDs we used were quite large) at my markings.  Each LED had a base, covered in silicone to protect it, which had a small circuit board that controlled its lighting.  To get the LEDs to show out the holes I'd drilled, I ended up having to dig out the interior cardboard more so they'd sit properly, and deep enough (see pix).

The last body treatment was a hole at the bottom of the point, where it would sit on a short metal shaft.  The shaft was sunk into the top of a dowel that we would then fasten to a post at the festival site.  At this point the surface of the heart was done and ready for paint.

To paint the heart, I bent a wire coathanger into a shape to support the heart through its speaker hole, and hang on a cord.  I primed it with a couple coats of spray primer, then gave it a last light sanding.  Finally I sprayed shiny paint in Cherry Red.  I did three light coats.  When it was dry I peeled off the masking tape over the copper handles.

Step 14: Finishing

Unfortunately there are not as many pictures of this as I'd like.  The final step was to put all the electronic parts inside the heart.  The LED strip was press fitted and then hot glued to hold it in place.  We stripped the sensor wires and soldered them to the circuit's two sensor leads on the bottom left and right sides of the board (see Step 1).  The speaker wires were connected to the amp output, and the LED strip was connected to the TCL shield (see step 3).  The rest of the electronics and the battery were just stuffed inside, and the lid pushed on, and it was ready to install.

Step 15: Cautions

As it turned out, the body was not quite strong enough to withstand a 7-year old actually swinging from the handles!  We had not considered that use case.  All the functionality survived, but the shell was slightly broken and battered by the end of its one day of installation.  Post-mortem analysis revealed that the bondo was pretty thin at several points, and the handles could have used much stronger reinforcement.  Should we make more of these, we will use a heavier duty internal structure, where the shell does not have to take all the unexpected forces that may be brought to bear by children, bears, dinosaurs, or whatever other users may arrive.