• Non ci sono risultati.

Development of a novel wearable ring-shaped biosensor

N/A
N/A
Protected

Academic year: 2021

Condividi "Development of a novel wearable ring-shaped biosensor"

Copied!
131
0
0

Testo completo

(1)

UNIVERSITA’ DEGLI STUDI DI PISA Facoltà di Ingegneria

Corso di laurea specialistica in Ingegneria Biomedica

TESI DI LAUREA

DEVELOPMENT OF A NOVEL WEARABLE RING-SHAPED BIOSENSOR

RELATORE:

Dott. Filippo CAVALLO

CONTRORELATORE Dott. Alessandro TOGNETTI

Candidato Olga DIYAKONOVA

(2)
(3)

Abstract

Nowadays, more and more, wearable devices are required in numerous application fields. The ground gained by this technology ranges from daily activity monitoring to medical applications and social communication.

In such a context, physiological sensors housing devices are inserted, among the most important requisites for these objects there is their miniaturization.

The present thesis work is aimed to design, to characterise and to validate a novel ring-shaped biosensor prototype. In particular, the system is required to monitor galvanic skin response and heart rate variability. Two commercial solutions have been implemented for this purpose: The Maxim 30100 photoplethysmography and the Seeed GSR sensors. A wearable prototype system, governed by a core ST’s STM32F401RE MCU and equipped with Bluetooth communication module, was obtained. A signal acquisition interface and signal elaboration algorithms have been developed in this work as well.

The customized wearable physiological system evaluation has been carried out by means of comparison with other commercial devices chosen as gold standard, i.e. the Shimmer’s GSR+ unit and the BioHarness’ Zephyr BH3.0 chest belt.

In order to evaluate the device performances, tests on 6 subjects were carried out. Attention was paid to realize a protocol capable of exploit these sensors in both mental and physical stress activities.

The main GSR and HRV parameters were extracted and the error between the waveforms obtained by our system and the gold standards were compared.

Reliable performances were obtained, especially in those cases in which the subject does not need to perform ample arm movements whilst wearing the device. In particular, the relax and the mental stress phases gave interbeat interval curves errors with a mean linear regression coefficient of determination of 0.7 ± 0.07 and a mean RMSE of 23.9 ± 12.0 ms (in a range of 400 ms), whilst for the GSR curves a R2 of

0.5 ± 0.3 and a RMSE of 0.0213 ± 0.0124 µS (in a range of 0.2333 µS) were obtained.

Importantly, the results of this work pave the way to the development of an easy to use wearable sensorised system suitable for health care, driving assisting and activity recognition.

(4)

Contents

Abstract ... 3 Contents ... 4 List of figures ... 6 List of tables ... 7 Introduction ... 8 Wearable technology ... 8

Aims of the work ... 10

1 Galvanic Skin Response and Heart Rate Variability ... 12

1.1 Galvanic Skin Response ... 12

1.1.1 Physiology in brief ... 12

1.1.2 A simple model ... 13

1.1.3 Methods of measurement ... 14

1.1.4 Signal dynamics and parameters extracted ... 16

1.2 Heart Rate and Heart Rate Variability ... 19

1.2.1 Features extracted in HRV analysis ... 19

1.2.2 Heart rate measurement systems ... 22

1.3 Existing solutions: sensing GSR and HRV contemporary. Literature review. ... 29

1.3.1 Empatica™ ... 29

1.3.2 Shimmer3 GSR+ unit ... 30

1.3.3 Silver sensors on patches ... 31

1.3.4 Other ring-shaped solutions ... 32

2 Materials and methods ... 34

2.1 The general idea ... 34

2.2 STM32 F401RE Nucleo board ... 34

2.2.1 Integrated Development Environment interface: IAR ... 39

2.2.2 System heart: the clock ... 39

2.2.3 Timing ... 42

2.2.4 Nucleo General-Purpose Input/Output (GPIOs) ... 46

2.2.5 Analog to digital converting ... 48

(5)

2.3 The Sensors chosen ... 55

2.3.1 GSR: inspiring to the Seeed solution ... 55

2.3.2 HRV: Maxim MAX30100 ... 62

2.4 Data collecting ... 71

2.4.1 The Bluetooth connection ... 74

2.4.2 Signal acquisition computer side: the runnable ... 77

2.5 Data processing and features extraction ... 83

2.5.1 GSR signal insights ... 83

2.5.2 HR data processing ... 89

2.6 Testing ... 96

2.6.1 Instrumentation... 96

2.6.2 Experimental protocol ... 99

3 Results and discussion ... 101

3.1 Testing results: features and waveforms comparison ... 105

3.1.1 Relax phase features ... 106

3.1.2 Mental stress phase features (Type 2) ... 110

3.1.3 Physical stress phase features ... 114

3.1.4 Waveform trends comparison ... 119

3.2 Discussion ... 123

3.3 Summary and conclusions ... 125

(6)

List of figures

Figure 1.1 Anatomy of an eccrine sweat gland. From [9] and [12]. ... 13

Figure 1.2 The electrical model of the GSR mechanism. From [14] ... 14

Figure 1.3 Components of an SCR signal (From [9]) ... 17

Figure 1.4 A scheme of the reflectance pulse oximetry paradigm: the light portion that passes through the skin is influenced by the underlying blood vessels content, in a so called “banana-shaped” path connecting the LED and the Photodetector. ... 23

Figure 1.5 Absorption spectra of Hemoglobin, with IR (at 700 nm) and Red (at 900 nm) highlighted. ... 25

Figure 1.6 A representation of the PPG signal origin, with the alternated component generated by the pulsatile part of artery blood. From [39]... 26

Figure 1.7 ECG and PPG waveforms in comparison. ... 26

Figure 1.8 Reflective and transmittal PPG waveforms under comparison during motion application. From [45] ... 28

Figure 1.9 Empatica E3 features (from[49])... 29

Figure 1.10 Empatica E3 software architecture. From [50] ... 30

Figure 1.11 Shimmer3 GSR+ unit solution ... 30

Figure 1.12 The flexible patch structure and appearance. From [48] ... 31

Figure 2.1 The Nucleo STM32 product family. From the ST’s official site. ... 35

Figure 2.2 The Nucleo board hardware apearence ... 36

Figure 2.3 The STM32 Nucleo board features used highlighted on the Features and peripherals conunts Table, from the STM32F401xD STM32F401xE datasheet ... 37

Figure 2.4 STM32F401xD/xE block diagram from the Datasheet ... 38

Figure 2.5 STM32F401xD/xE clock tree, from the reference manual ... 40

Figure 2.6 The NVIC block scheme ... 43

Figure 2.7 A scheme of the timing paradigm needed for the acquisition of two signals. ... 44

Figure 2.19 The ports needed for the Seeed signal acquisition on the Arduino connectors table and the electrical schematic of the User Manual. ... 61

Figure 2.28 The ST’s SPBT2632C2A class-2 Bluetooth module (a) and its evaluation module, the STEVAL-SPBT3ATV3 ... 74

Figure 2.39 Extraction of the baseline level from the signal cleans it from the spurious components, giving a waveform easier to procees ... 90

Figure 3.1 General trend of the HR (a) and GSR (b) signals acquired from the system developed during the entire trial (subject 4). ... 101

Figure 3.2 Heart beat waves compared between the devised device reflectance signal (in blue) and the Zephyr ECG signal (in red). ... 102

Figure 3.3 GSR signal of the devised device (in blue) and of the Shimmers’ signal (in red) after signals calibration. ... 103

Figure 3.4 An example of a missed peak for Simmer device. ... 103

