COMPUTE II ISSUE 3 / AUGUST/SEPTEMBER 1980 / PAGE 32
Marvin L. De Jong
Department of Mathematics-Physics
The School of the Ozarks
Pt. Lookout, MO 65726
The circuit shown in Figure 1 and the computer program given in the listing may be used to measure the pulse (heartbeat) rate of a person and display this result (in heartbeats per minute) on the AIM 65 display. A modified version of a PASCO Photo-Plethysmograph (PASCO Scientific, 1933 Republic Avenue, San Leandro, CA 94577) was used to detect the pulses. You might be able to build your own photo-plethysmograph using suitable infared photodiodes and phototransistors (such as the Fairchild FPA106 array) for a lot less money, but be prepared to do some experimentation. The voltage fluctuation from the plethysmograph is amplified by an instrumentation amplifier. We used an Analog Devices (Route 1, Industrial Park, P.O. Box 280, Norwood, MA 02062) AD521. The negative pulses from the AD521 are fed to a 555 timer that acts as a Schmitt trigger circuit, producing a well-defined square pulse at the clock input of the 74LS74. The LED will turn off when a pulse is detected. In the circuit of Figure 1, the 2000 ohm potentiometer on the AD521 controls the gain, and it should be adjusted so that heartbeats cause the LED to flash. An oscilloscope is very useful for making circuit adjustments.
The time interval between two successive pulses to the clock input of the 74LS74 is measured by the computer, and this result is converted to heartbeats per minute. The T1 timer on the 6522 on the AIM 65 microcomputer is used to produce a train of pulses that are fed to one input of the 74LS00 NAND gate. The period of these pulses is 100 microseconds. The leading edge of the heartbeat pulse at the clock input of the 74LS74 flips the Q output to logic one, gating the pulses from PB7 onto PB6 where the T2 counter/timer on the 6522 counts them. They are counted until the leading edge of the next heartbeat pulse flops the Q output to logic zero, closing the gate. Thus, the computer contains the number of 100 microsecond pulses that occurred between two heartbeats. Since f = 1/T where f is the frequency of the heartbeats and T is the time interval between beats, then f = 104/N where N is the number of pulses counted by the T2 counter/timer. Changing the units to pulses per minute gives f = 60 × 104/N.
We first describe the machine language subroutine called by the BASIC program. The instructions from $0E00 to $0E30 merely initialize the various 6522 registers. For example, T1 must produce a pulse train on PB7 and T2 must count pulses. A positive transition on CB1 must set a flag, while reading Port B produces a one microsecond pulse on CB2, clearing the flip-flop. Starting with the instruction at $0E30, the D-input of the flip-flop is set at logic one. Since the flip-flop was previously cleared, its output is currently at logic zero on the Q pin. The first heartbeat pulse reaching the flip-flop clock input sets the Q output to logic one. This transition is also detected by the instructions at $0E37 through $0E39, and as soon as it occurs, the program begins to watch the pulse count on T2.
Before switching the D-input of the flip-flop to logic zero in order to turn the gate off when the next heartbeat pulse arrives, the T2 counter is watched to allow approximately one-half a heartbeat period to elapse. It waits 0.0244 s to be exact (you may wish to decrease the value of the byte at $0E44). The reason for waiting lies in the fact that the wave shape of the heartbeat pulse (at least mine) has a secondary peak that can trigger the flip-flop if the gain is set a bit too high. So, we wait until this secondary pulse has been completed before catching the next heartbeat pulse. Bringing the D-input to logic zero allows the next clock pulse to switch Q to logic zero, closing the gate. The number of counts in T2 is obtained, and if T2 counted through zero, producing an interrupt (IRQ) request, the number of interrupts (counts exceeding 65536) are also obtained.
The BASIC program calls the machine language subroutine which then measures the number of 100 microsecond intervals between heartbeats. The BASIC program merely converts this number to a frequency and displays the result. Finally, it returns to measure another heartbeat period. Note that because of various time delays in processing the data, only every other heartbeat interval is measured.
I would not recommend that a novice experimenter with very little test equipment attempt to build this circuit. A number of adjustments are necessary and things like fluorescent lights can cause problems with the plethysmograph, in particular they can produce a 120 cycle modulation that triggers the circuit. The circuit does make a nice electronics project, and I am sure that improvements are possible. Of course, the circuit and the program are meant to be used for instructional purposes rather than in actual medical applications.
Besides being useful in teaching some simple biomedical instrumentation, this program and circuit might be useful for experiments on factors that alter the heartbeat rate. What about that last cup of coffee you drank? Can you exert control over your pulse rate with your mind? What is the cause of the statistical fluctuation in heartbeat rates when a person is simply relaxed? What happened to your heartbeat rate when that pretty girl walked by?
DIGITAL CARDIOTACHOMETER PROGRAM
10 POKE 04,00:POKE 05,14
20 Y = USR(0)
30 X = 65536*PEEK(51) + 256*PEEK(50) + PEEK(49)
40 R = 600000/X
50 R = INT(R + .5)
60 PRINT R; "PULSES/MIN"
70 GOTO 20
80 END
0E00 A9 B0 START LDA $B0 Initialize PCR on the 6522. CB 2 in output 0E02 8D 0C A0 STA PCR pulse mode. Transition an CB1 sets flag. 0E05 A9 81 LDA $81 Initialize DDRB so PB0 and PB1 are output 0E07 8D 02 A0 STA DDRB pins. 0E0A 8D 00 A0 STA PBD Set PB0 and PB7 to logic one. 0E0D CE 00 A0 DEC PBD Make D-input on flip-flop logic zero. 0E10 A9 E0 LDA $E0 Set up ACR so T1 is in free-running mode 0E12 8D 0B A0 STA ACR and T2 counts pulses. 0E15 A9 A0 LDA $A0 Set up IER so T2 produces interrupts when 0E17 8D 0E A0 STA IER it counts through zero. 0E1A A9 30 LDA $30 Set period of pulse train from PB7 to be 0E1C 8D 06 A0 STA T1LL 100 microseconds. 0E1F A9 00 LDA $00 0E21 8D 05 A0 STA T1LH Start pulse train from PB7. 0E24 A9 00 LDA $00 Clear interrupt counter. 0E26 85 33 STA PLSHI This location contains number of interrupts. 0E28 A9 FF LDA $FF Initialize the T2 counter to count down 0E2A 8D 08 A0 STA T2LL from $FFFF. 0E2D 8D 09 A0 STA T2CH 0E30 EE 00 A0 INC PBD Set D-input to logic one. Next pulse from 0E33 58 CLI plethysmograph will start timing. 0E34 AD 0D A0 WAIT LDA IFR Check flag to see if timing has started. 0E37 29 10 AND $10 Mask all except bit four of the IFR. 0E39 F0 F9 BEQ WAIT Loop here until a pulse starts the timing. 0E3B A9 00 LDA $00 Clear PCR to prevent clearing the 74LS74. 0E3D 8D 0C A0 STA PCR 0E40 AD 09 A0 LOAF LDA T2CH Read the timer. Wait here until about 0E43 C9 F4 CMP $F4 one-half the pulse period has passed 0E45 B0 F9 BCS LOAF before setting D-input to logic zero 0E47 CE 00 A0 DEC PBD at the next pulse. 0E4A AD 0D A0 LOITER LDA IPR Read the flag register. Has the next 0E4D 29 10 AND $10 pulse occurred? 0E4F F0 F9 BEQ LOITER No. Then wait here. 0E51 A9 FF LDA $FF Yes. Then count the pulses that have 0E53 38 SEC occurred (from PB7 to PB6). 0E54 ED 08 A0 SBC T2CL Low order byte of PB7 pulse count. 0E57 85 31 STA PLSLO 0E59 A9 FF LDA $FF Get middle byte of PB7 pulse count. 0E5B ED 09 A0 SBC T2CH 0E5E 85 32 STA PLSMI PLSHI, PLSMI, and PLSLO are read by the 0E60 78 SEI BASIC program. 0E61 4C D1 C0 JMP BASIC Return to BASIC program.
INTERRUPT ROUTINE: SET IRQ VECTOR TO $0E65
0E65 48 INTRPT PHA Save accumulator on the stack. 0E66 A9 FF LDA $FF Restart T2 by reloading it. 0E68 8D 09 A0 STA T2CH 0E6B 38 SEC Now increment the interrupt counter, PLSHI. 0E6C D8 CLD 0E6D A9 00 LDA $00 0E6F 65 33 ADC PLSHI 0E71 85 33 STA PLSHI Result into PLSHI. 0E73 68 PLA Recall accumulator contents. 0E74 40 RTI Return to the machine language subroutine.
Figure 1.
Interface circuit for the digital cardiotachometer.