You are on page 1of 22

1

Photoplethysmography (PPG) system
Geert Langereis, Version 2, February 2010


1  Introduction ........................................................................................................................ 2 
1.1  Background on photoplethysmography (PPG) ...................................................................... 2 
1.2  Specifications of the PPG implementation in this report ....................................................... 2 
2  Basic implementation ......................................................................................................... 4 
2.1  The optoelectronic parts ......................................................................................................... 4 
2.2  The electronic circuit ............................................................................................................. 4 
2.3  Arduino code: Analog “oscilloscope” mode .......................................................................... 8 
2.4  Arduino code: Digital timing interval mode .......................................................................... 8 
2.5  Postprocessing of interval data .............................................................................................. 9 
3  Signal processing .............................................................................................................. 11 
3.1  Heart-rate in the time domain (1): the asynchronous signal ................................................ 11 
3.2  Heart-rate in the time domain (2): key characteristics ......................................................... 12 
3.3  Heart-rate in the frequency domain ..................................................................................... 14 
3.4  Cross correlation in time and frequency .............................................................................. 14 
3.5  HRV standards ..................................................................................................................... 14 
4  Full two-channel system ................................................................................................... 16 
4.1  Hardware .............................................................................................................................. 16 
4.2  Arduino Code ....................................................................................................................... 16 
4.3  Extension to a multi-channel system ................................................................................... 18 
References ................................................................................................................................ 19 
Appendix A: Sensors from Kyto Electronics ........................................................................... 20 
Appendix B: PSpice netlist ...................................................................................................... 22 

2

1 Introduction
This chapter describes what photoplethismography is and what can be expected from the
implementation presented in this report.
1.1 Background on photoplethysmography (PPG)
Plethysmographs measure changes in volume. The only method to measure absolute changes
in blood volume accurately in the extremities is by using chamber-plethysmography. The
volume change can be converted into blood flow by using F = dV/dt. However, in some cases,
we are only interested in the relative volume, for example to see the pulsation rate of the
heart. In that case, information is in the timing and not in the amplitude or shape of the signal.
If that is the case, we can use electric impedance-plethysmography or photo-plethysmography
(PPG). Details on the background of plethysmography can be found in the book of Webster
[1]. A more comprehensive review on PPG is the paper of Allen from 2007 [2]. An example
of a system design is the thesis of Rhee at MIT from 2000 [3].
A PPG sensor can be used in reflection mode (for example on the finger) or in transmission
mode (for example on the ear) as shown in Figure 1.1. Normally, a wavelength in the near-
infrared is used because there we have the strongest modulation of the signal due to light
absorption in the haemoglobin in the blood
1
.

Figure 1.1: (a) Light transmitted into the finger pad is reflected off bone and detected by a photo sensor.
(b) Light transmitted through the aural pinna is detected by a photo sensor [1]
1.2 Specifications of the PPG implementation in this report
This document focuses on the following implementation:
- optical detection using an ear-lobe clip in transmission mode
- pulse filtering by means of a simple analog electronic circuit with a second order
bandpass between the characteristic frequencies 1.54Hz and 2.34Hz (-3dB points 1.0
and 3.5Hz) and a gain of 3700 in the peak.
- pulse detection using a comparator on the electronic circuit board to send out a digital
signal for time-interval measurements
- the analog electronic circuit is implemented as an add-on board for the Arduino
microcontroller platform [4]
- a microcontroller board to measure the timing intervals between heartbeats and to send
it to a computer using the USB bus
- signal processing on an external computer
Some other options for the partitioning over software and hardware are possible:
- it is an option to implement the signal post processing (for example HRV algorithms)
on the microcontroller board to make a stand-alone application

1
Note that heamoglobin and oxyheamoglobin pass equally at 805nm and have maximal difference at 660nm.
This difference is used in optical oxygen saturation sensors.
3

- although the filtering of the raw photo transistor output should be done electronically,
it is possible to do the subsequent pulse detection in software from the sampled analog
signal. This option might be advantageous to anticipate to level changes in the signal.

One should carefully consider the advantages and drawbacks of the optical ear-lobe sensor
method when designing an application. There are some clear advantages. First of all, it is non-
invasive and the PPG signal is strong and robust. In addition, the electronic circuit is fairly
simple and small. Because there is no electrical contact to the human body it is safe and can
even be used in water. See for example the “Aquapulse” product [5]. The drawbacks,
however, are the motion artefacts and the need for a potentiometer to adjust the signal
2
. The
alternative for heart-rate measurements is to use ECG and detect the heart-rate from the R-R
intervals.

2
The potentiometer is not absolutely required. We can live without, or we may come up with an improved
circuit design which included automatic gain control (AGC)
4

2 Basic implementation
This document tries to give sufficient background information to understand the system
implementation and choices. When this becomes confusing, just realise that the circuit of
Figure 2.3 and the Arduino code for interval measurements as shown in section 2.4 are the
only essential components. When having these two, and an ear-clip, the signal processing of
chapter 3 can be implemented in any software environment capable of serial communication
with an Arduino. It is also possible to implement heart-rate and HRV algorithms on the
Arduino itself.
2.1 The optoelectronic parts
Most of the implementation found elsewhere are using the combination of an infrared-LED
and a photo-transistor [1, 6, 7, 8], sometimes hand-made in a wooden clothes peg [9]. The
alternative for a photo transistor is a light-to-voltage optical sensor like the TSL250 [10]
which can be used in combination with a TSHA520 infrared LED [11]. The advantage is that
such a device includes a pre-amplifier which will reduce the system noise.

This report, however, makes use of ear-clips from Kyto Electronics as described in Appendix
A. The opto-electronic components in these ear-clips consist of an infra-red LED and a photo-
transistor. The cathode of the LED and the emitter of the photo-transistor are electrically
connected and accessible via a normal stereo 3.5mm jack connector. Characteristics, pictures,
specifications and connector details can be found in Appendix A. The ordering price of the
sensor was €6,50 for the amount of five and is mainly determined by the shipping costs.
2.2 The electronic circuit
The electronic circuit has four functions:
- Biasing of the LED
- Biasing of the photo-transistor
- Remove low-frequent motion-artefacts and drift
- Isolate the heartbeat pulse

C
0
R
0
R
1
R
2
C
2
LED
biasing
High-pass
filter
Low-pass
filter/amplifier
Photo-
transistor
biasing

Figure 2.1: Basic circuit topology
The circuit topology is shown in Figure 2.1. In the first stage, the LED is biased. For an
operational voltage of 5V, a resistor of (V
cc
-V
f
)/I
f
= (5V-1.2V)/65mA = 58Ω can be used,
5

with V
f
and I
f
the forward voltage and current from the datasheet of Table A.1. However, half
of the forward current was chosen by means of a 120Ω resistor.

