Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes...

58
IN DEGREE PROJECT INFORMATION AND COMMUNICATION TECHNOLOGY, SECOND CYCLE, 30 CREDITS , STOCKHOLM SWEDEN 2017 Embedded System Design for Pill Boxes with The Low Power Electronic Paper Display ALI KAMRAN KTH ROYAL INSTITUTE OF TECHNOLOGY SCHOOL OF INFORMATION AND COMMUNICATION TECHNOLOGY

Transcript of Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes...

Page 1: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

IN DEGREE PROJECT INFORMATION AND COMMUNICATION TECHNOLOGY,SECOND CYCLE, 30 CREDITS

, STOCKHOLM SWEDEN 2017

Embedded System Design for Pill Boxes with The Low Power Electronic Paper Display

ALI KAMRAN

KTH ROYAL INSTITUTE OF TECHNOLOGYSCHOOL OF INFORMATION AND COMMUNICATION TECHNOLOGY

Page 2: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

1

Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display

Master of Science in Embedded Systems

By

Ali Kamran

Supervisor

Yuxiang Huan

KTH Royal Institute of Technology, Sweden

Examiner

Prof. Lirong Zheng

KTH Royal Institute of Technology, Sweden

DEGREE PROJECT IN INFORMATION AND

COMMUNICATIONTECHNOLOGY

STOCKHOLM, SWEDEN 2017

Page 3: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

2

Abstract

The rapid development of technology in the health-care sector has led to the

discovery of many new illnesses and improved treatments that were not

possible earlier. However, many treatments and medicines for a specific disease

often come with several side effects. The accuracy in treatments with an optimal

result on specified targets is therefore desired with minimum side effects. This

requires that the production and the usage processes should be precise. The

scope of this study is not about the medicine production phase but rather on

managing a medicine schedule. How many times a medicine should be taken in

a day is strongly related to its dosage and following a precise timing plays a

crucial role in the individual’s health.

As a solution, a pill box based on a low power display (Electronic Paper Display,

EPD) together with an embedded system has been introduced by the project

owner (Victrix AB, Stockholm) .The pill box should have some different

functions like alarms, data logging and wireless reporting. Different types of

alarms including ringtone, vibration and voice recording/playing are required

as well. To be able to trace the already planned timing for taking medicines,

system will be able to save and report history of the past 100 days. Since every

single idea for solving different parts of the problem should be tested in real

system, a Quantitative Research based on experiments be used and the best

possible solution be selected and implemented in the project. Studying

technical material and also related works besides analyzing generated data after

each experiment were a useful tool for the system integration in this work.

As the result, a pill box based on an embedded system was designed and

integrated successfully. A hardware platform, in form of a prototype system

based on an ARM microcontroller and a compatible embedded software have

been designed, improved and tested successfully and are available.

At the end of this work, the low power E-paper display works properly, alarms

can be set and activated, data can be saved and also sent wirelessly. Basically,

the result of this project shows how an embedded system can be specialized and

programmed to be able to interact with patients and e.g. nurses in order to make

a stable and continuous connection between them.

Most of determined goals have been achieved and some of them be changed and

modified during the work. Also a few additional functions and improvements

be suggested as future work.

Keywords Embedded system, Low Power, ARM microcontroller, E-Paper display, Pill box, Wireless data communication, Bluetooth, SPI flash memory.

Page 4: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

3

Acknowledgement

First of all, I would like to thank the all responsible persons at KTH who were

directly connected to this work. Specially, I thank Professor Lirong Zheng for

accepting to be my academic examiner. He created a kind work atmosphere

from the beginning of the thesis project which I’m really thankful for.

Also, I deeply thank my project supervisor, Yuxiang Huan at KTH who helped

me in the project with his advices, recommendations and useful answers. He

was always available whenever I needed guidance which I really appreciate it.

I thank the company Victrix AB which gave me the opportunity to work with an

interesting project which was completely related to my education field. I tried

to use my academic knowledge and experiments in a concrete project which was

very valuable experience.

Last but never the least, I want to thank my family and my close friends for

supporting me during my education at KTH. Couple of weeks after starting my

thesis work, we got a lovely baby boy. I want to show him when he grows up

that I always try to be a good father to him and also to my older son.

Page 5: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

4

Table of Content

1 Introduction ............................................................................................................. 7 1.1 Background .......................................................................................................................... 7 1.2 Problem .......................................................................................................................... 8 1.3 Purpose ........................................................................................................................... 9 1.4 Goal ................................................................................................................................... 9 1.5 Benefits, Ethics and Sustainability ............................................................... 11 1.6 Methodology/Methods ......................................................................................... 12 1.7 Delimitations ............................................................................................................. 14 1.8 Outline ........................................................................................................................... 14

2 Technical Background ..................................................................................... 15 2.1 EPD (Electronic Paper Display) ..................................................................... 15 2.2 ARM Microcontroller ........................................................................................... 17 2.3 Volatile and Non-Volatile Memories ........................................................... 18 2.4 Wireless Data Communication ....................................................................... 19 2.5 Power Supply and Power Consumption .................................................... 20 2.6 Related Work ............................................................................................................. 22

3 Methodology .......................................................................................................... 29 3.1 Methods ........................................................................................................................ 29 3.2 Data Collection/Analysis .................................................................................... 30 3.3 Literature Review ................................................................................................... 30 3.4 System Integration ................................................................................................. 31

4 Embedded System Design .............................................................................. 32 4.1 System Architecture .............................................................................................. 32 4.2 Hardware Implementation ............................................................................... 34 4.3 Software Design ....................................................................................................... 40

5 Verification and Evaluation .......................................................................... 46 5.1 Verification of Critical Functions .................................................................. 46 5.2 System Verification ................................................................................................ 47 5.3 Performance, Power and Cost Evaluation ............................................... 49

6 Conclusion and Results ................................................................................... 51

7 References .............................................................................................................. 54

Page 6: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

5

List of Figures

Figure 1-1. A primary design of the pill box and how the E-paper display (EPD), buttons and 8 transparent pill slots will look like. ........................................... 10 Figure 1-2. Connection of pill slots and the main box from side view. ............. 11 Figure 2-1. Encapsulated white and black pigments in pixels which be repelled or attracted to electrodes. .................................................................................. 16 Figure 2-2. Partial attraction to electrodes to make gray color. ....................... 16 Figure 2-3. Package of the used microcontroller. The distance of 2 pins is 0.5 mm. .................................................................................................................... 17 Figure 2-4. Different packages of AT45DB161D. .............................................. 19 Figure 2-5. Connections between the microcontroller, Bluetooth module and a smart phone as a data reader. Both ARM MCU and Bluetooth module, HC-05, are in the pill box but ARM MCU sees all parts in the dash line as a system which can be reached through USART inter............................................................... 20 Figure 2-6. The medicine bag with printed matrix barcode. ........................... 22 Figure 2-7. The proposed pill box and how it contains camera and medicine bags. .................................................................................................................. 23 Figure 2-8. The proposed design for “Smart Pill Box” 25. The place for pills has been divided to slots with separated sensor. .................................................... 24 Figure 2-9. a) Circuit on bottom of each slot. b) Converting capacitance to frequency. .......................................................................................................... 25 Figure 2-10. 2.13 inch EDP (DEPG0213R01) which is connected to its starter kit by a 24 pin flat cable. ........................................................................................ 27 Figure 2-11. Provided embedded system based on MSP430F5529LP microcontroller from Texas Instrument to run, test and evaluate Pervasive’s E-papers. ............................................................................................................... 28 Figure 2-12. Pervasive extension board which contains analog components to operate E-paper displays. ................................................................................. 29 Figure 3-1. How a new module will be involved in the system and be consistent with other parts based on an experimental research strategy. ........................ 30 Figure 3-2. Connecting a module as a sub-system to main module (MCU) by two layers interfacing: Software based (drivers) and Hardware. ..................... 31 Figure 3-3. Single master / multiple slaves system. All modules listen to commands and answer to acquisitions. Each two sided arrow between the master and a slave corresponds interfacing box with dash line in Figure 3.2. 32 Figure 4-1, Structure of the pill box. All parts except the shown pill slot be placed in the main box shown in Figure 1.2. ............................................................... 33 Figure 4-2. Hardware of MCU board. STM32F103V8 ARM, JTAG debugging interface and DC power supply driving. ........................................................... 34 Figure 4-3. Hardware of the external memory, AT45db161D and its connections to the power supply and microcontroller. ........................................................ 35 Figure 4-4. E-paper display (Left side) and the Interface Board (Right side) which supplies power to EPD, contains some additional analog components and connects EPD to MCU through CON1. ...................................................... 36 Figure 4-5. Interface board between EPD and MCU board. ............................ 37 Figure 4-6. Sound recording/playing circuit use in the pill box. ..................... 37 Figure 4-7. Boost-Buck step-up regulator to give a fixed output voltage (3.3V). ........................................................................................................................... 38 Figure 4-8. Connection of the push buttons to I/O pins of microcontroller. .. 39

Page 7: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

6

Figure 4-9. Connection of Bluetooth module to serial port of microcontroller. ........................................................................................................................... 39 Figure 4-10. Conversion of pictures to monochrome bitmaps by vertical scanning. ........................................................................................................... 45 Figure 5-1. Functionality of the system shown on E-paper display. ................ 48 Figure 5-2. Performance of E-paper display in running mode. ....................... 49 Figure 5-3. Different operation states for low energy Bluetooth module (BLE) ........................................................................................................................... 50 Figure 6-1. Current consumption in run mode from RAM versus operation frequency (at 3.6 v). .......................................................................................... 53

List of Tables

Table 2-1, Peripherals in STM32F10X family and related power consumption. ............................................................................................................................ 21 Table 2-2, Light based (LDR) sensing test with a 4g pill. ................................ 25 Table 2-3, Capacitive based sensing test on different pills. ............................. 26 Table 4-1, Relations between sampling frequencies and durations of recording. ........................................................................................................................... 38 Table 5-1. Current consumptions in different modes. ...................................... 51 Table 5-2, Cost evaluation for the existing prototype system. .......................... 51

Page 8: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

7

1 Introduction

It is important for the patient to follow a precise plan when managing one or

multiple medications during a treatment of an illness [1]. Almost all medicines

today have been specialized with specific targets in our bodies. These targets

can be inner organs, hormones etc. This makes our medicines much more

complicated than before and patients are therefore required to take multiple

aspects into consideration when using a certain medicine. Some of these

important aspects are to take a proper and precise dosage, not taking some

medicines together or exactly after/before meals, etc. The other aspect which

also is very crucial during a treatment is the time interval between the

medications [2]. Both short-term and long-term impacts of a medicine are

strongly correlated with these time periods. The time interval that is

predetermined should be followed strictly where the dosage of a specific

medicine has been taken into consideration. In most cases, the long-term

impact of a chosen treatment needs to be studied. Thus, it is also necessary to

know how well a patient has been following a given plan. The scope of this study

is to design a pill box which can get a time schedule from a user and remind the

patients in predetermined times for facilitating the medicine taking process.

The pill box should also be able to save the data up 100 days which allows the

indication of the missed medication times.

1.1 Background

As a solution, a portable system which can be programmed and set up by the

user, making of alarms, saving, sending and showing the data on its display is

needed. Such system can be designed and implemented by simple

combinational and sequential digital components and circuits [3] like gates,

counters, latches, decoders, flip-flops etc. without any programming but will

however result in a product with poor quality compared to the goals of this

study. Another limitation with using such digital circuits is the size of a

production which will make a compact portable product impossible. However

it is possible to implement such digital circuits in a relatively powerful CPLD

with a big hardware area or even on an FPGA with any weaknesses. In that case,