Figure 3.5 A piece of the IBI signal waveforms analysed for the relax task. ... 106

Figure 3.6 A piece of the GSR signal waveforms analysed for the relax task. ... 108

(7)

Figure 3.8 A piece of theGSR signal waveforms analysed for the mental stress task. ... 113

Figure 3.9 A piece of the IBI signal waveforms analysed for the physical stress task. ... 115

Figure 3.10 A piece of the GSR signal waveforms analysed for the physical stress task. ... 117

Figure 3.11 R2 IBI waveform errors along the tasks for each participant. ... 121

Figure 3.12 R2 EDR waveform errors along the tasks for each participant. ... 122

Figure 3.13 Dislocation of ring sensors due to external load. (a) Traditional single-body design under external force. (b) The “MIT ring” isolating sensor under external force. From [57]. ... 123

Figure 3.14 Self-adjusting mechanism of the finger ring (a) and distribution of optical components over the flexible PCB: two photo-diodes and 4 LEDS (b). From [56] ... 124

Figure 3.15 Optical probe placements study from [53] (a) and [55] (b). ... 124

List of tables

Table 1 Electrodermal measures, definitions, and typical values. Taken from [9]. ______________________ 16 Table 2 Hear rate variability time domain parameters ______________________________________________ 20 Table 3 Commercial products embedding EDA or HR sensors available, with the ring-form in common __________ 32 Table 4 Ring solutions in literature _____________________________________________________________ 32 Table 5: Interbeat interval curves errors ________________________________________________________ 119 Table 6 GSR curves error __________________________________________________________________ 121

(8)

Introduction

Wearable technology

Wearable electronics pave the way to a simpler use and a stronger presence of technology in our lives. Nowadays, we say wearable tech, tech togs, fashionable technology or wearable devices whilst such technology could be only dreamt and depicted in sci fi until few years ago.

These are smart wearable electronic devices embedding computational and sensorial capabilities continuously monitoring the physiological parameters of the person wearing them and/or the surrounding environment conditions.

Generally, the term is referred to items which can be put on and taken off easily, but there are more invasive versions, as these implanted or in form of smart tattoos.

The International Electrotechnical Committee (IEC) Standardisation Management Board Strategic Group 10 on Wearables distinguishes between the following categories of smart wearables:

· Near-body electronics:

electronic devices and components located near an organism not contacting the external surface of the organism directly;

· On-body electronics:

intended to be located on an organism, contacting directly its external surface;

· In-body electronics:

devices implanted into the organism;

· Electronic Textiles:

fabrics or textile-based electronic devices and components.

Such technology, by exploiting communication protocols such as the Bluetooth, can qualify as Internet of

things, enabling objects to exchange data with other connected devices (thus realizing an independent

system), or with an operator, even in real time. All that developments in this field are aimed at allowing a constant and most hands-free usage of the functionalities of these devices needed. Furthermore, it is related to the concepts of ubiquitous and wearable computing. The latter one aims to extend the functionalities of clothing and to provide accessories with “sousveillance”.

One early piece of wearable technology is the calculator watch (1980s). An even earlier wearable technology is the hearing aid created in the 17th century.

(9)

Nowadays the use of wearables is spreading widely, in particular in the fields of health and fitness. Wearable tech gadgets are also primarily used as navigation tools, media/communication devices, as a gauge for alertness and energy levels or to synchronize data and communication from other gadgets.

Reporting some statistical data, according to a study made by Forbes in 2014, 71% of 16- to 24-year-old people like wearable tech, but it has to be noted an opposite result too: a study carried out in the UK in 2015 among 1000 people reported that 56% of the interviewed people stated that wearable tech is “just a fad” [1].

Figure 0.1 Interest in wearing/using a sensor device between US and European online adults.

Source: Forresters North American and European Consumer Technographics Consumer Technology Survey, 2014

Wearable devices are rapidly advancing in terms of technology, functionality, and size reduction, with more real-time applications for both personal and business purposes. In the consumer space, sales of smart wristbands started accelerating in 2013. One out of five American adults have a wearable device according to the 2014 Price WaterhouseCoopersWearable Future Report [2].

(10)

Aims of the work

This work consists on the design and the realization of a novel on-ring device aimed at monitoring physiological parameters, i.e. Galvanic Skin Response and Heart Rate Variability. The whole idea emerges from the ground of research in Healthcare and Ambient Assisted Living. Central to the wearable sensor design is the long-term wearability and a reliable sensor attachment. Due to the low weight and small size, rings are worn without removal more easily than watches. Additionally, it will be seen that the finger is one of the best places for the monitoring required.

Both Heart Rate Variability (HRV) and Galvanic Skin Response (GSR) are related to changes in autonomic nervous system (which controls the smooth muscles, the cardiac muscle and the secretion of glands) as well as to the emotional responses. Thus, observation of these signals is used to evaluate the behaviour of the autonomic nervous system, like in those subjects who are at higher risk of myocardial arrhythmias (e.g. ischemic cardiomyopathy)[3].

The combined monitoring of GSR and HRV is mainly related to the “Affective Computing”. This context is becoming increasingly important in healthcare, backed up by findings from neuroscience, cognitive science, psychology and other contexts as arts, cinematography and advertising areas.

The emotion arousal and the contextual autonomic nervous system reaction, formally defined in terms of

arousal (calm or excited) and valence (negative or positive) [4], are readily observable thanks to variations

in heart rate and in skin perspiration, allowing to gain insights into human health, decision making and behaviour. The possibility to detect variations of arousal and valence with wearable devices facilitates health therapies and services, resulting particularly suitable in precision medicine applications.

A popular example of a service of this kind is the stress monitoring, used as an instrument for detecting events of interest into the behaviour and health monitoring, aiding the treatment of addiction forms (e.g. smoking, drinking, overeating) and in assisting car/truck drivers.

The field of the physiological and behavioural reaction monitoring may benefit of a potential emotional states classification deriving from the utilisation of wearable technology. For instance, medications can be tailored to an individual, from the affect sensing: it is possible to individualize behaviours associated with mood, anxiety, personality disorders, and preclinical symptoms of psychosis[5],[6] thus modifying the medical treatment in response to these reactions.

One last example is an application in the communication and characterization of emotion in autism, a system that people diagnosed with autism spectrum disorders may use to express emotions to people they trust: sometimes these persons present unexpected self-injurious behaviours, which may be avoided if signalized by the device to someone near, where possible [4].

(11)

Wearable solutions for this kind of applications are designed to be used on wrist or attached as a patch (these based on silver nanowires or silver electrodes). At the time of this thesis work, no solution containing both these sensing unities on a ring has been found.

After the realization of a first prototype, an acquisition program and the analysis algorithms were customised. These tools were used as an aid for the evaluation tests brought on a small population of young subjects, with comparison to two commercial devices used as gold standard.

The results reported pave the route to a further miniaturization of the customized wearable physiological system designed into an easy to use wearable sensorised system suitable for health care, driving assisting and activity recognition.

(12)

1 Galvanic Skin Response and Heart Rate Variability

An insight into the physiology studied follows. For both the signals physiological origins, models, measurement techniques and parameters commonly extracted are reported. This study is fundamental for the understanding of the architecture to implement in the wearable device required and for further signal elaboration needed.

1.1 Galvanic Skin Response

The skin aids in the maintenance of water balance and in the body temperature control. These functions are carried out principally through vasoconstriction/dilation and through variation in the production of sweat. The importance of these balances involves the skin receiving continuously regulatory signals from the central nervous system, influenced by the external world.

