Content uploaded by Radovan Stojanovic
Author content
All content in this area was uploaded by Radovan Stojanovic on Nov 02, 2021
Content may be subject to copyright.
Outline
Introduction
Design approaches HW/SW/CLOUD
Covid19 examples
Conclusions
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Problem
How to design cost effective medical wearable
devices, based on the offtheshell HW and open
HWSWCloud platforms?
What are the prerequisites to perform it?
How to design the simplest biomedical instruments?
How to implement basic digital signal processing
operations for those instruments?
How to connect instruments to visual and feedback
interfaces, including clouds?
How to evaluate operation of an open HWSW
health care instrument?
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Introduction
Wearable medical devices
market is rapidly growing
29.76 billions USD in 2019
195.57 billions USD to reach by
2027
Exhibiting a (Compound Annual
Growth Rate) CAGR of 26.4%
during the forecast period
Covid19 pandemic boosted
demands for diagnostic and
patient monitoring medical
devices.
MECO’2021 and CPSIoT’2021, Budva, Montenegro
https://www.medgadget.com/2020/10/wearablemedicaldevicesmarket2020globalanalysisopportunitiestechnologicalinnovationresearch
reportsharetopplayersgrowthandforecastto2026.html
Introduction
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Latest trends and factors
Growing awareness regarding health and fitness
Increasing prevalence of chronic diseases
Rising geriatric population
Increasing technological innovations, especially
ICTs
Necessity to eliminate physical distance barrier
between patient and doctors
Introduction
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Segmentation of wearable devices
By applications
Home and office healthcare
Remote patient monitoring
Sport and fitness
Rehabilitation
Education and research
By products
Diagnostic and patient monitoring
Therapeutic wearables
Distribution channels
Pharmacies
Hypermarkets
On line distributors
Introduction
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Leading Players
Ypsomed AG
Sonova
Hologic Inc.
Siemens Healthcare GmbH
AiQ Smart Clothing
NeuroMetrix, Inc.
Apple Inc.
SAMSUNG
Fitbits
SugarBeat
Omron
Huawei
Garmin
…..
Advances of commercial
solutions
Practical,
Sometimes in lowcost
Sometimes of enough accuracy
Good support (software and
networking) and easy using
Low power, battery operated
Disadvantages of
commercial solutions
Closed systems in term of
HW/SW, signal processing and
upgrading.
Not suitable for research,
development and education
Introduction
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Our trial
To develop simple, open
wearables for using by patients,
engineers, researchers and any
person interesting on this topic.
Where we can do it easily?
Pulse
Motion
Blood Pressure
Oxygen saturation
Respiration
Temperature
Analyze of Photoplethysmogram
(PPG), Electrocardiogram (ECG)
and Electromyography (EMG)
signals.
Hydration
Skin Conductance…
Design Approach  General
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Design Steps
Design your system stepbystep, to be scalable.
Select proper sensor and proper frontend hardware, by using offthe
shell components in combination with your analogdigital knowledge.
Do not skip mechanics. Sometimes no electronics that can substitute
mechanical solutions.
Try from one signal to extract as much as possible features.
Use open source MCUs (Arduino, TI, ST).
Implement efficiency control and signal processing algorithms.
Improve visualization and recording.
Network device, locally and globally (cloud)
Use existing IoT servers.
Test –Use –DebugUpgrade.
Design Approach  General
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Example. Pulse oximetry from PPG  closed system
Commercial wearable, acquires and displays Oxygen Saturation (SpO2) and Pulse
(HR). The raw signal (PPG) is used, but not accessible by user.
https://www.scientificanimations.com/pulseoximetrymechanismhistoryusesources/
0 0.5 1 1.5 2 2.5 3 3.5 4
1.5
2
2.5
3
sec
Volts
DC+AC
RED
IR
Closed System
PPG
Design approach  General
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Closed vs Open system
We can extract from PPG signal numerous parameters important for sleep, apnea, stress,
arrhythmias, diabetes, blood pressure, respiration rate etc… As example:
1. SpO2, Oxygen saturation. One of the main parameters of the respiratory and blood transportation system
2. HR, Heart (Pulse) Rate
3. HRR, Heart Rate Rhythm
4. RHR, Resting Heart Rate
5. HRV, Heart Rate Variability
6. PI, Perfusion Index and Pleth Variability Index (PVI)
7. ARD, Arrhythmias detection
8. SAD, Sleep apnea detection
9. PPGP, Photoplethysmogram parameters, Systolic Amplitude, Pulse Width, Pulse Area, Peak to Peak
10. FDPPGP, First Derivative Photoplethysmogram Parameters
11. SDPPGP, First Derivative Photoplethysmogram Parameters
12. PD, Prediction of diabetes
13. SD, Stress detection
14. RR, Respiration rate….
0 0.5 1 1.5 2 2.5 3 3.5 4
1.5
2
2.5
3
sec
Volts
DC+AC
RED
IR
Design Approach  HW
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Pulse oximetry, open system, basic HWSW
architecture
Anolog
&
Digital
Front
End
ATiny
MCUs
or
ATmega
328
OLED
DISPLAY
ISP node
MCU
IoT node
Open device
IR transmiter IR receiver
Open device
Ambient light
Finger
movement
Design Approach  HW
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Direct interfacing to MC. The simplest
PPG frontend ever. HR configuration.
Couple of LEDs are directly connected
to MC’s pins. One LED is using as light
emitter and second as receiver.
Stojanovic, 2001
LED as light sensor
Design Approach  HW
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Direct interfacing to MCs . The simplest PPG frontend. HR and
SpO2 configuration.
Stojanovic, 2001
Design Approach  HW
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Minimal interfacing. HR, SpO2 sensing by
factory probe and MC. Classical LED driving
implemented by transistor bridge and intensity
control, implemented by DACs are replaced by 3 MC
pins and 2 resistors. As receiver, one transistor
amplifier and one OA are used. Stojanovic and
Skraba 2020
Design Approach  HW
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Improved minimal interfacing. By extending Transimpedance amplifier (TA)
with AC Amplifier (ACA).
VCC
R1
C1
R2 R3
Vr +