the eventual future modifications will be a little more difficult to be performed

since changing in a software is inherently easier than making changes in a HDL

(Hardware Description Language) in a hardware based platforms like CPLDs

and FPGAs. Today, most of the digital devices such as displays, memory devices

and wireless modules be initialized and configured by digital codes and

commands. Thus in such cases, using embedded programmable devices like

microcontrollers and microprocessors is really inevitable.

The selected MCU (Microcontroller Unit) in this project is a 32-bits ARM

microcontroller from STM32F1 family [4]. The Keil uvision compiler has also

been used for compiling and linking the written C-files. The delivered C-code

Page 9: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

8

also can be opened and modified by different version of Keil [5] by making some

simple changes.

Information in the form of time, date, alarms and different notifications and set

up instructions will be displayed on an EPD (Electronic Paper Display) [6]. The

basic reason of selecting an EPD in this work was its extremely good power

consumption properties and its thickness which in our case is only 1 mm.

A memory device from Atmel by serial communication has been selected in this

project for the purpose of saving data for each day in form of times, followed

and missed alarms.

A Bluetooth module, HC-05 [7], will be connected to MCU for sending the saved

data to another platform such as smart phones, tablets or computers. A voice

recording device, ISD1820 [8] is connected to the system for being able to

record and play voice notifications.

There are 3 different types of digital interfaces applied in the system which

allows MCU and the other modules to communicate with each other. The first

one is a simple GPIO (General Purpose Input Output) which can read/write

digital signals (3.3v or 0v) in/to one or several parallel pins. The second one is

a USART (Universal Synchronous/Asynchronous Receiver/Transmitter) [9]

which allows the communication between MCU and wireless transmission to

take place. And finally, the third one which is a SPI (Serial Peripheral Interface)

[10] which allows the communication between transmits data from MCU,

memory device and EPD to occur. The modules are then set together and the

interaction between them is assured.

The next step is to design the next product prototype by moving the hardware

to a PCB (Printed Circuit Board) board. This allows us to have a more stable

system during testing and improvement processes of the system.

The embedded software was developed in C language including the standard C

language rules, functions and interrupts.

All the named parts will be described and studied in details later in this work.

1.2 Problem

Detecting and preventing an illness are the basic steps in the health care system.

The medical treatment and the quality of it are also very important that must

be taken into consideration. It is crucial to make sure that all parts of the

defined medical treatment will be executed as it has been planned. Two

separate user groups will be involved in this case. The first group will take the

role of the treatment planners such as doctors, nurses or even a family member

who is in near contact with the patient while the second group will take the role

of the patients. The main problem occurs due to the non-continuous

contact/communication between these two groups during the treatment time.

There will be more difficulties if a patient has limitations in movement or

memory. There are also a small number of immigrant patients that have

difficulties in communicating with the doctors and the nurses due to a language

Page 10: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

9

problem. The mentioned problems might be even more severe for the medical

personal if getting a feedback from the patients is needed.

This feedback can be about the schedule of medications and how well the

patients has performed in following the provided plan in the last several days.

Effect of a medicine can be studied based upon the received feedback and the

main sources of every single undesirable effect should be known as fast as

possible.

There seems to be a need for a reliable, robust and traceable connection

between the two groups mentioned. The question this study is trying to answer

is how embedded system can help to establish this communication between

doctors/nurses and patients.

1.3 Purpose

After the aforementioned discussion of the problem, a solution can be

suggested and formulated. The considered solution will be initiated, designed

and improved during this study. A portable system which will be developed in

this study should be able to fulfill the requirements which were considered in

section the “1.2 problem”. Such system which contains many parts including

digital/analog modules and also embedded software needs to be documented

and described in details. In other word, the system integration in the embedded

system is the most important step in this work. Many technical details have to

be considered and a detailed documentation is needed if someone wants to

repeat this work or wants to improve its results. Thus the main purpose of the

written material in this work is making the final results documented and

repeatable. This creates a proper basic work in details for producing the

required pill box.

1.4 Goal

To be able to obtain a concrete product at the end of this study, all the ideas and

partial solutions in both software and hardware should be tested and studied in

a real hardware platform.

A literature review of the existing methods and applications will be performed

during this project for the assessment of the feasibility and the possibility of

applying the best method available. Otherwise, several candidate solutions

(mostly software based solutions) might remain on the table without knowing

which one them is the best possible solution for this project. On other hand, the

software part of the embedded system cannot be improved without a proper

and working hardware. There are some tools in form of simulators for testing

and verifying a written code for a hardware but it is not possible to guaranty

that a tested code in these simulator tools will work perfectly also in reality.

There might be problematic cases where the simulator cannot consider all the

details of the hardware. Simulators have been improved and using them for

testing a code during improving an embedded software is helpful but testing

written codes on an existing hardware platform is needed.

Page 11: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

10

Thus, a considerable part of this work is to design and create a prototype

embedded system for the pill box. Having a working system based on studying

the theoretical backgrounds related to the project presents the best achieved

results. The primary design of the pill box is available in Figure 1.1.

Figure 1-1. A primary design of the pill box and how the E-paper display (EPD), buttons and 8 transparent pill slots will look like.

As it shown in Figure 1.1, EPD shows all needed information including actual

time, date, maximum 8 alarms and 4 extra alarms specified by small (x) marks

, missed alarms and etc. Also 5 buttons (MODE, SET, STOP, Up and Down) will

be used e.g. for setting time, date and alarms or sending saved data.

Page 12: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

11

The middle box (also called main box) contains of main system, display, power

supply and 2 sliding pill boxes (each one contains 4 pill slots) which connect to

middle box from top and bottom side.

Furthermore, 8 LEDs on middle box indicate which slot should be opened and

containing medicines should be taken in specified times. Mechanical details can

be seen in Figure 1.2.

Figure 1-2. Connection of pill slots and the main box from side view.

The future work and also eventual changes and modifications should be applied

on this work easily. Thus, delivering a working system as a basic framework

after all the tests in hardware and software is the main goal of the project.

1.5 Benefits, Ethics and Sustainability

As mentioned before, the pill box as a product and also the studies to design

and improve it, are a concrete results of this work. The main groups of people

who will directly benefit from the results, are patients and those who help them

for having a more reliable and precise medical treatment process. It can also

help to investigate the effects of different medicines. The current development

has led to many advanced improvements in biological and chemical sciences

which are often behind of producing different medicines. But unfortunately,

effect of a medicine can vary from one patient to another which makes the

situation more complicated. By helping patients to take medicines in time and

by studying the previous data of taking medicines, the effect of a medicine on a

specific patient can be measured with higher quality.

There are other groups who can benefit from results of this project. We can call

these benefits as indirect benefits. Since the framework of this project is

embedded system, it inherently belongs to electronics and embedded computer

sciences. A system based on embedded system has often several sub modules

including displays, I/Os, MCUs, memories and software.

The main challenge in this area is to combine and match these modules in a

way that will simplify the system and will make it easier for connecting with

other systems available.

Page 13: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

12

In this project, we also have several electronics and software modules which

work together and form the final system. Such modular system can also be used

in partial form. It means that some parts of the work and results from this

project can be used in other similar projects and studies, even with a completely

different approach and goals. Using an ARM microcontroller in an embedded

system or using an E-paper display when power consumption properties are

important, are some of these partial benefits which can be delivered by this

work.

Moreover, there are some other aspects in the project which can be considered

and studied from ethics viewpoints. The finalized project is a touchable product,

which often can be programmed by others and gather data which can be

collected and analyzed by doctors and/or nurses.

It means that existing the suggested pill box and its functionality is somehow in

contrast to privacy of patients. How exactly privacy of patients is defined can be

discussed. On the other hand, validity of the gathered and saved data by the pill

box can be discussed. Another issue that is of most importance is the subject of

privacy, how much data is the pill box allowed to gather about an individual’s

health. There might also be misunderstanding where the patient is unaware of

the fact that data is being collected through this pill box.

About the sustainability, the project and its results can be considered from

another perspective. From a society perspective, results of the project help

people to receive more efficient services and medical aid. By using such system,

some new possibilities will be created to be able to care about patients even

more. There must be a connection between those who wishes to help others and

those whom need help. A smarter pill box makes this possible that e.g. a nurse

can analyze the data available and help the patient through this pill-box even if

she is not beside him/her.

We all know that substances and heavy metals used in batteries damage our

environment unless an efficient recycling program is applied [11]. On the other

hand, execution of this recycling process is quite difficult. Thousands of

batteries with different sizes, types etc. are being left disposed in the world every

day. This is very hard to be control, but a proper way to reduce its undesirable

impacts on our environment can be made through minimizing the usage of such

batteries. One of the basic tasks in this work design of the pill box was to have

a very good power consumption properties. Due to this, an E-paper display with

low power consumption has been selected. On the other hand, in the ARM-

MCU, only those embedded parts which have been used directly in the work

have been connected to the power supply to minimize the power consumption.

1.6 Methodology/Methods

Choosing a method for doing a project based on researches is a crucial issue.

How a research will be performed should be formulated in a standard and

known pattern. A research is the base of a work and it will be used, referred,

Page 14: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

13

continued or improved later in future researches and works. Thus, it is

important to know how prior works had done and how different aspect of a

research including philosophical assumptions, methods or approaches had

been considered. It is therefore important to make a proper literature review

which was done in this study.

The two basic categories of research methods are “Quantitative” and

“Qualitative” research methods [12].

A quantitative research is based on experiments, measuring of variables and

testing to be able to verify or falsify different theories and hypothesis. That’s

why in this method, all hypothesis and theories have to be measurable with

quantifications. Commonly in this method, it is needed to have a big set of data

and statistics to be able to evaluate all hypothesis.

The other method is a qualitative research which has more focus on

understanding the meanings to reach tentative hypothesis. This method often

needs smaller data sets to study correctness of hypothesis and theories.

There is not an obvious and clear boundary between the named methods and it

can sometimes be tricky and difficult to choose one method which can clearly

cover all the aspects of a research. Our viewpoint depends on a specific project

and its inherent properties and requirements. It can also happen that a project

can or needs to be performed by a combination of the two methods which is

called the “Triangulation” method. This makes it possible to get more reliable

results. Although both of methods can be used as complements but it’s

recommended to pick one of them and be consistent during a research.

In this work, already existing modules (e.g. the Electronic Paper Display,

Bluetooth and ARM-MCU) was applied and mounted in a bigger system. The

main part of the work is to make them compatible and consistent with each

other. This requires the study of each part separately first and then consider

them as modules with different inputs, outputs and control parameters. The

different modules are then gathered and connected to each other. The tools for

the connecting phase (beside the physical connections) are mainly software

based functions.

How good software based functions will be created and improved requires

many tests, changes and comparisons in an experimental manner. Therefore,

“Positivism” as philosophical assumption in the research has been chosen.

As mentioned earlier, experiment of different technical theories to achieve the

best possible result is a main tool in this work. Thus, the type of the research

method will be “experimental” in this study. The different hypotheses will be

evaluated and consequently verified or falsified based on the conducted tests.

Then, the hypothesis which generates best results and delivers more stable

system will be selected and used. This makes a “Deductive” approach suitable

for the research approach in this project.

Page 15: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

14

1.7 Delimitations

Since this work uses some specific modules and components, generated results

including all parameters and C-codes are strongly dependent on the used

modules. In fact, the main assumption in this work is that all selected and used

modules will not be changed during the work.

Almost all functions in the delivered software created in this project are

matched with the selected components. For example, functions which belong

to the E-paper display in the main program only work with the display with part

number GDEH0213B1. There is also the same situation when it comes to the

