2016-03-14 (M) Cyborg Heart Rate Sensor

Pseudo code was written to read the pulse sensor. The stock code was written with the understanding that it was to be integrated into larger projects and therefore it used interrupts to ensure it would read the sensor at carefully regulated intervals. Since this project will be doing very little else, it should be acceptable to use a program without interrupts.

The concept of this program was to take good readings until a reasonable range could be found, to indicate the sensor saw skin, then calculate the upper and lower limits of what it was seeing. From those limits it would be possible to see when a heartbeat was detected.

Indented text in blue is the pseudo code.


If Y is high
     Take a reading
     If it's below 10
          Ignore, break
     If it's above 1013
          Ignore, break
     Add to queue of Z stored readings
     As soon as the queue is full
          Calculate the MIN from the last Z readings
          Calculate the MAX from the last Z readings
          Set bit Y high so this isn't repeated every time

If Y is low
Take a reading
If it's below 10
     Increment integer X
     Break
If it's above 1013
     Increment integer X
     Break
If the new reading is less than MIN
     Write MIN to the value of the new reading
If the new reading is greater than MAX
     Write MAX to the value of the new reading
If the new reading is more than 3/4 of the way from MIN to MAX
     Set bit T high
Otherwise
     Set bit T low

If T is high
     Activate an output or whatever

If T is low
     Dectivate the output or whatever

Map the analog value from MIN↔MAX to 0↔255
Write the mapped value to an LED

Pseudo code was translated into Arduino code on codebender.cc. This code cannot be programmed to a Digispark from a browser, it must be pasted into the Arduino IDE and Digispark support software must be installed.


To do:
  • Write pseudo code for extracting heart rate
  • Program with Digispark
  • Debug

The rest of the posts for this project have been arranged by date.

First time here?

Completed projects from year 1.
Completed projects from year 2



This disclaimer must be intact and whole. This disclaimer must be included if a project is distributed.

All information in this blog, or linked by this blog, are not to be taken as advice or solicitation. Anyone attempting to replicate, in whole or in part, is responsible for the outcome and procedure. Any loss of functionality, money, property or similar, is the responsibility of those involved in the replication.

All digital communication regarding the email address 24hourengineer@gmail.com becomes the intellectual property of Brian McEvoy. Any information contained within these messages may be distributed or retained at the discretion of Brian McEvoy. Any email sent to this address, or any email account owned by Brian McEvoy, cannot be used to claim property or assets.

Comments to the blog may be utilized or erased at the discretion of the owner. No one posting may claim claim property or assets based on their post.

This blog, including pictures and text, is copyright to Brian McEvoy.

2016-03-10 (Th)

Comments