VCC
TA
OA1
C2
R4
P1
VA=VAMB+VDC+VAC
con
chopp
con
chopp
3D
variant
AD0 AD1
VA=VAMB+VDC+K*VAC
R4
R5 C4
C5
+
OA2
Fcut=0.1Hz
Fcut=5Hz
Fcut=1kHz
https://grabcad.com/library/fingerclipforpulsesensorarduino1
To obtain better signal, avoiding
noise
K=R4/R5
OA=TLC272
R1=3.3M
C1=33pF
Vr=1V
R4=220Ohm
LEDIRs (pair of
tranmiter
reseiver)
Works in continuous or chopper
(recommendable) modes
Design Approach  HW
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Improved version that works in chopper mode with S&H and ACA.
VCC
9
5
R1
C1
R4 R5
Vr +

VCC
VA=VAMB+VDC+VAC
VB= VDC+VAMB
R2
R3
VC=VDC + VAMBVAC* R3/R2

+
C2 
+R4 R5
C3 C4
A0
SW_IR_RED
CMOS_SW
A
B
C
D
TA
ACA
MC
C5
S&H LPF
OA1
OA2
OA3
C5
Design Approach  HW
MECO’2021 and CPSIoT’2021, Budva, Montenegro
By proper timing one TA and one ACA can be used for acquiring both IR and
RED channels, or it can be done by one TA and two ACAs.
a) b)
A
C1
D1
D2
C2
A0
A1
SH_IR
SH_RED
P1 P2 P3
COM GND
VCC
ACA
ACA
TA
Driver MC
A
C
D
A0
SH_IR_RED
P1 P2 P3
COM GND
VCC
ACA
TA
Driver MC
RED
IR
DRIVE RED &
SAMPLE
SWITCH
TO IR &
SABILISE DRIVE IR &
SAMPLE
CALCULATE &
SWITCH
TO RED &
SABILISE
SpO2 timing with 1 TA
amplifier and 2 ACA
amplifiers
SpO2 timing with 1 TA and 1 ACA
Design Approach  HW
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Respiration ration (RR) amplifier based on
thermistor and microphone.
VCC
R1
C1
R4 R5
Vr +
VCC
VA=VDC+VAC
VB= VDC
R2
R3
VC=VDC VAC* R3/R2

