Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:11 07 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Heart rate revisited

Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 10:20pm 23 Jul 2016
Copy link to clipboard 
Print this post

A couple of years ago I made a heart rate monitor for the Maximite.
http://www.thebackshed.com/forum/forum_posts.asp?TID=6435&KW=heart+rate

Recently, I redid the software for a micromite and LCD.
Still using the seeedstudio ear-clip sensor as I find it the easiest to use for a quick test.

I do have a 'proper' ECG but the Micromite is easiest to set up - I hate those sticky pads.



The wallplate isn't really yellow!


' OPTION LCDPANEL controller, orientation, D/C pin, reset pin [,CS pin]
' OPTION LCDPANEL ILI9341, RL, 4,5,6
' OPTION TOUCH T_CS pin, T_IRQ pin
' OPTION TOUCH 7,2
' other pins used are 3, 14, 25
' GUI CALIBRATE
'OPTION EXPLICIT
option AUTORUN ON
CLS
DIM samples=12, Ppin = 16, Led = 23, pstart
DIM beatTime, beatPeriod
DIM av(samples)
SETPIN Ppin, INTH, beat
SETPIN Led, DOUT
PIN(Led) = 0
beatTime = TIMER
r = chart()
DO
testtime=TIMER
IF (testtime-beattime)>6000 THEN
TEXT 10,5, "No pulse detected! ",LT,1,2,rgb(red)
beatTime = TIMER
pStart=0
ENDIF

LOOP


END

SUB beat
beatTimeNow = TIMER
beatPeriod=beatTimeNow-beatTime
beatTime=beatTimeNow
PULSE Led, 40
IF beatperiod > 5 AND beatperiod < 3000 THEN
pulseRate=INT(60000/beatPeriod+.5)
s= x/2 MOD samples
pav=pav-av(s)+ pulserate
av(s)=pulseRate
pr$= STR$(pulseRate,3)
r = clr_ahead(x)
TEXT 10 ,5, "Pulse: "+pr$,LT,1,2

IF pStart > samples THEN
avp=INT(pav/samples+0.5)
avg$=STR$(avp,3)
'CIRCLE X+40, 240-avp, 2, 1, 1, rgb(red), rgb(red)
BOX X+40, 240-avp, 4, 4, 1, RGB(RED), RGB(RED)
TEXT 10,5, "Pulse: "+pr$+" av: "+avg$,LT,1,2
ELSE
TEXT 10,5, "Pulse: "+pr$,LT,1,2
pStart = pStart +1
ENDIF
IF pStart>0 THEN
IF pulseRate > 200 THEN
'CIRCLE X+40, 40, 2, 1, 1, rgb(white), rgb(white)
BOX X+40, 40, 4, 4, 1, RGB(WHITE), RGB(WHITE)
ELSE
'CIRCLE X+40, 240-pulserate, 2, 1, 1, rgb(Yellow), rgb(Yellow)
BOX X+40, 240-pulserate, 4, 4, 1, RGB(YELLOW), RGB(YELLOW)
ENDIF
ENDIF
x = (x+2) MOD 260
ENDIF
END SUB

FUNCTION chart()
CLS
LINE 38,40,38,239,1,RGB(BLUE)
LINE 38,239,310,239,1,RGB(BLUE)
FOR ys = 20 TO 200 STEP 20
y = 240 - ys
TEXT 5,y-5, STR$(ys,3)
NEXT ys
END FUNCTION

FUNCTION clr_ahead(x)
IF x > 1 THEN
BOX X+42, 30, 10, 207, 1, RGB(BLACK), RGB(BLACK)
ELSE
BOX X+40, 30, 12, 207, 1, RGB(BLACK), RGB(BLACK)
BOX 306, 30, 4, 207, 1, RGB(BLACK), RGB(BLACK)
ENDIF
LINE X+48, 40, X+48, 235, 1,RGB(127,127,127)
END FUNCTION


Jim


VK7JH
MMedit
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025