In the next stage, the photo-transistor is biased. The choice of this biasing resistor is made
based on the example circuits in literature [1, 6, 7, 8] and a value of 22kΩ was used with
satisfying results.
The high-pass filter is a simple first-order RC circuit with a lower frequency bound of
(2πR
0
C
0
)
-1
. The low-pass filter is implemented as an active filter to facilitate amplification as
well. The high pass filter has a cut-off at (2πR
2
C
2
)
-1
and amplifies (R
1
+ R
2
) / R
2
times. The
high-pass filter frequency and the low–pass filter frequency have to be chosen such that we
end-up with a band-pass filter to amplify the 2Hz frequency, because that is the steepness of
the PPG pulse signal. To make the bandpass-filter more effective, the high-pass and low-pass
filters are implemented twice resulting in a transfer function given by
( )
2
0 0
0 0
2 2
2
2 1
2 1
1
2 1
C R j 1
C R j
C R j 1
C
R R
R R
j 1
R
R R
j H
(
(
(
(
¸
(

¸

e +
e
e +
+
e +
+
= e . (2.1)
Figure 2.2 shows the modulus of the transfer function on a log-log scale with the
characteristic indicators.
R +R
1 2
1 1
1
R
1
1
2 R t
0
C
0
2 R t
2
C
2
2 R // t(
1
R )C
2 2
2
Frequency
M
o
d
u
l
u
s

Figure 2.2: Schematic transfer function, created from equation (2.1)
In Table 2.1 the component values and characteristic frequencies of the circuits found in
literature are found. We can see that these are roughly the same. The values of Pico
Technologies [9] are used in our implementation. For R
1
= 10kΩ and R
2
= 1MΩ, the
asymptotic gain A = (R
1
+R
2
)/R
1
square becomes 10.200, but is effectively 3700 in the peak.

Finally, the whole circuit is shown in Figure 2.3. The sensor is now replaced by a connector,
so only the biasing resistors R
5
and R
1
are visible. Between the filter stages a potentiometer is
used because it appeared that sometimes the output signal was too big.

The combination of R
11
, D
1
and D
2
is used to deal with the symmetrical power of 5V from the
Arduino board. The two diodes define a reference level at two times their band gap, so at
1.2V. The pin ANALOG_OUT is connected with one of the analog in pins of the Arduino.
The comparator made with IC2B is used to do threshold detection with the reference level as
6

detection level, and creates a digital out where the rising edge can be used for timing interval
measurements.

Table 2.1: Filter implementations of circuits in literature
Webster [1] Pico [9] Ibrahim [8] Cornell [6] Maplin [7]
Stage 1 Stage 2 Stage 1 Stage 2
R
1
10,0 kΩ 8,20 kΩ 1,00 kΩ 1,00 kΩ 4,70 kΩ
R
2
1,00 MΩ 1,00 MΩ 560 kΩ 100 kΩ 1,00 MΩ
C
2
68,0 nF 100 nF 100 nF 470 nF 100 nF

A (101,00)
2
(122,95)
2
(561,00)
2
(101,00)
2
(213,77)
2

f
lp
2,34 Hz 1,59 Hz 2,84 Hz 3,39 Hz 1,59 Hz
f
hp
236,39 Hz 195,68 Hz 1594,39 Hz 342,01 Hz 340,22 Hz

R
0
1,60 MΩ 47,0 kΩ 68,0 kΩ 20,0 kΩ 1,00 MΩ 1,00 MΩ
C
0
2,00 µF 2,20 µF 1,00 µF 10,0 µF 1,00 µF 100 nF

f
hp
0,05 Hz 1,54 Hz 2,34 Hz 0,80 Hz 0,16 Hz 1,59 Hz


Figure 2.3: Complete circuit, including connectors to Arduino
Note that the circuit shown in Figure 2.3 was drawn using the free version of Eagle Schematic
[12]. This program, which is available for Windows and Mac OS-X, can be used to draw
circuits and to assist with printed circuit board development. For circuit simulations, one
normally can take PSpice for Windows [13], which is unfortunately not available for Mac OS-
X, and would require re-drawing of the circuit. An alternative is to use a User Language
Program (ULP) script for exporting PSpice netlists from Eagle [14] and to run it using
MacSpice [15].
In Figure 2.4, the MacSpice circuit simulation is shown. It was made using the netlist and
simulation code of Appendix B. As a comparison, Figure 2.5 shows the frequency response
on pin ANALOG_OUT as calculated using equation (2.1). This means that the operational
amplifiers are assumed to be ideal and the reference level construction with the two diodes is
omitted. By comparing Figure 2.4 and Figure 2.5, we can see that our analytical model
describes the filter operation sufficiently well.
7


Figure 2.4: Transfer function simulated with MacSpice. As can be seen in the netlist of Appendix B, trace
v(10) is the input signal, trace v(6) the signal after the first filter stage, and trace v(2) the signal after the
second stage, so equal to ANALOG_OUT
0.1 1 10 100 1
.
10
3
1
.
10
4
1
10
100
1
.
10
3
1
.
10
4
Frequency [Hz]
M
o
d
u
l
u
s

[
]

Figure 2.5: Calculated frequency response of the filter circuit of Figure 2.3 using equation (2.1)
Finally, the circuit is made on a printed circuit board and tested. In Figure 2.6 the oscilloscope
image is shown. The blue trace is the reference level and the orange trace the PPG signal. The
comparator stage will have no problem to detect the zero crossings.

Figure 2.6: Oscilloscope image of measured heartbeat, measured on pin “ANALOG_OUT”
8

2.3 Arduino code: Analog “oscilloscope” mode
For the Arduino code we can have two approaches. In the first option, we sample the analog
input at equidistant intervals. This is a good option to view the analog signal, hence the name
“oscilloscope mode”. To sample at 500Hz, we have to use a timer interrupt.
The second approach is to use the digital signal from the comparator and create a hardware
interrupt at every low-to-high zero crossing. This will be described in the next section, and is
referred to as “interval mode”.

In “Clear Timer on Compare” or “CTC mode” (WGM13:0 = 4), the OCR1A register is used
to manipulate the counter resolution. In CTC mode the counter is cleared to zero when the
counter value (TCNT1) matches the OCR1A. The OCR1A defines the top value for the
counter, hence also its resolution.
The waveform generated will have a maximum frequency of f
OC1A
= f
clk_I/O
/2 when OCR1A is
set to zero (0x0000). The waveform frequency is defined by the following equation:
( ) OCRnA 1 N 2
f
f
O / I _ clk
OCnA
+ · ·
= (2.2)
The N variable represents the prescaler factor (1, 8, 64, 256, or 1024).

The code for sampling the analog signal on the analog pin 0 with a fixed frequency of 500Hz
is as follows:



2.4 Arduino code: Digital timing interval mode
In interval mode, the output signal of the comparator (DIGITAL_OUT in Figure 2.3) is
connected to digital pin 2 of the Arduino. The concept is that this pin can generate an INT0
hardware interrupt at every low-to-high zero crossing. When doing so, the interesting
const int Baudrate = 19200;
const int Analog_Input_Pin = 0;

void setup()
{
Serial.begin(Baudrate); // For sending data to the computer over USB
cli(); // disable interrupts while messing with their settings
TCCR1A = 0x00; // clear default timer settings
TCCR1B = 0x00; // timer in normal mode
TCCR1B |= (1 << WGM12); // Configure timer 1 for CTC mode
TCCR1B |= (0 << CS12); // Set timer prescaling by setting 3 bits
TCCR1B |= (1 << CS11); // 001=1, 010=8, 011=64, 100=256, 101=1024
TCCR1B |= (1 << CS10);
TIMSK1 |= (1 << OCIE1A); // Enable CTC interrupt with OCF1A flag in TIFR1
OCR1A = 124; // Set CTC compare value, results into 500Hz for fI/O =
8MHz
sei(); // turn interrupts back on
}

void loop() {
// nothing to do, its all in the interrupt handlers!
}

ISR(TIMER1_COMPA_vect) // when timer counts down it fires this interrupt for
scope-mode
{
int val = analogRead(Analog_Input_Pin);
Serial.write( (val >> 2));
}
9

information is in the time between the interrupt and the previous interrupt. This time can be
measured with a resolution of 4µs which is more than accurate enough.

The code looks like:


2.5 Postprocessing of interval data
The Arduino sends high resolution samples over the USB bus to a computer for evaluation. It
is up to the user to choose the favorite programming environment to represent the data. A
LabView shell is available which gives primary information and can store the data for more
advanced post-processing.

Figure 2.7: LabView program screenshot
const int Baudrate = 19200;
const int Digital_Input_Pin = 2; // the pin that the heart-rate sensor is attached which
contains INT0

void setup()
{
Serial.begin(Baudrate); // For sending data to the computer over USB
pinMode(Digital_Input_Pin, INPUT);
attachInterrupt(0, Send_Interval, RISING); // Attach to INT0
}

void loop() {
// nothing to do, its all in the interrupt handlers!
}

unsigned long LastTime, NewTime, j;
void Send_Interval()
{
NewTime = micros(); // Resolution 4us, only one overrurn in 70 minutes
Serial.println(NewTime-LastTime, HEX);
LastTime = NewTime;
}

10


Figure 2.8:LabView program screenshot

11

3 Signal processing
This chapter gives some basic formulas for implementing heart-rate and heart-rate variability
algorithms in your software. It also provides some terminology commonly used for stochastic
signals. The input signal is the digital interval information from the Arduino. More details on
the mathematical background of signal processing of stochastic signals can be found on the
web at Wolfram MathWorld [16].
3.1 Heart-rate in the time domain (1): the asynchronous signal
The digital signal coming from the Arduino has the strange phenomenon that samples do not
come in at equidistant periods: the signal is asynchronous. It is sketched in Figure 3.1 as a
series of samples x
i
. Between every two subsequent data samples x
i
and x
i-1
there is a square
surface because the height of the sample is equal to the time-spacing with the previous
sample.
Time
x
1
t
1
x
2
t
2
x
3
t
3
x
4
t
4
x
5
t
5

Figure 3.1: Asynchronous interval signal
The signal is characterized by:
- Samples x
i
are discrete in amplitude: these are unsigned-long (4 bytes = 32 bits)
numbers representing the time intervals in µs. Because the actual time resolution as
specified by Arduino is 4µs, the two lower bits are not significant, meaning we have
30 bits effectively in the amplitudes of x
i
.
- The lengths of the time intervals [t
i
- t
i-1
] are equal to the numbers represented in the
samples, so we can say
| |
i 1 i i
x t t = ÷
÷
. (3.1)
However, the time intervals are transmitted over the USB/serial line with a very time-
unreliable protocol. There is not enough significance in the timing information, and we
should take the amplitude information as the source for signal processing.

Over a certain time period, we may assume the asynchronous signal to be “stationary”. This
means that the characteristics (average, standard deviation, etc.) at t
1
are identical to the
characteristics at t
N
for every N. The signal becomes non-stationary, for example, when we
change the level of physical exercise or arousal during a single measurement. In that case, we
have to work with a running average or an alternative representation technique.
When we have a stationary situation, and the variation on the intervals [t
i
- t
i-1
] is small
with respect to the absolute interval, we can consider the data sequence x as a quasi-
synchronous signal. This means the mathematical average of the samples x is equal to
the average heart-rate and equal to the nominal sample interval.
Realizing this, we can think of the signal as a synchronous signal (meaning fixed periods
between the samples), but with the real intervals in the amplitudes x
i
. In mathematical writing:
| |
1 1 i i
' t ' t µ = ÷
÷
(3.2)
12

with µ
1
the average of the intervals x
i
and t
i
’ the equivalent of the sample times t
i
, mapped
onto an equidistant time grid. Two options are possible as shown in Figure 3.2.
Time
Time
x
1
x
1
t
1
t
1
x
2
x
2
t
2
t
2
x
3
x
3
t
3
t
3
x
4
x
4
t
4
t
4
x
5
x
5
t
5
t
5
µ µ µ µ

Figure 3.2: Two options for interpretation of the asynchronous heart rate sample peak series of the
Arduino into a synchronous equivalent. See text for explanation
The Arduino heart pulse interval samples are the black sample peaks. They appear at
asynchronous intervals. In the top graph, the samples are mapped onto an equidistant (=
synchronous) sample peak series (red) with a spacing equal to the average heart rate µ
0
. In the
lower graph, we have converted to a synchronous sample peak series as well, but now with a
subsampled higher data rate with arbitrary spacing. In the second case we assume the heart
rate was equal to x
i
during the whole previous interval t
i-1
to t
i
.
The first option with µ
1
as the synchronous time base works well for local heart rate averages,
standard deviations and even FFT’s (spectral analysis). The second solution becomes the only
option when comparing two heart-rates (cross correlations). Satisfying results have been
observed with re-sample intervals of 100ms up to 500ms. This is a good compromise between
numerical reliability and the increase of data points.
3.2 Heart-rate in the time domain (2): key characteristics
Characteristics in the time domain, can be described in terms of “moments” of the
“expectation value”. The expectation value of the k-th moment is defined as
( )
}
·
· ÷
= ÷ µ dx x f x x
k k
k
(3.3)
for continuous functions. In this definition, f(x) is the probability function of the “process” or
“signal” x. For a finite discrete realisation (“ensemble”) x
1
..x
N
this becomes
( )
¿
=
= ÷ µ
N
1 i
k
i
k
k
x f x x . (3.4)
Note that a process where the probability function f(x) can be determined from each
individual realisation x
1
..x
N
is called “ergodic”. Ergodic processes make the mathematics
much easier. For example, for our signal the probability function f(x) is equal to 1/N, because
every sample has the same probability of occurrence and the process is ergodic.

13

The first order and second order moments have a well-known meaning. The first order
moment (k = 1) is equal to
( )
¿
=
= ÷ µ
N
1 i
i 1
x f x x (3.5)
where we can include the probability function f(x)=1/N and find
( )
¿ ¿ ¿
= = =
= = = ÷ µ
N
1 i
i
N
1 i
i
N
1 i
i 1
x
N
1
N
x
x f x x (3.6)
which is known as the average of ensemble x. The second order moment is normally taken
around the mean, and given by
( ) ( ) ( ) ( )
2
N
1 i
2
1 i
N
1 i
2
1 i
2
1 2
x
N
1
x f x x o = µ ÷ = µ ÷ = µ ÷ ÷ µ
¿ ¿
= =
. (3.7)
The term σ
2
is the variance and is the square of the standard deviation σ.

Variance can be interpreted as the correlation of a signal with itself. Consider the expectation
value of a signal x on time t with the same signal x on time t+τ. We can write
( ) ( ) ( ) t + ÷ t t x t x R
xx
(3.8)
which is called the “autocorrelation function”. Note that
( )
2 2
1 xx
0 R o + µ = (3.9)
is the absolute maximum of R
xx
in t = 0. It is important to know that the autocorrelation
function is the Fourier transform of the spectral density function S
xx
(f). So, with our discrete
signals, we can simply use (inverse) Fast Fourier Transforms (FFT’s) to generate frequency
spectra of our data. According to the Wiener-Khinchin Theorem, we can even generate the
power spectrum immediately from the raw data without generating the cross-correlation
function first.

In time critical applications, where we want to plot the variations in mean and/or standard
deviation, there is normally no time to calculate the average of the whole dataset, or a series
of subsets. In such cases, a moving average is taken. The algorithms to calculate a moving
average have the advantage that we do not have to store and recall all the previous samples.
There are many moving average options, but the most common is the “exponential moving
average” EMA: the new one is simply added using a weighting factor. The equation is
( )
1 i i i
EMA 1 x EMA
÷
o ÷ + o = (3.10)
showing that we only have to store the previous EMA. The degree of weighing decrease is
expressed as a constant smoothing factor α, a number between 0 and 1. A higher α discounts
older observations faster. Alternatively, α may be expressed in terms of N time periods, where
α = 2/(N+1). For example, N = 19 is equivalent to α = 0.1. The half-life of the weights (the
interval over which the weights decrease by a factor of two) is approximately N/2.8854.
Note that in our case of heartbeats, we have sufficient time (almost a second) between two
subsequent samples. Therefore, moving averages are not in the standard representation
methods of heart-rate variability.
14

3.3 Heart-rate in the frequency domain
The signal has a discrete time and a discrete amplitude. This means we can transform to the
frequency domain using Fast Fourier Transforms (FFT). For a sampled sequence of N points
x
1
..x
N
, the FFT returns N frequency values X
1
..X
N
. This maps onto a horizontal frequency
axis as
- X
1
is the power of the DC content, or in other words the power of the average heart
rate. Because this is a huge peak in our case with respect to the more interesting
information in the higher frequencies, it can be wise to remove the average DC signal
from the signal x
1
..x
N
first, and then do the FFT.
- X
N/2
is the power at the half the sampling frequency, so corresponding to the power at
a frequency of (2µ
1
)
-1
Hz. Note that due to the relation between amplitude and average
asynchronous sample interval (equation (3.2)), the spectrum has a relation between
the frequency and power axis as well. This will not be the case when the synchronous
subsampling of Figure 3.2 is used. Half the sampling frequency is the highest
frequency in the FFT result: the higher points are a symmetrical copy of the lower
frequency points.
- The result is that the frequency resolution is equal to (µ
1
N)
-1
Hz. So with X
1
at 0Hz,
X
2
is at (µ
1
N)
-1
Hz.
A practical example is the following. When the Arduino board returns a nominal heart beat
interval of 800ms, this corresponds to a heart rate of 75 bpm, or 0.125Hz. An FFT of any
number of samples would contain frequency information up to half the sampling frequency,
so 0.625Hz. With one minute of sampling, 60 samples, the lowest frequency visible in the
spectrum is 0.021Hz. So, for observing variations in the heart rate lower than 0.021Hz, we
have to measure for at least one minute.
3.4 Cross correlation in time and frequency
Besides the concept of autocorrelation, we can define cross-correlations between signals x and
y, using
( ) ( ) ( ) t + ÷ t t y t x R
xy
. (3.11)
The (inverse) Fourier transform of the cross-correlation function is called the cross-spectrum.
For linear system we can find
( ) ( ) ( ) f S f S f S
yy xx
2
xy
= , (3.12)
a condition sometimes used to to check the linear relation between x and y.
3.5 HRV standards
Some representations of the average, standard deviation and frequency components have
become widely acceptable in the field of heart-rate variability [17, 18].

Time-domain methods
These are based on the beat-to-beat or NN intervals, which are analyzed to give variables such
as:
- SDNN, the standard deviation of NN intervals. Often calculated over a 24-hour period.
- SDANN, the standard deviation of the average NN intervals calculated over short
periods, usually 5 minutes. SDANN is therefore a measure of changes in heart rate due
to cycles longer than 5 minutes.
- RMSSD, the square root of the mean squared difference of successive NNs.
- NN50, the number of pairs of successive NNs that differ by more than 50 ms.
15

- pNN50, the proportion of NN50 divided by total number of NNs.
Geometric methods are a subclass of time-domain measures in which the NN intervals are
converted to a geometric pattern, then analyzed. Most of these methods use a discrete scale
for the NN interval length.
In a Poincaré plot, the relation between two neighbouring intervals is plotted as shown in
Figure 3.3. It is described scientifically and mathematically correct by Brennan in 2001 [19], a
paper which is also useful for the other time-domain evaluation methods.

Figure 3.3: Poincaré plot with on the horizontal axis the NN intervals and on the vertical axis the length of
the previous NN interval [19]
Frequency-domain methods
Several methods are available. Power spectral density, using parametric or nonparametric
methods, provides basic information of the power (variation) distribution across frequencies.
One of the most commonly used PSD methods is the Fast Fourier transform.

Several frequency bands of interest have been defined in humans:
- High Frequency band (HF) between 0.15 and 0.4 Hz. HF is driven by respiration and
appears to derive mainly from vagal activity (parasympathetic nervous system).
- Low Frequency band (LF) between 0.04 and 0.15 Hz. LF derives from both
parasympathetic and sympathetic activity and has been hypothesized to reflect the
delay in the baroreceptor loop.
- Very Low Frequency band (VLF) band between 0.0033 and 0.04 Hz. The origin of
VLF is not well known.
- Ultra Low Frequency (ULF) band between 0 and 0.0033 Hz. The major background of
ULF is day–night variation and therefore is only expressed in 24-hour recordings.
The ratio of low-to-high frequency spectra power (LF/HF) is has been proposed as an index of
sympathetic to parasympathetic balance of heart rate fluctuation, but this is controversial
because of the lack of understanding of the mechanisms for the LF component.
16

4 Full two-channel system
For measuring the cross-correlation between two heart-rates, we need two timed hardware
inputs. Although this chapter focuses on the measurement of two heart rates, the technical
solutions are applicable for any second sensor next to the PPG sensor, for example
respiration rate, ECG, etc.
4.1 Hardware
For a 2-channel system, the circuit of Figure 2.3 is simply implemented twice. One
DIGITAL_OUT is connected to digital pin 2 (INT0) of the Arduino and the other to digital
pin 3 (INT1). The ANALOG_OUT of the first circuit to analog input 0 and the other to
analog input 1 of the Arduino.
The power supply is shared by the two sub-circuits, but the reference level (defined by R11
and the two diodes D1 and D2) can not be shared. The reason is that a pulse signal on channel
A will push down the reference level a little bit. This would cause an inverted signal on
channel B and vice versa. Although the variation on the reference level is quite small, due to
the amplification of 3700 times, the final cross-talk signal will be in the same amplitude range
as actual heartbeats.
4.2 Arduino Code
The following code has the additional feature that it supports both analog and digital inputs
for two channels, called A and B. These channels can be selected individually or together.
After a reset, the code first acknowledges by sending the prompt “>”. Next, the computer has
to indicate which mode is preferred. The options are:
- Mode “I”: measure timing intervals for channel A only
- Mode “K”: measure timing intervals for channel B only
- Mode “J”: measure timing intervals for channel A and B
- Mode “S”: sample channel A at 500Hz
- Mode “T”: sample channel B at 500Hz
- Mode “U”: sample channels A and B at 500Hz
In the timing interval mode, the measured interval is put on the USB bus as character “A” or
“B”, depending on the channel, and next the time interval as a hexadecimal string in µs
resolution.
In oscilloscope mode, either one byte or two bytes are put on the USB bus (as a byte, not as a
character) depending on single channel or two channel operation. Note that of the 10-
resolution, the two least significant bits are simply discarded.


const int Baudrate = 19200;
const int Analog_Input_Pin_A = 0;
const int Digital_Input_Pin_A = 2; // heart-rate sensor, INT0
const int Analog_Input_Pin_B = 1;
const int Digital_Input_Pin_B = 3; // heart-rate sensor, INT1
int Mode;

void setup()
{
Serial.begin(Baudrate); // For sending data to the computer over USB
Serial.print("Start");
while (Serial.available()==0){
}
Mode = Serial.read();



....... Continued on next page
17


Continuation from previous page .......

switch (Mode)
{
case 'I': // Interval mode, input A only
pinMode(Digital_Input_Pin_A, INPUT);
attachInterrupt(0, Send_Interval_A, RISING); // Attach to INT0
break;
case 'K': // Interval mode, input B only
pinMode(Digital_Input_Pin_B, INPUT);
attachInterrupt(1, Send_Interval_B, RISING); // Attach to INT1
break;
case 'J': // Interval mode, input A and B
pinMode(Digital_Input_Pin_A, INPUT);
pinMode(Digital_Input_Pin_B, INPUT);
attachInterrupt(0, Send_Interval_A, RISING); // Attach to INT0
attachInterrupt(1, Send_Interval_B, RISING); // Attach to INT1
break;
default: // Scope mode, S = A only, T = B only, U = A and B
cli(); // disable interrupts while messing with their settings
TCCR1A = 0x00; // clear default timer settings, this kills the millis()
function,
TCCR1B = 0x00; // timer in normal mode
TCCR1B |= (1 << WGM12); // Configure timer 1 for CTC mode
TCCR1B |= (0 << CS12); // Set timer prescaling by setting 3 bits
TCCR1B |= (1 << CS11); // 001=1, 010=8, 011=64, 100=256, 101=1024
TCCR1B |= (1 << CS10);
TIMSK1 |= (1 << OCIE1A); // Enable CTC interrupt with OCF1A flag in TIFR1
OCR1A = 124; // Set CTC compare value, results into 500Hz for fI/O =
8MHz
sei(); // turn interrupts back on
}
}

void loop() {
// nothing to do, its all in the interrupt handlers!
}

unsigned long LastTime_A, NewTime_A, LastTime_B, NewTime_B;

void Send_Interval_A()
{
NewTime_A = micros(); // Resolution 4us, only one overrurn in 70 minutes
Serial.print("A");
Serial.println(NewTime_A-LastTime_A, HEX);
LastTime_A = NewTime_A;
}

void Send_Interval_B()
{
NewTime_B = micros(); // Resolution 4us, only one overrurn in 70 minutes
Serial.print("B");
Serial.println(NewTime_B-LastTime_B, HEX);
LastTime_B = NewTime_B;
}

ISR(TIMER1_COMPA_vect) // when timer counts down it fires this interrupt for
scope-mode
{
if ((Mode=='S') || (Mode=='U'))
{
int val_A = analogRead(Analog_Input_Pin_A);
Serial.write((val_A >> 2));
}
if ((Mode=='T') || (Mode=='U'))
{
int val_B = analogRead(Analog_Input_Pin_B);
Serial.write((val_B >> 2));
}
}
18

4.3 Extension to a multi-channel system
The problem with the approach of section 4.1, is that we can use two channels maximum.
This is because there are only two hardware interrupt inputs on the Arduino (INT0 and INT1).
A suggestion for a solution to go to eight or more channels is shown in Figure 4.1. The
modules PPG1 up to PPG8 are identical circuits like Figure 2.3. The digital outputs are put
together using an 8-input OR port. This port generates the interrupt, for example INT0. It is
the task of the software on the board to determine which of the eight subcircuits caused the
interrupt. This can be done by scanning digital inputs 0 to 7.
PPG 1
PPG 2
PPG 8
Analog input 0
Digital input 0
Analog input 1
Digital input 1
Analog input 7
Digital input 7
INT0 OR

Figure 4.1: Extension to an 8-channel sensor system
19

References
[1] John G. Webster (editor), Medical instrumentation, application and design, second edition,
Houghton Mifflin Company, 1992
[2] John Allen, Photoplethysmography and its application in clinical physiological measurement,
Physiol. Meas. 28 (2007) R1–R39
[3] Sokwoo Rhee, Design And Analysis Of Artifact-Resistive Finger Photoplethysmographic
Sensors For Vital Sign Monitoring, Ph.D. MIT, 2000
[4] Arduino open-source electronics prototyping platform, website www.arduino.cc
[5] Aqua Pulse - Product Details, Finnish website
http://www.finisinc.com/Technology/aquapulse_technology.aspx
[6] Cornell, BioNB 442: Lab 9, Finger Plethysmograph
[7] Pulse Rate Monitor module supplied by Maplin.co.uk, designed by the teaching resources
department of the University of Middlesex
http://www.maplin.co.uk/Module.aspx?ModuleNo=220066&C=5716&U=shop_N56FL
[8] Dogan Ibrahim, Kadri Buruncuk, Heart rate measurement from the finger using a low-cost
microcontroller
[9] Calculating the heartrate with a pulse plethysmograph, Pico Technologies,
http://www.picotech.com/experiments/calculating_heart_rate/
[10] TSL250, TSL251, TSL252, Light-to-voltage optical sensors, Texas Intstruments Datasheet
[11] TSHA520, High Speed Infrared Emitting Diode, 870 nm, GaAlAs Double Hetero, Vishay
Datasheet
[12] Eagle Schematic, Layout and Autorouter, Version 5, both Windows and Mac shareware
versions were used for this project, http://www.cadsoftusa.com/
[13] PSpice Schematic Student edition 9.1, Shareware Windows program, http://www.electronics-
lab.com/downloads/schematic/013/
[14] Eagle to spice User Language Program (ULP script) for Spice netlist export from Eagle. See
http://www.cadsoft.de/download.htm under “ULP”
[15] Charles D. H. Williams, MacSpice 3f5, http://www.macspice.com/
[16] Wolfram Mathworld, http://mathworld.wolfram.com/
[17] M. Malik, J.T. Bigger, A.J. Camm, R.E. Kleiger, Heart rate variability: Standards of
measurement, physiological interpretation, European heart journal, 1996, volume: 17, issue: 3,
pp. 354-381
[18] Wikipedia, page on Heart Rate Variability, http://en.wikipedia.org/wiki/Heart_rate_variability
[19] M. Brennan, M. Palaniswami, P. Kamen, Do existing measures of Poincare plot geometry
reflect nonlinear features of heart rate variability?, IEEE Transactions on Biomedical
Engineering, Volume 48, Issue 11, Nov. 2001, pp. 1342 – 1347
20

Appendix A: Sensors from Kyto Electronics
The ear lobe pulse sensor HRM-2511B is shown in Figure A.1, together with the electrical
connections. There is no rubber shield from environmental light, but no strong disturbing
signals were observed when used indoors. The electrical specifications are summarized in
Table A.1, and were obtained from a datasheet requested from Kyto Electronics. Figure A.2
shows to typical graphs from the same datasheet.

Figure A.1: Ear lobe pulse sensor HRM-2511B

Table A.1: Specifications of the two optoelectronic components in the HRM-2511B ear-lobe clip
LED Photo transistor
Manufacturer Lucky Light Electronics Co. China Lucky Light Electronics Co. China
Device code LL-AR180IRC-2A LL-AR180PTC-1A
Chip material GaAlAs InGaN
Max power 130mW 150mW
Forward current 1A (1/10 duty cycle, 0.1ms pulse width) .
Continuous forward current 65 mA .
Reverse voltage 5V .
Forward voltage 1.2V (I
f
= 70mA) .
Reverse current max 10µA (V
r
= 5V) 5-30nA (dark 0mW/cm
2
, V
r
= 10V)
Operating temperature range -50°C to +85°C -20°C to +80°C
Storage temperature -40°C to 100°C -40°C to +85°C
Peak wavelength 940nm (I
f
=20mA) 940nm
Spectral bandwidth 45nm (I
f
=20mA) 400-1200nm (λ
0.5
)
Radiant intensity 3.0mW/sr (I
f
=20mA)
Open circuit voltage . 0.41 V (5mW/cm
2
, 940nm)
Short-circuit current . 7 µA (5mW/cm
2
, 940nm)
Reverse light current . 4.5 µA (5mW/cm
2
, 940nm, V
r
= 5V)
Reverse breakdown voltage . 32-50V (0mW/cm
2
, 100µA)
Total capacitance . 25pF (0mW/cm
2
, V
r
=3V, 1MHz)
Response time (rise and fall) . 50ns (V
r
=10V, R
L
=1kΩ)

The HRM-2511C and HRM-2511D are similar products, but then in reflection mode. Kyto
Electronics does provide a printed circuit board for filtering, biasing and level detection for all
HRM-2511x products as shown in Figure A.3. We have no experience with this board, but it
is probably similar to our circuit with the absence of the potentiometer.
21


Figure A.2: Collector-current vs. collector-emitter voltage (left-hand) and collector-current vs. Irradiance
(right-hand) for the HRM-2511B

Figure A.3: The HRM-4509 switches analog signals of heart rate into digital signals

22

Appendix B: PSpice netlist

* SPICE netlist from Pulse Sensor.sch
* 18-1-10 22:05
***************************
*
* Node Net
* 0 GND
* 1 +5V
* 2 ANALOG_OUT
* 3 DIGITAL_OUT
* 4 N$1
* 5 N$2
* 6 N$3
* 7 N$5
* 8 N$6
* 9 N$7
* 10 N$8
* 11 N$9
* 12 N$11
* 13 N$12
* 14 N$13
* 15 N$14
* 16 N$16
*
***************************

C1 10 11 2.2uF
C2 9 2 68nF
*connect pin6 to pin12 to remove the potmeter for the simulation
*C4 12 7 2.2uF
C4 6 7 2.2uF
C7 1 0 100nF
C9 5 6 68nF
D1 15 13 1N4148
D2 13 0 1N4148
LED1 16 0 1N4148
XIC1A 11 5 1 0 6 LM358
XIC1B 7 9 1 0 2 LM358
XIC2B 4 14 1 0 3 LM358
R1 10 1 22k
R2 15 9 10k
R3 15 5 10k
R4 6 5 1Meg
*R5 8 1 120
R6 2 9 1Meg
R7 15 11 47k
*connect pin6 to pin12 to remove the potmeter for the simulation
*R8 15 6 12 10k
R8 15 6 10k
R9 4 2 100k
R10 15 7 47k
R11 15 1 4k7
R12 14 15 100k
R13 3 4 1Meg
R14 16 3 2k7

V1 10 0 DC 1V AC 1V PULSE(-2 2 1m 100n 100n 10m 20m)
V2 1 0 5V

*pinorder A K
.MODEL 1N4148 D IS=222p RS=68.6m BV=75.0 IBV=1.00u CJO=4.00p M=0.333 N=1.65 TT=5.76n

* PinOrder: I+ I- V+ V- O
.INCLUDE LM358.cir

.control
ac dec 10 0.01Hz 10kHz
plot log(v(10)) log(v(2)) log(v(6))
.endc

.end

1

Introduction

This chapter describes what photoplethismography is and what can be expected from the implementation presented in this report. 1.1 Background on photoplethysmography (PPG) Plethysmographs measure changes in volume. The only method to measure absolute changes in blood volume accurately in the extremities is by using chamber-plethysmography. The volume change can be converted into blood flow by using F = dV/dt. However, in some cases, we are only interested in the relative volume, for example to see the pulsation rate of the heart. In that case, information is in the timing and not in the amplitude or shape of the signal. If that is the case, we can use electric impedance-plethysmography or photo-plethysmography (PPG). Details on the background of plethysmography can be found in the book of Webster [1]. A more comprehensive review on PPG is the paper of Allen from 2007 [2]. An example of a system design is the thesis of Rhee at MIT from 2000 [3]. A PPG sensor can be used in reflection mode (for example on the finger) or in transmission mode (for example on the ear) as shown in Figure 1.1. Normally, a wavelength in the nearinfrared is used because there we have the strongest modulation of the signal due to light absorption in the haemoglobin in the blood1.

Figure 1.1: (a) Light transmitted into the finger pad is reflected off bone and detected by a photo sensor. (b) Light transmitted through the aural pinna is detected by a photo sensor [1]

1.2

Specifications of the PPG implementation in this report

This document focuses on the following implementation:  optical detection using an ear-lobe clip in transmission mode  pulse filtering by means of a simple analog electronic circuit with a second order bandpass between the characteristic frequencies 1.54Hz and 2.34Hz (-3dB points 1.0 and 3.5Hz) and a gain of 3700 in the peak.  pulse detection using a comparator on the electronic circuit board to send out a digital signal for time-interval measurements  the analog electronic circuit is implemented as an add-on board for the Arduino microcontroller platform [4]  a microcontroller board to measure the timing intervals between heartbeats and to send it to a computer using the USB bus  signal processing on an external computer Some other options for the partitioning over software and hardware are possible:  it is an option to implement the signal post processing (for example HRV algorithms) on the microcontroller board to make a stand-alone application

Note that heamoglobin and oxyheamoglobin pass equally at 805nm and have maximal difference at 660nm. This difference is used in optical oxygen saturation sensors.

1

2

or we may come up with an improved circuit design which included automatic gain control (AGC) 2 3 . The drawbacks. In addition. however. it is noninvasive and the PPG signal is strong and robust. First of all. See for example the “Aquapulse” product [5]. This option might be advantageous to anticipate to level changes in the signal. although the filtering of the raw photo transistor output should be done electronically. the electronic circuit is fairly simple and small. We can live without. The alternative for heart-rate measurements is to use ECG and detect the heart-rate from the R-R intervals. One should carefully consider the advantages and drawbacks of the optical ear-lobe sensor method when designing an application. are the motion artefacts and the need for a potentiometer to adjust the signal2. The potentiometer is not absolutely required. There are some clear advantages. Because there is no electrical contact to the human body it is safe and can even be used in water. it is possible to do the subsequent pulse detection in software from the sampled analog signal.

8]. 2.1: Basic circuit topology The circuit topology is shown in Figure 2. just realise that the circuit of Figure 2. It is also possible to implement heart-rate and HRV algorithms on the Arduino itself. and an ear-clip. the LED is biased. 7. The advantage is that such a device includes a pre-amplifier which will reduce the system noise. sometimes hand-made in a wooden clothes peg [9]. specifications and connector details can be found in Appendix A. pictures.50 for the amount of five and is mainly determined by the shipping costs. This report. The cathode of the LED and the emitter of the photo-transistor are electrically connected and accessible via a normal stereo 3. makes use of ear-clips from Kyto Electronics as described in Appendix A.1. In the first stage. The alternative for a photo transistor is a light-to-voltage optical sensor like the TSL250 [10] which can be used in combination with a TSHA520 infrared LED [11].1 The optoelectronic parts Most of the implementation found elsewhere are using the combination of an infrared-LED and a photo-transistor [1. For an operational voltage of 5V. 6. 2. Characteristics. When having these two.5mm jack connector. the signal processing of chapter 3 can be implemented in any software environment capable of serial communication with an Arduino.2V)/65mA = 58Ω can be used.3 and the Arduino code for interval measurements as shown in section 2.2 Basic implementation This document tries to give sufficient background information to understand the system implementation and choices.4 are the only essential components. The opto-electronic components in these ear-clips consist of an infra-red LED and a phototransistor. The ordering price of the sensor was €6. however. a resistor of (Vcc-Vf)/If = (5V-1. 4 . When this becomes confusing.2 The electronic circuit The electronic circuit has four functions:  Biasing of the LED  Biasing of the photo-transistor  Remove low-frequent motion-artefacts and drift  Isolate the heartbeat pulse R2 C0 C2 R0 R1 LED Photobiasing transistor biasing High-pass filter Low-pass filter/amplifier Figure 2.

For R1 = 10kΩ and R2 = 1MΩ.1 the component values and characteristic frequencies of the circuits found in literature are found.1) Figure 2. Finally. so only the biasing resistors R5 and R1 are visible. The values of Pico Technologies [9] are used in our implementation. the photo-transistor is biased. the high-pass and low-pass filters are implemented twice resulting in a transfer function given by R1R 2    R  R 1  j R  R C 2 j R C  2 0 0 1 2  . the asymptotic gain A = (R1+R2)/R1 square becomes 10. The high-pass filter is a simple first-order RC circuit with a lower frequency bound of (2πR0C0)-1. but is effectively 3700 in the peak.2V. The high pass filter has a cut-off at (2πR2C2)-1 and amplifies (R1 + R2) / R2 times. The choice of this biasing resistor is made based on the example circuits in literature [1. 7. The low-pass filter is implemented as an active filter to facilitate amplification as well. 6. 8] and a value of 22kΩ was used with satisfying results. The sensor is now replaced by a connector. The pin ANALOG_OUT is connected with one of the analog in pins of the Arduino. half of the forward current was chosen by means of a 120Ω resistor.3. so at 1. Between the filter stages a potentiometer is used because it appeared that sometimes the output signal was too big.1. The two diodes define a reference level at two times their band gap.2: Schematic transfer function. H  j    1 1  jR 2C 2 1  jR 0C0   R1     2 (2. In the next stage. To make the bandpass-filter more effective. The combination of R11. because that is the steepness of the PPG pulse signal. the whole circuit is shown in Figure 2.200.with Vf and If the forward voltage and current from the datasheet of Table A. The comparator made with IC2B is used to do threshold detection with the reference level as 5 . We can see that these are roughly the same. The high-pass filter frequency and the low–pass filter frequency have to be chosen such that we end-up with a band-pass filter to amplify the 2Hz frequency. However. created from equation (2. D1 and D2 is used to deal with the symmetrical power of 5V from the Arduino board.1) In Table 2. 2 R1+R2 R1 Modulus 1 2R1//R2)C2 1 1 1 2R0C0 2R2C2 Frequency Figure 2.2 shows the modulus of the transfer function on a log-log scale with the characteristic indicators.

0 kΩ 1.1: Filter implementations of circuits in literature Webster [1] R1 R2 C2 A flp fhp R0 C0 fhp 1.22 Hz 1.84 Hz 1594.00 MΩ 560 kΩ 100 nF 100 nF (122.05 Hz Pico [9] 10.detection level. one normally can take PSpice for Windows [13]. It was made using the netlist and simulation code of Appendix B. As a comparison.34 Hz Figure 2.00)2 2.77)2 1.00 µF 2. including connectors to Arduino Note that the circuit shown in Figure 2. An alternative is to use a User Language Program (ULP) script for exporting PSpice netlists from Eagle [14] and to run it using MacSpice [15]. For circuit simulations.00 µF 0.01 Hz 20.0 kΩ 10.00 µF 0. This program.59 Hz 340.60 MΩ 2.59 Hz 68.4.39 Hz 342. which is unfortunately not available for Mac OSX.00 MΩ 100 nF (213.39 Hz Cornell [6] 1.4 and Figure 2.00 MΩ 68.00 MΩ 100 nF 1.70 kΩ 1. the MacSpice circuit simulation is shown.95)2 1.5 shows the frequency response on pin ANALOG_OUT as calculated using equation (2.39 Hz 47. we can see that our analytical model describes the filter operation sufficiently well.34 Hz 236. and creates a digital out where the rising edge can be used for timing interval measurements.0 kΩ 1. In Figure 2.16 Hz 1. can be used to draw circuits and to assist with printed circuit board development.00 kΩ 100 kΩ 470 nF (101.80 Hz Maplin [7] Stage 1 Stage 2 4.00 kΩ 1.5.3 was drawn using the free version of Eagle Schematic [12].59 Hz 195. This means that the operational amplifiers are assumed to be ideal and the reference level construction with the two diodes is omitted. which is available for Windows and Mac OS-X.68 Hz (561.00 MΩ 1. Table 2.20 µF 1.1).00)2 3.3: Complete circuit.00)2 2. By comparing Figure 2.20 kΩ 1.54 Hz Ibrahim [8] Stage 1 Stage 2 8.0 kΩ 2.0 µF 0.0 nF (101. and would require re-drawing of the circuit. Figure 2. 6 .

and trace v(2) the signal after the second stage. Figure 2. measured on pin “ANALOG_OUT” 7 . As can be seen in the netlist of Appendix B. In Figure 2.5: Calculated frequency response of the filter circuit of Figure 2. The blue trace is the reference level and the orange trace the PPG signal.6: Oscilloscope image of measured heartbeat. trace v(10) is the input signal.4: Transfer function simulated with MacSpice. The comparator stage will have no problem to detect the zero crossings.3 using equation (2.6 the oscilloscope image is shown.1) Finally.Figure 2. trace v(6) the signal after the first filter stage. the circuit is made on a printed circuit board and tested. so equal to ANALOG_OUT 1 10 4 1 10 Modulus [] 3 100 10 1 0.1 1 10 100 Frequency [Hz] 1 10 3 1 10 4 Figure 2.

To sample at 500Hz. 8MHz sei().2. In CTC mode the counter is cleared to zero when the counter value (TCNT1) matches the OCR1A. TIMSK1 |= (1 << OCIE1A). } // // // // // // // For sending data to the computer over USB disable interrupts while messing with their settings clear default timer settings timer in normal mode Configure timer 1 for CTC mode Set timer prescaling by setting 3 bits 001=1. The waveform generated will have a maximum frequency of fOC1A = fclk_I/O/2 when OCR1A is set to zero (0x0000). results into 500Hz for fI/O = // turn interrupts back on void loop() { // nothing to do. TCCR1A = 0x00. The second approach is to use the digital signal from the comparator and create a hardware interrupt at every low-to-high zero crossing. const int Analog_Input_Pin = 0. hence the name “oscilloscope mode”. The waveform frequency is defined by the following equation: f OCnA  2  N  1  OCRnA  f clk _ I / O (2. The code for sampling the analog signal on the analog pin 0 with a fixed frequency of 500Hz is as follows: const int Baudrate = 19200. 100=256. } 2. 256. 011=64. or 1024).write( (val >> 2)). OCR1A = 124.3) is connected to digital pin 2 of the Arduino. its all in the interrupt handlers! } ISR(TIMER1_COMPA_vect) // when timer counts down it fires this interrupt for scope-mode { int val = analogRead(Analog_Input_Pin). TCCR1B = 0x00. This is a good option to view the analog signal. the interesting 8 . we have to use a timer interrupt. TCCR1B |= (1 << CS11). void setup() { Serial. When doing so. In “Clear Timer on Compare” or “CTC mode” (WGM13:0 = 4). hence also its resolution. 8. the output signal of the comparator (DIGITAL_OUT in Figure 2. TCCR1B |= (1 << CS10). The OCR1A defines the top value for the counter. Serial. 101=1024 // Enable CTC interrupt with OCF1A flag in TIFR1 // Set CTC compare value. TCCR1B |= (1 << WGM12). This will be described in the next section.2) The N variable represents the prescaler factor (1. cli(). In the first option. the OCR1A register is used to manipulate the counter resolution. 64. we sample the analog input at equidistant intervals.3 Arduino code: Analog “oscilloscope” mode For the Arduino code we can have two approaches.4 Arduino code: Digital timing interval mode In interval mode.begin(Baudrate). The concept is that this pin can generate an INT0 hardware interrupt at every low-to-high zero crossing. TCCR1B |= (0 << CS12). and is referred to as “interval mode”. 010=8.

println(NewTime-LastTime. contains INT0 // the pin that the heart-rate sensor is attached which void setup() { Serial. Send_Interval.begin(Baudrate). It is up to the user to choose the favorite programming environment to represent the data. attachInterrupt(0. const int Digital_Input_Pin = 2. The code looks like: const int Baudrate = 19200. j. LastTime = NewTime.5 Postprocessing of interval data The Arduino sends high resolution samples over the USB bus to a computer for evaluation.information is in the time between the interrupt and the previous interrupt. // Resolution 4us.7: LabView program screenshot 9 . NewTime. This time can be measured with a resolution of 4µs which is more than accurate enough. Figure 2. } 2. its all in the interrupt handlers! } unsigned long LastTime. HEX). RISING). // For sending data to the computer over USB pinMode(Digital_Input_Pin. A LabView shell is available which gives primary information and can store the data for more advanced post-processing. // Attach to INT0 } void loop() { // nothing to do. only one overrurn in 70 minutes Serial. INPUT). void Send_Interval() { NewTime = micros().

Figure 2.8:LabView program screenshot 10 .

etc. so we can say t i  t i 1   x i . In that case.1: Asynchronous interval signal The signal is characterized by:  Samples xi are discrete in amplitude: these are unsigned-long (4 bytes = 32 bits) numbers representing the time intervals in µs. (3. the time intervals are transmitted over the USB/serial line with a very timeunreliable protocol. When we have a stationary situation. x1 x2 x3 x4 x5 t1 t2 t3 t4 t5 Time Figure 3. More details on the mathematical background of signal processing of stochastic signals can be found on the web at Wolfram MathWorld [16]. for example.) at t1 are identical to the characteristics at tN for every N. The signal becomes non-stationary. we can consider the data sequence x as a quasisynchronous signal.  The lengths of the time intervals [ti . we may assume the asynchronous signal to be “stationary”. This means the mathematical average of the samples x is equal to the average heart-rate and equal to the nominal sample interval.ti-1] is small with respect to the absolute interval. It is sketched in Figure 3. when we change the level of physical exercise or arousal during a single measurement.1 as a series of samples xi. This means that the characteristics (average. In mathematical writing: t i ' t i 1 '  1 (3.1) However. The input signal is the digital interval information from the Arduino. we have to work with a running average or an alternative representation technique. Over a certain time period. Because the actual time resolution as specified by Arduino is 4µs. Between every two subsequent data samples xi and xi-1 there is a square surface because the height of the sample is equal to the time-spacing with the previous sample. and the variation on the intervals [ti . but with the real intervals in the amplitudes xi.1 Heart-rate in the time domain (1): the asynchronous signal The digital signal coming from the Arduino has the strange phenomenon that samples do not come in at equidistant periods: the signal is asynchronous.ti-1] are equal to the numbers represented in the samples. 3. standard deviation. we can think of the signal as a synchronous signal (meaning fixed periods between the samples). There is not enough significance in the timing information. meaning we have 30 bits effectively in the amplitudes of xi. Realizing this. and we should take the amplitude information as the source for signal processing. It also provides some terminology commonly used for stochastic signals.3 Signal processing This chapter gives some basic formulas for implementing heart-rate and heart-rate variability algorithms in your software. the two lower bits are not significant.2) 11 .

standard deviations and even FFT’s (spectral analysis). The second solution becomes the only option when comparing two heart-rates (cross correlations). The first option with µ1 as the synchronous time base works well for local heart rate averages. In the second case we assume the heart rate was equal to xi during the whole previous interval ti-1 to ti. The expectation value of the k-th moment is defined as  k  x k    x f x dx k (3. can be described in terms of “moments” of the “expectation value”.3) for continuous functions. In the top graph. Ergodic processes make the mathematics much easier. the samples are mapped onto an equidistant (= synchronous) sample peak series (red) with a spacing equal to the average heart rate µ0.xN this becomes  k  x k   x i f x  . In this definition. They appear at asynchronous intervals. For a finite discrete realisation (“ensemble”) x1. 12 . mapped onto an equidistant time grid. f(x) is the probability function of the “process” or “signal” x.4) Note that a process where the probability function f(x) can be determined from each individual realisation x1. k i 1 N (3. but now with a subsampled higher data rate with arbitrary spacing. Satisfying results have been observed with re-sample intervals of 100ms up to 500ms. for our signal the probability function f(x) is equal to 1/N.xN is called “ergodic”. This is a good compromise between numerical reliability and the increase of data points.with µ1 the average of the intervals xi and ti’ the equivalent of the sample times ti...2: Two options for interpretation of the asynchronous heart rate sample peak series of the Arduino into a synchronous equivalent.2. Two options are possible as shown in Figure 3. For example. we have converted to a synchronous sample peak series as well. See text for explanation The Arduino heart pulse interval samples are the black sample peaks. x1  t1 t2 x2  t3 x3  t4 x4  t5 Time x5 x1 x2 x3 x4 x5 t1 t2 t3 t4 t5 Time Figure 3. because every sample has the same probability of occurrence and the process is ergodic.2 Heart-rate in the time domain (2): key characteristics Characteristics in the time domain. In the lower graph. 3.

we can simply use (inverse) Fast Fourier Transforms (FFT’s) to generate frequency spectra of our data. where we want to plot the variations in mean and/or standard deviation. but the most common is the “exponential moving average” EMA: the new one is simply added using a weighting factor. Note that R xx 0  1  2 2 (3.The first order and second order moments have a well-known meaning. moving averages are not in the standard representation methods of heart-rate variability. A higher α discounts older observations faster. It is important to know that the autocorrelation function is the Fourier transform of the spectral density function Sxx(f).1. The second order moment is normally taken around the mean. For example. there is normally no time to calculate the average of the whole dataset. N i 1 (3. we have sufficient time (almost a second) between two subsequent samples. 13 .8854. N = 19 is equivalent to α = 0.10) showing that we only have to store the previous EMA. and given by  2  x  1    x i  1  f x   2 2 i 1 N 1 N  x i  1 2  2 .7) The term σ2 is the variance and is the square of the standard deviation σ. α may be expressed in terms of N time periods.5) where we can include the probability function f(x)=1/N and find 1  x   x i f x    i 1 i 1 N N xi 1 N   xi N N i 1 (3. a number between 0 and 1. The equation is EMA i  x i  1   EMA i 1 (3. Note that in our case of heartbeats. Therefore. Variance can be interpreted as the correlation of a signal with itself. The first order moment (k = 1) is equal to 1  x   x i f x  i 1 N (3. According to the Wiener-Khinchin Theorem. Consider the expectation value of a signal x on time t with the same signal x on time t+τ. Alternatively.8) which is called the “autocorrelation function”. We can write R xx   x t x t    (3. The algorithms to calculate a moving average have the advantage that we do not have to store and recall all the previous samples. where α = 2/(N+1). The half-life of the weights (the interval over which the weights decrease by a factor of two) is approximately N/2.9) is the absolute maximum of Rxx in  = 0. In such cases. The degree of weighing decrease is expressed as a constant smoothing factor α. or a series of subsets.6) which is known as the average of ensemble x. we can even generate the power spectrum immediately from the raw data without generating the cross-correlation function first. So. In time critical applications. with our discrete signals. There are many moving average options. a moving average is taken.

This means we can transform to the frequency domain using Fast Fourier Transforms (FFT). the spectrum has a relation between the frequency and power axis as well. and then do the FFT.021Hz.xN. Half the sampling frequency is the highest frequency in the FFT result: the higher points are a symmetrical copy of the lower frequency points. Time-domain methods These are based on the beat-to-beat or NN intervals.. the standard deviation of NN intervals.021Hz.  The result is that the frequency resolution is equal to (µ1N)-1Hz. using R xy    x t yt    . A practical example is the following. the standard deviation of the average NN intervals calculated over short periods. Because this is a huge peak in our case with respect to the more interesting information in the higher frequencies. 2 (3.2 is used. or in other words the power of the average heart rate. SDANN is therefore a measure of changes in heart rate due to cycles longer than 5 minutes. 14 . 3. An FFT of any number of samples would contain frequency information up to half the sampling frequency. 3. This maps onto a horizontal frequency axis as  X1 is the power of the DC content. (3.5 HRV standards Some representations of the average. For linear system we can find Sxy f   Sxx f Syy f  .  SDANN.625Hz.  RMSSD. So with X1 at 0Hz. With one minute of sampling.  XN/2 is the power at the half the sampling frequency. so corresponding to the power at a frequency of (2µ1)-1Hz..12) a condition sometimes used to to check the linear relation between x and y.125Hz.XN. this corresponds to a heart rate of 75 bpm. which are analyzed to give variables such as:  SDNN. so 0. we have to measure for at least one minute. For a sampled sequence of N points x1. 18]. Note that due to the relation between amplitude and average asynchronous sample interval (equation (3. the FFT returns N frequency values X1. the number of pairs of successive NNs that differ by more than 50 ms. Often calculated over a 24-hour period. it can be wise to remove the average DC signal from the signal x1. This will not be the case when the synchronous subsampling of Figure 3. So. the lowest frequency visible in the spectrum is 0.2)). the square root of the mean squared difference of successive NNs. for observing variations in the heart rate lower than 0. or 0. standard deviation and frequency components have become widely acceptable in the field of heart-rate variability [17.3 Heart-rate in the frequency domain The signal has a discrete time and a discrete amplitude.11) The (inverse) Fourier transform of the cross-correlation function is called the cross-spectrum. When the Arduino board returns a nominal heart beat interval of 800ms.xN first. usually 5 minutes.. we can define cross-correlations between signals x and y. X2 is at (µ1N)-1Hz.  NN50. 60 samples.3.4 Cross correlation in time and frequency Besides the concept of autocorrelation.

The major background of ULF is day–night variation and therefore is only expressed in 24-hour recordings. The origin of VLF is not well known. LF derives from both parasympathetic and sympathetic activity and has been hypothesized to reflect the delay in the baroreceptor loop. the relation between two neighbouring intervals is plotted as shown in Figure 3. 15 .0033 Hz.4 Hz.  Very Low Frequency band (VLF) band between 0. using parametric or nonparametric methods.  Ultra Low Frequency (ULF) band between 0 and 0. One of the most commonly used PSD methods is the Fast Fourier transform.15 Hz. Geometric methods are a subclass of time-domain measures in which the NN intervals are converted to a geometric pattern.04 Hz. but this is controversial because of the lack of understanding of the mechanisms for the LF component.  Low Frequency band (LF) between 0. HF is driven by respiration and appears to derive mainly from vagal activity (parasympathetic nervous system).0033 and 0.04 and 0. then analyzed. The ratio of low-to-high frequency spectra power (LF/HF) is has been proposed as an index of sympathetic to parasympathetic balance of heart rate fluctuation. Figure 3. In a Poincaré plot. Most of these methods use a discrete scale for the NN interval length. It is described scientifically and mathematically correct by Brennan in 2001 [19].15 and 0. pNN50. provides basic information of the power (variation) distribution across frequencies. the proportion of NN50 divided by total number of NNs. Several frequency bands of interest have been defined in humans:  High Frequency band (HF) between 0.3: Poincaré plot with on the horizontal axis the NN intervals and on the vertical axis the length of the previous NN interval [19] Frequency-domain methods Several methods are available.3. Power spectral density. a paper which is also useful for the other time-domain evaluation methods.

const int const int const int const int const int int Mode. depending on the channel. 4. Although the variation on the reference level is quite small.read(). After a reset. Continued on next page 16 . not as a character) depending on single channel or two channel operation. the measured interval is put on the USB bus as character “A” or “B”. Baudrate = 19200. the code first acknowledges by sending the prompt “>”. INT0 Analog_Input_Pin_B = 1.. ECG. The power supply is shared by the two sub-circuits. for example respiration rate. 4. the computer has to indicate which mode is preferred.available()==0){ } Mode = Serial. and next the time interval as a hexadecimal string in µs resolution. Next. The reason is that a pulse signal on channel A will push down the reference level a little bit. but the reference level (defined by R11 and the two diodes D1 and D2) can not be shared. Digital_Input_Pin_B = 3. // heart-rate sensor. called A and B... while (Serial. INT1 void setup() { Serial. The ANALOG_OUT of the first circuit to analog input 0 and the other to analog input 1 of the Arduino. we need two timed hardware inputs. // heart-rate sensor. the circuit of Figure 2..3 is simply implemented twice. the final cross-talk signal will be in the same amplitude range as actual heartbeats. the technical solutions are applicable for any second sensor next to the PPG sensor.. Note that of the 10resolution. due to the amplification of 3700 times.1 Hardware For a 2-channel system. In oscilloscope mode. the two least significant bits are simply discarded..2 Arduino Code The following code has the additional feature that it supports both analog and digital inputs for two channels. either one byte or two bytes are put on the USB bus (as a byte. Digital_Input_Pin_A = 2. The options are:  Mode “I”: measure timing intervals for channel A only  Mode “K”: measure timing intervals for channel B only  Mode “J”: measure timing intervals for channel A and B  Mode “S”: sample channel A at 500Hz  Mode “T”: sample channel B at 500Hz  Mode “U”: sample channels A and B at 500Hz In the timing interval mode.begin(Baudrate). // For sending data to the computer over USB . Although this chapter focuses on the measurement of two heart rates. One DIGITAL_OUT is connected to digital pin 2 (INT0) of the Arduino and the other to digital pin 3 (INT1). This would cause an inverted signal on channel B and vice versa. Analog_Input_Pin_A = 0. Serial. etc.4 Full two-channel system For measuring the cross-correlation between two heart-rates.print("Start"). These channels can be selected individually or together.

INPUT). Serial. RISING). 011=64.print("A"). } ISR(TIMER1_COMPA_vect) // when timer counts down it fires this interrupt for scope-mode { if ((Mode=='S') || (Mode=='U')) { int val_A = analogRead(Analog_Input_Pin_A). switch (Mode) { case 'I': // Interval mode. } if ((Mode=='T') || (Mode=='U')) { int val_B = analogRead(Analog_Input_Pin_B). RISING).. LastTime_A = NewTime_A. // Resolution 4us. // Enable CTC interrupt with OCF1A flag in TIFR1 OCR1A = 124. void Send_Interval_A() { NewTime_A = micros(). input A and B pinMode(Digital_Input_Pin_A. this kills the millis() function. 100=256. attachInterrupt(0. only one overrurn in 70 minutes Serial. // timer in normal mode TCCR1B |= (1 << WGM12). INPUT). pinMode(Digital_Input_Pin_B. RISING). // Set CTC compare value. T = B only. } void Send_Interval_B() { NewTime_B = micros().. S = A only.write((val_A >> 2)). RISING). // Set timer prescaling by setting 3 bits TCCR1B |= (1 << CS11).. HEX).write((val_B >> 2)). // clear default timer settings. // Attach to INT0 attachInterrupt(1. HEX). attachInterrupt(0. // turn interrupts back on } } void loop() { // nothing to do. attachInterrupt(1. INPUT). its all in the interrupt handlers! } unsigned long LastTime_A. input B only pinMode(Digital_Input_Pin_B. Serial.print("B"). results into 500Hz for fI/O = 8MHz sei().. Serial.println(NewTime_A-LastTime_A. } } 17 . // Attach to INT1 break.. INPUT). Serial. // disable interrupts while messing with their settings TCCR1A = 0x00. TCCR1B = 0x00. U = A and B cli().Continuation from previous page . LastTime_B. Send_Interval_A.. // Attach to INT1 break. NewTime_B. 010=8.println(NewTime_B-LastTime_B. // Configure timer 1 for CTC mode TCCR1B |= (0 << CS12). 101=1024 TCCR1B |= (1 << CS10). NewTime_A. Send_Interval_B. case 'J': // Interval mode. // 001=1. only one overrurn in 70 minutes Serial. TIMSK1 |= (1 << OCIE1A). Send_Interval_A. // Resolution 4us. input A only pinMode(Digital_Input_Pin_A. // Attach to INT0 break. Send_Interval_B. LastTime_B = NewTime_B. default: // Scope mode. case 'K': // Interval mode.