1.1.1 Physiology in brief

There are three types of sweat glands: eccrine, apocrine and apoeccrine. The first ones are innervated by sympathetic nerves, in this way the response has been considered linked with the concepts of emotion, arousal and attention. Amygdala (for affective processes), hypothalamus, limbic system, cortical (orienting and attention) and basal ganglion influences and the reticular formation (sensory stimulation) in the brain stem are important among brain systems involved [7],[8].

Thus, the secretory part of these sweat glands have mostly sympathetic cholinergic innervation, brought by postganglionic fibers called “sudomotor fibers” [9]. Each gland is innervated by divers fibers [10], and in reverse each sudomotor unit branches widely on a skin area of about 1.28 cm2 [11].

The widely held theory about the mechanism and the function of the Skin Conductance (SC) (also known as Electro Dermal Activity EDA) has been elaborated by Darrow (1927) who measured simultaneously EDA and sweat secretion. Contextually, Darrow found that these two aspects are strictly related, reporting the responses beginning at about one second before moisture appearance on the surface of the skin. It was concluded that the signal was more directly dependent on the activity of the sweat glands, not on the sweat on the skin per se [9].

(13)

Figure 1.1 Anatomy of an eccrine sweat gland. From [9] and [12].

Different nerve bundles go to the head/face, abdomen, arms/hands, and legs/feet. And in these sites the concentration of the glands varies markedly over the skin. Since the endocrine sweat glands located on the palmar and plantar surfaces are involved in grasping and keeping the skin flexible for sensory discrimination, these are more responsive to significant and emotional stimuli, being associated with the “fight or flight” reflex [9]. Thus, studies of differences among the sites on the skin report that the highest density of eccrine sweat glands is present on the palms and soles (600 to 700 glands/cm2) [12]. Some physiological differences

on the racial belonging plan (e.g. between Congoid and Caucasoid races) have been found too [13].

1.1.2 A simple model

A simple model of the GSR mechanism can be based entirely on the sweat glands. The sweat is conducted on the skin surface through a sweat duct, a long tubular portion of the gland, passing through dermis and epidermis. These ducts can be modelled as a set of variable resistors wired in parallel. Sweat will rise in ducts in varying amounts and in varying density along surface, depending on the degree of stimulation of the sympathetic nervous system. The stratum corneum is not well conducting, but the increasing volume of sweat in the ducts create a path characterized by a lower resistance, being the sweat a weak electrolyte. The higher the sweat content, the lower the resistance in the variable resistor, which results in EDA signal changes too. An “oversimplified” electrical model purposed by Edelberg gives an idea of the relationship between the ductal potential and skin surface measurements [14]:

(14)

Figure 1.2 The electrical model of the GSR mechanism. From [14]

The essential elements of the circuit are listed below.

• S – the lumen potential. This potential is negative, originating from the active reabsorption of Na+

in the duct under the epidermis (Cl- following passively). The lumen-negative potential thus

generated is plainly reaching the 50-70 mV across the duct wall;

• E is a smaller superficial negative potential. Changes very slowly, relatively unimportant. • 𝑅𝑠 is the resistance of the sweat duct itself, between the potential S and the skin surface; • 𝑅𝑒- the epidermis resistance between the skin surface and the interstitial fluid.

The electrode on the surface is placed between these resistors, and the measure will be affected by all of these elements, albeit a little voltage drop across 𝑅𝑠is expected, given that 𝑅𝑠>> 𝑅𝑒. Both these values are, almost by definition, variable: 𝑅𝑒changes with the duct filling and emptying, while 𝑅𝑠reflects the corneum hydration.

In addition to the duct filling, three other processes influencing the skin conductance behaviour have been suggested:

• Hydraulic pressure in the epidermal portion of the duct wall, in some cases, may become high enough to trigger a greater permeability and provide a “shunt” pathway in the duct wall, between the lumen and the epidermis;

• A poral valve at the skin surface, up to a certain hydraulic pressure level, offers resistance to current flow. Then it is forced by the secreted liquid;

• The sweat pushed through the duct, produces deeper corneum levels hydration. Edelberg proposes that this diffusion of the sweat away from the periductal area actually increases epidermal resistance [15].

1.1.3 Methods of measurement

All the factors seen are summarized by the overall Skin Conductance Level, measured by tree different methods:

(15)

· Direct current application via electrodes on the skin (considered as an “exosomatic method”, also referred to as bipolar recording method)

· Alternating current application via electrodes on the skin (another “exosomatic method”) · Without the application of external current (endosomatic method)

There are few points to focus on before going straight to the method preferred. The first one is about the endosomatic approach. This method is possible as long as an electrical potential difference can be measured across the palmar and plantar skin, without external voltage applied. The waveform, resulting from the application of a single electrode on the active site and an electrode at a relatively inactive site, results to be quite complex. A reason for that is the concurrence of all the signal components seen before to fluctuate either on a positive potential or a negative one, in respect of the reference site, following mainly the variations of the values represented by the 𝑅𝑠 and 𝑅𝑒 in the model. Still, the electrodermal arousals (responses) are easily seen in this approach, but due to this behaviour, evaluation and characterization of the data is difficult. The chosen solution is the direct current application. Nevertheless, comparing the second and the third solutions, both present the advantage of having all the components working in the same direction, so that an overall effect on the skin resistance can be evaluated. The simpler procedure, for both, consists of applying a small voltage on two electrodes placed on the same body side (avoiding ECG artefacts), on an intact palmar surface, including a small resistor in series with the skin. Since the small resistor is negligible in respect of the skin resistance amount, applying Ohm’s law, the current between the electrodes – and through the resistor – will be

𝐼 = 𝐸 𝑅⁄ 𝑠𝑘𝑖𝑛 (1.1)

The usual units of scale are kΩ or MΩ, since skin resistances are very large. The substantial difference between the AC and DC approaches consist in the electrodes becoming polarized over the surface in contact with the skin in the DC one, thus starting to behave as a rechargeable battery with a voltage opposing to the applied one. Nevertheless, the AC method has not been demonstrated to provide a better behaviour so far.

Generally, GSR sensors have a 1 cm² stimulating electrode made of Ag/AgCl (silver/silver- chloride), preferred for the minimum development of bias potentials and polarization. These are placed either in reusable snap – on Velcro straps or in a patch sticker. The former can be applied as-is; the patch sticker requires the use of a conductive gel, improving the conductivity between skin and electrode.

The most common placements are the distal phalanges of the fingers on the volar side and the thenar eminences of the palms, because of the major density of sweat glands in these areas [12].

The signal measurement, as shown below, occurs upon either a psychological or physical stimulation because of the electrodermal activation in response to the external stimulus.

(16)

There are two main components to the overall EDA: the general tonic-level that relates to the slower acting factors and background characteristics of the signal and the phasic component, which relates to the faster changing elements of the signal, commonly called Skin Conductance Response. The tonic component is commonly characterized by the measure of the so-called “Skin Conduction Level” (SCL) variation. The change in conduction level is thought to reflect nonspecific changes in autonomic arousal, but the SCL alone gives only a small contribution to the overall signal, whilst both components convey important information about different neural mechanisms. Importantly, the SCR may occur without a specific stimulus, and it is referred as “spontaneous” or “nonspecific” SCR (NS-SCR). During the analysis of the skin conductance signal, a minimum amplitude change is to be declared as a criterion for the classification of an arousal as a true Skin Conduction Response.

1.1.4 Signal dynamics and parameters extracted

