Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 16:22 18 May 2024 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 : Maximite heart rate monitor.

Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 04:26pm 11 Jun 2014
Copy link to clipboard 
Print this post

I have had reason to take an interest in my heart rate lately.
The usual chest strap types and Android apps tended to give average readings and I am more interested in the variability.

Maximite to the rescue.
' pulse monitor for colour Maximite
' 12 June 2014
' TassyJim
' pin 21 connected to the pulse detector.
' www.seeedstudio.com/depot/Grove-Earclip-Heart-Rate-Sensor-p- 1116.html
'
' pin 12 used as an output to LED or CRO etc.
'
' P print screen to PULSE.BAS (will overwrite any existing capture)
' C clear screen and start again
' L start logging data to file (will append to same date file)
' X stop logging to file
' ^C to quit.

Cls
samples=12
Dim av(samples)
SetPin 21, 6, beat
SetPin 12, 8
Pin(12) = 0
beatTime = Timer
GoSub chart
tick$ = Mid$(Time$,7,1)
Do
testtime=Timer
If (testtime-beattime)>6000 Then
Print @(1,10) "No pulse detected! "
beatTime = Timer
pStart=0
EndIf
k$=Inkey$
If k$="P" Or k$="p" Then SaveBMP "pulse.bmp"
If k$="C" Or k$="c" Then
Cls
GoSub chart
x=0
EndIf
If k$="L" Or k$="l" Then
filename$=Mid$(Date$,9,2)+Mid$(Date$,4,2)+Left$(Date$,2)+".c sv"
If logit = 0 Then Open filename$ For append As #2
Print #2, Date$;" ";Time$;" Start"
Print #2, "Time,Pulse,Average"
logit=1
EndIf
If k$="X" Or k$="x" Then
If logit = 1 Then
Print #2, Date$;" ";Time$; " Closed"
Close #2
EndIf
logit=0
EndIf
If tick$ <> Mid$(Time$,7,1) Then
tick$ = Mid$(Time$,7,1)
Line (x+39,60) - (x+39, 70) , White
EndIf
Loop
If logit = 1 Then Close #2
End

beat:
beatTimeNow = Timer
beatPeriod=beatTimeNow-beatTime
beatTime=beatTimeNow
Pulse 12, 40
If beatperiod > 5 And beatperiod < 3000 Then
pulseRate=Int(60000/beatPeriod+.5)
s= x Mod samples
pav=pav-av(s)+ pulserate
av(s)=pulseRate
GoSub clr_ahead
pr$=Format$(pulseRate,"% 4g")
If pStart>0 Then
Pixel(x+40,300-pulserate) = Yellow
EndIf
If pStart > samples Then
av=Int(pav/samples+0.5)
avg$=Format$(av,"% 4g")
Pixel(x+40,300-av) = Red
Print @(1,10) "Pulse rate: ";pr$;" Pulse av: ";avg$;" "
Else
Print @(1,10) "Pulse rate: ";pr$;" "
pStart = pStart +1
EndIf
If logit = 1 Then
Print #2, Time$;",";pr$;",";avg$
EndIf
x = (x+1) Mod 360
EndIf
IReturn

chart:
Cls
For ys = 0 To 240 Step 20
y = 300 - ys
Line (40,y) - (400, y), Blue
Print @(5,y-5) ys
Next ys
Return

clr_ahead:
Line (x+40,300) - (x+50,0), Black,BF
For ys = 0 To 240 Step 20
y = 300 - ys
Line (x+40,y) - (x+46, y), Blue
Next ys
Return

The code is for a colur Maximite so the colours would need to be changed for the Mono Maximite.

Example for April:



The yellow dots are the instantaneous readings and the red is the average over 12 pulses.

I was booked in for an electric shock treatment today but after they plugged me in, they discovered that things were back to normal so no zapping today.

Today's trace:



The blip at the end is when I reached down for the keyboard.

Yesterday's trace was more like the first one so whatever happened to fix it, happened last night.

The cardiologist doesn't really like the idea of a Maximite diagnostic kit but I might try him with a couple of printouts next week.

Jim
VK7JH
MMedit   MMBasic Help
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 815
Posted: 09:31pm 11 Jun 2014
Copy link to clipboard 
Print this post

Hi Jim,

thanks for sharing the code. I think I will buy the seedstudio sensor.
I hope it's all ok with you?

Frank
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 12:25pm 12 Jun 2014
Copy link to clipboard 
Print this post

Seeedstudio was the only place I could find the sensor with decoder. I have tried chest straps with 5kHz transmitters. They work but are not as convenient to attach when all you want is a quick check. The chest straps are a lot better when doing a serious workout.

I also have a Polar Bluetooth chest strap but when I tried to talk to it with my bluetooth V2.1 modules, the chest strap didn't go into low power mode so it would run for 20 seconds or so and then quit. The battery would only last an hour or two. A bluetooth V4 module is in the mail so I think (hope) that will help.

The final project will have the maximite recording speed and distance etc from my treadmill along with the heart rate.

Jim
VK7JH
MMedit   MMBasic Help
 
Print this page


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

© JAQ Software 2024