other components (e.g. C-code compiler, microcontroller and external

memory) in the main system inside the pill box. The results of this work can be

regenerated, repeated and evaluated only if the reader uses same modules and

assumptions which are named in this paper. It is still possible to use another

device with different characteristics and properties but the related parts in the

delivered software must be modified or changed in a proper way. Eventual

changes and modifications in both hardware and software should be able to

keep the consistency between all parts.

1.8 Outline

A linear structure for this thesis work has been selected where Chapter 2

introduces necessary technical backgrounds which are needed to understand

the details of the work. Chapter 2 describes the used modules as the sub-

systems and gives a brief introduction for each one. Also Chapter 2 provides the

related works in the area and reviews different ideas.

Chapter 3 describes how this project has been performed and which methods

has been used. Also different types of data in this work and how the data be

collected and analyzed will be descried in Chapter 3. How the literature and

datasheets has been gathered and used and which approach for system

integration has been considered is also available in Chapter 3.

In the beginning of Chapter 4 the top level system which contains sub-systems

will be illustrated. Since the system consisted of hardware and software parts,

2 viewpoints namely software and hardware has been used for describing the

top level system in Chapter 4.

Chapter 5 explains and evaluates the achieved results and describes how well

the results are. Also the strengths and weaknesses of the obtained results will

be reviewed in Chapter 5.

Chapter 6 gives the final conclusion of this thesis work and introduces and

suggests some future work for improving the obtained results of this work.

Page 16: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

15

2 Technical Background

In this section, all parts and modules which have been used in the project will be reviewed. Thanks to the modular property of the work, it is actually easy to divide the system into some smaller parts and study each part separately.

2.1 EPD (Electronic Paper Display)

There are many types of displays today and each one has own usage and

technology. Different displays have been specialized for different requirements.

Some of these requirements are for example displaying pictures or frames with

very high resolution or be able to be refreshed very fast between frames for

showing a smooth video. In fact, there are a wide range of display solutions for

different application.

In our case, we need a thin, light and low power display. It has to be thin because

available space in a hand holding and portable system like a pill box is very

limited. Designers try to choose tiny components and put them very close

together to save space. On the other hand, it has to be a low power display

because the needed power in portable devises are obviously based on batteries

which takes space and also are heavy. Ordinary displays like a TFT displays

(Thin Film Transistor) have very high performance and fast by thousands of

colors for each pixel but they are relatively heavy and big with several

millimeters thickness. An ordinary TFT display consumes much more power in

compare with an EPD and will not be a proper choice in this work.

A better choice for a portable pill box can preferably be an EPD. There are

several limitations in using such displays but their strengths like power

consumption properties are extremely good.

The used EPD in this work is a 2.13 inch E-ink display by part number

GDEH0213B1 [13] from Good-Display Company [14]. It has only 1mm

thickness. Also its power consumption properties are excellent which is only

40mW during updating and 0.017mW in standby mode. Because of this fact

that an EPD doesn’t emit light, it doesn’t need to consume much energy. Also,

it has some weaknesses which can be accepted in this work. Some of these

weaknesses are showing only 2 colors (white and black) and having a relatively

long refresh time which is about 600 ms.

The technology behind an EPD is based on having charged black and white

particles in size of micrometers encapsulated in tiny containers/pixels as it has

been illustrated in Figure 2.1. Pixels are bounded between two layers of

electrodes (an electrode in back side of display and a transparent electrode on

top side of display) which induct an electric field through a pixel. Black particles

(also called beads) are negative charged and will be repelled to top of the screen

and be visible as a black spot if a negative charge applies on bottom electrode

[15].

Page 17: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

16

Figure 2-1. Encapsulated white and black pigments in pixels which be repelled or attracted to electrodes.

Charges on electrodes and consequently related electric fields for each pixel can

be changed individually. It means that every single pixel is independent from

other pixels. In some improved displays as Figure 2.2, there are more than one

electrode on each side of each pixel. This makes it possible to attract/repel a

ratio of pigments and show a combination of white and black colors namely

gray color.

Figure 2-2. Partial attraction to electrodes to make gray color.

Page 18: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

17

2.2 ARM Microcontroller

Today, a wide range of microcontrollers is available and a proper device

regarding to a specific application can be picked and used. Performance,

number of I/Os, having various internal peripherals are some of properties that

usually be considered when a microcontroller be studied.

In this work, a 32-bit Cortex-M3 ARM from STM32f10X family have been used.

Some of properties and features of this device that are directly related to this

project are according to following:

72MHz clock frequency

Up to 128 Kbytes flash memory and 20 Kbytes RAM

2.0 to 3.6V application supply and I/Os

32 kHz oscillator for RTC with calibration

2 x 12-bit, 1 µs A/D converters (up to 16 channels)

Up to 80 fast I/O ports

Serial wire debug (SWD) & JTAG interfaces

Three 16-bit timers

Up to 9 communication interfaces (USB, I2C, SPI, USART, CAN, …) Different cores are available in different physical packages. There are many

types of microcontrollers in DIP (Dual Line Package) package including 16-bit

AVRs (Atmel MCUs) and PICs (Microchip MCUs) but all packages in STM32

family are in SMD (Surface Montage Devices). Even SMD packages are

available in several forms including LFBGA, UFBG, TFBGA and VFQFPN but

the selected device and package in this work is LQFP100 [16]. The number

“100” points to number of pins in the package. Figure 2.3 illustrates appearance

of the package used in this project.

Figure 2-3. Package of the used microcontroller. The distance of 2 pins is 0.5 mm.

Page 19: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

18

The most popular language for writing codes for a microcontroller is C and it

can be written and translated to lower levels of codes like binary and object

codes by a suitable and compatible compiler. Afterward, the generated code

which is executable on a hardware will be transferred to a microcontroller.

The used compiler here is uVision Keil ARM V.4 and the delivered C code has

been generated by this version but it can be modified very easy to be able to use

in other versions of Keil.

The programming tool for burning codes on the microcontroller in this project

have been J-tag [17] and ST-Link [18].

2.3 Volatile and Non-Volatile Memories

The two main categories of memories are RAM (Random Access Memory) and

ROM (Read Only Memory). Reading and writing from and to RAM is often fast.

For instance, access time to internal embedded RAM in STM32f10X family is

about 12 ns while this access time is 70 to 90 ns for the embedded ROM memory

in same device [19]. From other hand, RAM has own weakness. It needs to be

connected to a power supply to be able to keep a saved data. It means that such

memories are volatile.

One of the requirements in the pill box is saving some data. The saved data

belong to the past 100 days and this risk exists that one day in the 100 days

batteries should be changed. In this case, the device will lose all data saved in

RAM if power supply is shut down.

For this problem, an external flash memory has been considered in this project.

The selected memory device is AT45DB161D [20] which has properties and

features as following:

16 Megabits Non-volatile memory

2.5 to 3.6 V power supply

Up to 66 MHz SPI serial interface

Continuous Read Capability through Entire Array

Low-power Dissipation, 7 mA Active Read Current Typical ,25 µA

Standby Current Typical

Data Retention – 20 Years

AT45RD161D is available in some different packages and sizes as Figure 2.4

illustrates. In this project, the SOIC package has been tested and used.

This memory should be programmed and initialized by sending some codes and

commands. It has actually a default state and it is not necessarily needed to be

initialized but user can change its setting according to a desired functionality.

For example, size of memory pages inside the main memory array can be

selected as 512 bytes or 528 bytes or maximum speed of SPI interface can be

changed to a lower speeds like 33 MHz.

Page 20: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

19

Figure 2-4. Different packages of AT45DB161D.

2.4 Wireless Data Communication

Sending information from one node to other node wirelessly needs to know how

electromagnetic waves work and how a user can make a reliable and stable

connection between the nodes. Thanks to very compact modules in the market,

it has been easy to get rid of details which belong to telecommunication and

waves. An example is nRF24L01 [21] module which is a single chip 2.4GHz

transceiver. Using one module on each node makes it possible to send and

receive data but a reader device in this project is actually a smart phone, tablet

or a computer which don’t have access to this module.

Another solution for wireless communication which is easier to apply is

Bluetooth standard. The most important reason that makes it easy to use is that

almost all today’s productions including smart platforms and computers have

an embedded Bluetooth transceivers. In this case, there is a node which already

has own wireless module and for be able to make a connection, our system as

the other node also should be equipped with same interface.

The used Bluetooth module in this project is HC-05 which is able to be detected

by other platforms and be connected to them. From other side, it opens a serial

port compatible with USART standard as Figure 2.5 illustrates.

Thus from the microcontroller’s viewpoint, the reader platform (e.g. a smart

phone) which reads the saved information from the pill box is connected by a

serial communication interface. It means that when a user wants to send data

to the platforms, doesn’t consider all technical details, complicated protocols or

algorithms which are bounded in the dash line in Picture 2.4.

Page 21: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

20

In similarity to the memory device (AT45DB161D) in the previous section, HC-

05 also needs to be programmed and initialized before using. A set of standard

commands called AT-Commands [22] has been defined for changing all

possible setting inside the Bluetooth module. Some of these settings are e.g.

changing baud rate of the serial port or ID of the Bluetooth device. This ID is

the same string of characters which will show up when reader platform searches

all active and open Bluetooth devices in an area.

Figure 2-5. Connections between the microcontroller, Bluetooth module and a smart phone as a data reader. Both ARM MCU and Bluetooth module, HC-05, are in the pill box but ARM MCU sees all parts in the dash line as a system which can be reached through USART inter.

2.5 Power Supply and Power Consumption

The easiest way to supply power in a portable device is using couple of AAA or

AA batteries. Maybe, this is not the best technical choice today but these types

of batteries are available and accessible almost everywhere in the world. On the

other hand, this solution is very simple and also robust because the batteries

are not a fixed part of pill box and can be replaced easily.

The other important issue which should be considered in design of a portable

device is power consumption. If one neglects the power consumptions which

belongs to alarms (including lights, vibrations and sound playing) and E-paper

which is extremely low power, it remains only embedded system which

consumes power.

There are several peripherals (GPIOs, Timers, USB …) inside the used ARM

microcontroller which can remain disabled or be enabled if they are needed to

do some tasks. By enabling only necessary peripherals in the microcontroller,

power consumption can be minimized.

Table 2.1 shows details about power consumption of each peripheral inside

STM32F10X family.

Page 22: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

21

Peripherals µA/MHz

DMA1 16.53

BusMatrix 8.33

APB1-Bridge 10.28

TIM2 32.50

TIM3 31.39

TIM4 31.94

SPI2 4.17

USART2 12.22

USART3 12.22

I2C1 10.00

I2C2 10.00

USB 17.78

CAN1 18.06

WWDG 2.50

PWR 1.76

BKP 2.50

IWDG 11.67

APB2-Bridge 3.75

GPIOA 6.67

GPIOB 6.53

GPIOC 6.53

GPIOD 6.53

GPIOE 6.39

SPI1 4.72

USART1 11.94

TIM1 23.33

ADC1 17.50

ADC2 16.07

Table 2-1, Peripherals in STM32F10X family and related power consumption.

As it can be seen in Table 2.1, current consumptions of peripherals are

proportional to speed of processing in the microcontroller. An 8MHz external

crystal oscillator for clocking has been used but internal clock speed in the

microcontroller is higher and is 72MHz. The internal PLL unit (Phase Lock

Loop) by factor 9 has been initialized and used to speed up the clock rate for

inner peripherals.

By using a simple calculation and also by considering the used peripherals and

theirs current consumptions, an estimated value for the microcontroller’s

current consumption in 72MHz clock speed can be determined about 7.5 mA.

Page 23: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

22

Since voltage of the power supply is 3.3v, power consumption of embedded