Many factors influence the SC behaviour, e.g. ambient temperature and humidity, respiration and cardiac cycle [16], time of day, skin condition, recording side (left or right), and the variation is pretty wide [17]. The typical range is between 2 µS and 20 µS [9],[14]. Such variability is the main reason for removing the tonic level from the overall signal for analyses purposes, but other solutions have been purposed for the so-called between-subject normalization [18].

Commonly the signal decreases while subjects are at rest and rapidly increases as a stimulus occurs. Definitions and typical values of EDA are given in Table 7.1

Table 1 Electrodermal measures, definitions, and typical values. Taken from [9].

Measure Definition Typical Values

Skin conductance level

(SCL) Tonic level of electrical conductivity of skin 2-20 µS Change in SCL Gradual changes in SCL measured at two or more points

in time 1-3 µS

Frequency of NS-SCRs Number of SCRs in absence of identifiable eliciting

stimulus 1-3 per min

SCR amplitude Phasic increase in conductance shortly following stimulus

onset 0.1-1.0 µS

SCR latency Temporal interval between stimulus onset and SCR

initiation 1-3 s

SCR rise time Temporal interval between SCR initiation and SCR peak

(17)

17

SCR half recovery time Temporal interval between SCR peak and point of 50%

recovery of SCR amplitude 2-10 s

SCR habitation (trials to habituation)

Number of stimulus presentations before two or three trials with no response

2–8 stimulus Presentations

SCR habituation (slope) Rate of change of ER-SCR amplitude 0.01-0.5 µS per trial

Figure 1.3 Components of an SCR signal (From [9])

Since most of the resistance is developed between the germinating and the upper corneum layers, the sweat amount should cause the resistance to exceed a certain threshold depending mostly on these two layers, in order to impact the SCR. When the sweat fills the pores, the corneum becomes more conductive. The onset latency, as the time occurred between a stimulus and an electrodermal response, reflects the various durations of the many mechanisms involved: afferent stimulus, afferent transmission time, efferent signal transmission, electro-chemical conversion, end-organ, sweat release time1 [19]. The majority of the

onset times fall within 1-3 s, and any response being inside this window is considered to be elicited by the relative stimulus.

The rise time is another important feature observed, i.e. the time spent by the response to reach a quarter of its peak. The signal initial phase slope depends on the rise time. It is probably generated by the cumulative effect of the asynchronous ducts filling stimulated by the end-organs responsiveness: in this phase, the rate of recruiting sweat glands rises and the surface of the stratus corneum gets more hydrated2.

The SCR size may be related to the number of parallel ducts recruited under the electrode area [20], their dimensions and the degree of stimulation synchrony. On the other hand, this amplitude is influenced by the rate of the sweat production, its movement through the sweat duct, its expulsion on the surface and the consequent reabsorption. Moreover, the same thing can be seen from the very origin: the response amplitude is related to the integrated sudomotor nerve activity, which reflects the action potentials

1The conduction from central activation to the sweat glands (depending on the distance, 1,1 m, on average) [81]. The unmyelinated axons are relatively slow, average time for the transmission is estimated to be of 348 ms and a sweat in a variable time, ranging through a second.

(18)

frequency3. Such physiological factors may suggest clinical screening applications in the neuronal diseases

field.

Generally, after a large response elicited by the initial stimuli, a gradually decreasing reactivity follows, with repeated replica. This behaviour is named “habituation”. It is interesting to note that the rate of habituation, together with the recovery time, are considered to be indicative of differential physiological involvement of the amygdala and the hippocampus, allowing to acquire information on the attention of an individual [14].

Opposite to this concept is the “orienting response”, a generalized physiological/psychological state responding to an unexpected stimulus. The skin conductance response is commonly used to get insight into psychiatric disorders, e.g. attention deficit or hyperactivity disorder, schizophrenia and posttraumatic stress disorder [21].

Lastly, the decay time (also called half recovery time) is to be related to the reabsorption of the sweat and to the terminal sweat duct collapse [15]. It ranges between 2 and 10 seconds. [9] It is highly correlated to the rise time, therefore brings redundant information.

(19)

1.2 Heart Rate and Heart Rate Variability

Once it was commonly reckoned that normally our heart beats steadily, changing only with external stimuluses, like joy, fear, anxiety, etc. Not long ago, as soon as it became possible to measure the heart rhythm more precisely, it has been discovered that not only it presents some degree of variability, but also (after the key findings between 70’s and 90’s) that it has specific origins, related to other physiological phenomena [22]. Indeed, the beat of the healthy heart is not regular at all. The variations are a result of many factors, including the mental state (stress), exercise and fatigue. Additionally, the beat rate presents periodical variations because of respiration, thermoregulation, blood pressure regulation, actions of the renin-angiotensin system and other factors.

The phenomenon of the oscillation in the interval between consecutive heart beats as well as oscillations between consecutive instantaneous heart rates, measured in milliseconds (ms) is defined as Heart Rate Variability (HRV) [23].

The balancing of the circulatory function is primarily carried out through the interplay of the sympathetic and vagal outflows: the autonomic nervous system (ANS) exert frequent and small adjustments on the cardiovascular system, and thus, on the heart rate through vagal and sympathetic branches [24] [25]. So, we can see that at rest vagal tone is predominant, and it results in a slight bradycardia; during activity, in order to respond to an increased metabolic demand, heart rate is increased subsequently to a reduced vagal activity with a concurrent rise in sympathetic modulation. After intense physical activity, a recovery phase follows, which may continue with a phase of rapid and monoexponential decline in heart rate, due to vagal reactivation, followed by a slow and sustained decline phase [26].

Due to an autonomic background, these fluctuations constitute an important source of information about cardiovascular and nervous systems such as basic investigations of the autonomic state regulation and/or target function impairment, studies of links between psychological and physiological spheres, evaluations of clinical risks (e.g. myocardial infarction, sudden cardiac death, hypertension,) [23] . Interestingly, recent works support the hypothesis that ANS acts an important role not only in the balances involving viscera (genitourinary system, gastrointestinal tract and others besides heart and vessels), but also in the modulation of metabolism, immune system and inflammation [27].

1.2.1 Features extracted in HRV analysis

Heart rate variability analysis follows the two “reciprocal” approaches: analysis in the time and analysis in the frequency domain. The former, addressing the question of “How much variability is there?”, works with statistical calculations performed on the collected inter-beat intervals; the latter, dealing with the

(20)

question “What are the underlying rhythms?”, operates using the Fourier analysis to split the total variance into groups of compounding frequencies [28].

1.2.1.1 Time domain analysis

Time domain variables are divided into two classes: those based on intervals occurred between two consecutive beats (interbeat intervals) and those based on comparisons of the durations of adjacent cycles. Among the variables that can be determined there are the mean interbeat interval and the mean heart rate. . Thus, all the measurements require the detection of each heartbeat. Only “regular” beats should be considered, as explained later. In fact, all the so called ectopic beats, arrhythmic events and artefacts are not processed, which is why the alternative “normal to normal interval” (NN) term can be found in literature. It should be noted that NN interval value is linked to the Heart Rate measure by the following simple algebric equation:

𝐻𝑅 = 60,000/𝑁𝑁. (1.2) a) Statistical methods

These measurements can be calculated from series of cycle intervals or instantaneous heart rates. The series more useful for statistical analysis are recorded over longer periods, usually 24 hours, and all the following parameters are derived with respect to this duration:

Table 2 Hear rate variability time domain parameters

Variable

Units Definition

Comments

SDNN ms Standard deviation of all normal intervals in the

entire recording (also called SDRR or CLV)