PPG 1 PPG 2 Digital input 0 Digital input 1 Digital input 7 OR INT0 PPG 8 Analog input 0 Analog input 1 Analog input 7 Figure 4. This port generates the interrupt.4. for example INT0.3. is that we can use two channels maximum. The modules PPG1 up to PPG8 are identical circuits like Figure 2.1: Extension to an 8-channel sensor system 18 . This is because there are only two hardware interrupt inputs on the Arduino (INT0 and INT1). A suggestion for a solution to go to eight or more channels is shown in Figure 4. It is the task of the software on the board to determine which of the eight subcircuits caused the interrupt. The digital outputs are put together using an 8-input OR port.1.3 Extension to a multi-channel system The problem with the approach of section 4. This can be done by scanning digital inputs 0 to 7.1.

High Speed Infrared Emitting Diode. Meas.cadsoft. A. BioNB 442: Lab 9. http://www.org/wiki/Heart_rate_variability M.htm under “ULP” Charles D. Bigger.aspx Cornell.com/experiments/calculating_heart_rate/ Pico Technologies. issue: 3. http://www.wikipedia.com/ M. Light-to-voltage optical sensors. Texas Intstruments Datasheet TSHA520.uk. R. Kamen. physiological interpretation. Kleiger. Photoplethysmography and its application in clinical physiological measurement. Palaniswami.T. volume: 17.arduino. European heart journal. http://mathworld. Layout and Autorouter. second edition. 2001.uk/Module. Heart rate measurement from the finger using a low-cost microcontroller Calculating the heartrate with a pulse plethysmograph. website www. See http://www. 870 nm.co. Physiol. Do existing measures of Poincare plot geometry reflect nonlinear features of heart rate variability?. 1996.macspice. page on Heart Rate Variability. Vishay Datasheet Eagle Schematic.com/Technology/aquapulse_technology. pp.J. Medical instrumentation. http://www. Ph. Nov.aspx?ModuleNo=220066&C=5716&U=shop_N56FL Dogan Ibrahim. Brennan. application and design. GaAlAs Double Hetero. IEEE Transactions on Biomedical Engineering. Issue 11. Houghton Mifflin Company. http://en. Version 5.wolfram. P. Malik.electronicslab. MacSpice 3f5. Volume 48. Webster (editor). 2000 Arduino open-source electronics prototyping platform.D.picotech. http://www. Design And Analysis Of Artifact-Resistive Finger Photoplethysmographic Sensors For Vital Sign Monitoring. 1992 John Allen.cadsoftusa. Kadri Buruncuk. [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] TSL250. Finnish website http://www.com/ PSpice Schematic Student edition 9.com/ Wolfram Mathworld.finisinc. TSL252. pp. both Windows and Mac shareware versions were used for this project.References [1] [2] [3] [4] [5] [6] [7] John G.com/downloads/schematic/013/ Eagle to spice User Language Program (ULP script) for Spice netlist export from Eagle. M. J.1. 1342 – 1347 [18] [19] 19 . 354-381 Wikipedia. TSL251.co. Shareware Windows program. 28 (2007) R1–R39 Sokwoo Rhee. Camm.E. Williams. Finger Plethysmograph Pulse Rate Monitor module supplied by Maplin.Product Details.de/download. Heart rate variability: Standards of measurement.maplin. designed by the teaching resources department of the University of Middlesex http://www. H. MIT.cc Aqua Pulse .