system will be around 25mW.

2.6 Related Work

Design and realization of different solutions in the area depend on which

requirements and usage aspects will be considered more important. Some pill

boxes have more focus on contacts between patients and e.g. healthcare centers

or nurses while other products try to have maximum interact with patients.

There is a very wide range of ideas, electronic components and technical

complexities which can be implemented and used in a pill box. In different

cases, it is actually the balance between requirements, resources and usage

specifications which affect the final design.

In “A Smart Pill Box with Remind and Consumption Confirmation Functions”

[23], a relatively complex solution based on image processing has been used.

The idea is making packages of pills in transparent plastic bags as it shown in

Figure 2.6. On each pill package there is a specific printed matrix barcode which

contains all needed information about the encapsulated pills. The information

cover e.g. number and dosage of medicines and also times that it should be

taken.

Figure 2-6. The medicine bag with printed matrix barcode.

The idea is that after visiting a doctor, receiving medicines and returning home,

the patient scans all received medicine bags by a camera which is placed on

inner side of cover in the pill box as it shown in Figure 2.7. The camera reads

data from the barcode and allocates a scheduled time and also related alarms

for reminding the patient at desired times. Then, all scanned bags will be placed

inside the pill box. When it’s time to take a medicine, alarms will remind the

patient to open a bag and take his/her medicine. User takes a bag and scans it

by the camera for being sure if the picked bag is correct or not. If the picked bag

is incorrect, an alarm will notice the user to take the correct one. After opening

the correct bag and taking medicines, user needs to scan the empty bag by the

camera to register and save the picked bag in history as an in time taken

package.

Page 24: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

23

Figure 2-7. The proposed pill box and how it contains camera and medicine bags.

Its most significant strength in compare with the designed pill box in this work

is that entering information to the system is considerably easier. In the

introduced pill box [23], all information about alarms will be set in the timing

system only by scanning the matrix barcodes. In this work, times for alarms in

this project have to be set manually by pushing couple of buttons. In general, it

is good idea to decrease the physical interacts (e.g. pushing buttons) between

users and user interfaces on the pill box but such system has own weaknesses

as following:

The pill box needs medicines packages with compatible matrix barcodes

to work. This requires that doctors, nurses or pharmacies should have

access to some necessary substructures to print barcodes or encapsulate

pills otherwise the pill box will be useless. Therefore, the proposed pill

box cannot be used everywhere and will be limited to places that related

people and resources can be consistent with it.

The scanned packages don’t have special slots and will just be placed

inside the pill box. By considering this fact that some patients have to

have many medicines in several bags, it will be difficult to pick the

correct bag at the first or even second and third time when a patient picks

a bag. In this case patient has to check many bags to reach the correct

one.

Usage of the proposed pill box is relatively complicated and it can be a

bit tricky to use when patients are old or incapable. In this case, patients

need helps from other people while the goal of a pill box is help patients

to be more independent.

In the other work, “Smart Pill Box” [24], different ideas have been considered

and studied. Designer in the named work, mostly has focus on two basic things.

The first one is finding a solution for sensing existence of pills in slots and also

Page 25: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

24

try to estimate number of them. The second one is reporting information about

the estimation by sending data through a GSM channel. The integrated block

diagram of the design can be found in Figure 2.8. The used microcontroller is a

LPC2148 core from Philips. Raw data from slots and corresponding sensors be

multiplexed into the microcontroller. Then, an estimated result of number of

pills will be calculated and sent to a target (e.g. a healthcare center or similar)

wirelessly.

Figure 2-8. The proposed design for “Smart Pill Box” 25. The place for pills has been divided to slots with separated sensor.

For sensing existence of pills, 3 different solutions have been introduced:

Milligram measuring Load Cell, Light based sensing and Capacitive based

sensing.

The first method is based on sensing and measuring mass of pills in the slots.

The usual load cells based on strain gauges are able to sense masses in kilogram

scales very easy but sensing in milligram scales is considerably difficult and

expensive. Thus using this method in a pill box is absolutely unreasonable.

Light based sensing is the second possible way to know if a slot is empty or not

and try to estimate number of pills in it. The selected tool for sensing light in

this solution is an LDR (Light Dependent Resistor). Its resistance depends on

ambient illumination. More light on the LDR makes its resistance lower and

this is sensible by analog bridges and amplifiers and also analog to digital

converters. Table 2.2 shows results of a light sensing experiment in two

conditions (indoor and outdoor) which has been done on a 4g pill in a slot in

some different times.

Page 26: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

25

Time Indoor (in V) Outdoor (in V)

06:30 4.98 4.94

08:30 4.36 3.87

13:40 3.91 2.75

17:00 4.64 3.92

21:30 4.83 5.00

Table 2-2, Light based (LDR) sensing test with a 4g pill.

The last introduced way for sensing pills is capacitive sensing based on changes

in dielectric material in a capacitance. In this idea, a slot which also contains

some pills (or an empty slot) be considered as a capacitor. Pills will act as

dielectric materials in capacitors. To be more pills in a slot leads to increase

capacitance in the same slot. Bottom side of each slot has equipped by two

separated parts of copper and existence of pills changes the capacitance

between them as it shown in Figure 2.9-a. Furthermore, a simple circuit

converts changes in the capacitor to changes in frequency of a PWM output as

Figure 2.9-b. This can be measured by a timer inside the microcontroller. Table

2.3 shows results of some tests on different size of pills.

Figure 2-9. a) Circuit on bottom of each slot. b) Converting capacitance to frequency.

Page 27: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

26

Medicine Frequency (Hz)

50mg 20580

100mg 20240

4000mg 19990

5000mg 19700

Empty 21000 or higher

Hand Touch 5000

Table 2-3, Capacitive based sensing test on different pills.

After gathering information from slots, data be sent by using a private channel,

based on a sim card and a GSM port. Some issues about this design can be

studied and considered as following:

It is interesting way to know about state of a pill box regardless where it

is. But in similar to [23], it needs to have some special resources and

substructures to support functions of the pill box. If the goal is design a

product which can be used everywhere in the world, the mentioned

requirements and substructures cannot be neglected. Otherwise the pill

box can be very useful.

Some experiments have been done and functionality of GSM channel has

been tested in the project. According to the delivered results,

functionality of the system can often be limited by the network problems

or busy lines of communication. It means that such technical problems

and limitations should be expected and considered.

The experiments of light and capacitive based tests show that results

cannot be accurate and reliable especially when number of pills wants to

be estimated. Ambient illumination in light based and how pills are

located in slots in capacitive based tests can change results considerably.

But checking the slot to see if they are empty or not and report the result

can be implemented with higher reliability.

There are substances in some medicines which are sensible to electric or

magnetic fields. It is possible that some medicines will be affected by

such fields. This should be considered even if the eventual effects are not

significant.

Selecting and using a low power display which consumes minimum energy to

work is also an important requirement in this work. Besides the proper

consumption properties, also size, contrast and resolution of selected display is

important. Since there are several options in usage of the pill box which should

Page 28: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

27

be set or changed, it is necessary to have a display which is able to show details

on its screen. Some of these details are couple of words or short sentences in

menus which guide users to desired pages to modify related parameters or

execute some functions. Some of these functions can be e.g. send the saved data

to another device or recording or playing sounds for alarms. This requires to

have a display which has enough resolution.

There are many options to select and use an E-paper display but some of them

which have almost same needed properties in this work have been studied and

considered as follows.

The first display is DEPG0213R01 [25] which is a 2.13 inch, 122X250 pixels,

black/white and red matrix E-paper display from DKE [26]. Its operating

voltage range is 2.4 to 3.6 and its power consumption is between 15 and 24 mW.

Also there is an additional product from DKE which is compatible with the

mentioned display. It is a starting kit based on a microcontroller from

Microchip, PIC18F25J11 [27].

Because E-paper displays like other types of displays needs some software

based tools and drivers to work, different producers offer some hardware

platforms for their displays. These platforms called starter kits or evaluation

boards help users to operate and evaluate displays and try to modify or

customize the drivers and functions. Then, a user can create and improve own

software tools which also contains given display functions in same platform.

Figure 2.10 illustrates DEPG0213R01 display and also its starter kit based on

PIC18F25J11 microcontroller. Given codes are in C language and is available

when the starter kit be ordered.

Figure 2-10. 2.13 inch EDP (DEPG0213R01) which is connected to its starter kit by a 24 pin flat cable.

According to the specification of the display, refresh time is about 1 second

which is relatively high. This will cause that usage of a pill box or in general an

embedded system which uses this display becomes limited by time. For

Page 29: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

28

instance, every change in parameters during working with a system based on

this display takes at least 1 second and it can be boring for a user. On the other

hand, the used microcontroller in this starter kit is not a very powerful

microcontroller. Since some other additional functions like NFC (Near Filed

Communication) will be added to the pill box as the future works, choosing a

more powerful microcontroller with more process ability is reasonable. Also

number of available I/Os on microcontroller is important since there are

several LEDs, buttons and modules (Bluetooth, sound recorder, external

memory etc.) which should be connected to control unit despite this fact that

PIC18F25J11 has only 19 inputs/outputs. Thus it is inevitable to use another

platform and microcontroller to improve the C code for the pill box.

The other display with similar properties is a 2.7 inch, 264X176 pixels, black

and white E-paper from Pervasivedisplays [28] with part number E2271CS021

[29]. Similar to the DKE display some additional evaluation boards are

available for working with already created functions. But in contrast with DKE,

Pervasivedisplays provides 2 boards to operate displays. First board is

MSP430F5529 Texas Instrument’s Launchpad development kit [30] shown in

Figure 2.11 which consists of the microcontroller and be used for running the

given software to operate the display.

Figure 2-11. Provided embedded system based on MSP430F5529LP microcontroller from Texas Instrument to run, test and evaluate Pervasive’s E-papers.

The other provided board which is also needed to operate the display is an

extension board which contains some necessary additional analog circuits and

components. Actually, inputs of this board are power supply and digital lines to

communicate with the microcontroller and its output is a 40pin SMD connector

which be connected to the E-paper. It is also compatible with some other

Page 30: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

29

displays with different sizes (1.44 and 2.0 inch E-paper displays) as Figure 2.12

illustrates.

Figure 2-12. Pervasive extension board which contains analog components to operate E-paper displays.

The available C code for this product have Texas Instruments microcontroller

as the target and is compatible with its peripherals. It is obvious that display

functions can be written from the beginning according to the given

specifications and datasheets but it will be easier and also more reliable if a

programmer will use same codes directly provided by the producer. For

instance, the pill box and its functions should be based on this microcontroller

if one wants to use existing codes and display functions. On the other hand, the

provided extension board is very general with big size compatible with three

sizes of displays and is not able to be used in a compact prototype. For example,

the used E-paper display in this thesis work has a very smaller extension board.

Its size is 25mm by 35mm and is suitable to be used in a compact prototype. In

Chapter 4, comprehensive details will be available about it.

3 Methodology

In this chapter, different aspects of the selected research method and

methodology and also literature study will be considered and studied in details.

3.1 Methods

In order to achieve the expected results, an appropriate method in this work is

necessary to be picked and followed. As it mentioned before in Chapter 1.5

(Methodology/Methods) and by considering inherent properties of this project,

a quantitative research was introduced and selected. The proper tool for

integrating all parts in the embedded system used in the pill box is doing

experiments, tests and eventual corrections and modifications by following a

simple flowchart available in Figure 3.1.

Page 31: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

30

That’s why an Experimental research strategy and design which concerns

control over all factors that may affect the results of an experiment has been

followed. This strategy provides cause-and-effect relationships between

variables in best possible way. It means that correlations between independent