Based on the time series of NN intervals

AVNN ms Mean of all normal intervals in the entire recording

SDNNIDX ms Mean of all the 5-minute segments standard deviations of NN intervals over the total recording

SDANN ms Standard deviation of all the 5-minute NN interval

means of the recording

r-MSSD ms

The root-mean-square successive difference: calculates the square root of the mean of the squared differences between successive NN intervals

Measure of short term variation in the NN interval, based on comparisons between successive beats

pNN50 % Percentage of differences between successive NN intervals over the recording that are greater than 50 ms

b) Geometric methods

The NN intervals can also be converted into geometric patterns, e.g. sample density distribution of the durations or sample density distribution of the differences between adjacent NN intervals, Lorenz plot of the interbeat intervals. A simple formula for the variation evaluation, based on

(21)

either the geometric or graphic properties of the resulting pattern is…. The approaches generally used for the analysis are:

• A basic measurement of the pattern, e.g. the width of the distribution histogram at a specified level is a proxy for HRV

• Pattern interpolation by mathematically defined shape: for example, the distribution histogram may be approximated by a triangle, or the differential histogram by an exponential curve. The parameters of the mathematical describing functions are used • The geometric pattern may be classified into shape-based categories, representing

different HRV classes: triangular, linear and elliptic shapes of Lorenz plots exist [25].

Most of the geometric techniques require to smoothen the histograms by discretising its scale. These techniques have the advantage of being less influenced by the analytical quality of the NN series, but they require at least 20 minutes of recording for the pattern construction.

A triangular interpolation may be applied to the NN interval (TINN) histogram in order to obtain the baseline width of the distribution (minimum square difference is used to find this approximation).

The HRV triangular index, instead, is the integral of the density distribution: the use of a discrete scale implies an approximation depending on the length of the data binning.

Both these approaches express the HRV, and are influenced principally by lower frequencies. The geometric methods feature a relative stability in respect of the analytical quality of the NN series. However, a great number of NN intervals is needed (at least 20 minutes) for the pattern construction, so this approach is not suitable for short term analysis.

1.2.1.2 Frequency domain analysis

Insight into cyclic variations of the heart rate may be obtained decomposing it into single components. Since 1960’s, manifold methods for the tachogram analysis have been devised. The mathematical complexity is greater, and an accurate timing is required.

Explicit relations between frequential components of the HRV signal and the vary features of the neurovegetative control systems were studied by Akselrod et al., who defined three relevant peaks, and paved the way to the definition of the periodic components of heart rate variability, classified within some frequency bands [9][24][29]:

· In young individuals at rest, the most discernible band is at the respiratory frequency (RSA) or

high frequency power (HFP or HF). It is considered to range nominally between 0.15 Hz and

0.4 Hz. RSA is mediated essentially by fluctuations of vagal – cardiac nerve control, which occurs at higher frequencies.

(22)

· R – R interval oscillations occurring in the 0.05-0.15 Hz interval are within the so-called low –

frequency band (LF) (or low frequency power (LFP)) The LF rhythms are considered to reflect

mainly sympathetic activation (sympathetic mediators appear to exert their influence over long time periods), although also depending on vagal origin.

· The lowest R – R fluctuations occur at frequencies below 0.05 Hz, in the very low frequencies (VLFs band, 0.003-0.05 Hz), including probably thermoregulatory cycles or fluctuations related to plasma renin activity, and slower, ultra-low frequencies (ULFs), that include circadian rhythms.

A practical consequence of this behaviour is that HRV may be used, again, as indicator or indirect measure of the subjects’ status relative to these bands. Indeed, in any moment the LFP/HFP ratio is an indicator of the sympatho-vagal balance.

Information about the distribution of the power spectrum (variance) is given by the Power Spectral Density (PSD) analysis. Methods for PSD calculation may be either nonparametric or parametric, according to the speed of the algorithm required, data amount, spectral components necessary for smoothness and post processing requests. In the frequency analysis, the “faster” bands, i.e. HF, LF and VLF may be analysed with the use of short and long-term recordings and are expressed as absolute values of power (ms2). Sometimes

LF and HF are measured in normalized units too, intended as the power of the component in proportion to the total power minus the VLF component. The ULF component can be monitored in the long-term recordings analysis.

Other possible approaches are the Rhythm Pattern Analysis and the Nonlinear methods, described are in brief in [25].

1.2.2 Heart rate measurement systems

The gold standard approach for the HR detection comprises electrocardiographic signal analysis, but the ways of measuring the heart rate are numerous. The alternative to the detection of the R-R interval on a ECG tracing is using pulse cycle intervals, as they can be detected from several devices, such as cardiovascular or SpO2 monitors. The information coming from these options is often referred to as Pulse

Rate Variability (PRV). Going quickly through the recent developments of wearable systems applied to these two branches it is possible to find:

· Textile solutions, as a custom T-shirt and textile belts with embedded textile electrodes (Andreoni et al.[30] ) or small electrodes integrated in clothes ([31],[32],[33],[34]);

(23)

· Devices for which has been made use of piezoelectric pressure sensors, measuring the HR by sensing the arterial pulse wave ([35],[36],[37],[38]);

· Other solutions: ballistocardiographes, sound analysing microphones and accelerometers.

A simple way of tracking the heart rate behaviour is given by the techniques of photoplethysmography (PPG) and “vibrational spectroscopy”: simple solutions exist using an IR emitting diode alone, for the sole detection of the heart rate, whereas the blood oxygenation requires use of two sensors for the splitting of the concentrations of oxygenated and unoxygenated haemoglobin in blood.

In this work, a pulse oximeter and heart rate sensor will be used, therefore herein an insight into this technique follows.

1.2.2.1 Photoplethysmography sensing

The principle behind PPG sensors is optical detection of blood volume changes in the microvascular bed of the tissue and oxygenation. Most changes in blood flow occur in arteries and arterioles during the systolic/diastolic phases. In these phases predominance of Haemoglobin carrying oxygen or, instead, the Haemoglobin free from it is noticeable.

The conception of the idea is traceable to the early 1930’s, when German researchers used spectrophotometers to study light transmission through human skin: according to the results of the research the two macromolecules of Oxyhaemoglobin and Deoxyhaemoglobin present different absorbance at different wavelengths. The concept of a non-invasive, inexpensive oxygen saturation measurement system was born: a sensor device is drawn close to a thin part of the body (typically a fingertip or earlobe), passing two wavelengths of light through it and detecting the transmitted portion of light with a photodetector. Other possible applications exploiting the transmittance paradigm, reflectance pulse oximetry is used, in which similarly the reflected portion of light is detected.

Figure 1.4 A scheme of the reflectance pulse oximetry paradigm: the light portion that passes through the skin is influenced by the underlying blood vessels content, in a so called “banana-shaped” path connecting the LED and the Photodetector.

(24)

The process is governed by the Beer-Lambert law: 𝐴 = log (𝐼𝐼

0), (1.3)

modified in case of reflectance to:

𝐴 = log (𝐼𝐼

0) = 𝜀𝐶𝑙 ∙ 𝐷𝑃𝐹 + 𝐺 (1.4)

Being

· A – the attenuation of the input light, · I0 the incident light intensity,

· I the transmitted/reflected one;

· 𝜀 – the extinction coefficient (quantifying the capability of a chromophore4 to absorb the light, at a specific wavelength, in [𝐿⁄𝑐𝑚 ∗ 𝑚𝑜𝑙]),

· C – mean concentration [𝑚𝑜𝑙 𝐿⁄ ],

· l – the distance between the source and the photodetector [cm],

