Week 15 : How to Visualize a Heartbeat (sort of)

Assignment

Write an application that interfaces with an input &/or output device.

My Goals

What I Learned

  • I need a signal that's stronger than 20 mA to visualize it in Processing
  • Processing is pretty easy to use and fun to play with

Downloads

Serial Print (Arduino IDE) and Graph (Processing)

Documentation

For this week’s assignment, I decided to start with watching a Youtube tutorial on Arduino and Processing. I discovered that Processing code was easier to understand than Arduino. After watching the first tutorial, I was able to generate this drawing interface.

First dabble into drawing program using #Processing #fabacademy #coding

A video posted by @min_o on

Next, I decided to try to visualize the pulse data from my Pulse Sensor board from Week 10. One of the first (of many) problems I started to discover about my Pulse Sensor board was that the Eagle library part for the generic 6-pin header was the mirror opposite of the AVR ISP, which meant I couldn't connect the pulse sensor to my Hello Echo board as I had originally planned.

My solution was to use 3 male-to-female wires connecting the GND, VCC and Signal legs to GND, 5V and A0 in the Arduino Uno.

I used the example code from the Arduino website and was able to generate a graph. All I had to do was to name “myPort” to “pulse”, change the Serial Port number to [5] (see instructions on how to do this below), and I changed the colour of my graph to turquoise by changing the values under Stroke (you can do this by googling the RGB code for turquoise - it’s 52,221,221).

How to find out your Serial Port Number for Processing code

In Processing, you need to tell the program where your board is connected. You can do this by:

  • Go to Arduino
  • Look under Tools > Serial Port
  • Count which number port your board is connected to (starting from 0 - not 1)

And then I tried to fix my pulse sensor...

I would show the video of that first attempt here, except here’s what happened. I was annoyed that I wasn’t able to actually read a real heartbeat through my pulse sensor. It turned out that the pulse waves I was seeing in the oscilloscope were really just noise. The pulse sensor I thought I had built was really just a Noise Sensor.

I started googling around to see if I could find a way to reduce the noise of my pulse sensor, when I realized that I had VCC and GND connected incorrectly in my schematic. This was related to the mistake I realized in Week 10 - the OpAmp part I was referring to in the original schematic was flipped with the same part in the Eagle library. You can read more about my adventures in building a pulse sensor in Week 10.

First, I tried to Macgyver the board by soldering wires to it, but the problem was bigger than I could solve on the surface. I finally decided to re-route my board, and took off all the parts I wanted to reuse.

By the time I realized I forgot to get a video of the graph being generated with my Noise Sensor, I had already ripped the board apart.

I proceeded to re-route and remill the Pulse Sensor board. I accidently placed the OpAmp in upside down and burnt it out. I tried to flip it around and test the board in case it was still working, but the oscilloscope showed me that the OpAmp was completely dead.

So I replaced the OpAmp and saw a huge difference in the signal from the Oscilloscope. It took some time to magnify the signal large enough to see the difference, which was approximately 20 mA, but the Pulse Sensor was finally reading my heartbeat. It only took... 5 weeks. No big deal. ;)

Next, I wanted to see if the code I had originally used in Processing would work with this new board. Unfortunately, because the signal from the Pulse Sensor was so slight, my heart beat simply could not be picked up in Processing. Craig said that I would need at least 1 Amp difference to be able to visualize it in Processing.

It was disappointing, but at the same time, I learned a lot about Pulse Sensors and analogue signals. The slight wave that you're seeing in the video above was just me moving my finger up and down against the sensor, not a real heart beat.