and dependent factors during the system integration be considered and a stable

system consisted of all modules will be provided.

Figure 3-1. How a new module will be involved in the system and be consistent with other parts based on an experimental research strategy.

3.2 Data Collection/Analysis

There are two types of data which should be collected and analyzed. First of all,

it is specifications and technical details belong to all modules and sub-systems.

The best sources to provide this type of data and information are datasheets

and user manuals given by companies which manufacture components and

modules.

The other type of data is all data which be generated during system integration

process. Regardless of results of an experiment which can be successful or not,

a set of data will be generated which describes both functionality and

consistency. This type of data will be considered as descriptive and inferential

data which describe how well the system has been integrated and sub-systems

are consistent.

Afterwards, these 2 types of data will be analyzed for necessary corrections in

order to put all modules together with more consistency. This makes Statistics

method an appropriate method for analyzing data in this work.

3.3 Literature Review

During integration of an embedded system, there are many parameters which

have to be considered and be controlled. This requires very good knowledge

about every single module which will be added to the system. That’s why a

significant part of literature study in this work was studying specifications and

Page 32: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

31

user manuals for all modules. Also studying earlier works and experiments was

very useful because it is possible to omit some details when several properties

of a module must be considered. Besides the used results from other works, a

set of application notes provided by producers have been used in this work.

Data sheets, user manuals and specifications consist of all detailed information

about a specific product. Those have focus on the product itself and usually not

about the product’s interaction in a bigger system. On the other hand,

application notes give us more superficial details but wider information about

a product which usually contains practical details when a user tries to integrate

the module in a system.

3.4 System Integration

The connections between sub-modules and main module can be considered as

interfacing with two abstract layers. As it shown in Figure 3.2, the two layers of

interfacing are physical layer and drivers. The physical layers are conductive

connections between pins or wires. Power supplies, and digital or analog

voltage levels be transferred in this way. The other layer is software based

connections called drivers which make it possible to pair two nodes. Here, the

nodes are actually main module and one sub-module. In fact, drivers use

physical layers to send and receive data, commands and signals between two

nodes. Usually, drivers be created and applied in CUPs or microcontrollers to

make a plugged module work. The microcontrollers consider all parameters

and details which are about functionality of a module and use them in drivers

to be able to talk with connected modules. Commonly it is microcontrollers

which act as masters in such modular systems and other modules/sub-systems

listen to commands and acquisitions as slaves. Since in this project we have only

one microcontroller, the integrated system will be considered as a single-master

and multi-slaves system as it shown in Figure 3.3.

Figure 3-2. Connecting a module as a sub-system to main module (MCU) by two layers interfacing: Software based (drivers) and Hardware.

Page 33: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

32

Figure 3-3. Single master / multiple slaves system. All modules listen to commands and answer to acquisitions. Each two sided arrow between the master and a slave corresponds interfacing box with dash line in Figure 3.2.

4 Embedded System Design

In this chapter the project and its details will be described and reviewed. First,

the system architecture describes how all parts have been integrated and how

connections between them look like. Furthermore, the work be splitted into two

other parts namely Hardware Implementation and Software Design. These

two parts are strongly connected to each other but still it is possible to consider

one of them first and describe related details and properties and then focus on

the other.

4.1 System Architecture

In Chapter 2 (Technical Background), some brief information about

functionality of key components was available. Also what a component as a sub-

system needs to do studied in Chapter 2. Here we will see how the integrated

system looks like and consider whole system which involves all used

components and modules. Since the created system is the first version of a

working system, it will be a prototype version. Obviously, the given structure

here is not a compact and optimal design and is not ready to be considered as a

final version of the system. There are many optimizations and improvements

which should be done before having a commercial version but most of these

optimizations are out of scope of this work. The introduced prototype can be

considered a useful base for all needed optimizations because necessary

changes after this work mostly consisted of changes in hardware. Although

applying some software modifications is inevitable when hardware be changed

but it will be limited to simple changes in interfacing issues, I/Os or similar.

Figure 4.1 illustrates structure of the integrated system and brief details about

the connections between them. In the given structure, showing power supplies

for different parts of the system has been neglected (with the exception of

batteries and power regulator) and only digital signals between the MCU board

(STM32F10x Board) and other modules have been considered.

Page 34: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

33

Source of needed power supply can be provided by two or three 1.5 volt batteries

or similar. Actually it depends on final design and current requirements and

limitations. Thanks to the power regulator, a wide range of input voltage (0.9V

~ 6V) can be applied to the system as power supply while the output of the

power regulator is always 3.3V.

Also as a simple user interface, five push-buttons are connected to the MCU

board to input commands and set the alarms.

In this version, a one-way communication between the pill box and a smart

phone (or similar platforms) has been implemented. Data from MCU board be

transferred to the Bluetooth module (HC-05) by standard serial interface

(USART).

Figure 4-1, Structure of the pill box. All parts except the shown pill slot be placed in the main box shown in Figure 1.2.

Furthermore, 8 blinking LEDs be used for lighting up inside of 8 pill slots and

indicate which slot(s) should be opened and medicines should be taken. Figure

4.1 shows one of the 8 pill slots from side view.

The external memory (AT45DB161D) is an 8-pins IC which has been mounted

on a tiny PCB with 8 pin-headers and is connected to the MCU board by wires.

The EPD (GDE0213B1 display), beside the digital signals which are used for

receiving commands and data from MCU board and also reporting status to it,

needs some analog driving to work. All needed components for analog driving

have been mounted on a PCB board called Interface Board. Thanks to this

board, connecting to the display becomes easy in the prototype version of the

system. Also it has a 24-pins SMD connector to plug the EDP.

As it mentioned before, some different physical notifications including simple

beeps, vibration and sound playing will be used for alarms. Type of a

Page 35: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

34

notification can be selected when an alarm be set. A buzzer for beep signals, a

tiny vibration dc motor for vibration and a sound recording/playing based on

ISD1820 IC have been used for the voice or audio notifications.

This was a general view of the whole system which will be used in the pill box

but in the next sections (Hardware Implementation and Software Design) in

this chapter, more details about each part will be available.

4.2 Hardware Implementation

In this part more details about hardware of each used module will be considered

and reviewed. Since the MCU board in the whole system acts like a central

module, it can be good idea to start review its hardware first.

The used MCU board in this project is actually a general purpose hardware

which mostly gives us access to all I/O ports and programming interfaces. Also

it provides some components which are needed to run the microcontroller as it

can be seen in Figure 4.2. As it mentioned, it’s a temporary platform to be able

to form a prototype and can be more optimized in future steps. For instance,

two crystal oscillators provide two types of clocks. A 32.678 KHz oscillator is

used for running internal RTC (Real Time Clock). Its special frequency which

actually is 2 raised with 15 is suitable for creating seconds. A prescaler circuit

inside the chip reduces the provided clock to a low rate clock which is 1 Hz.

Furthermore, the low rate counter feeds a 32-bit counter which counts and

saves number of seconds. Also the low rate clock can be used for requesting

interrupt every second. In the next section (Software Design) in this chapter,

more details about usage and functionality of RTC will be described.

Figure 4-2. Hardware of MCU board. STM32F103V8 ARM, JTAG debugging interface and DC power supply driving.

Page 36: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

35

J3 is a 20-pin male connector which provides connections to SWJ (Serial Wire

JTAG) debugging signals on the microcontroller. The connector is compatible

with standard JTAG debugger but other debugger which support this standard,

also are able to be connected to the Cortex debug port by simple adaptors. In

this project, both J-Link and ST-Link have been used. The SWJ signal are

JTMS, JTCK, JTDI, JTDO and NJTRST which are alternate functions for PA13,

PA14, PA15, PB3 and PB4 respectively.

An 8 MHz crystal also is connected to the microcontroller and provides clocks

but internal peripherals in the ARM microcontroller work with higher speed.

Internal PLL (Phase Locked Loop) multiplies provided frequency by 9 speeds

up the system clock up to 72 MHz.

Boot-0 and Boot-1 pins on the microcontroller have been connected to ground

and have logic “0”. By applying different logic values on these pins, boot

configuration can be set up. The applied condition here selects main flash

memory as boot space. The other option was applying logic “11” to Boot-0 and

Boot-1 to select embedded SRAM as boot space.

The selected microcontroller in this work, except a 128 Kbyte embedded flash

memory for program, doesn’t have an additional non-volatile memory for

saving data. However it is somehow possible to use the available embedded

flash memory for saving and recovering data when the program inside the

microcontroller is running but in this work another solution has been selected.

As it was introduced in Chapter 2 (Technical Background), AT45DB161D as an

external non-volatile memory has been chosen for saving generated data. It is

compact, reliable and easy to use. Its communication interface is SPI (Serial

Peripheral Interface) which is a simple synchronous serial bus. Speed of SPI

bus in this case can be up to 66 MHz. All needed signals to talk to the memory

are SI (serial in), SO (serial out), SCK (serial clock) and CS (chip select) which

are connected to PA7 (7th bit of port-A on microcontroller), PE12, PA5 and PA3

respectively as the details available in Figure 4.3. Data or commands through

SI clocked in to the memory and reported responses or recovered data clocked

out through SD. Both reading and writing processes be synchronized by

generated clocks from MCU and external memory acts as slave.

Figure 4-3. Hardware of the external memory, AT45db161D and its connections to the power supply and microcontroller.

Page 37: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

36

Size of the memory is 16 Mbits which is actually more than what we need. Data

to be saved is actually information belong to 100 past days and for each day,

date and taken/missed alarms will be saved. It means that needed memory

space is less than 1 Kbyte and depends on how memory bits and bytes be

allocated. A part of future work for this project is adding NFC (Near Filed

Communication) instead of Bluetooth and having more memory space is

reasonable. On the other hand AT45DB161D is very small and also inexpensive.

Written and prepared functions as a part of program code which read/write

data and commands from/to AT45DB161DB will be described in Software

Design section.

One of the important partial goals in this work was using a low power display.

That’s why an E-paper display called EPD was good choice in this work. Here,

more details about hardware of the selected display be discussed. There are two

parts related to it, display itself and the Interface Board (as it can be seen on

right side of Figure 4.1) which supplies power, drives the display and also

provides easy connections. We start with the display itself. The display with part

number GDEH0213B1 [13] shown in Figure 4.4 has a 2.13 inch screen with

23.8mm×48.5mm active area, 250 (H)×122 (V) resolution, 1mm thickness and

rectangular pixels (0.195mm×0.194mm). The display has a 24-pin flat cable

which be connected to an interface board. The interface board contains all

components right side of the vertical dash line in Figure 4.4.

Figure 4-4. E-paper display (Left side) and the Interface Board (Right side) which supplies power to EPD, contains some additional analog components and connects EPD to MCU through CON1.

Page 38: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

37

Furthermore, digital signals including serial data, clock, chip select, busy signal,

bus-select and reset pin are available to reach and use through a 2×10 pin

connector called CON1 on the interface board. The connector CON1 be mounted

to the MCU board and seven I/O pins from microcontroller shown in two

ellipses in Figure 4.4 be connected to the corresponding signals. Figure 4.5

shows how the interface board looks like.

Figure 4-5. Interface board between EPD and MCU board.

As the system needs to play a voice signal for alarms with voice notifications, a

simple solution was using a voice recorder device. It consisted of an IC with part

number ISD1820 and some additional analog components as Figure 4.6

illustrates. An 8ohm, 0.5 watt speaker and a capacitive microphone are

connected to SP1/SP2 and MIC1/MIC2 respectively and again, the ellipse in

Figure 4.6 shows 2 signals namely REC and PLAY which be controlled by PA6

and PD13 on microcontroller. The quality of a recorded which is actually