· DPF, Differential Pathlength Factor, the one keeping into account the shape of the path the light is following from emitter to the detector

· G – containing the unknown aspects, as scattering coefficient and the behaviour of the emitter/receiver geometry.

Nowadays, SpO2 sensors are equipped with red and infrared (IR) light-emitting diodes (LEDs), i.e. mostly

wavelengths of 650 nm and 950 nm, used as light source [39]. The emitted light is absorbed, reflected and scattered by the tissues, primarily relatively to the small variations in blood perfusion of the tissue. Recently, novel solutions using green and blue light LEDs have been studied and reported, [40].

Oxyhaemoglobin absorbs more infrared light than red light, and Deoxyhaemoglobin has the opposite behaviour.

(25)

Figure 1.5 Absorption spectra of Hemoglobin, with IR (at 700 nm) and Red (at 900 nm) highlighted.

The PPG recognises these changes by detection of differences in intensity between the emitted and reflected/transmitted light.

Thus, the amount of absorbed light depends on many physical properties: · Concentration of light absorbing substance (Beer’s law);

· Length of the light absorbing substance (Lambert’s law); · Oxyhaemoglobin and deoxyhaemoglobin presence, With a side effect influence of

· Blood volume,

· Blood vessel wall movement and · The orientation of erythrocytes

The resulting signal waveform consists of both a direct and an alternating current component: the constant part of this signal consists of the tissues absorbance, the venous blood and non-pulsatile component of artery blood. The non-pulsatile component is not entirely static, since the oxygenation of blood influences the signal: changes in the intrathoracic pressure due to respiration cause changes into the venous return and cardiac output, which in turn modulates blood pressure forming the alternating current component present into the signal5. The fundamental frequency of the alternated component depends on the heart

rate, as can be seen in Figure 1.6.

5Respiratory activity may be monitored by filtering and processing the PPG signal appropriately, given that ventilation induces changes in

(26)

Figure 1.6 A representation of the PPG signal origin, with the alternated component generated by the pulsatile part of artery blood. From [39]

In particular, the relation between the ECG wave signal and the PPG can be seen in Figure 1.7, below: as a systole occurs, the blood flow into the vessels rapidly increases giving successively a peak into the PPG waveform [41].

Figure 1.7 ECG and PPG waveforms in comparison.

Following to the arterial blood oxygen saturation monitoring and heart rate extrapolation, further applications include the cardiac output estimation, atherosclerosis, peripheral arterial occlusion and other peripheral diagnosis.

1.2.2.1.1 The PPG technique validity

A fundamental point is the validation of this technique as substitute of the electrocardiogram analysis. Many studies about such topic can be found in literature, from an accurate comparison of these , it can be found that results show a sufficient accuracy, above all, for the tasks in which subjects are at rest (although many studies show that short-term variability is somewhat overestimated by PRV, due to coupling effects between respiration an the cardiovascular system [42]). Little of physical activity and some mental stresses

(27)

may arrive to impair the agreement of PRV and HRV. In fact, although PPG is particularly suitable for wearable solutions, its signal is easily modifiable by motion: motion artifacts corrupt the signal limiting the practical accuracy and applicability of instruments for monitoring pulse rate during physical tests, and in most cases, the noise falls within the same frequency band of the measured physiological signal. Smart, advanced signal processing methods are needed to overcome this problem, e.g. by coupling the acquisition with inertial motion analysis [43]. The applied external pressure due to the sensor bonding affects the contact between the sensors and the measurement site reducing the blood vessel diameter thus changing the signal amplitude with the variation of the microcirculation [44]. Such technique results poorly sensitive to electromagnetic interference.

A wearable photoplethysmography sensor has to cope with several technical issues, deriving from the factors affecting this sensing. Thus, firstly an understanding of these factors is required.

Summarizing, factors affecting PPG measurements are: • Area of contact between the probe and the skin.

Factor important in terms of a greater Signal to Noise Ratio.

• Applied external pressure of the probe on the contact area.

As seen above, the external pressure changes the blood volume underlying the sensor.

• External light conditions.

A wearable sensor is exposed to different light sources during long-term monitoring, ranging from flickering room light to direct sunlight exposure.

• Subject’s movement.

It can be seen from the power spectrum analysis, that the motion artefact often overlaps with the true pulse signal at nearly the same frequency. Therefore, a noise filter does not work for PPG.

1.2.2.1.2 Techniques for motion artefacts reduction

LEDs and Photo Detectors (PD) location.

The sensor arrangement determines the signal quality and robustness against motion artefact and external pressure. Asada et al. showed as placing the sensors on one lateral face of the finger near the digital artery benefits the signal acquisition [45].

Furthermore, positioning the sensors into the transmission configuration improves the device performances with respect to motion artefact, SNR and power requirements

(28)

[46][46][46][46][46][46][46][47]. For the reflective PPG more secure attachments than for the transmittal one are required, in order to always have a sensor channel receiving a signal without light disturbance, when an air gap affects the others. Indeed, in the case of the transmittal PPG configurations the light no leakage problems can be created, being the LED and the PD placed on the opposite sites of the finger.

Figure 1.8 Reflective and transmittal PPG waveforms under comparison during motion application. From [45]

Sensor Pressure.

An external pressure applied on the tissue surrounding the artery increases the pulsations amplitude observed reducing the transmural pressure: the pulsatile amplitude reaches a maximum when the transmural pressure approaches zero [48], and external light is harder to reach the photodetector. However, pressure application may interfere with tissue perfusion: it must be always well below the levels that could damage the vasculature.

Noise reference.

It is invariably important to monitor whether the signals obtained are reliable or not, by checking acquisition conditions. If the sensor monitors improper acquisition conditions, questionable data can be rejected. Finger motion can be measured with MEMS inertial sensors or other PPG optical sensors with a higher sensitivity.

(29)

1.3 Existing solutions: sensing GSR and HRV contemporary. Literature review.

Many works in literature and many commercial systems monitoring either the GSR or the HRV can be found. Interestingly, only few wearable devices can monitor both these parameters. In this section, examples of wearable sensors for the monitoring of HRV and GSR parameters are introduced.

1.3.1 Empatica™

The Empatica is a wearable solution for biofeedback and data acquisition. It includes four sensors on a wristband: a photoplethysmograph, an EDA sensor, a 3-axis accelerometer, and a temperature sensor. The package is 4cm × 4cm. It can operate either in streaming mode by using a Bluetooth 4.0 (Bluetooth Low Energy BLE) interface or offline exploiting a built-in flash memory (Figure 1.9).

Figure 1.9 Empatica E3 features (from[49])

The system features good data quality and a battery durability of 16 hrs in streaming mode. The PPG sensors software embeds a proprietary artefact removal technique, thanks to combination of multiple wavelengths, and is characterised by a resolution of 0.9 nW, whereas the EDA software features a dynamic range spanning between 0 and 100 µS with a resolution of 900 pS.

The system has two main working modalities: In-memory Recording and Real-time Streaming, with the corresponding desktop and mobile software platforms. After the acquisition, data is stored to the Empatica cloud server and a signal processing software extracts features from the raw signals [50].

(30)

Figure 1.10 Empatica E3 software architecture. From [50]

In the course of the thesis work a comparison with this system has been made: unfortunately, it presents a very low sampling rate, 4 Hz. Therefore, this device has not been used any further.

1.3.2 Shimmer3 GSR+ unit

