We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
I'm using a timer and external interrupt to detect the pulse, i can set the timer to run for 5 secs and loop back. But the program cannot vector to the external interrupt. This is my interrupt configurations and routine.
;******************************************** ;-----------INTERRUPTS CONFIGURATIONS-------- ;******************************************** MOV IE,#8CH MOV SWCINT,#000H MOV EIE1,#000H MOV EIE2,#000H MOV EIP1,#000H MOV EIP2,#000H MOV IP,#08H ;**************************** ;-Timer 1 Overflow Interrupt- ;**************************** T1_INT: CLR TF1 ; Clear overflow flag MOV TH1,#0D0H MOV TL1,#0A0H RETI ;********************** ;-External Interrupt 1- ;********************** EX_INT: INC 40H ; Increment 40H RETI
Does the input to the external interrupt need to be digital? Any advice would be nice... Thanks in advance.
Doesn't the data sheet have a suggestion how you stop the timer or alternatively just reads out the timer count?
If you are going to develop the program in assembler, then you must figure out a way to either manage with an 8-bit timing value - or how to combine a high and low byte into a 16-bit number. Further, you must figure out how you convert a period time to a frequency (f = 1/T). This would be trivial in C.
My oscillator can only reach a minimum of 2MHz. In this case, the timer will overflow before the pulse come in. And if i take the time between 2 pulse, it will not be accurate. I could not find a 12KHz crystal which can give me 1ms ticks. I can only find 32.768KHz crystal which gives me 0.36ms ticks. Therefore, the program will run very slow and refreshes very slow.
I just thought of a method using 2MHz... Can i just run the timer when the 1st pulse comes in and let it overflow? Everytime it overflow, i increment a variable until it reaches the 2nd pulse. Than i multiply the variable with 0.39sec(Time to overflow) to give me the time. Than i 1/T = F... Than F * 60 = BPM... Just asking whether isit advisable to use the method.
Can i just run the timer when the 1st pulse comes in and let it overflow?
Yes !
That's the whole secret behind measuring long time intervals with a fast timer.
Yes, most people would count timer overflows before having to use special crystals that are not suitable for the rest of the application.
But, as I wrote in your previous thread, you really do not want to base your bmp on the time between two heart beats! The heart is not a metronome where each beat comes at exactly the same time interval. There is a bit of jitter, so you want to measure the time between a couple of heart beats to get an average.
I see... So instead of incrementing a variable until the 2nd pulse, i should increment until the 3-4 pulse?
Correct! No existing (real) heart beat monitor measures the pulse using a single heart beat interval.
I see... Thanks..
natur3
That would be one way to do it, but it would result in a very slow update rate, which might prove very irritating to the user of the device.
Instead, you can measure the beat-to-beat frequency, but output an average value of the last X measurements (the larger X, the smoother the output).
What do u mean by "output an average value of the last X measurements"? What is X measurements?
What is X measurements?
X is a positive number which is larger than 1.
So if X is 4, you take four beat-to-beat measurements and average them.
"4 beat-to-beat measurements"
You mean like from one pulse to 1 pulse, that is considerd one beat-to-beat? If i take 4 beat-to-beat, won't that a very long time?
The concept is called a running average.
You use the time between beat 5 and 1 (4 periods) to emit a bmp.
Then you use the time between beat 6 and 2 (4 periods) to emit a bmp.
Then you use the time between beat 7 and 3 (4 periods) to emit a bmp.
The first output will not be available until after you have detected 5 heart beats. Then, the display may update for every new heart beat detected.
However, since a normal person at the best has a rest pulse just under 30 and normally in the 50-70 bpm, you can ignore the concept of a running average.
If you take the time between 5 beats, a pulse of 28 bmp would give the first result after 9-11 seconds and then a new value every 9 seconds.
With a more normal pulse of 60, the first value would be available afer 4-5 seconds, with a new update every 4 seconds.
A young person at very hard load would with a pulse of 200 get a first value after 1.2-1.5 seconds, and a new update every 1.2 seconds.
I see... Many thanks for your all help...
Regards, natur3