correlated to frequency of the sound can be adjusted by changing sample rate.

A resistor, R1, between ROSC pin on ISD1820 and ground determines sample

rate of sound recording. Since memory of the ISD1820 is limited, price of sound

recording with higher frequency is shorter recording. Table 4.1 shows relations

between resistance of R1, durations of recording and also sampling frequencies.

In this project, selected value for R1 is 100KΩ which gives 10 second recording with

2.6 KHz sample rate.

Figure 4-6. Sound recording/playing circuit use in the pill box.

Page 39: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

38

R1 Duration Sample Rate

80 KΩ 8 sec. 3.4 KHz

100 KΩ 10 sec. 2.6 KHz

120 KΩ 12 sec. 2.3 KHz

160 KΩ 16 sec. 1.7 KHz

200 KΩ 20 sec. 1.3 KHz

Table 4-1, Relations between sampling frequencies and durations of recording.

As Figure 4.1 shows, a wide range of input voltage can be applied to the system.

It is actually thanks to a Boost-Buck step-up switching regulator (ME2149)

which has been used on the power supply line. The used regulator circuit based

on ME2149 chip is available in Figure 4.7. Details about how it works will not

be considered in this work but some properties about its functionality is as

follows. The output voltage has been locked on 3.3V while the input voltage can

be between 0.9V and 6V. The switching regulator’s working frequency is 1MHz

and its efficiency is up to 85%. Although it is possible to use a lower levels of

voltages (less than 3.3V) for feeding ME2149 to deliver a 3.3V power supply but

input current in this case from battery (or batteries) to ME2149 will be

increased and lifetime for batteries will be decreased. Thus choosing a voltage

level which is near to 3.3V is a reasonable choice. That’s why using at least two

1.5V battery cells in the pill box is recommended. Tuning the output voltage is

possible by choosing an appropriate values for R1 and R2 for getting feedback

from output voltage. For instance, R1 and R2 have 16.5 KΩ and 10KΩ resistance

respectively. It is possible to have some deviations from the desired output level

but since it is less than 5%, it can be neglected. As a precaution, using a schottky

diode next to the inductor and using input and output capacitors for more

stability are recommended as it shown in Figure 4.7.

Figure 4-7. Boost-Buck step-up regulator to give a fixed output voltage (3.3V).

As a simple user interface for changing setting of the pill box, five push buttons

have been used. Pushing each push buttons connects corresponding I/O pin of

microcontroller to ground as Figure 4.8 shows. Each I/O pin has pulled up by a

Page 40: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

39

10KΩ resistor to make it sure that all I/O pins have logic state “1” if any push

buttons has been pushed.

Figure 4-8. Connection of the push buttons to I/O pins of microcontroller.

For sending saved data which shows which days which alarms have been

missed, an HC-05 Bluetooth module be connected to the microcontroller as

Figure 4.9 illustrates. Except the power supply pins, there are two other types

of inputs and outputs to configure, control or use the module.

RX and TX pins which receive and send data or commands in serial form

which is compatible with standard USART (Universal

Synchronous/Asynchronous receiver/transmitter)

“State” or “KEY” pin which can be connected to logic “1” or “0”. Its logic

state determines in which mode the module will work. In usual mode,

HC-05 gets data through the USART1TX from the microcontroller and

sends it wirelessly to a paired device via Bluetooth. The other mode is

“AT Mode” which puts the module in configuration mode. In this state,

some commands called “AT Commands” will be written to module’s RX

pin from microcontroller to change setting of the module. For example

baud rate of serial communication or ID of the module can be modified

and changed. Also the module can act as a master, search for other

devices and send connection requests to them. Such functions be

executed in “AT Mode”.

Figure 4-9. Connection of Bluetooth module to serial port of microcontroller.

Page 41: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

40

4.3 Software Design

In the section 4.2, hardware of the whole embedded system used in the pill box

is introduced and described in details. The designed hardware will be controlled

and managed and all modules will be used by a written software which be

executed in the microcontroller. The software in this work has been written by

standard C and used IDE for compiling and debugging the code is Keil-

Uvision4.

It is possible to work directly with all inner peripherals and their registers in the

microcontroller but it will be very difficult when a software grows and becomes

bigger. In fact, it is inevitable to have a relatively big software with many details

when several peripherals inside of a microcontroller and some external

modules will be used and managed. That’s why some libraries have been created

and are available to use by companies which manufacture microcontrollers.

In this work, STM32 Standard Peripheral Libraries, v3.4.0 [31] by

STMicroelectronics have been used to integrate of different parts of the written

software. The used library consisted of pairs of C files and their corresponding

header files for a specific task. A group of these source files be used to introduce

all registers and their corresponding addresses by easy understanding names.

Another group of source files called drivers have more focus on one specific

peripheral and give some executable functions with higher level of abstraction.

It means that a driver gathers all needed registers and modifies them when user

calls functions. That’s why most available functions have input arguments to

determine how the changes and modifications on related registers should be

done. The good thing about usage of these functions is that user doesn’t have to

know in details where the registers are and which values should be written to

them when a function be called. Including these header/source files to a project

gives users access to their functions. In following, some drivers used in this

work will introduced and described:

stm32f10x_gpio (.c/.h)

This driver gives access to work with general purpose I/Os. Most of

digital inputs and outputs have some other alternate functions. However

there is maybe a default function assigned to a GPIO pin, most of times

it is necessary to change it to what we need. As an example, pin 68 of

STM32f103V8 (can be seen in Figure 4.2) has two different alternate

functions namely 9-th of Port-A as a digital I/O and also TX pin of

USART1.It has been used as USART1-TX while its default function was

a digital I/O. Such changes be done by related functions available in this

driver. The driver has own type which is a struct by some fields.

“GPIO_InitTypeDef” as the struct and GPIO_Pin (for masking desired pin

to be configured), GPIO_Speed (for determining selectable speed options)

and GPIO_Mode (for selecting one of alternate functions for GPIOs) as its

fields are provided to determine condition of GPIOs. Also there is

another type (GPIO_TypeDef) which be used for pointing to available

Page 42: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

41

ports (here: A, B, C, D and E). The used functions from this driver in this

work are as follows:

1. GPIO_Init(GPIO_TypeDef*GPIOx,GPIO_InitTypeDef*

GPIO_InitStruct) 2. GPIO_ReadInputData(GPIO_TypeDef* GPIOx) 3. GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) 4. GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)

Except the communication with Bluetooth module which is based on

serial port (USART1), all communications with other parts of system are

done by writing and reading digital data to/from I/O pins which uses

functions 2, 3 and 4 from the list above. Even the communication with

the E-paper display uses these three functions. As it mentioned before in

section 1.1 (Background), interfacing with EPD is based on SPI

communication which has 1 bit data and also 1 bit click pulses. In this

project, also implementation of this synchronous communication be

done by writing/reading to/from digital I/Os. Also by toggling a digital

I/O the clock pulse for SPI standard be generated. For instance,

following statements change state of data pin (PD10 of microcontroller):

#define EPD_W21_MOSI_0 GPIO_ResetBits(GPIOD,GPIO_Pin_10) #define EPD_W21_MOSI_1 GPIO_SetBits(GPIOD, GPIO_Pin_10)

As it can be seen, PD10 is output pin from Master (MCU) and also input

pin for Slave (EPD). Also statements below be used for generating clock

pulses which be sent by PD9:

#define EPD_W21_CLK_0 GPIO_ResetBits(GPIOD, GPIO_Pin_9) #define EPD_W21_CLK_1 GPIO_SetBits(GPIOD, GPIO_Pin_9)

Besides all statements above, some similar usage of such functions be

used to control CS (chip select), DC (Data or Command?!), RST (Reset)

and BS (Busy) bit as it can be seen in Figure 4.4.

The communication with the external flash memory (AT45DB161D) has

same structure as we used for EPD but on other I/O pins available in

Figure 4.3.

Also the buttons connected to 5 pins of port E be read by function

number 2 which checks if the I/O pins have been connected to ground

or not as Figure 4.9 illustrates.

stm32f10x_usart (.c/.h)

The second used library in the software is USART driver which gives

some functions to work with the standard serial interface. For instance,

there are 4 functions that have been used in this project:

1. USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef*

USART_InitStruct)

Page 43: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

42

2. USART_Cmd(USART1, ENABLE) 3. USART_SendData(USART_TypeDef* USARTx, uint16_t Data) 4. USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t

USART_FLAG)

Here also we have a struct (USART_InitTypeDef) with some fields which

describe conditions of USART bus. The fields which should be initialized

are .USART_BaudRate/ _WordLength/ _StopBits/ _Parity. After filling

the fields by desired values and calling function 1, USART1 with 115200

Kb/s baud rate, 8 bits length, 1 stop bit and no parity bit has been

initiated in this project. Then, function 2 be called to make USART1 port

start and ready to send data. After starting the port, function 3 can be

used for sending a value by length 1 byte. Function 4 is for checking if

the output buffer for TX is ready to be loaded by new data to be send or

not.

Stdio.h

As it mentioned about the previous driver for initializing USART port,

data by length 8 bits are able to be send every time that

USART_SendData() be called. But all information to be send wirelessly are

in form of numbers, sentences etc. That’s why USART_SendData() will

not be used directly. Otherwise it would be very difficult to use serial port

to transmit data. An useful function in such cases is printf() which is a

function of stdio (Standard Input Output) library. It in turn calls

another function namely PUTCHAR_PROTOTYPE (it can have another names

in different libraries) which can be redefined by user. Actually, user is

able to put an arbitrary low level function which sends 1 character to an

arbitrary target (i.e. USART, LCD or …). Here, USART_SendData() has

been called in PUTCHAR_PROTOTYPE. Then printf uses the new definition of

PUTCHAR_PROTOTYPE to print out data to desired target namely USART1.

stm32f10x_rtc (.c/.h)

One of most important tasks in the software is timing. A precis clock

should be implemented in the embedded system because defined alarms

should be activated in correct times. It is actually possible to design a

clock by delays or timers but sometime it is not easy to get accurate time

periods to generate i.e. seconds. Fortunately, there is an embedded real

time clock (RTC) inside of the used microcontroller. The RTC works

independently and has own external clock source. As it mentioned before

in 4.2 (Hardware Implementation), a 32.768 KHz external crystal

oscillator be connected to osc32-in and osc32-out which are alternate

functions of PC14 and PC15 respectively. By using an appropriate

prescaler namely 32767, an accurate square wave with 1Hz frequency be

generated and be used as clock pulse for a 32-bit counter. The used

functions from this library are as follows:

Page 44: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

43

1. RTC_WaitForSynchro(void) 2. RTC_WaitForLastTask(void) 3. RTC_SetPrescaler(uint32_t PrescalerValue) 4. RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState) 5. RTC_GetITStatus(RTC_IT_SEC) 6. RTC_ClearITPendingBit(RTC_IT_SEC)

Function 1 checks if RTC is ready to be configured when power and

system clock be applied to the embedded hardware inside

microcontroller. Function 2 should be called every time user wants to

write some values on RTC’s registers. It actually indicates that RTC is

ready to get a new command/adjustment for changing its setting.

Function 3 adjusts the prescaler between external oscillator and RTC

counter. To set RTC period to 1sec, PrescalerValue (RTC_PV) has been

calculated as following equation 4.1:

RTC period=RTC_CLK/(RTC_PV+1) = (32.768 KHz)/(32767+1) (4.1)

Function 4 enables RTC interrupt and also specifies its source. In the

project, RTC_IT_SEC has been assigned to RTC_IT which selects seconds

as interrupt source. When RTC interrupt has occurred (every second),

