Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/15/01 13:42
Read: times


 
#16645 - RE: HeartBeat Detector
If a digital signal with one and only one negative going transition per period (per beat) is available, you can follow this strategy (8052 at 12MHz):
1) Connect the signal to an interrupt input, say INT0.
2) Program a timer, say Timer 0, in mode 2, so that it generates an overflow interrupt every 200 us.
3) Write an ISR for the timer 0 interupt with:
tim0isr:
djnz prescaler,exit
move prescaler,#100
inc counter
exit:
reti
so that counter is incremented every 20 mseg.
4) Write an ISR for the external interrupt (INT0) that saves counter in period and resets counter.
ext0isr:
mov period,counter
mov counter,#0
mov a,peridod
mov dptr,#lookup
movc a,@a+dptr
mov bpm,a
reti
The value of period should be, for example, in the range 12 (for 250 bpm) to 250 (for 12 bpm).
lookup is a look-up table that converts period into beats per minute (less than 256 bytes).
lookup:
db 0ffh,...

7) Write a main code that initializes prescaler to 100 and counter to 0, enable the interrupts you use, and enters a main loop where you can do what you like with the bpm value.

The main drawback of this method is the lack of resolution, specially in the lower and higher ends.
I think that the resolution can be improved using 2-byte values for period and a larger look-up table. This implies changes in prescaling too.
You must also decide what behavior is to be expected when signal frequency is out of range, for example when the sensor is not applied to any patient.

The code I propose is only orientative, I have not tested it.

Regards,

Alfredo.


List of 13 messages in thread
TopicAuthorDate
HeartBeat Detector            01/01/70 00:00      
RE: HeartBeat Detector            01/01/70 00:00      
RE: HeartBeat Detector            01/01/70 00:00      
RE: HeartBeat Detector            01/01/70 00:00      
RE: HeartBeat Detector            01/01/70 00:00      
RE: HeartBeat Detector            01/01/70 00:00      
RE: HeartBeat Detector            01/01/70 00:00      
RE: HeartBeat Detector            01/01/70 00:00      
RE: HeartBeat Detector            01/01/70 00:00      
RE: HeartBeat Detector            01/01/70 00:00      
RE: HeartBeat Detector            01/01/70 00:00      
RE: HeartBeat Detector            01/01/70 00:00      
RE: HeartBeat Detector            01/01/70 00:00      

Back to Subject List