+
R4 R5
C3 C4
A1
CMOS_SW
A
B
C
D
TA
ACA
MC
C5
LPF
OA1
OA3
C5
Temp
Res
inhale
exhale
inhale
exhale
Design Approach –HWSWtiming
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Synchronizing acquisition process of vital signs with one
timer interrupt and downsampling. The signal generated in
timer interrupt is, also, used for producing negative voltage
for powering.
C1=2.2uF
C2=33uF
GND
VI/0 pin
Timer interrupt 512 Hz
/2
Sample ECG in 256Hz
Sample PPG in 32Hz
/8
/8
RR sample in 4Hz
Design Approach  HW
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Recommendations
All above +
Design analog front end carefully.
Always support analog front end by small
microcontrollers like ATTiny or TI MSP430.
Do it modular. Basic and advanced variants.
Use lowpower consummation strategies.
Use on the processor analog peripherals, as example
comparators, OAs in case of TI MSP430
Never escape real ground. Virtual ground introduce
noise, especially in ECG and EMG amplifiers.
Real powering can be very easy made by charge pump
and MC.
Implement basic signal processing algorithms in
firware.
Smart sensor should be very easy upgraded to wearable
instrument, by adding user interface or connecting it to
the smart phone.
Try to integrate all on PCB, even electrodes.
Always use down sampling techniques for acquisition,
synchronizing the process on timer interrupts.
Integrate battery on sensor’s PCB
Battery
Analog & digital
Frontend
ATTiny or TI
MSP430
Communication modules
WireWireless
Advanced I/O user interface
and visualization module
Basic I/O interface, few
LEDs and few SWs
POWER I/O ANALOG I/ODIGITAL I/O
AN/DIG I/0
BASIC CONFIGURATION
ADVANCED CONFIGURATION
Sensors
Wearable health device, basic and
advanced architecture
Design Approach  SW
Software considerations
Most of control, handling and signal processing
algorithms are realized in software
Here we speak about most useful basic algorithms,
from statistics, filtering and FFT, mostly based on
tips and tricks and optimized programming.
The algorithms should be on line, low power with
minimal memory requirements.
It means SPEED, POWER and MEMORY
optimized
We should to have a basic DSP library adjusted to
our needs.
MECO’2021 and CPSIoT’2021, Budva, Montenegro
Design Approach  SW
Statistical approach, arrhythmia and stress detector, calculate statistical
parameters online without occupying memory
MECO’2021 and CPSIoT’2021, Budva, Montenegro
rr1 rr2 rr3
rr1 rr2 rr3
Detect rr online Do statistics
online
AVERAGE_TIME
sample rr HR,STD,HRV
//DO STATISTICS FOR HR AND STDEV
short int stat_count=0;
long int par_sum_rr=0; //partial sum for mean value
long int std_sum=0; //partial sum for std value
short int HR_AVE=0; //HR in AVERAGE_TIME
int STD=0; // STD in AVERAGE_TIME
int arithmia=0; //arithmia counter
void do_statistics(int rr)
{
float B;
if(rr>1500  rr<500) // Arrhythmias detected
{
HR_AVE=0;
arithmia++;
par_sum_rr=0;
std_sum=0;
stat_count=0;
STD=0;
}
else
{
stat_count++; //statistics counter
if(stat_count>1)
{
par_sum_rr=par_sum_rr+long(rr); //partial sum for mean value
std_sum=std_sum+long(rr)*long(rr); //partial sum for std value
if(stat_count>=AVERAGE_TIME)
{
B=float(par_sum_rr)/float(AVERAGE_TIME1); //mean value
HR_AVE=short(60000/B); // HR from mean value
B=(B*B); // mean*mean
std_sum=std_sum/(AVERAGE_TIME1);
STD=round(sqrt(float(float(std_sum)B))); //formula for standard deviation
stat_count=0;
par_sum_rr=0;
std_sum=0;
} } }
}
Design Approach  SW
MECO’2021 and CPSIoT’2021, Budva, Montenegro
const int fs=200; //sampling frequency
//filter variables
const int fc_l=5; //corner frequency HP
float alfa=0; //coefficient LP
float y_old_lp=0; //previous value y LP
const int fc_h=15; //corner frequency LP
float beta=0; //coefficient HP
float y_old_hp=0; //previous value x HP
float x_old_hp=0; //previous value y HP
void setup()
{
…..
alfa=calculate_alfa((float)(fc_h), fs); //calculate_alfa
beta=calculate_beta((float)(fc_l), fs); //calculate beta
…..
}
//coefficient alfa for LP filter
float calculate_alfa(float fc, float fs)
{
float alfa;
alfa=(2*PI*fc/fs)/((2*PI*fc/fs)+1);
return alfa;
}
//coefficient beta in HP filter
float calculate_beta(float fc, float fs)
{
float beta;
beta=1/((2*PI*fc/fs)+1);
return beta;
}
//LP filter of 1st order
float low_pass1(float alfa, float x)
{
float y=0;
y=alfa*x+(1.0alfa)*y_old_lp;
y_old_lp=y;
return y;
}
//HP filter of 1st order
float high_pass1(float beta, float x)
{
float y=0;
y=beta*y_old_hp+beta*(xx_old_hp);
y_old_hp=y;
x_old_hp=x;
return y;
}
void loop()
{
…..
sample= analogRead(AD0);
y1=high_pass1(beta, float(sample);//HPF 5Hz
y2=low_pass1(alfa,y1); // LPF 15Hz
……
}
•RC (LP) i CR (HP) filter implementation,
using fs and fc. Basic configuration.
Calculation of coefficients
Design Approach  SW
MECO’2021 and CPSIoT’2021, Budva, Montenegro
//IIR FILTER FLOAT IMPLEMENTATION
//a(1)*y(n) = b(1)*x(n) + b(2)*x(n1) + ... + b(nb+1)*x(n
nb)
//  a(2)*y(n1)  ...  a(na+1)*y(nna)
// calling yout=iir_filtar(xin, a_c, b_c, n);
#define N 4
double y[N+1]={0,0,0,0,0};
double x[N+1]={0,0,0,0,0};
// a(1)*y(n)=b(1)*x(n)+b(2)*x(n1)a(2)*y(n1)
double a_c[]={1.0000, 0.9975}; //floating coefficients
double b_c[]={ 0.0013, 0.0013};
double iir_filtar(double p, double *a_coef, double *b_coef, int
N_order)
{
int i;
x[0]=p;
y[0]=*b_coef*x[0];
for(i=1; i<=N_order; i++)
y[0]=y[0]+(*(b_coef+i)*x[i]);
for(i=1; i<=N_order; i++)
y[0]=y[0](*(a_coef+i)*y[i]);
for(i=N; i>0; i) //Circular
{
y[i]=y[i1];
x[i]=x[i1];
}
return(y[0]); }
//IIR FILTER INTEGER IMPLEMENTATION
long a_co[]={1, 199}; //integer coefficients
long b_co[]={29, 29};
long yi[N+1]={0,0,0,0,0};
long xi[N+1]={0,0,0,0,0};
long iir_filtar_int(long p, long *a_coef, long *b_coef,
int N_order)
{
short i;
xi[0]=p;
yi[0]=(*b_coef*xi[0])>>8;
for(i=1; i<=N_order; i++){
yi[0]=yi[0]((*(a_coef+i)*yi[i])>>8);
}
for(i=N; i>0; i) //Circular
{
yi[i]=yi[i1];
xi[i]=xi[i1];
}
return(yi[0]);
}
p=(long)(x<<8); //Calling integer IIR filter
yk=iir_filtar_int(p,a_co,b_co, 1);
Design Approach  SW
MECO’2021 and CPSIoT’2021, Budva, Montenegro
//DC REMOVAL
float al=0.995;
float yn_1=0;
float xn_1=0;
float DC_removal(float x)
{
float y;
y=al*yn_1+xxn_1;
yn_1=y;
xn_1=x;
return(y);
}
//DC TRACKING
int32_t ydc_old=0;
int DC_Tracking(int x)
{
int32_t ydc;
ydc= ydc_old+((((int32_t) x << 16)  ydc_old) >> 9);
ydc_old=ydc;
return (ydc>>16);
}
//IIR NOTCH FILTER WITH
//COEFFICIENTS CALCULATION
fs=1000;
f0=50; // REMOVE 50Hz flicker
b0=1;
b1=2*cos(2*pi*f0/fs);
b2=1; r=0.999;
a0=1;
a1=2*r*cos(2*pi*f0/fs)
a2=r*r;
Design Approach  SW
MECO’2021 and CPSIoT’2021, Budva,
Montenegro
//SMOOTHING, CIRCULAR BUFFERING
float average_sum(float x)
{
short i;
float filterout=0.0;
// DirectForm FIR
del[0] = x; // input for filter
filterout = del[0]; // Set up filter sum
for (i = LENGTH1; i > 0; i){ // Get sum of products
filterout += del[i];
del[i] = del[i1]; // Renew input array
}
return (filterout);
}
//POSITIVE SLOPE calculation
int16_t x_old_slope_fix=0;
int16_t slope_fix(int16_t x)
{
int16_t slope=0;
slope=xx_old_slope_fix;
if(slope<=0) slope=0;
x_old_slope_fix=x;
return slope;
}
Design Approach  SW
MECO’2021 and CPSIoT’2021, Budva, Montenegro
0 0.5 1 1.5 2 2.5 3 3.5 4
1.5
2
2.5
3
sec
Volts
00.5 1 1.5 2 2.5 3 3.5 4
0
50
100
150
200
250
Hz
Int FFT (DC+AC)
0 0.5 11.5 2 2.5 3 3.5 4
0
2
4
6
8
10
Hz
Int FFT (AC)
60 beats/min
SpO2= 94.6
DC+AC
RED
IR
SRED(DC)
SIR(AC)
SRED(AC)
SIR(DC)
//Finding SpO2 from FFT Spectrum for FFT_N points
…..
#include "fix_fft.h" //Include fix_t libraray
….
//define variables for fix fft
char im[FFT_N], data_d c_red[FFT_N], data_dc_ir[FFT_N],
data_ac_red[FFT_N], data_ac_ir[FFT_N];
if(k>FFT_N)//when the number of sa mples exceed FFT_N(256) {
.......
//SPO2 calculation
for(i=0;i<FFT_N;i++)im[i]=0;
//RED FFT DC
fix_fft(data_dc_red, im, 8, 0);//Call Fix FFT
MAX_DC_RED =sqr t(data_dc_red[0]*data_dc_red[0]
+im[0]*im[0]);//Spectrum(0)
//IR FFT DC
for(i=0;i<FFT_N;i++)im[i]=0;
fix_fft(data_dc_ir, im, 8, 0);//Call Fix FFT
MAX_DC_IR =sq rt(data_dc_ ir[0]*data_dc_ir[0]+
im[0]*im[0]);
//HR from IR and finding maxim um in FFT AC RED
// Spectrum
dat=0;
HR_RED=0;
MAX_AC_RED=0;
for(i=0;i<FFT_N;i++)im[i]=0;
fix_fft(data_ac_red, im, 8, 0);
for (i =1;i <FFT_N/2;i++)
{
dat =sqrt(data_ac_red[i]*dat a_ac_red[i]+
im[i]*im[i]);
if (dat>MAX_AC_RED) {HR_RED=i;
MAX_AC_RED=d at;}
}
//Finding maximum in FFT AC I R Spectrum
dat=0;
HR_IR=0;
MAX_AC_IR=0;
for(i=0;i<FFT_N;i++)im[i]=0;
fix_fft(data_ac_ir, im, 8, 0);
for (i=1;i <FFT_N/2;i++)
{
dat =sqrt(data_ac_ir[i]*data_ac_ir[i]+
im[i]*im[i]);
if (dat>MAX_AC_IR ) {HR_IR=i;
MAX_AC_IR=dat;}
}
//Calculate RR
float A=float(MAX_AC_RED)/float(MAX_DC_ RED);
float B=float(MAX_AC_IR)/float(MAX_DC_IR);
RR=A/B;
........
//Calculate SpO2
SpO2=11025*RR;
...... }
RR=SRED(AC))/SRED(DC)/SIR(AC)/SIR(DC)
SpO2=11025*RR //approximatively equation
HR(Hz)=peak_position_in_Hz_off_SIR(AC)
•Plying with peaks in FFT spectrum, case
of SpO2 and HR, noise immune method
Covid19 examples –HW/SW
The measuring set is a
headset like, very
intuitive to use, based on
sensors for detecting,
breathing, heart rate and
temperature, that can be
mounted in a headset. In
combination with the mask,
the system gives better
results, as the mask by itself
is amplifying breathing
signals. In addition to time
domain algorithms, FFT
and STFFT (Short Time
FFT) are used for signal
processing.
MECO’2020 and CPSIoT’2020, Budva, Montenegro
HR, SpO2
TempRR by
Thermistor
or MIC
Covid19 examples –HW/SW
MECO'2015, Budva, June 2015, Mentenegro
The PPG and RR signals obtained by circuits
preprocessing circuits additional processing by
Arduino. Analog preprocessing allows to have a good
quality signals.
The methodology is effective on breathing detection
for both, microphone and thermistor inputs.
Covid19 examples –HW/SW
MECO’2020 and CPSIoT’2020, Budva, Montenegro
In case of MIC the envelope is detected by different methods, as
Hilbert. The FFT and STFFT is applied. The RR is calculated by
peak detection.
TimeFrequency Approach Frequency method
Covid19 examples –HW/SW
MECO’2020 and CPSIoT’2020, Budva, Montenegro
By “Syntrofos” device, it is possible for everyone to have a personal COVID signal
monitor, 24/7/365. The Syntrofos Basic version monitors Temperature, Pulse,
Respiration Rhythm , sisplaying PhotoPlethysmographic Signal (PPG) and Respiration
Signal (RR). VIDEO.
Covid19 examples –HW/SW/CLOUD
MECO’2021 and CPSIoT’2021, Budva, Montenegro
IoT concept. See:
http://www.meconet.me/SmartAgro
http://www.meconet.me/SmartEnergy
http://www.meconet.me/SmartHealth
Power supply
+
Battery
nodeMCU
Actuator
Battery
Smart
wireless
Sensor
+
MCU
+
Wireless
(RF,BT,ZB..)
Router
Commercial
IoT platforms
ThingSpeak
IFTTT
Zapper
CLOUD
RF433
Power
Switch
Power
action
RF
Receiver
WiFi
Wire
Sensor
S1
220V
User’s
Server (web page)
Client
Server #1 Server #2
Wearable health sensor
Conclusions
MECO’2021 and CPSIoT’2021, Budva, Montenegro
We discussed some of the principles to design open HWSW for
medical wearables.
The approaches can be useful from basic till advanced levels of
designing.
Some examples of efficient design we did on this topic: Stress detector
implemented on ATtiny85 (less than 512byte RAM) that acquires ECG
signal visualize it and implement, stress, HR and arrhythmias monitor.
Then SpO2, RR, and Temperature monitor using frequency domain
(FFT) that occupies less than 10024 bytes (RAM), suitable for Arduino
Uno.
To design acceptable medical wearables we need wide knowledge.
As example the monitor of Covid19 symptoms has been presented.
Those are only trials and we continue our works.