flow of program jumps to a specific address and function

RTC_IRQHandler(void) be called. In the function, interrupt source be

checked first by function5 and be cleared manually by function 6 and a

register which contains number of seconds be added by one. Every 60

seconds namely every 1 minute, another function from RTC_IRQHandler

named Service be called to update the clock. Also a comparison between

already set alarms and the actual time be done in function Service.

Furthermore, the STOP button be checked every second in

RTC_IRQHandler to deactivate an active and running notification. As it

mentioned before a notification can be a single tone sound from a buzzer,

vibration or playing an already recorded voice.

stm32f10x_tim (.c/.h)

This driver has some functions to initialize and use embedded timers of

the microcontroller. In this project, Timer2 has been used to create

periodic interrupts and a function (service_tim2()) will be called when

interrupts be requested. In an embedded software having a function

which be called periodically can be very useful. Usually, such function

are called System-Tick function and can be modified by user. It means

that user can add own commands or even functions inside of these

periodic functions. In the project, service_tim2() has been used for

having accurate delays and also for checking status of the buttons. The

used functions from this driver are:

Page 45: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

44

1. TIM_TimeBaseInit(TIM2, &TIM_TimeBaseInitStruct) 2. TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE) 3. TIM_Cmd(TIM2, ENABLE)

Function one initiates Timer2 by some desired properties. The

properties be determined by modifying some fields which belong to a

struct namely TIM_TimeBaseInitStruct. The fields are TIM_Prescale,

TIM_Period, TIM_CounterMode which has been assigned by 71, 999 and

TIM_CounterMode_Up respectively. The two first selected values are

according to following equation which describes relation between

system clock, timer prescaler, timer period and frequency of generated

overflow interrupt.

(4.2) overflows(Hz)=TimerClock/((TIM_Prescaler+1)*(TIM_Period+1))

By considering that TimerClock is connected to the system clock which

is 72MHz, frequency of overflows becomes 1 KHz. It means the function

service_tim2() be called every 1 millisecond and all commands inside

of it be executed 1000 times per second.

Assigning TIM_CounterMode_Up to TIM_CounterMode determines that

timer register be added by one and its value goes up by every clock.

Function 2 enables timer2 overflow interrupt and function 3 connects

clock to timer’s and starts counting.

Display_EPD_W21 (.c/.h)

One of the most important drivers which has been used for showing

information on display (EPD) is this driver. It contains some lower level

drivers but the used functions in this project be called directly from this

driver. For instance, Display_EPD_W21_Aux (.c/.h) describes how the

E-paper display is connected to microcontroller and how functions for

serial data communication (SPI_Write(unsigned char value)) has been

implemented. Also Display_EPD_W21_Config.h is included in top level

driver (Display_EPD_W21) which contains all registers and look up tables

and information about size of display (250 x 128 pixels). The used

functions from the top level library are:

1. EPD_init_Full(void) 2. EPD_init_Part(void) 3. EPD_Dis_Full(char*DisBuffer,unsigned char Label) 4. EPD_Dis_Part(xStart,xEnd,yStart,yEnd,char*DisBuffer,unsi

gned char Label)

The display be initiated in two different forms, Full and Partial modes by

calling function 1 or 2. In full mode entire display be refreshed by

sending a display data which has same size as the display namely 250 x

Page 46: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

45

128 pixels. The input parameter “Label” in function 3 and 4 is actually a

flag which takes values 1 or 0 and determines how data will be written to

the display’s RAM. Function 3 only needs information about where pixel

data have been saved while function 4 needs some additional

information which determines where on the screen, pixel data should be

written and shown. Before calling function 3, function 1 and before

calling function 4, function 2 should be called for a correct initializing.

Texts, icons and symbols be converted to monochrome patterns by a

program called Image2Lcd and result of the conversion be saved in form

of bytes. Each bit in the bytes represents one pixel and its value

determines which color (1: black or 2: white) should be used for showing

a pixel.

Figure 4.10 illustrates how the program Image2Lcd looks like and how

scanning pixels of a picture be performed.

Figure 4-10. Conversion of pictures to monochrome bitmaps by vertical scanning.

Besides using already existing functions available in the used drivers, some

other functions were created and used for saving/reading data in or from the

external memory (AT45DB161D). The created and used function to

communicate with the external memory are:

1. void AT45_ReadID(void) 2. void AT45_ReadStatus(void) 3. void AT45_Do_512(void) 4. unsigned char AT45_InByte(void) 5. void AT45_SendCMD(unsigned char CMD) 6. void AT45_InitR(unsigned int addres) 7. void AT45_InitW(unsigned int addres)

Function 1 reads ID number of the device and actually is a test which guarantees

that the communication with device is correct. The function fetches and prints

out 4 bytes as device ID which is same ID as datasheet has stated. Function 2

reads status byte from device which gives information about size of pages,

protect status (device is read only or not) and also ready/busy status. Data space

Page 47: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

46

inside this memory has been divided into pages by size 512 or 528 bytes. Device

has been initialized to have 528 bytes in each page after manufacturing but by

programming an OTP (One Time Programmable) register it has been changed

to a data space by 512 bytes in every page. The number 512 is actually a round

power of 2 and it maybe can be easier to use. Function 3 changes size of pages

to 512 and as it mentioned before it is an irreversible action. Function 3 and 4

read and write 1 byte from/to device by SPI interface. Before reading or writing

data, device has to be initialized in corresponding mode. That’s why function 6

before function 4 and function 7 before function 5 should be called.

This was a summary about software based tools have been used in this project.

The main body of the software has been written by standard C and forms a big

part of the generated software. Standard functions in C have been used to

combine all parts together and manage them. Setting time and date, setting

alarms, recording sound and playing it as a notification, saving missed alarms

on end of each day (23:59 —> 00:00) and sending the saved data by Bluetooth

connection is main tasks which are done in the project. Also it has been tried to

show relevant information on the EPD to help user to work easier with the pill

box. In next section it will be shown how the interact with user looks like, how

the system has been tested and evaluated.

5 Verification and Evaluation

After integrating software and hardware, it’s time to test system. Since the

system consists of some inner modules, first level of the tests has focus on

functionality of the used modules. We call it module testing. Here, a module can

be either a pure software module or a combination of software and hardware

modules. For example working with the external memory be considered as a

combinational module which consists of both hardware and supporting

software. In following, first, testing of modules and the system testing will be

considered and described:

5.1 Verification of Critical Functions

Before creating the main body of the software which contains all sub-programs

and functions for all modules, some temporary programs for testing modules

were created and tested individually. Such temporary programs which can be

considered as simple test benches were designed to check if a module is working

and how its eventual inputs and outputs should be used in a system. After

testing and doing necessary modification, modules became ready to be

integrated to the main system. Some of individual testing are as follows:

Page 48: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

47

First of all, GPIOs and having access to them were tested by writing

digital values to ports and also checking if I/O pins can be read. Buttons

were connected to system afterwards.

Serial port, USART bus, was initiated and tested by using printf function

from stdio library.

Bluetooth module, HC-05, was initiated and its setting was changed by

sending AT Commands via serial port. Test data was sent to an Android

platform without any problem.

A 32.768 KHz crystal is connected to RTC unit and it worked as it should.

Also periodic interrupts were active and be tested.

Partial and also complete refreshing on EPD were tested and display

became ready to get data to show.

Supplying power to the system through ME2149F regulator is tested by

a wide range of input voltages (2V ~ 6V) and system was stable.

Some test data were sent via SPI connection and saved in the external

memory in specific address. Then same data were read from the address.

Also Timer 2 is initiated with desired specifications and prescaler and

worked properly.

5.2 System Verification

After testing different parts individually, system started to be integrated and all

modules including software module and hardware were combined together.

Sub-systems became consistent and pill box worked as expected. Figure 5.1

illustrates appearance of screen when the system is running. Figure 5.1.a shows

how the screen looks like after setting time, date and alarms. As it shows, 8

ordinary alarms and 4 extra alarms have been initiated. Some of digits are

hollow or strikethrough which means that corresponding alarms have been

missed (here, in Figure 5.1.a, second and fifth alarm and also first extra alarm).

In this case, an icon by 3 small pills shows up which means that one or more

alarms have been missed.

To change setting, time, date, alarms and type of notifications, a simple menu

has been created as Figure 5.1.b. When system is running and user pushes and

holds MODE buttons for 3 second, menu shows up and different items can be

selected. A select dot, points to items and can be moved by Up and DOWN

buttons. Pushing SET button selects the item that pointer points to. Setting up

the 3 first items (“Time, Date”, “Alarm” and “X-Alarm”) is similar. For example,

changing or initializing alarm has been shown in Figure 5.1.c. After selecting

the second item from main menu, user can select which alarm wants to be

modified by pushing MODE button again. By pushing Up and DOWN and SET

buttons it is possible to set a time for the alarm and also select an individual

notification for it. As it shown in Figure 5.1.c, 3 different notifications are

available to set.

Page 49: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

48

By selecting the item “REC” from the main menu, it is possible to record a sound

for sound notification. Also, it is possible to play and hear the recorded sound

before accept it as it shown in Figure 5.1.d and Figure 5.1.e.

To send the saved data which shows which alarms in which days have missed,

user should select “SEND” item from the menu. Also it is possible to see the

saved data on screen by selecting item “Calendar” from menu as Figure 5.1.f.

Pushing on Up and DOWN buttons moves the date forward or backward and

corresponding data about alarms belong to selected day will appear on screen.

a b

c

d e

f

Figure 5-1. Functionality of the system shown on E-paper display.

Page 50: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

49

5.3 Performance, Power and Cost Evaluation

The designed embedded system in the pill box worked properly and results of

the system verification were mostly as expected before system integration.

Regarding weaknesses in performance of the system, there are 2 issues which

can be considered and discussed:

1. The selected E-paper display has an inherent delay and it cannot be

refreshed fast. It means that whenever microcontroller sends some

data to show on EPD, a relatively long delay about 700 ms should be

considered before sending new data. The interesting thing is that the

necessary delay is almost regardless of size of an image. Thus it is

better to refresh a big part of the display rather than smaller parts.

From other hand, the screen in this project consists of several smaller

digits, symbols and visual items which have to be refreshed

individually. That’s why from a user’s perspective the system can be

seen a sluggish and slow system and changing its setting can be a little

boring but its basic functionality is completely acceptable.

2. The other issue is about E-paper display again. As it mentioned before,

the display consists of pixels which can take 2 colors namely black and

white. Theoretically, a section of screen can be refreshed and changed

and all previous data in the section completely will be deleted. In

practice the selected display is a little different and when one looks at

the screen very close and meticulously, very weak shade of previous

image in the section is detectable. Fortunately, it is not very

destructive and screen is still clear and can be used usually as it shown

in Figure 5.2.

Figure 5-2. Performance of E-paper display in running mode.

Also the input current to the system applied from three 1.5 V batteries was

measured as 6.5 mA. It means that its power consumption is about 30 mW.

The current was measured when the system was in stand-by state which was

consuming a stationary power. It has some higher consumption peaks which

take place when the display be refreshed or the Bluetooth module sends data.

Since these consumption peaks occur very rarely (of course in compare with the

stationary state), it can be neglected in long terms.

Page 51: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

50

As it mentioned earlier, some of the selected components have different

operation states and some of them like the regulator have a wide efficiency

range. Selecting more efficient components with lower power consumption or

putting components on sleep or idle states when their functionality are not

needed can considerably reduce the power consumption. For instance, Figure

5.3 shows the different operation states which belongs to a low power Bluetooth

module (BLE). As it can be seen in Figure 5.3, the module first is on sleep mode

and draws only 0.001 mA current. Then it goes to wake up mode (State 1) and