1ms pulse width) 65 mA 5V 1. but no strong disturbing signals were observed when used indoors. Figure A. Photo transistor Lucky Light Electronics Co. Vr = 5V) 32-50V (0mW/cm2.2 shows to typical graphs from the same datasheet.1: Ear lobe pulse sensor HRM-2511B Table A.1: Specifications of the two optoelectronic components in the HRM-2511B ear-lobe clip Manufacturer Device code Chip material Max power Forward current Continuous forward current Reverse voltage Forward voltage Reverse current max Operating temperature range Storage temperature Peak wavelength Spectral bandwidth Radiant intensity Open circuit voltage Short-circuit current Reverse light current Reverse breakdown voltage Total capacitance Response time (rise and fall) LED Lucky Light Electronics Co. 100µA) 25pF (0mW/cm2. RL=1kΩ) The HRM-2511C and HRM-2511D are similar products. Figure A. but then in reflection mode. Vr=3V. 1MHz) 50ns (Vr=10V.0mW/sr (If=20mA) . .2V (If = 70mA) 10µA (Vr = 5V) -50°C to +85°C -40°C to 100°C 940nm (If=20mA) 45nm (If=20mA) 3. and were obtained from a datasheet requested from Kyto Electronics. 940nm. 0. . There is no rubber shield from environmental light. China LL-AR180PTC-1A InGaN 150mW . 940nm) 4. China LL-AR180IRC-2A GaAlAs 130mW 1A (1/10 duty cycle. . 5-30nA (dark 0mW/cm2. biasing and level detection for all HRM-2511x products as shown in Figure A. Kyto Electronics does provide a printed circuit board for filtering.Appendix A: Sensors from Kyto Electronics The ear lobe pulse sensor HRM-2511B is shown in Figure A. . 940nm) 7 µA (5mW/cm2. . together with the electrical connections.3.1. . We have no experience with this board.41 V (5mW/cm2. but it is probably similar to our circuit with the absence of the potentiometer. .1.5 µA (5mW/cm2. 20 . The electrical specifications are summarized in Table A.5) 0. Vr = 10V) -20°C to +80°C -40°C to +85°C 940nm 400-1200nm (λ0. .

3: The HRM-4509 switches analog signals of heart rate into digital signals 21 .2: Collector-current vs.Figure A. Irradiance (right-hand) for the HRM-2511B Figure A. collector-emitter voltage (left-hand) and collector-current vs.

00p * PinOrder: I+ I.76n 22 .2uF C7 1 0 100nF C9 5 6 68nF D1 15 13 1N4148 D2 13 0 1N4148 LED1 16 0 1N4148 XIC1A 11 5 1 0 6 LM358 XIC1B 7 9 1 0 2 LM358 XIC2B 4 14 1 0 3 LM358 R1 10 1 22k R2 15 9 10k R3 15 5 10k R4 6 5 1Meg *R5 8 1 120 R6 2 9 1Meg R7 15 11 47k *connect pin6 to pin12 to remove the potmeter for the simulation *R8 15 6 12 10k R8 15 6 10k R9 4 2 100k R10 15 7 47k R11 15 1 4k7 R12 14 15 100k R13 3 4 1Meg R14 16 3 2k7 V1 V2 10 0 DC 1V AC 1V PULSE(-2 2 1m 100n 100n 10m 20m) 1 0 5V *pinorder A K .01Hz 10kHz plot log(v(10)) log(v(2)) log(v(6)) .65 TT=5.sch * 18-1-10 22:05 *************************** * * Node Net * 0 GND * 1 +5V * 2 ANALOG_OUT * 3 DIGITAL_OUT * 4 N$1 * 5 N$2 * 6 N$3 * 7 N$5 * 8 N$6 * 9 N$7 * 10 N$8 * 11 N$9 * 12 N$11 * 13 N$12 * 14 N$13 * 15 N$14 * 16 N$16 * *************************** C1 10 11 2.cir .INCLUDE LM358.control ac dec 10 0.O .V+ V.Appendix B: PSpice netlist * SPICE netlist from Pulse Sensor.endc .00u CJO=4.MODEL 1N4148 D IS=222p RS=68.2uF C4 6 7 2.0 IBV=1.2uF C2 9 2 68nF *connect pin6 to pin12 to remove the potmeter for the simulation *C4 12 7 2.6m BV=75.333 N=1.end M=0.