The Shimmer™ on wrist wearable unit Shimmer3 GSR+ allows to measure the electrical characteristics of the skin as well as capturing a PPG signal for HR estimation by means of an ear clip (Figure 1.11). The data collected can be transmitted in real-time and logged or streamed via Bluetooth to a PC or a mobile device. The Shimmer has proprietary software, which can be purchased on the web site [51].

While the range of EDA detection is comparable to that of the Empatica system, its resolution is between 0.2µS and 100µS. This is the system used as a gold standard for the developed system.

(31)

1.3.3 Silver sensors on patches

The Silver sensor are of a very different concept, reported just as an example of an alternative solution to the wearable devices. The patches present their own clues and prides, like patch adherence, energy sources request, against little size.

An example is the device devised by Sunghyun Yoon et al in 2016: a flexible wearable patch applicable on the wrist for the physiological sensing for the stress monitoring [52]. This technology integrates three sensors, for skin temperature, skin conductance and pulse wave detection. It has a small size (25 mm × 15 mm × 72 µm) and a small skin contact area, by virtue of the invention of an integrated multi-layer structure and the associated microfabrication process.

The pulse wave sensor is made of a flexible piezoelectric membrane. It detects piezoelectric output voltage generated by the pulsation of radial artery at human wrist stimulus (Figure 1.12).

The skin conductance sensor adapts bipolar recording method using two electrodes of the sensor for current voltage supply to measure the electric current change (Figure 1.12).

The skin conductance sensor detects the conductance change of 2–20 µS with a resolution of 0.02 µS and a sensitivity of 0.28 µS / 0.02 µS.

(32)

1.3.4 Other ring-shaped solutions

The ring form is captivating for its small size and ease to wear. Many developers have worked on this solution, obtaining devices intended for personal use, not yet inserted into clinical environment. A general, quick overview of the existing solutions at the moment of the thesis work is presented in the Table 3.

Table 3 Commercial products embedding EDA or HR sensors available, with the ring-form in common

MOTIV™ ring

The first wearable ring that has an optical heart rate sensor built into it.

Oura™ ring

Health monitoring ring with temperature, optical and motion sensors

Indiegogo moodmetric ring “Mood monitoring” ring with an EDA sensor

On-ring sensored devices that can be found in literature for the sole PPG or GSR monitoring, cited in this study as well, are reported in the table below:

Table 4 Ring solutions in literature PPG Rings

Cheng-Yang Huang et al.

“Novel Wearable and Wireless Ring-Type Pulse Oximeter with Multi-Detectors ([53])”

Study of the practicability of a ring-type pulse oximeter with a multi-detector

Seung-Min Park et al.

“Real-Time heart rate monitoring System based on Ring-Type Pulse Oximeter Sensor” [54]

Real time heart rate monitoring system.

(33)

Alireza Avakh Kisomi et al. “A Novel Wireless Ring-shaped Multi-Site Pulse Oximeter” [55]

Ring shaped oximeter that using six sets of LEDs and photodetectors.

J. Solà et al.

“SpO2 sensor embedded in a finger ring: design and implementation” [56]

A new mechanical conception of the probe.

Sokwoo Rhee et al. “Artifact-Resistant Power-Efficient Design of Finger-Ring Plethysmographic Sensors” [57]

A first prototype of a miniaturized, telemetric, photoplethysmograph sensor for long-term, continuous monitoring

GSR ring

Jari Torniainen et al.

“Feasibility of an Electrodermal Activity Ring Prototype as a Research Tool” [58]

(34)

2 Materials and methods

2.1 The general idea

A first prototype of the system under development requires relatively small sensors for heart rate and skin conductance monitoring, and a µC acquisition unit. Additionally, a Bluetooth communication module will be set in order to reach a wireless data communication. All the validation procedure will aim to demonstrate the validity of an on-ring acquisition, i.e. the acceptability of a signal taken from the sole finger. Thus, the steps following the sensors setting will involve the signal conditioning and the characteristic parameters extrapolation.

The device developed in this work will be further referred to as “Customised Wearable Physiological system (CWP system o CWPS).

2.2 STM32 F401RE Nucleo board

The electronical board used is part of the ST’s “Nucleo” family development boards, created for quick prototyping of devices requiring a STM32 microcontroller.

(35)

Figure 2.1 The Nucleo STM32 product family. From the ST’s official site.

These boards provide the possibility to be extended with a large number of hardware add-ons and integrate an ST-Link debugger/programmer, so that there is no need for a separate probe.

The key features of the specific F401RE board are:

• STM32 microcontroller in QFP64 package • Two types of extension resources:

· Arduino™ Uno V3 connectivity