then goes to pre-processing state (State 2). Other states are pre-RX (State 3),

RX which receive data (State 4), TX which sends data (State 6), stand-by (State

7). After the state 7, the module be forced to go to the sleep mode again. The

important result by using such approach is that the system gets rid of delivering

a continuous 7.4 mA in stand-by (State 2 and 7) when any data be sent or

received. Unfortunately the selected Bluetooth device in this work (HC-05)

doesn’t have any sleep or idle state and draws a continuous current. A simple

solution when using HC-05 can be disconnecting it from the power supply by a

switch. More details about the currents and the states for selected module and

also for some suggested modules can be found in Table 5.1.

Figure 5-3. Different operation states for low energy Bluetooth module (BLE)

Page 52: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

51

Device Sleep Stand-By Active Notes

HC-05 _ 30-40 mA 8 mA

BLE 1 µA 7.4 mA 17.5

ME2149 _ _ _ 78~91 % efficiency

AT45DB161D 9 µA 25 µA 7 mA

EPD _ 5 µA 12 mA

ISD1820 _ 10 µA 30 mA

STM32LXXX 1 µA _ 9 µA With real time clock

STM32F103v8 _ _ 50 mA At 72 MHz Table 5-1. Current consumptions in different modes.

Since a considerable part of the system is based on an embedded software,

system’s cost mostly becomes limited to its hardware. A cost evaluation of the

prototype version can be summarized as Table 5.2. The evaluated costs is for

only one product and it will be reduced considerably when several samples will

be produced.

STM32F103V8 6 $

PCB design for MCU 30 $

ME2149 regulator 4 $

Bluetooth module 5 $

AT45DB161D 5 $

GDE0213B1 E-paper display 8 $

Voice recording module 3 $

Sum 61 $

Table 5-2, Cost evaluation for the existing prototype system.

6 Conclusion and Results

Design of a low power embedded system for a hand-holding pill box was

performed successfully and the introduced goals in section 1.4 were met. It

means that a working hardware platform and also a consistent software were

combined together to create a prototype version of an embedded system. A low

power E-paper display was used, data was saved and sent wirelessly and power

supply was managed by a flexible regulator. All communications between

modules were made and the system is ready for future modifications and

improvements according to new requirements.

Page 53: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

52

A positive effect is that software used in the project is completely modular which

causes that future works on the system becomes easier. The software has been

divided into several files and each file describes a specific task in the system.

As it mentioned in section 5.3, the selected display had some weaknesses and

limitations for this particular usage. There is any solution to make it faster but

background shades because of previous data can be deleted by a master refresh

which renews the screen. Even this solution is not reasonable as it also takes

time and master refresh can’t be performed between all partial screen updates.

It seems that selected display is more proper for systems which don’t refresh

their display very often. That’s why a suggested future work on the system is to

find a display which is faster and has more flexible partial refresh properties

and try to replace it with the used display.

Also design a more compact PCB (Printed Circuit Board) which includes all

used module is a valid future work. Power regulator, wireless module, external

memory, display interface board and sound recording module can be integrated

in one single board to have a compact production.

Other wireless solutions like NFC (Near-Field Communication) which has even

easier usage can be used in the pill box instead of the Bluetooth. To establish a

Bluetooth communication, the pill box needs to be searched and a connection

request should be sent to it manually in this version of the work. Actually, from

the company’s (Victrix AB [32]) point view, a NFC communication is better to

be used in the final version of the pill box. However, it was necessary to open a

wireless communication port to send the saved data and that’s why a Bluetooth

communication was implemented in this version of the pill box. Thanks to that,

a primary sending of data could be tested and verified. A data transition based

on the NFC communication will be initiated and performed easily and only by

holding the pill box near a NFC reader. Thus replacing the Bluetooth with the

NFC wireless communication is also recommended.

In the beginning of the work, a 72 MHz clock be selected as the internal clock

to be sure that speed of processing would not be a limitation. In fact, choosing

a high clock is not necessarily a good choice when a microcontroller can

perform its tasks even by lower clocks. The cost of choosing higher clocks is

more power consumption which is not optimal. As it can be seen on Figure 6.1,

current consumption of the microcontroller is strongly connected to the

frequency of the internal clock. The available results in Figure 6.1 differ from

the results of this work and it’s because of this fact that another test set up has

been used for generating data for Figure 6.1. For instance, code is running from

RAM and all peripherals are active but it’s different in this work. As a future

work, choosing a minimum clock for the microcontroller is recommended.

Page 54: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

53

Figure 6-1. Current consumption in run mode from RAM versus operation frequency (at 3.6 v).

Other possible optimizations in power consumption by studying and using

more low power components and modules also be recommended.

Page 55: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

54

7 References

[1] National Institute on Aging, "NIH, Safe Use of Medicines," 1 Sep. 2010. [Online]. Available: https://www.nia.nih.gov/sites/default/files/safe_use_of_medicines_0.pdf. [Accessed 1 3 2017].

[2] U.S. Department of Health and Human Services, "FDA," 12 02 2016. [Online]. Available: https://www.fda.gov/drugs/resourcesforyou/specialfeatures/ucm485545.htm. [Accessed 1 3 2017].

[3] S. P. Vingron, "Combinational Circuits," in Logic Circuit Design , Austria, Springer, 2012, pp. 3-95.

[4] STMicro, "ST," ARM MCUs, 2017. [Online]. Available: http://www.st.com/en/microcontrollers/stm32f1-series.html?querycriteria=productId=SS1031. [Accessed 01 03 2017].

[5] "ARMKeil," Microcontroller Tools, 2017. [Online]. Available: http://www2.keil.com/mdk5/uvision/. [Accessed 02 03 2017].

[6] J. Heikenfeld, P. Drzaic and T. Koch, "A critical review of the present and future prospects forelectronic paper," Society for Information Display, pp. 3-10, 2011.

[7] Wavesen, 2017. [Online]. Available: http://cdn.makezine.com/uploads/2014/03/hc_hc-05-user-instructions-bluetooth.pdf. [Accessed 01 02 2017].

[8] "Elecfreaks," 09 05 2015. [Online]. Available: https://www.elecfreaks.com/wiki/index.php?title=Voice_Record_Module_-_ISD1820. [Accessed 05 02 2017].

[9] MIcroChip, 2001. [Online]. Available: http://ww1.microchip.com/downloads/en/DeviceDoc/USART.pdf. [Accessed 10 03 2017].

[10] M. Grusin, "Sparkfun," [Online]. Available: https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi. [Accessed 10 03 2017].

[11] A. Ali and N. Elsharawy, "Evaluation of some heavy metals residues in batteries and deep litter," Veterinary World,, no. 2017, pp. 262-269, 2017.

[12] A. Hakansson, "Portal of Research Methods and Methodologies for," WORLDCOMP'13, pp. 1-7, 2013.

[13] Good-Display, [Online]. Available: http://www.good-display.com/products_detail/productId=346.html. [Accessed 10 03 2017].

[14] "Good-Display," [Online]. Available: http://www.good-display.com/comcontent_detail/&FrontComContent_list01-1270458837000CurrentIds=3__4&comContentId=4&comp_stats=comp-FrontComContent_list01-1270458837000.html.

[15] "E-Ink," E-paper production, [Online]. Available: https://www.youtube.com/watch?v=Oqu1--AzM7U.

Page 56: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

55

[16] STMicroelectronics, "ST," 2015. [Online]. Available: http://www.st.com/content/ccc/resource/technical/document/datasheet/33/d4/6f/1d/df/0b/4c/6d/CD00161566.pdf/files/CD00161566.pdf/jcr:content/translations/en.CD00161566.pdf. [Accessed 10 03 2017].

[17] Lauterbach GmbH, 27 03 2017. [Online]. Available: http://www2.lauterbach.com/pdf/training_jtag.pdf. [Accessed 15 03 2017].

[18] STMicroelectronics, "ST," 2016. [Online]. Available: http://www.st.com/content/ccc/resource/technical/document/data_brief/group0/01/bd/4c/1b/8e/24/4d/89/DM00334043/files/DM00334043.pdf/jcr:content/translations/en.DM00334043.pdf. [Accessed 15 03 2017].

[19] STMicroelectronics, "ST," 2010. [Online]. Available: http://www.st.com/content/ccc/resource/technical/document/application_note/27/bf/f5/e8/d7/82/44/6f/CD00200423.pdf/files/CD00200423.pdf/jcr:content/translations/en.CD00200423.pdf. [Accessed 20 03 2017].

[20] ATMEL, "Sparkfun," 2006. [Online]. Available: https://www.sparkfun.com/datasheets/IC/AT45DB161D.pdf. [Accessed 02 04 2017].

[21] Nordic Semiconductor, "Sparkfun," 03 2008. [Online]. Available: https://www.sparkfun.com/datasheets/Components/SMD/nRF24L01Pluss_Preliminary_Product_Specification_v1_0.pdf. [Accessed 15 03 2017].

[22] Robodoupe, 04 2011. [Online]. Available: http://robodoupe.cz/wp-content/uploads/2017/05/FOR4FP2HKZAVRT6.pdf. [Accessed 15 03 2017].

[23] W. Huai-Kuei, W. Chi-Ming, L. Pang-Hsing, P. Sheng-Po, W. Xun-Cong, L. Chih-Hi and T. Kuan-Hui, "A Smart Pill Box with Remind and Consumption Functions," Global Conference on Consumer Electronics (GCCE), pp. 658-659, 2015.

[24] S. Aakash Sunil and R. Ashwin, "Smart Pill Box," Indian Journal of Science and Technology, vol. 8, p. 189–194, 2015.

[25] DKE Group LTD, "China E-Paper," 12 06 2016. [Online]. Available: http://www.china-epaper.com/uploads/soft/DEPG0213c.pdf. [Accessed 23 04 2017].

[26] "DKE," E-Paper Products, 2015. [Online]. Available: http://www.china-epaper.com/a/product/. [Accessed 27 04 2017].

[27] Microchip, 2009. [Online]. Available: http://ww1.microchip.com/downloads/en/DeviceDoc/39932b.pdf. [Accessed 27 04 2017].

[28] pervasivedisplays, EPD Productions, 2016. [Online]. Available: http://www.pervasivedisplays.com/. [Accessed 27 04 2017].

Page 57: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

56

[29] Pervasive, "EPD Productions," 07 09 2016. [Online]. Available: http://www.pervasivedisplays.com/LiteratureRetrieve.aspx?ID=238025. [Accessed 27 04 2017].

[30] Texas Instruments, "TI," 04 2017. [Online]. Available: https://www.google.se/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwiAwfHnmpPUAhWlE5oKHRfTBZAQFggoMAA&url=http%3A%2F%2Fwww.ti.com%2Flit%2Fslau533&usg=AFQjCNHdZ9i5eMNj6yuVOD7DTpLqbxOiUA&sig2=AGLavVwesBHcrQfKVnLIFA. [Accessed 05 2017].

[31] STMicroelectronics, "STM32F10x_StdPeriph_Examples Directory Reference V3.4.0," 12 2011. [Online]. Available: http://www.longlandclan.id.au/~stuartl/stm32f10x_stdperiph_lib_um/dir_99c2c2e90c0eb5ad2d8169236455be70.html. [Accessed 17 01 2017].

[32] Victrix AB, "Dosis," [Online]. Available: http://www.dosis.se/eng/. [Accessed 1 03 2017].

Page 58: Embedded System Design for Pill Boxes with The …1130039/...1 Embedded System Design for Pill Boxes with the Low Power Electronic Paper Display Master of Science in Embedded Systems

TRITA -ICT-EX-2017:86

www.kth.se