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.
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:
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.
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 highTake a readingIf it's below 10Ignore, breakIf it's above 1013Ignore, breakAdd to queue of Z stored readingsAs soon as the queue is fullCalculate the MIN from the last Z readingsCalculate the MAX from the last Z readingsSet bit Y high so this isn't repeated every timeIf Y is lowTake a readingIf it's below 10Increment integer XBreakIf it's above 1013Increment integer XBreakIf the new reading is less than MINWrite MIN to the value of the new readingIf the new reading is greater than MAXWrite MAX to the value of the new readingIf the new reading is more than 3/4 of the way from MIN to MAXSet bit T highOtherwiseSet bit T lowIf T is highActivate an output or whateverIf T is lowDectivate the output or whateverMap the analog value from MIN↔MAX to 0↔255Write 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.
Disclaimer for http://24hourengineer.blogspot.com/
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
Post a Comment