· ST morpho extension pin headers for full access to all STM32 I/Os • ARM® mbed™ (see http://mbed.org)

• On-board (removable) ST-LINK/V2-1 debugger/programmer with SWD connector: · Selection-mode switch to use the kit as a standalone ST-LINK/V2-1

• Flexible board power supply:

· USB VBUS or external source (3.3V, 5V, 7 - 12V) · Power management access point

• Three LEDs:

· USB communication (LD1), user LED (LD2), power LED (LD3) • Two push-buttons: USER and RESET

(36)

· Virtual COM port · Mass storage · Debug port

• Support of wide choice of Integrated Development Environments (IDEs) including IAR™, ARM® Keil®, GCC-based IDEs

Figure 2.2 The Nucleo board hardware apearence

Microcontroller’s features:

• Core: ARM® 32-bit Cortex®-M4 CPU with FPU, Adaptive real-time accelerator (ART Accelerator™) allowing 0-wait state execution from Flash memory, frequency up to 84 MHz, memory protection unit, 105 DMIPS/1.25 DMIPS/MHz (Dhrystone 2.1), and DSP instructions • Memories

· up to 512 Kbytes of Flash memory · up to 96 Kbytes of SRAM

• Clock, reset and supply management

· 1.7 V to 3.6 V application supply and I/Os · POR, PDR, PVD and BOR

The Figure 2.3 (below) depicts a brief summary of the main microcontroller features, with the most important of them used in this work highlighted in light blue:

(37)

Figure 2.3 The STM32 Nucleo board features used highlighted on the Features and peripherals conunts Table, from the STM32F401xD STM32F401xE datasheet

Another way to see the system used is the block scheme below, showing the general idea of the sources needed and of their connections.

(38)

Figure 2.4 STM32F401xD/xE block diagram from the Datasheet

(39)

2.2.1 Integrated Development Environment interface: IAR

IAR Embedded Workbench, from the Swedish IAR Systems computer software company has been used for software application building. The Integrated Development Environment is the framework containing all the tools needed for a software/firmware development, i.e. a C/C++ compiler, an assembler, a linker, library tools, the editor, a project manager and a debugger. The specific IDE is suitable for supporting the STMicroelectronics’ 32-bit ARM-based microcontrollers. The IDE follows the Cortex Microcontroller Software Interface Standard (CMSIS), a vendor-independent hardware abstraction layer for the Cortex-M processor series. This tool enables the use of simple software interfaces to the processor and the peripherals, written in a language closer to the direct meaning of the information carried and prearranging smart structures for the interaction with the MCU’s registers. Additionally, it simplifies the code reuse between different vendors products.

2.2.2 System heart: the clock

On reset, for default, the internal RC oscillator (High-Speed Internal RC oscillator, HSI) is selected as CPU clock, bringing a frequency of 16MHz (1% of accuracy at 25°C). The application can then change the system clock to either the RC oscillator or an external 4-26MHz source (High-Speed External user clock, HSE). The STM32F4 board has a built in external oscillator fitted with an 8MHz crystal. The use of the internal system clock has been maintained in the present work.

The default clock source is input to a PLL, permitting to obtain an 84MHz frequency. The PLL multiplies a clock source by a factor varying between 2 to 16, being it’s input one of the HSI, HSE or HSE/2, selected by the application as mentioned above.

Generally, in order to lower the device’s current draw, the on-chip peripherals are being switched off by removing access to their master clocks, that in the case of the STM32 devices are known as the hardware and peripheral clocks. In this way, only those peripherals that are actually needed are powered on. They’re controlled by the Reset and Clock Control group of registers (RCC). There are two registers for the enabling of a clock, which in turn enables a peripheral required: RCC_AHB1ENR and RCC_AHB2ENR for the Hardware clock, APB for the Peripheral clock. In this way, to turn a system on, (e.g. the ADC or GPIO peripherals), a bit in the ENR register is to “set”; and to turn it off a bit is to “reset” in the corresponding

RCC_AHBxRSTR register. Examples of this procedure will follow.

Once selected the clock source, the internal system and peripheral cocks are to be configured. The internal clocks, reported in Figure 2.5, are:

(40)

Used to determine the speed at which instructions are executed. Maximum speed – 168MHz.

· Two Advanced High-Performance Busses (AHB1 and AHB2)

Derived from the system clock, same maximum speed.

· Low speed Advanced Peripheral Bus (APB1)

Derived from AHB, with a maximum speed of 42MHz.

· High speed Advanced Peripheral Bus (APB2)

Derived from AHB, with a maximum frequency of 84MHz.

A number of the peripheral clocks are not derived from the system clock but have their own independent source.

Figure 2.5 STM32F401xD/xE clock tree, from the reference manual

Several

prescalers allow their

(41)

AHB is a bus protocol published by ARM Ltd company for the Advanced Microcontroller Bus Architecture version 2 (AMBA). The AMBA is an on-chip interconnect specification for the connection and management of functional blocks in system-on-a-chip (SoC) designs.

APB is designed for low bandwidth control accesses, for example register interfaces on system peripherals. This bus has an address and data phase similar to AHB but features a reduced complexity for the signal handling.

2.2.2.1 Zoom on the Reset and Clock Control peripheral

The STM32 clock distribution network is supported by the firmware module stm32f4xx_rcc.[ch], that controls the main system clock and PLLs, while any required configuration of those is handled in the start-up code.

The stm32f4xx_rcc.c/h files provide firmware functions to manage functionalities of the RCC as: · Internal/external clocks, PLL, CSS and MCO configuration

· System, AHB and APB busses clocks configuration · Peripheral clocks configuration

· Interrupts and flags management.

The start-up code is responsible to:

· Configure the clock source to be used to drive the System clock (if the application needs higher frequency/performance)

· Configure the System clock frequency and Flash settings · Configure the AHB and APB busses prescalers

· Enable the clock for the peripheral(s) to be used

· Configure the clock source(s) for peripherals which clocks are not derived from the System clock (I2S, RTC, ADC, USB OTG FS/SDIO/RNG).

(42)

void RCC_Config() { RCC_DeInit(); RCC_HSICmd(ENABLE); RCC_HCLKConfig(RCC_SYSCLK_Div1); /*84MHz*/ RCC_PCLK2Config(RCC_HCLK_Div1); /*APB2:84MHz*/ RCC_PCLK1Config(RCC_HCLK_Div2); /*APB1:42MHz*/ FLASH_PrefetchBufferCmd(ENABLE); FLASH_SetLatency(FLASH_Latency_2); RCC_PLLConfig(RCC_PLLSource_HSI, 16, 336, 4, 7); RCC_PLLCmd(ENABLE); while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) { } RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK ); while(RCC_GetSYSCLKSource() != 0x08) { } RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE); }

2.2.3 Timing

The execution of a program occurs line after line: jumps from one part to another are pre-programmed and used to follow decisions based on real-time conditions or, as in this case, to run multiple different tasks alternatively. So, in other words, these programmed jumps are predictable and important events outside of the processor, which will require its immediate attention and action while executing a program. This situation of suspension of the execution is actually the interrupt request. The interruption is issued either by a component built into the microcontroller, by software or by an external hardware connected to a pin of a port, sending the corresponding electrical signal, i.e. the interrupt request.

Querying alternatively the two sensors, GSR and PPG, requires precise timing and frequency control. The interrupts’ behaviour fits these needs: this functionality is achieved by the use of a general-purpose timer, the Tim5, which enables an interrupt condition in the main infinite loop.

A specific hardware is responsible for releasing the processor from complex tasks, involving the needs of the handling of the interrupt requests: the interrupt controller. This block of hardware receives an interrupt request signal, interprets it as justified to stop the processor from the regular program execution and forces it to jump to the so-called interrupt function and execute it. It is the due of the processor, then, to return to the regular program.

(43)

In STM32F4XX series microcontrollers this interrupt controller is called Nested Vectored Interrupt Controller (NVIC), receiving signals from most of the hardware built into the microcontroller by itself and those from ports – through an additional hardware, the External Interrupt/event Controller (EXTI).

Figure 2.6 The NVIC block scheme

Once the processor receives the interrupt notification, it requests the code of the request source and uses it to find the pointer to the corresponding function.

It is to note that:

· The interrupt function must be designed in order to avoid any disruption of the execution of the regular program. The compiler must be notified that this is the function to be executed in case of the specific request, through its identification as interrupt function in a specific file. It cannot receive or return any arguments and those used within it must be declared as global at the beginning of the program.

· The NVIC must be configured and enabled. The changing of the settings within this controller is a delicate task and the relative registers can be accessed only from a privileged state of the processor. For this reason, a set of functions is included in a CMSIS library in the compiler package. · The controller EXTI should be configured and enabled if signals at ports are to be sorted out. · The requests are prioritized: when a high priority interrupt function is under execution, other,

lower priority requests, must wait.

The use of a timer allows to periodically interrupt the execution at precisely defined time intervals. In the specific case, it will trigger the signals’ acquisition and sending codes. The block diagram representing the behaviour of the microcontroller is given in Figure. The timer TIM5 receives the system clock signal with 84MHz of speed and is configured to make pulses with a frequency determined by the following condition:

𝑓𝑠 = 𝑆𝑌𝑆𝐶𝐿𝐾

(𝑇𝑝 + 1) ∗ 𝑃𝑟𝑒𝑠𝑐𝑎𝑙𝑒𝑟=

84 ∗ 106

(999 + 1) ∗ 840= 100𝐻𝑧 (2.1) Being

Riferimenti

Documenti correlati

It was shown [2] that degree distribution of the network has dramatic consequences on the spreading of the disease: while regular lattices and random networks have a non-zero

Dei 144 pazienti randomizzati nel gruppo MMC, sono stati analizzati 105 pazienti: alcuni dei pazienti esclusi dallo studio non erano affetti da UUTUC n=11, altri sono morti subito

L’esplicitazione degli esiti di questo lavoro e dei suoi pre- supposti metodologici costituisce l’occasione per una riflessione sul SH come tema di ricerca, “letto” nella

before the sand barrier, the average minimum wind speed at 20 meters after the sand barrier reduced by 32.5% compared with that before the sand barrier; Combined sand barrier

It seems very promising to study how heart rate and its variability relate to drivers’ different levels of sleepiness, extracting particular features from the heart rate signal, in

The joint action of these two effects within the multilateral and the regional trade systems gives rise to the result that, for the same number of direct trade partners, the R&D

Here, to make up for the relative sparseness of weather and hydrological data, or malfunctioning at the highest altitudes, we complemented ground data using series of remote sensing