67
0 MASSEY UNIVERSITY SCHOOL OF ENGINEERING AND ADVANCED TECHNOLOGY Engineering Project Submitted as part requirement for B.Eng (Hons) In Telecommunications and Network Engineering Wireless Intelligent Bed Sensing System By Usman Awan 04107411 2009 SUPERVISORS 1. Dr. Subhas Mukhopadhyay 2. Dr. Gourab Sen Gupta

Wireless Intelligent Bed Sensing System

Embed Size (px)

DESCRIPTION

final year project report

Citation preview

Page 1: Wireless Intelligent Bed Sensing System

0

MASSEY UNIVERSITY

SCHOOL OF ENGINEERING AND ADVANCED TECHNOLOGY

Engineering Project Submitted as part requirement for B.Eng (Hons)

In

Telecommunications and Network Engineering

Wireless Intelligent Bed Sensing System

By

Usman Awan

04107411

2009

SUPERVISORS

1. Dr. Subhas Mukhopadhyay 2. Dr. Gourab Sen Gupta

Page 2: Wireless Intelligent Bed Sensing System

1

Acknowledgements:

First of all I would like to thank my supervisor Associate Professor Dr. Subhas

Mukhopadhyay for all his support and help throughout the project. All the credit goes to

Dr. Subhas for giving me the opportunity to work on this project.

I would also like to thank my co-supervisor Senior Lecturer Dr. Gourab Sen Gupta for

helping me through this project. His help during the microcontroller programming process

played a vital role in the success of the project.

I am also very thankful to PhD student Anuroop Gaddam for all his help, his discussions,

problem solving skills and assistance that he provided throughout the project. Without

Anuroop this project would not have been possible.

Page 3: Wireless Intelligent Bed Sensing System

2

Summary:

The elderly population of the world is growing rapidly, creating the need to increase

geriatric care. More and more old people prefer to live independently alone at home. Due

to the advancement in wireless communications and electronics over the past years, the

development of low cost, low power multi functional sensors is receiving increasing

attention. This sensing technology is playing a vital role in enhancing the quality of life for

elderly. A wireless sensor based smart-home monitoring system is being developed which

detects the usage of household appliances.

One of the main sensors used in this smart home is the bed sensor system which monitors

sleeping pattern of the user. This system is developed for the elderly people living alone at

home or people with disabilities, who require immediate medical attention in case of an

emergency or when an abnormal situation arises. In case of emergency the system sends

a message to the caregiver or the person monitoring the system. This provides monitoring

of the users without invading their privacy.

In this report we discuss the design of an Intelligent Wireless Bed Sensor System to

monitor the elderly. This sensor system not only detects the presence of a person on the

bed, it can also indicate the person’s position on the bed. This system uses four sensors

which are placed under the four legs of the bed. These sensors are connected to a driver

circuit to get the analogue output which is converted into digital using the ADC (Analog to

Digital Converter) of the microcontroller.

Initial test results for this project were conducted using 25 lbs sensors connected to the

legs of a small coffee table. These tests made sure that our algorithm and driving circuit

was working properly. Then this system was used with 100 lbs sensors to get experimental

results by connecting the sensors to the four legs of the bed. The tests were conducted for

various subjects using the bed. All these tests gave us positive results and proved the

potential of the Wireless Intelligent Bed Sensor System.

Page 4: Wireless Intelligent Bed Sensing System

3

Table of Contents

1.0 Introduction …………………………………………………………………………………………………………….. 6

2.0 Background …………………………………………………………………………………………………………….. 10

3.0 Need for Bed Monitoring ………………………………………………………………………………………… 13

4.0 System Overview …………………………………………………………………………………………………….. 15

5.0 Hardware ……………………………………………………………………………………………………………….. 17

5.1 Flexi-Force Sensors ……………………………………………………………………………………… 17

5.2 Driver Circuit ………………………………………………………………………………………………. 20

5.3 Microcontroller …………………………………………………………………………………………… 24

5.4 RF Module …………………………………………………………………………………………………… 25

6.0 Software ………………………………………………………………………………………………………….……… 28

7.0 Experiments and Results …………………………………………………………………………………......... 30

7.1 Sensor Characteristics …………………………………………………………………………………. 30

7.2 The four sensor response using a table ……………………………………………………….. 32

7.3 Sensor Test using a Bed ……………………………………………………………………………….. 41

8.0 The Market Potential ………………………………………………………………………………………………. 45

9.0 Problems Faced ………………………………………………………………………………………………………. 47

10.0 Conclusions …………………………………………………………………………………………………………… 48

11.0 Future Work ………………………………………………………………………………………………………….. 50

12.0 References …………………………………………………………………………………………………………….. 51

13.0 Appendices ……………………………………………………………………………………………………………. 53

Page 5: Wireless Intelligent Bed Sensing System

4

List of Figures

Figure 1 World Population Growth …….……………………………………………………………………......... 7

Figure 2 Life Expectancy of the World ………………………………………………………………………….…. 8

Figure 3 Configuration of a smart home monitoring system based on limited number

of wireless sensors ………………………………………………………………………………………………………… 11

Figure 4 Functional block diagram of a wireless bed sensor system ………………………………. 16

Figure 5 A Flexi-Force Sensor …………………………………………………………………………………………. 17

Figure 6 Sensor Construction …………………………………………………………………………………………. 18

Figure 7 Resistance Curve & Conductance Curve ………………………………………………………….… 19

Figure 8 Sensor Response Graph ………………………………………………………………………………….… 19

Figure 9 The recommended sensor circuit ……………………………………………………………………… 21

Figure 10 Schematic of the Driving Circuit ……………………………………………………………………… 23

Figure 11 PCB design of the Driving Circuit ………………………………………………………..………….. 23

Figure 12 Linx RF Module ………………………………………………………………………………………………. 26

Figure 13 Schematic of the RF Module ………………………………………………………………………….. 27

Figure 14 PCB of the RF Module …………………………………………………………………………………….. 27

Figure 15 Sensor head sandwiched between disc plates ………………………………………………... 30

Figure 16 Force to Voltage characteristics of the sensor ……………………………………………….. 31

Figure 17 The table and sensor setup ……………………………………………………………………………. 32

Figure 18 Driving Circuit and the Microcontroller with the sensor display …………………..… 33

Figure 19 The table surface divided in to cells along and x and y axes ………………………..… 34

Figure 20 Sensor 1 response ………………………………………………………………………………………….. 35

Figure 21 Sensor 2 response ………………………………………………………………………………………….. 36

Figure 22 Sensor 3 response ………………………………………………………………………….................. 37

Figure 23 Sensor 4 response ……………………………………………………………………………………….... 37

Figure 24 Combined results of all the four sensor outputs ……………………………………………. 38

Figure 25 Zone Allocation …………………………………………………………………………………………….. 38

Figure 26 The placement of a sensor under a leg ………………………………………………………….. 41

Page 6: Wireless Intelligent Bed Sensing System

5

Figure 27 The position of four sensors under the four legs of a bed …………………………... 42

Figure 28 An elderly person lying on bed is being monitored …………………………………..... 42

Figure 29 A child lying on bed is being monitored ……………………………………………………... 43

List of Tables

Table 1: Experimental observation of locating the weight …………………………………………….. 39

Table 2: Location of the weight …………………………………………………………………………………….. 40

Table 3: Experimental results with inhabitant lying on bed ……………………………………………. 44

Page 7: Wireless Intelligent Bed Sensing System

6

1. Introduction:

One of the most important features that human beings have is the ability to sense. We

use our senses in our daily life to perform various tasks. Sensors are also playing a vital

role in the development of science and technology. A sensor acquires a physical

parameter and converts it into a signal suitable for processing. Sensors are electrical or

mechanical components that are used to measure a property or behavior of an object or

system. Sensors can be mechanical such as pressure sensors, electrical such as voltmeter,

ammeter, radar etc, thermal such as thermometers or optical sensors such as photo-

detectors, infrared sensors, fiber-optic sensors etc.

Wireless sensors have much more advantages over wired sensors. These sensors are easy

to install as no wiring is needed so they simplify the designs of system. The wireless

sensors are much more flexible, portable and consume less power as compared to wired

sensors. Wireless sensors can be used in locations that are geographically far apart to

monitor activities remotely. These sensors also allow easy expansion or upgrade of

existing systems.

The average human age i.e. the life expectancy of humans has increased over the past

decade. This means that there are more elderly people living in the world today then

there were 10 – 20 years ago. The world population growth can be seen in the figure

below. One problem adding to the aging population is that hospitals aren’t able to coupe

with large number of patients so hospitals are looking to send people back as soon as

possible to recoup at home. Many elderly people prefer to live alone at home rather than

living with their adult children or living in rest homes.

Page 8: Wireless Intelligent Bed Sensing System

7

Fig. 1: World Population Growth

From this plot we can see that the population of people above 65 years old is increasing at

a higher percentage as compared to people below 65. For example if we look at the year

2010, the population growth of people below 65 years old is increasing at the rate of 3%

while population growth of people 65 years old or above is increasing at a rate of 9%. This

shows that in the year 2010 the elderly people will have a 6% higher population growth

rate than under 65 year olds. These results prove that the elderly population is increasing

at a greater rate than young people. The main reason for this is the improved healthcare

system over the years.

The proportion of elderly people in any population is growing rapidly thus creating a need

to increase geriatric care. In New Zealand the median age of the population is projected to

rise from 36.6 in 2010 to 43.1 in 2050 [8].

Page 9: Wireless Intelligent Bed Sensing System

8

Fig. 2: Life Expectancy of the World

As sensing technology continues to evolve, it is playing an important role in improving the

quality of life for elderly people and their families. A home based on wireless sensor

systems has been developed for monitoring. The current system is based on sensors

which detect the usage of household appliances/devices. It has been realized that there is

a need of incorporating a bed-sensor to the current monitoring system.

The main aim of the bed sensor system discussed in this report is to monitor the sleeping

patterns of an old person or a patient living alone in a house who needs medical attention

in case of emergency or if an abnormal situation arises. This sensor system will also be

used to monitor the general sleeping patterns of any humans. They will be helpful in

determining when a person is restless at night or when he/she is sleeping calmly. This

intelligent sensor system can perform various data collection and processing functions,

including data interpretation and fusion of data from multiple sensors. There are several

sensors readily available in the market, but making them intelligent in context to a specific

Page 10: Wireless Intelligent Bed Sensing System

9

situation is always a challenging task. In our case this intelligent bed sensor system will not

only detect the usage pattern of the bed but will also have the capability to collate data

and flag out anomalies. This sensor system can be a life saving device.

In our bed sensor system we will be using four flexi force sensors. These sensors will be

placed under the four legs of the bed. These sensors will measure the weight on the bed

and respond accordingly. The sensor system will send the information to a central

controller unit which in turn is connected to a PC. The sensor unit and the PC

communicate wirelessly through radio frequencies (RF).

Page 11: Wireless Intelligent Bed Sensing System

10

2. Background:

A lot of work has been done over the past years of using technology to monitor and help

out people. Sensor technology is playing a vital role in this field. Sensors are being used to

monitor all kinds of human activities and are making lives much easier. One of the areas

where this technology is playing a key role is the monitoring of elderly people living alone

at home. Another area it is helpful in is monitoring people with disabilities without a

helper being at their side constantly.

Work is being done on creating a smart home. A smart home is a home based on wireless

sensing technologies. This home is based on the integration of different sensor

technologies as shown in figure below. The sensors used communicate wirelessly. The

objective of this home is to monitor appliances/devices of special interest, both electrical

and non electrical. This smart home is basically being created for old people who prefer to

live alone at home. With the help of this smart home these elderly people can be

monitored without invading their privacy. In case of an emergency or unusual activity a

warning message can be sent to the family relatives or the care-giver without them

actually being at the home. It is not required to monitor all the appliances at home but the

daily activities of a person under monitor should be available to the system. The data from

these sensors are collated by a central processor, which saves all the data for processing

as well as to understand the life style of the person under care by the system.

Page 12: Wireless Intelligent Bed Sensing System

11

Fig. 3: Configuration of a smart home monitoring system based on limited number of

wireless sensors

One of the main sensors used in the smart home is the bed monitoring sensor. This sensor

is used to monitor the sleeping behavior of the user. This sensor is in particular useful to

monitor elderly people living alone at home or people living at homes with disabilities.

These sensors use weight measuring technique to indicate if a person is on the bed or not.

This sensor system can prove to be a life saving device for many users. There have been

many different types of bed sensors made and are readily available in the market. Some of

these sensors are wired and some use wireless technology.

There are bed sensor mats and pads available in the market. The sensors used in these

pads are pressure sensors. These sensor pads/mats are either placed on the mattress

under the bed sheet. These sensor systems alert the care-givers via an alarm that a person

is getting out of the bed. That is, when the weight is taken off the mat, the alarm sounds.

Many of these types of sensors are being used in hospitals for monitoring fall risk patients

and residents. The problem with these sensor mats is that they are placed on the bed and

Page 13: Wireless Intelligent Bed Sensing System

12

can result in discomfort for the user. Another problem is these sensors are usually wired

so these wires can also be a hindrance and result in discomfort of the user. These sensor

systems are also expensive to run as compared to wireless sensor systems.

A prototype of a bed monitoring device using wireless sensor has been developed, which

has demonstrated its feasibility for monitoring the activity of a user in bed. This system is

different from the sensor pad-alarm systems. This system offers the monitoring of

subjects 24 hours 365 days a year. These sensors offer the monitoring of bed at low cost,

less complexity and good accuracy. The system uses a Flexi-Force sensor to measure the

pressure and give the results according to that. The sensor is connected to a driving circuit

which in turn is connected to a microcontroller to convert the analog readings from the

circuit into digital. The microcontroller can send this information using RF (Radio

Frequency) signals wirelessly to the controller unit. These wireless sensors are much

efficient to use than wired sensors. These sensors are flexible, portable and consume less

power. The sensor is placed under leg of a bed so they provide monitoring without any

disturbance or discomfort to the user. The problem with this sensor system is that it only

uses one sensor which just provides us one result which is either there is someone on the

bed or there is no one on the bed.

The aim of our project was to create a bed monitoring system using four sensors. This

makes our sensor system intelligent. We will not only monitor if a person is on the bed or

not but we can gather a variety of different results based on the four sensors. The four

sensors are also placed under the four legs of the bed and are connected to a driving

circuit and a microcontroller to get the analog and digital results. Our intelligent bed

sensor system can not only be used to monitor elderly people but can also be used to

monitor the sleeping pattern of any person in general.

Page 14: Wireless Intelligent Bed Sensing System

13

3. Need for Bed Monitoring:

In the process of developing a smart digital monitoring home, it has been realized that

there is a need for incorporating a bed check monitoring system with the existing system.

In the absence of caregivers at night for an elderly person living alone, it is required for a

preventive measure to avoid sudden accidents in the home environment. The main

purpose of this kind of sensor unit is to monitor the bed usage of an old person or a

disable patient who is living alone in a house and needs immediate medical attention in

case of an emergency.

Since, a bed is a place where a person spends most of their time in the house. We

consider three scenarios in which the bed sensor will be useful.

A person who has a habit of waking up at a particular time in the morning sleeps

beyond his usual wakeup time.

A person who has a particular sleeping time and he/she is not in bed past their

usual bed time.

If a person is constantly moving on the bed i.e. they are restless.

The first two situations indicate that the person might have had a serious health issue or

fell down somewhere in the house which made him/her unable to reach for medical

assistance. The third scenario may indicate that the person is unwell or medically

distressed.

This intelligent bed monitoring sensor system cannot only be used for elderly and patients

but it can also be used to monitor the sleeping patterns of anyone. We can monitor

people who have restless sleep at night and gather the results for that. It can also be

helpful in monitoring someone who has a habit of sleep-walking.

Page 15: Wireless Intelligent Bed Sensing System

14

So, the Bed Monitoring Wireless Sensor monitors the abnormalities in the person’s daily

sleep window period and may act as a lifesaver. Many types of bed monitoring devices

have been developed in the past, but these systems are mainly used to detect monitoring

fall risk-patients and residents in a hospitals scenario. Our bed sensor system will

incorporate intelligent features, it will not only monitor if a person is on or off the bed but

will also be helpful in monitoring the sleeping patterns of patients 24 hours a day 365 days

a year.

Although another option to monitor the bed could be the use of cameras. This would be

efficient but the problem with this approach is that it would incur higher costs to buy

these 24 hours surveillance cameras and to install and monitor them. The use of cameras

will also affect the privacy of the user which is a major feature that the bed sensor system

provides.

Page 16: Wireless Intelligent Bed Sensing System

15

4. System Overview:

The intelligent bed monitoring system is based on four Flexi-Force sensors. These are

pressure measurement sensors and respond accordingly when a force/load is applied to

the sensing area of the sensor. In the case of bed monitoring, these four sensors are

placed under the four legs of the bed to determine if a force is being applied on the bed

i.e. someone is lying on the bed. The sensors were calibrated in such a way that the

system could confirm that the force on the bed is exerted by a human subject rather than

a pet or an inanimate object. The sensors are then connected to a driving circuit. This

driving circuit is a signal conditioning circuit to reduce noise in the signal. The driving

circuit provides us with a voltage value at the output so we get linear values of

load/weight versus output voltage plot. These sensor output voltages are analog values

so, they are sent to the microcontroller to convert them into digital values. We use the

ADC (Analog to Digital Converter) of the microcontroller to achieve this task. The

measured weight of each sensor is displayed on the LCD of the microcontroller. The

microcontroller is then connected to a RF (Radio Frequency) transmitter which transmits

the data wirelessly to a central processing unit which in turn is connected to a PC

(Personal Computer). The results from the PC can be sent to the care-giver or the person

monitoring the bed sensor system. A block diagram of the system is shown in figure 4.

Page 17: Wireless Intelligent Bed Sensing System

16

Bed Sensor 1

Amplifier / Signal conditioning

Bed Sensor 2

Amplifier / Signal conditioning

Bed Sensor 3

Amplifier / Signal conditioning

Bed Sensor 4

Amplifier / Signal conditioning

ADC

µController

LCD Display

RF Transmitter

Fig. 4: Functional block diagram of a wireless bed sensor system

Page 18: Wireless Intelligent Bed Sensing System

17

5. Hardware:

The hardware that we use in our system plays an important role in making the system

efficient and effective. The hardware components are the basic parts that make up our

bed sensor system. The main hardware components are Flexi-Force sensors, the driving

circuit, and the microcontroller used for converting analog values to digital and the RF

module for transmitting and receiving data wirelessly.

5.1 Flexi-Force Sensors:

The bed sensor system uses the Tekscan’s Flexi-Force Sensors. The Flexi-Force

sensors were chosen because of their reliability, cost-effectiveness and ease of

integration.

Fig. 5: A Flexi-Force Sensor

The Flexi-Force sensor is ultra-thin (0.008”), flexible printed circuit that senses contact

force i.e. the force or load being applied to the sensor. The force sensor is constructed of

two layers of substrate (polyester) film. On each layer, a conductive material (silver) is

applied, followed by a layer of pressure-sensitive ink. Adhesive is then used to laminate

the two layers of substrate together to form the force sensor. The active sensing area is

defined by the silver circle on top of the pressure-sensitive ink. Silver extends from the

sensing area to the connectors at the other end of the sensor, forming the conductive

leads. The sensors are terminated with male square pins, allowing them to be easily

incorporated into a circuit. The two outer pins of the connector are active and the center

pin is inactive.

Page 19: Wireless Intelligent Bed Sensing System

18

Fig. 6: Sensor Construction

Flexi-Force sensors are strategically placed underneath the bed legs to determine if a

force is being exerted on the bed. The Flexi-Force single element force sensor acts as a

force sensing resistor in an electrical circuit. When there is no force applied on the sensor

the resistance of the sensor is very high. When a force is applied to the sensor, this

resistance decreases. This resistance is inversely proportional to the force applied on the

sensor. The conductance curve of the force-conductance graph shows linear relationship.

The conductance and resistance curves for a force sensor are shown below.

Page 20: Wireless Intelligent Bed Sensing System

19

Fig. 7: Resistance Curve Conductance Curve

One way in which the sensor can be used is to use it in an application to incorporate it into

a force-to-voltage circuit. The output voltage varies linearly with the exerted force. This is

shown in the figure below.

Fig. 8: Sensor Response Graph

Page 21: Wireless Intelligent Bed Sensing System

20

The pressure sensor that we are using for our bed sensor is the 100 lbs (pounds) sensor.

This sensor can measure up to 444N of force (45.5 kg). To differentiate between

inanimate objects and human beings, we calibrate the sensor unit so that the force

applied by each extremity should produce a significant voltage output.

Some of the physical parameters of flexi force sensor are:

1. The operating range of temperature is from -9°C to 60°C,

2. Repeatability is +/- 2.5% of full scale (conditioned sensor when 80% force applied),

3. Linearity is <+/- 5%,

4. Hysteresis is <4.5% of full scale

5.2 Driver Circuit:

The four sensors of our bed sensor system are all connected to a driving circuit to

get the output voltage to force relationship. The recommended driving circuit for the flexi

force sensor is shown below. This circuit is driven by a 5V DC excitation voltage. The

circuit uses an inverting amplifier to produce analogue output based on the sensor

resistance and a fixed reference resistance (RF). The dynamic force range (sensitivity) of

the sensor can be changed by changing the value of RF or by changing the drive voltage VT.

A lower reference resistance and/or a drive voltage will make the sensor less sensitive and

increase its active force range. A -5V is also connected to drive the sensors.

Page 22: Wireless Intelligent Bed Sensing System

21

Fig. 9: The recommended sensor circuit

Our driver circuit used in the bed sensor system is based on this recommended Flexi-Force

sensor circuit. In our driver circuit we use the IC (Integrated Circuit) chip LM324N. This

consists of four low power quad operational amplifiers. The chip also has an external

power supply which is 5V and a ground pin. The four sensors are connected to each of the

four amplifiers. These inverting Op-Amps provide us with analogue voltage signals. The

sensor input is connected to the inverting input of the amplifier and the non-inverting

input is connected to ground. We use a variable resistor (potentiometer) to change the

sensitivity of the sensors according to our needs.

We use a 3 pin voltage regulator LM7805 at the start of our driving circuit. This voltage

regulator is a fixed 5V output regulator. This regulator has an input pin, an output pin and

a ground pin. The input pin is connected to the external input voltage of 9V. The regulator

converts this voltage and gives 5V at its output pin. The purpose of using this regulator is

so that we can use our sensor system anywhere by connecting a 9V or 12V adapter as the

voltage supply. The regulator converts this voltage into 5V and gives that to the rest of the

driver circuit to work appropriately.

Page 23: Wireless Intelligent Bed Sensing System

22

We can see from the recommended circuit that we need a positive as well as negative 5V

supply to connect to the sensor. This negative 5V is achieved by using a voltage inverter

chip. The chip that we use in our driving circuit is MAX828 chip. This chip is used to

generate a -5V supply from a +5V logic supply to power analogue circuitry. The MAX828

are ultra-small monolithic, CMOS charge-pump inverters. This IC comes in a 5-pin package

and can deliver 25mA with a voltage drop of 500mV. This chip only requires two external

10uF capacitors to get the desired output.

Since MAX828 is a Switched-Capacitor voltage inverter so it causes a 12 kHz noise at the

output. This noise can considerably affect the output of the sensors, resulting in an

unstable output. To eliminate this noise we have used a low-pass filter at the output

terminal of each of the sensors. This filter suppresses the high frequency noise in the

output of the amplifier. The waveform output from the driver circuit before and after the

filter is shown in Appendix A.

The circuitry for one sensor is shown on the next page. Rs represents the force sensor. The

same is required for all the four sensors. The complete schematic of the system is shown

in Appendix A.

Page 24: Wireless Intelligent Bed Sensing System

23

Fig. 10: Schematic of the Driving Circuit

13 12

9

8 75

4

14

2

17

10

9

8

7

4

3

2

1

0

1

0 1

5

43

1

2

2

1

2

1

2

1

2

1

2

1

2

1

2

1

2

1

1 2 3 4 5 6 7

14 13 12 11 10 9 8

3 2 1 3 2 1 3 2 1 3 2 1

2

3

1 2

3

1 2

3

1 2

3

1

21 21 2121

1

3

2

2

1 1

2

2 1

2 1

2

1

3 2 1

Fig. 11: PCB design of the Driving Circuit

Page 25: Wireless Intelligent Bed Sensing System

24

5.3 Microcontroller:

The main purpose of using a microcontroller in our bed sensor system is to read

and display the results digitally. The microcontroller used in our system is Silabs

C8051F020. This microcontroller was chosen because of its rich resources. We used the

ADC (Analog to Digital Converter) of the microcontroller to convert our analogue outputs

from the driver circuit. The ADC has 12-bit resolution and 8-channel multiplexed single-

ended inputs. We used four of these inputs to connect the four analogue outputs from

our sensors. The digital values are displayed on the LCD of the microcontroller. Digital I/O

ports (port6 and 7) are used to interface the microcontroller to the LCD module.

The reference voltage of the ADC converter of the microcontroller is 2.4V. Therefore the

maximum output response of the sensor is made to be below or equal to 2.4V. This is

done by adjusting the Rf1 potentiometer as the drive voltage is fixed at -5V. The ADC is

capable of running at a sampling frequency of 100 KBPS which is adequate for this

application. The conversion clock frequency of the SAR (Successive Approximation

Register) can be programmed to be up to 2.5 MHz.

The microcontroller runs off a crystal of 22.1184 MHz and is programmed in C. The

microcontroller has two UART (Universal Asynchronous Receiver Transmitter) modules of

which one is used to interface with the RF transmitter. The UART outputs RS232 protocol

serial data at TTL level; hence interfacing with the RF module does not require any

additional translator. The UART is programmed to transmit serial data at 38400 baud rate,

8-bit data, 1 stop bit and no parity.

Page 26: Wireless Intelligent Bed Sensing System

25

5.4 RF Module:

The RF (Radio Frequency) module is used to transmit the data between the

microcontroller connected to the driving circuit and the central control unit. The RF

module is connected to output port of the microcontroller. It takes the readings from the

microcontroller and transmits them via the RF circuit to the controller unit using radio

frequencies.

The RF module consists of three main components, a Linx® TRM-418-LT chip, a multiplexer

chip MC14016BCL and a hex inverter from the chip SN74HC04D.

The Linx chip is a transceiver which is used for bidirectional wireless transfer of data,

control or command information in 418 MHz band. This chip is a surface mount device and

it has long range, low cost and low power consumption. The chip has 12 pins out of which

we are using 9 in our RF module circuit. Since this chip is a low power consumer we supply

it power directly from the microcontroller port. So, we don’t need an external power

supply for this chip. Pin 1 is connected to the antenna which is used for RF transmission of

data. Pin 2 and 10 are connected to the ground of the microcontroller port and pin 11 is

connected to its power supply. Pin 5 is the Analog RMS (Average) Voltage Reference which

is connected to Vcc (Port 11). Pin 12 is the level adjust line which can be used to adjust the

output power level of the transmitter. This pin is also connected to Vcc to get the highest

output, while placing a resistor to Vcc lowers the output level. Pin 9 is the Power Down

which is used to pull this line to low or leave floating to place the receiver into a low-

current state. The module does not send or receive a signal in this state so we pull high to

activate the transceiver. Pin 8 is the Transmit/Receive which is used to pull the line low to

place the transceiver into receive mode and to pull it high in the transmit mode. Pin 7 is

the digital data line which will output the received data when in receive mode and it is the

data input in the Transmit Mode. The diagram of all these pins connected to the module

circuit is shown in figure 13.

Page 27: Wireless Intelligent Bed Sensing System

26

Fig. 12 Linx RF Module

The MC14016BCL chip is a quad analog/quad multiplexer. This chip acts like a switch and

consists of four independent switches capable of controlling either digital or analog

signals. We use two of these switches in our module circuit to transmit and receive data.

This chip is used to multiplex the single data line available on Linx RF module, in order

transmit and receive the data. To make the switch work we set the control line which

comes from the microcontroller port to high (1).

We also use an inverter to control the output from the T/R select pin of the Linx chip. So if

our module is in transmit mode and control line is high, then switch 1 will work. Since the

control line is high it will set switch 2 to receive mode as well. In order to avoid the

problem of having both transmit and receive switches working at the same time, we use

an inverter in front of the control input to switch 2. This sets switch 2 to low, thus no data

is received. When the control line is set to low switch 1 does not transmit anything, so

switch 2 starts to receive data.

The microcontroller Port 1 is used to transmit and receive data. Pin 1 is used to transmit

and Pin 2 to receive data. Pin 5 of this port is used as a control pin which is set to either hi

(1) or lo (0). When it is hi it allows the data to go through and stops it when it is lo. This

control pin is connected to the two switches to make them work.

Page 28: Wireless Intelligent Bed Sensing System

27

Fig. 13: Schematic of the RF Module

53

21

67

8 91011

12

13

7

8

9

10

11

126

5

4

3

2

1

1

2

1

2

1 2 3 4 5 6 7

14 13 12 11 10 9 8

891011121314

7654321

10

9

8

7

6

5

4

3

2

1

21

Fig. 14: PCB of the RF Module

Page 29: Wireless Intelligent Bed Sensing System

28

6. Software:

There are basically two main types of software that we have used in the implementation

of the Intelligent Bed Sensor System. We have used Altium Designer and Silabs IDE

(Integrated Development Environment).

Altium designer was used to create the circuit diagrams of our driver circuit. Then these

schematics were converted into PCB (Printed Circuit Board) diagrams and the physical PCB

was constructed based on these diagrams. Altium provided a huge library selection from

which all the components and their footprints were easily found. The projects created in

Altium were all PCB projects.

The other software which was used as part of the project was Silabs IDE. This software

was used to program the microcontroller. We used C language to program the

microcontroller. Silabs has its own development studio which provides an environment to

develop the software and then load the software onto the microcontroller. The software

initializes the microcontroller by setting values in registers in the microcontroller. This

initializes the input and output ports and enables and disables the microcontroller.

In our microcontroller program we use the 12-bit Analog to Digital Converter ADC0. This

consists of 9-channel, configurable analog multiplexer (AMUX0), a programmable gain

amplifier (PGA0) and a 12-bit Successive Approximation Register (SAR) ADC. ADC0 is

enabled by setting AD0EN to 1. AMUX0, PGA0 and the ADC data conversion modes are all

configurable via SFRs. The ADC0 can be programmed through the following sequence:

1) Configure the voltage reference (REF0CN)

2) Set the SAR0 conversion clock frequency and PGA0 gain (ADC0CF)

3) Configure the multiplexer input channels (AMX0CF)

4) Select the desired multiplexer input channel (AMX0SL)

Page 30: Wireless Intelligent Bed Sensing System

29

5) Set the appropriate control bits and start of conversion mode and turn on ADC0

(ADC0CN)

The ADC conversion takes place when the timer flows. In our program we are using Timer

3. Timer 3 is always configured as an auto reload timer, with the 16-bit reload value held

in TMR3LL (low byte) and TMR3RLH (high byte) registers. The Timer 3 is programmed in

the following way:

1) Write the auto-reload value into the auto-reload registers (TMR3RLL and

TMR3RLH)

2) Write the starting value for count up sequence into the count registers (TMR3L and

TMR3H)

3) Select the desired clock source (T3XCLK) and frequency (T3M), set the control bits

(TR3) and turn on Timer 3 (TMR3CN)

TMR3CN is used to select the clock source and is the only SFR used to configure Timer 3.

Page 31: Wireless Intelligent Bed Sensing System

30

7. Experiments and Results:

In this section we present the results and tests carried out during the project. There were

three main phases of experimentation conducted for this project. First we tested the

individual sensor characteristics, then we tested the four sensors using a table and then

the sensor system was tested using a bed. All these phases are described in detail below.

7.1 Sensor Characteristics:

The first step of the experimentation process was testing the characteristics of the

Flexi-Force sensor. The sensor used for this experiment was 25 lbs sensor. First thing we

did was make small metal discs which had the same diameter as the active sensing area of

the sensor. The sensing area of the sensor was sandwiched between two of these metal

discs when taking measurements. The purpose of this was to ensure that the load applied

to the sensor is evenly distributed across its sensing surface.

Fig. 15: Sensor head sandwiched between disc plates

Page 32: Wireless Intelligent Bed Sensing System

31

This sensor was tested by applying load to it and plotting the Force versus Voltage graph.

The sensor was connected to the driving circuit to get the analogue output thorough a

multi-meter and digital output through the microcontroller. For our experiment we used

sand in a pot as weight. A small solid cylindrical base with the same diameter as the

sensor head was used at the bottom of the pot to concentrate the load directly on top of

the sensor. The load applied to the sensor was from 0.5kg up to 11.5 kg in incremental

steps of 0.5 kg. Three consecutive readings were taken for every weight added to the

sensor to check its repeatability. The average of these three readings was taken as the

final output. Beyond 11.5 kg the response of the sensor was saturated and for any

additional weight to that we got the same reading as at 11.5 kg. This was because we

were using a 25 lbs (11.4kg) sensor. The Force to Voltage characteristics of the sensor are

shown in the figure below.

Sensor Test 2 y = 0.1939x + 0.0848

R2 = 0.9872

0

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2

2.2

2.4

2.6

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7 7.5 8 8.5 9 9.5 10 10.5 11 11.5 12 12.5

Force (kg)

Vo

ltag

e (

V)

Fig. 16: Force to Voltage characteristics of the sensor

Page 33: Wireless Intelligent Bed Sensing System

32

7.2 The four sensor response using a table:

The next step of experimentation involved testing all the four sensors connected

together and reading and comparing their outputs. At the time of this experiment the 100

lbs sensors (which are required for a bed) were not available. So, this experiment was

conducted using the 25 lbs sensors placed under the four legs of a small coffee table as

shown in the figure below. This sensor experiment was done to test the accuracy and the

usefulness of the proposed algorithm.

The table used was an evenly balanced table with equal amount of force being exerted on

each of the legs. The sensors were sandwiched between flat metal plates and connected

(taped) to the bottom of the legs of the table. These plates were used to ensure that equal

amount of force was distributed to every point in the sensing head of the sensor. It was

also made sure that the table is being tested on an even floor so that equal amount of

force is applied on each of the legs.

Fig. 17: The table and sensor setup

Page 34: Wireless Intelligent Bed Sensing System

33

The potentiometers (Rf) on the driving circuit were also adjusted to show the same output

value for all the sensors in idle condition. This was useful as the force was applied on the

sensors, all the values increased with the same rate and showed the same value when

weight was applied at the center point of the table.

The sensors were connected to the driving circuit which gives the analog output voltage as

the force is applied on a sensor. This analog input was then sent to the microcontroller in

which the ADC converts it to a digital output and displays it on the LCD as shown in the

figure.

Fig. 18: Driving Circuit and the Microcontroller with the sensor display

The surface area of the table was calibrated and divided into four zones known as Zone1,

Zone2, Zone3 and Zone4. Each of these zones was further divided into cells along

horizontal x axis (width) and vertical y axis (height). The cells were 10x14 that is 10 cells

along the x axis and 14 cells along the y axis as shown in figure below. The table was

calibrated in this way to get the exact reaction of the sensors and to observe how force

being applied in each of the cells affected the output. A fixed amount of weight (6kg) was

Page 35: Wireless Intelligent Bed Sensing System

34

used to test the sensors. We used a thin solid cylindrical base at the bottom of the weight

to make sure that the entire force was acting directly on the particular cell on the table.

The force versus voltage results were taken by placing equal amount of weight in each of

the cells and recording the output from the microcontroller. This gave us a good idea of

how the output reacts to force applied at every point on the table. These results

determined the reaction of our sensors when applied with force.

Fig. 19: The table surface divided in to cells along and x and y axes

After the set-up was complete for the experiments we started taking the results. A fixed

weight of 6kg was used to apply force at each of the cells and take the corresponding

output from the microcontroller.

Page 36: Wireless Intelligent Bed Sensing System

35

The following surface plots show the result of our experiments done on the table. The

plots were plotted as the reaction force output which results as the 6kg weight is applied

on each of the cell. The plots show exactly where the maximum force is being applied. The

force is plotted on the vertical z axis and the horizontal y and x axes represent the cell

where the force is being applied. The surface colour distribution represents the amount of

weight that is being applied on the sensors.

From this first plot we can see the response of Sensor 1. The highest value for this sensor

is 884 which is equal to 8.84 kg. This value is at the cell x1y1 which is the position right

above the leg of the table where sensor1 is attached. The minimum value for this sensor is

at cell x10y14 which is above the leg where sensor4 is attached. This is to be expected as

the sensor will show the highest value when the weight is directly above it and show the

minimum value when the weight is at the farthest point from the sensor.

Fig. 20: Sensor 1 response

Page 37: Wireless Intelligent Bed Sensing System

36

The following plot is the result for Sensor 2. From this plot we can see that the highest

value is around 700 which is at the cell x1y14 which is located right above the leg where

sensor2 is connected. The minimum value is 225 at cell x10y1 which is the farthest part

from sensor2.

Fig. 21: Sensor 2 response

Similarly it can be seen from the surface plot for Sensor 3 that the maximum value is at

cell x10y1 which is 845. This cell is located on top of the leg of the table where sensor3 is

placed. The minum value for this sensor will be at the cell located above the sensor2.

Page 38: Wireless Intelligent Bed Sensing System

37

Fig. 22: Sensor 3 response

Sensor4 also shows similar response with the highest value 888 being at the cell x10y14

which is above the leg connected to sensor4. The minimum value for this sensor is at the

cell located above the Sensor1.

Fig. 23: Sensor 4 response

Page 39: Wireless Intelligent Bed Sensing System

38

The following plot shows the combined results of all the four sensor outputs. It can be

seen from the U-shaped curve that more force is being applied to the corners. These are

the four corners of the table under which the sensors are placed. This is true with the fact

that sensors will experince the maximum force when the weight is placed directly on top

of the snesor.

Fig. 24: Combined results of all the four sensor outputs

The table was calibrated and divided into four zones known as Zone1, Zone2, Zone3 and

Zone4 as shown in figure below.

Fig. 25: Zone Allocation

Page 40: Wireless Intelligent Bed Sensing System

39

Ideally if the weight is in the centre point of the table, the response of sensors,

1 2 3 4 avgS S S S S

where ( 1 2 3 4) / 4avgS S S S S

To detect the position of the weight with respect to the zone on the table, the

microcontroller program is made to continuously monitor the ADC inputs from the four

sensors. The weight position is calculated based on the following conditions:

If ( 1 2) ( 3 4)S S S S , then the weight is positioned in the upper half (UH)

If ( 3 4) ( 1 2)S S S S , then the weight is positioned in the lower half (LoH)

If ( 1 3) ( 2 4)S S S S , then the weight is positioned in the left half (LeH)

If ( 2 4) ( 1 3)S S S S , then the weight is positioned in the right half (RH)

Based on the above observation, it can be concluded that-

ZONE 1: If UH and LeH both are true,

ZONE 2: If UH and RH both are true,

ZONE 3: If LeH and LoH both are true,

ZONE 4: If LoH and RH both are true.

Actual

Position

Sensors

1

Sensors

2

Sensor

3

Sensor

4

Calculated

Position

ZONE 1 890 441 498 370 ZONE 1

ZONE 2 470 791 385 485 ZONE 2

ZONE 3 480 405 815 460 ZONE 3

ZONE 4 385 452 472 857 ZONE 4

Table 1: Experimental observation of locating the weight

Page 41: Wireless Intelligent Bed Sensing System

40

Once the above observations were done further investigations were carried out to

calculate/estimate, at which location the weight is predominant. The weight is positioned

at various points along the line joining the middle point and the edge of the location of

Sensors1 (dotted line in figure 22). By using the following interpolation technique the

position of the weight is calculated and is shown in table 2.

max1S : Maximum output of the Sensor1 corresponding to the weight located on leg 1

avgS : Average signal of the four sensors

1S : Output of Sensor1

d : Distance between the center of the table to the edge corresponding to Sensor1

p : Position of the weight along the line

max

1

1

avg

avg

S Sp d

S S

(1)

Actual position of the

weight from the

centre (cm)

Calculated position (cm) Error (%)

0 4 -

10 9 10

20 17 15

30 27 10

40 39 2.5

50 49 2

Table 2: Location of the weight

From table 2 it is seen that the system can be used to estimate the location of the weight

with a fair amount of accuracy. The error can be reduced further if the signals from the

other sensors are also used in the interpolation technique.

Page 42: Wireless Intelligent Bed Sensing System

41

7.3 Sensor tests using a bed:

The last step of the experimentation was to test the sensor system for the purpose

that it had been built for. In this part, the sensor system was tested using a bed and real

life scenarios. The sensors used in this experiment were the 100 lbs (45.5 kg) sensors.

Fig. 26: The placement of a sensor under a leg

The Flexi-Force sensors were strategically placed under the legs of the bed to determine if

a force is being exerted on the bed i.e. someone is lying on the bed. In this experiment the

sensors were calibrated to make sure that the force being exerted on the bed was from a

human body rather than some inanimate object. The schematic representation of the four

sensors placed under the bed is shown below. S1, S2, S3 and S4 represent the four sensors

Sensor 1, Sensor 2, Sensor 3 and Sensor 4 respectively.

Page 43: Wireless Intelligent Bed Sensing System

42

Fig. 27: The position of four sensors under the four legs of a bed

The output signals from the four sensors are interfaced to four different channels of the

12-bit ADC of the Silabs microcontroller C8051F020. The signals are measured by reading

the ADC channels and the values are stored in the microcontroller. These values are

displayed on the LCD of the microcontroller.

The output signals from the microcontroller are used to determine all the information

related to person’s posture, quality of sleep and so on.

The experiments to test the bed sensor system were conducted with three inhabitants,

one elderly person of 74 years of age and around 42 kg of weight, one 5 year old child

with 20 kg of weight and one adult with 68.5 kg of weight.

Fig. 28: An elderly person lying on bed is being monitored

S1

S2

S3 S4

Page 44: Wireless Intelligent Bed Sensing System

43

Fig. 29: A child lying on bed is being monitored

The results that we concluded from the experiment are shown in table below. We can see

from these results that under normal situation all the four sensors read very similar

weights. The sensors only measure the weight of the bed in this situation, so each sensor

shows roughly one-fourth of the weight of the bed. When a person lies on the bed the

sensors read different readings depending on the amount of weight shared by that

particular leg of the bed. The total weight measured by the four sensors is roughly equal

to the weight of the bed and the weight of the person. From table 3 it can be easily said

whether the bed is occupied by an elderly or a child from weight consideration. The

position of the head whether the head is at (S1, S2) side or (S3, S4) side can easily be said

by checking the difference of the sensors signals. The pair of sensors with the head side on

them would show higher reading as compared to the other sensors.

Page 45: Wireless Intelligent Bed Sensing System

44

Test

condition

Reading

S1

(kg)

Reading

S2

(kg)

Reading

S3

(kg)

Reading

S4

(kg)

Total

weight

(kg)

Only Bed 10.3 10.4 10.3 10.5 41.2

Elderly in the

middle

18.4 15.2 23.6 26.9 84.1

Elderly on one

side

22.2 16.5 26.2 19.3 84.2

Elderly on

another side

14.0 21.3 18.5 30.5 84.3

Child in the

middle

13.5 14.3 16.9 17.0 61.7

Child on one

side

14.6 10.5 21.6 15.1 61.8

Child on

another side

12.2 13.4 13.7 22.4 61.7

Adult in the

middle

18.7 20.8 36.7 33.8 110

Adult on one

side

25.2 14.2 45.5 25.3 110.2

Adult on

another side

13.7 22.5 25.8 48.1 110.1

Adult lying

diagonally

(S4-S1)

17.2 20.5 28.2 44.3 110.2

Adult lying

diagonally

(S3-S2)

21.5 17.4 44.8 26.5 110.2

Table 3: Experimental results with inhabitant lying on bed

Page 46: Wireless Intelligent Bed Sensing System

45

The following observations are made with reference to figure 24:

S1 : Signal from Sensors#1.

S2 : Signal from Sensors#2.

S3 : Signal from Sensors#3.

S4 : Signal from Sensors#4.

Savg = (S1 + S2 + S3 +S4)/4; Savg is the average signal.

If (S1 + S2) > 2* Savg; the head is at (S1, S2) side.

If (S3 + S4) > 2* Savg; the head is at (S3, S4) side.

If (S1 + S3) = (S2 + S4); the person is sleeping in the middle of the bed.

If (S1 + S3) > (S2 + S4); the person is sleeping in the right side of the bed.

If (S1 + S3) < (S2 + S4); the person is sleeping in the left side of the bed.

If the sleep quality is good, the four sensors will provide signals which are quite steady. If

the person is suffering from lack of sleep, the sensors will not provide steady signals. The

signals from the sensors can be studied and conclusions can be drawn based on sensors’

information. If the person comes out of the bed at night, the time duration for which the

bed is not used is monitored. The time information can be used for making some decision.

Since the bed sensing system has been configured around a microcontroller, the processor

can do some amount of processing and the conclusions along with the sensors output is

sent to the central controller. The central controller can do another level of processing.

Page 47: Wireless Intelligent Bed Sensing System

46

8. The Market Potential:

The bed sensor system was designed and fabricated keeping in mind that the end product

should be simple, flexible, reliable, efficient and cost-effective so that and old person

living alone on his pension can afford to buy the system and use it as a stand-alone device.

The Wireless Intelligent Bed Sensor System has a bright future in the market as this device

can prove to be a life saver in some cases. This system will be of great importance to

elderly people living alone at home or people living with disabilities. The system also helps

in avoiding the use of having a care giver or helper constantly monitoring the patient by

being by their side. The caregivers can monitor the subject without actually being at the

house as the system works using wireless technology for transmitting and receiving

information. The system will alarm the caregiver or the person monitoring the sensor

system in case of an emergency or any unusual activity. This feature of the system

provides safety to its users without invading their privacy.

The major components used in the system are Flexi-Force sensors, the driving circuit and

the microcontroller. These sensors are flexible, cost-effective and can easily be integrated.

Our driving circuit does not use any major components so it is also cost-effective to build.

The microcontroller we have used has a rich list of functions and is in an affordable range

for the user.

So, the end product that we have for our Bed Sensor System has all the necessary

elements for it to be successful in the market. The product developed is simple and easy

to use for the user.

Page 48: Wireless Intelligent Bed Sensing System

47

9. Problems Faced:

Although we reached the goal of having a working prototype of Bed Sensor System at the

end but there were some problems that we faced along the way. One of the things that

took us the most time was the selection of the right components for the driving circuit.

We overcame this problem through trial and error by using various circuit configurations.

We had minor problems like some of our components blew up due to high voltages

provided to the circuit. Since we were using the MAX828 micro chip, we had some

problems in soldering of our components as the circuit used to get shorted.

One of the main problems that we had with our initial circuit was that the output signal

had a lot of noise in it. This noise was affecting our microcontroller readings which weren’t

stable. We overcame this problem by using a low pass filter at the output of the sensors.

Another problem that we had with the initial testing of the characteristics of the Flexi-

Force sensor was that the sensor was very sensitive so the weight that we used for testing

the sensor had to be placed exactly on the same spot on top of the sensor. Slight

unbalance of the weight would result in the sensor readings changing drastically. This

problem was overcome by taking three readings for each weight and taking the average

reading as the final output. We also made a mark on the weight to make sure that the

load is placed on exactly the same spot for all the weights.

Other than these problems we did not have any major problems in this project. The

experimentation was mostly based on trial and error. This was to ensure that we get the

best results possible.

Page 49: Wireless Intelligent Bed Sensing System

48

10. Conclusions:

To conclude, we can say overall the project has been a success. The main aim of the

project was to have a prototype working Bed Sensor System which has been developed.

This sensor system accurately measures the forces that are applied on the bed. This

intelligent bed sensing system has been designed and fabricated as a part of the smart

home based on wireless sensors.

We first tested our algorithm using a table and the four 25 lbs sensors as we did not have

the 100 lbs sensors available at the time. The results from our table test were satisfying.

The driving circuit gave us good output values from the sensors and the microcontroller

program was also accurate in reading these output values and converting and displaying

them in digital format. The actual results from this table test show that the system was

working fine as the sensor with the most weight on top of it showed the highest reading

on the microcontroller.

After the success of the experiment using the four sensors to measure the weight on a

table we used our circuit and program to conduct tests on an actual bed and a subject. In

this experiment the 100 lbs sensors were used. The results achieved from this experiment

were also as expected. These results gave us a good idea of how our system works. All the

sensors measured the right readings. When the head of the human subject was on the

side with sensor 1 and sensor 2 connected these sensors showed a high value and vice

versa for sensor 3 and sensor 4. Also sensors 1 and 3 showed high readings when a person

was towards the right side of the bed and sensors 2 and 4 read high when the person was

leaning towards the left side of the bed.

From these results we can conclude that the system can estimate the position of the

actual loading point. The response from the sensor system can be used to report normal

sleep, uncomfortable sleep, sitting on the bed at night time or no one being on the bed for

Page 50: Wireless Intelligent Bed Sensing System

49

a long time. Any abnormality of sleep can be detected and transmitted to the central

controller for generating the warning message to the person monitoring the system. So

this system will be useful in monitoring the bed using the intelligent wireless sensor

system.

Page 51: Wireless Intelligent Bed Sensing System

50

11. Future Work:

We have been working on further improving our Bed Sensor System in order to make it

more efficient and cost-effective. We have developed a new driving circuit for the system.

This new circuit uses a differential amplifier circuit for the sensor output using a single

supply (0-5V) only. This helps a great deal as we no longer require the use of MAX828

switched capacitor voltage inverter to generate -5V. This also helps us save costs on the

circuit and reduces the number of IC chips used. The new circuit is only based on SMD

(Surface Mounted Device) components which are ultra small components. These reduce

the size of our PCB (Printed Circuit Board). We have made the PCB for this circuit and have

tested it to some extent using the sensors. The results from this circuit are promising. Due

to the lack of time we haven’t been able to test this circuit using a table or an actual bed.

Future work can be done using this circuit in order to achieve a more effective and more

compact driving circuit for our Bed Sensor System.

Improvements can also be made in the ADC output by averaging the output over several

samples to smooth our minor fluctuations in the sensor output voltage (which is generally

due to noise).

The interpolation technique could be extended to incorporate the rate of output from all

the sensors to calculate the position of the load.

The microcontroller can be connected to the PC using UART (Universal Asynchronous

Receiver Transmitter) module (RS232). The microcontroller will pass the data pertaining to

the load position on the bed to a program running on the PC which will depict the

position/orientation of the person (on a simulated bed on the computer screen) in real-

time mode. The data will be logged over an extended period and an inference engine will

deduce the quality of sleep or generate alarm in case of abnormal usage of the bed.

Page 52: Wireless Intelligent Bed Sensing System

51

12. References:

[1] A. Gaddam, S. C. Mukhopadhyay and G. Sen Gupta, “Wireless Sensors Based Smart

Home to care Elder People”, Proceedings of 2008 Digital signal Processing Creative Design

Contest, pp. 21-28, November 29, 2008, Southern Technological University, Tainan,

Taiwan.

[2] A. Gaddam, S.C. Mukhopadhyay and G. Sen Gupta, Necessity of a Bed Sensor in a

Smart Digital Home to Care for Elder-people, Proceedings of the 2008 IEEE Sensors

conference, Lecce, Italy, October 26-28, 2008, page 1340-1343.

[3] Bowman, R. (2009). Doctors are where patient’s are. Retrieved October 23, 2009, from

http://www.dailyyonder.com/doctors-are-where-patients-arent/2009/02/12/1924

[4] G. Sen Gupta, A. Gaddam and S.C. Mukhopadhyay, Implementation of Wireless

Sensors Based Home Monitoring System, Proceedings of the 2008 IEEE Sensors

conference, Lecce, Italy, October 26-28, 2008, page 1332-1335.

[5] Independent Living Centres Australia. (2009). Bed checking monitoring systems.

Retrieved October 25, 2009, from

http://www.ilcaustralia.org/home/search4.asp?state=WA&page=2&MC=61&MinC=59

[6] Koontz, D. (2009). Life expectancy. Retrieved October 24, 2009, from

http://en.wikipedia.org/wiki/Life_expectancy

[7] Kristoff, S. (2008). An intorduction to sensors. Retrieved October 22, 2009, from

http://engineering.suite101.com/article.cfm/an_introduction_to_sensors

Page 53: Wireless Intelligent Bed Sensing System

52

[8] Population Division of the Department of Economic and Social Affairs of the United

Nations Secretariat, World Population Prospects: The 2008 Revision,

http://esa.un.org/unpp

[9] S.C.Mukhopadhyay, A. Gaddam and G. Sen Gupta, “A safe, sound and Secured Living

Environment for Elder People: Wireless Sensors based Digital Home”, Proceedings of 2008

IEEE TENCON, October 18-21, 2008, Hyderabad, India.

[10] Tekscan. (2009). FlexiForce force sensors. Retrieved October 25, 2009, from

http://www.tekscan.com/Flexi-Force/Flexi-Force.html

[11] Chew, M. T., & Sen Gupta, G. (2005). Embedded Programming with Field-

Programmable Mixed-Signal uControllers.

Page 54: Wireless Intelligent Bed Sensing System

53

13. Appendices:

Appendix A:

The schematic of the Driving circuit for all four sensors

Page 55: Wireless Intelligent Bed Sensing System

54

The waveform output of the driving circuit with and without filter

This is the waveform that we get at the output from the sensors. The bottom line shows

the output before the low pass filter and the top line shows the ouput after the filter has

been used. We can see from this the affect of using a filter to reduce noise in our signal.

Page 56: Wireless Intelligent Bed Sensing System

55

Appendix B: Data Sheets

Page 57: Wireless Intelligent Bed Sensing System

56

Page 58: Wireless Intelligent Bed Sensing System

57

Page 59: Wireless Intelligent Bed Sensing System

58

Page 60: Wireless Intelligent Bed Sensing System

59

Appendix C: Microcontroller Code for the Bed Sensor System

//-- Filename : BED_SENSOR_4_FINAL(2).c

//-- Uses Timer 3 Overflow to initiate ADC conversion

//-- Uses the External Crystal oscillator at 22MHz

//-- Measures the Force (analog output) from a Sensor cirucit and

Dsiplays in Digital

//-- format on the LCD

//-- ADC0 interrupt is enabled.

//-- Flashes green LED when SW2 (P3.7) is pressed

#include <c8051f020.h>

#include <stdio.h>

//-----------------------------------------------------------------------

-------------

// Global Defines

//-----------------------------------------------------------------------

-------------

#define LCD_DAT_PORT P6 // LCD is in 8 bit mode

#define LCD_CTRL_PORT P7 // 3 control pins on P7

#define RS_MASK 0x01 // for assessing LCD_CTRL_PORT

#define RW_MASK 0x02

#define E_MASK 0x04

//-----------------------------------------------------------------------

-------------

// Global MACROS

//-----------------------------------------------------------------------

-------------

#define pulse_E();\

small_delay(1);\

LCD_CTRL_PORT = LCD_CTRL_PORT | E_MASK;\

small_delay(1);\

LCD_CTRL_PORT = LCD_CTRL_PORT & ~E_MASK;\

//-- function prototypes ------------------------------------------------

----

void lcd_init (void); // initialize the lcd to 8 bit mode

void lcd_busy_wait (void); // wait until the lcd is no longer

busy

char putchar (char c); // replaces standard function and

uses LCD

void lcd_cmd (char cmd); // write a command to the lcd

controller

void lcd_home (void); // home curser

void lcd_clear (void); // clear display

void lcd_goto (char addr); // move to address addr

void lcd_move_curser(char dist); // moves curser forward or back by

dist

void lcd_curser (bit on); // 1 displays curser, 0 hides it

Page 61: Wireless Intelligent Bed Sensing System

60

void lcd_puts (char string[]); // send string to lcd at current

curser location

void small_delay (char d); // 8 bit, about 0.34us per count

@22.1MHz

void large_delay (char d); // 16 bit, about 82us per count

@22.1MHz

void huge_delay (char d); // 24 bit, about 22ms per count

@22.1MHz

//-----------------------------------------------------------------------

----

//-----------------------------------------------------------------------

-------------

// 16-bit SFR Definitions for 'F02x

//-----------------------------------------------------------------------

-------------

sfr16 DP = 0x82; // data pointer

sfr16 TMR3RL = 0x92; // Timer3 reload value

sfr16 TMR3 = 0x94; // Timer3 counter

sfr16 ADC0 = 0xbe; // ADC0 data

sfr16 ADC0GT = 0xc4; // ADC0 greater than window

sfr16 ADC0LT = 0xc6; // ADC0 less than window

sfr16 RCAP2 = 0xca; // Timer2 capture/reload

sfr16 T2 = 0xcc; // Timer2

sfr16 RCAP4 = 0xe4; // Timer4 capture/reload

sfr16 T4 = 0xf4; // Timer4

sfr16 DAC0 = 0xd2; // DAC0 data

sfr16 DAC1 = 0xd5; // DAC1 data

//-----------------------------------------------------------------------

-------------

// Global CONSTANTS

//-----------------------------------------------------------------------

-------------

#define SYSCLK 22118450 //-- External Crystal Oscillator @22MHz

unsigned char LCD_count;

int Sensor1, Sensor2, Sensor3, Sensor4; //-- variables to store

ADC0 value

int channel;

//-- function prototypes ------------------------------------------------

----

void Init_Clock(void); //-- initialise the clock to use external crystal

oscillator

void Init_Port(void); //-- Configures the Crossbar and GPIO ports

void Init_ADC0(void); //-- Initialise the ADC1

void Init_Timer3(unsigned int counts);

void Timer3_ISR(void); //-- ISR for Timer 3

void ADC0_ISR(void); //-- ADC0 end-of-conversion ISR

//-----------------------------------------------------------------------

----

Page 62: Wireless Intelligent Bed Sensing System

61

void main(void)

{

LCD_count = 0;

EA = 0; //-- disable global interrupts

//-- It is a good idea to disable interrupts

before all the initialisation

//-- is complete

//-- disable watchdog timer

WDTCN = 0xDE;

WDTCN = 0xAD;

Init_Clock();

Init_Port();

Init_ADC0();

Init_Timer3(10237); //-- Initialise Timer3 to generate

interrupts every 30ms

lcd_init();

lcd_curser(0);

lcd_clear();

EA = 1; //-- enable global interrupts

P5 = 0x0F; //-- Turn the 4 green LEDs off

while(1) //-- go on forever

{

LCD_count++;

if ( (LCD_count % 100) == 0) //-- do every 100th count

{

LCD_count = 0;

lcd_goto(0x00); //-- First row of LCD

printf("S1:%4d", Sensor1);

printf(" S3:%4d", Sensor3);

lcd_goto(0x40); //-- Second Row of LCD

printf("S2:%4d", Sensor2);

printf(" S4:%4d", Sensor4);

huge_delay(3);

} //-- do every 100th count

} //-- end of while loop

}

void Init_Clock(void)

{

OSCXCN = 0x67; //-- 0110 0111b

//-- External Osc Freq Control Bits (XFCN2-0) set to 111 because

crystal frequency > 6.7 MHz

//-- Crystal Oscillator Mode (XOSCMD2-0) set to 110

// OSCXCN = 0x77; //-- if you want Crsytal Osc. Mode with

divide by 2 stage

//-- wait till XTLVLD pin is set

while ( !(OSCXCN & 0x80) );

Page 63: Wireless Intelligent Bed Sensing System

62

OSCICN = 0x88; //-- 1000 1000b

//-- Bit 2 : Internal Osc. disabled (IOSCEN = 0)

//-- Bit 3 : Uses External Oscillator as System Clock (CLKSL = 1)

//-- Bit 7 : Missing Clock Detector Enabled (MSCLKE = 1)

}

void Init_Port(void) //-- Configures the Crossbar and GPIO ports

{

XBR1 = 0x00;

XBR2 = 0x40; //-- Enable Crossbar and weak pull-ups

(globally)

P1MDOUT |= 0x40; //-- Enable P1.6 (LED) as push-pull output

//-- Configure P3.7 for input

P3MDOUT &= 0x7F; //-- Write a logic 0 to set Open-Drain Output

mode

P3 |= 0x80; //-- write a logic 1 to P3.7

//-- Port 7-4 I/O Lines

P74OUT = 0x48; // Output configuration for

P4-7

// (P7[0:3] Push Pull)

- Control Lines for LCD

// (P6 Open-Drain)-

Data Lines for LCD

// (P5[7:4] Push Pull)

- 4 LEDs

// (P5[3:0] Open Drain)

- 4 Push-Button Switches (input)

// (P4 Open Drain) - 8

DIP Switches (input)

//-- Write a logic 1 to those pins which are to be used for input

P5 |= 0x0F;

P4 = 0xFF;

}

//-- Configure Timer3 to auto-reload and generate an interrupt at

interval

//-- specified by <counts> using SYSCLK/12 as its time base.

void Init_Timer3 (unsigned int counts)

{

// TMR3CN = 0x00; //-- Stop Timer3; Clear TF3;

//-- use SYSCLK/12 as timebase

TMR3CN |= 0x02; //-- uses SYSCLK (NOT SYSCLK/12)

TMR3RL = counts; //-- Init reload values

TMR3 = 0xffff; //-- set to reload immediately

// EIE2 &= ~0x01; //-- disable Timer3 interrupts

EIE2 |= 0x01; //-- enable Timer3 interrupts

TMR3CN |= 0x04; //-- start Timer3 by setting TR3 (TMR3CN.2) to

1

}

void Init_ADC0(void)

{

REF0CN = 0x07; //-- Enable internal bias generator and

internal reference buffer

Page 64: Wireless Intelligent Bed Sensing System

63

// Select ADC0 reference from VREF0

pin

// ADC0CF = 0x86; //-- SAR0 conversion clock=1.3MHz approx.,

Gain=0.5 (default)

// ADC0CF = 0x80; //-- SAR0 conversion clock=1.3MHz approx.,

Gain=1

ADC0CF = 0x81; //-- SAR0 conversion clock=1.3MHz approx.,

Gain=2

AMX0CF = 0x00; //-- 8 single-ended inputs

AMX0SL = 0x01; //-- Select Sensor1

channel = 0;

ADC0CN = 0x84; //-- enable ADC0, Continuous Tracking Mode

// Conversion initiated on Timer 3

overflow, ADC0 data is right justified

EIE2 |= 0x02; //-- enable ADC Interrupts

}

//-- Interrupt Service Routine

//-- This routine changes the state of the LED whenever Timer3 overflows

every 10th time.

void Timer3_ISR (void) interrupt 14

{

TMR3CN &= ~(0x80); // clear TF3

}

void ADC0_ISR(void) interrupt 15

{

AD0INT = 0; //-- clear ADC0 conversion complete interrupt

flag

if (channel == 0) //-- Sensor1 Reading

{

Sensor1 = ADC0;

AMX0SL = 0x02; //-- Select AIN0.1

channel = 1;

}

else if (channel == 1) //-- Sensor2 Reading

{

Sensor2 = ADC0;

AMX0SL = 0x03; //-- Select AIN0.2

channel = 2;

}

else if (channel == 2) //-- Sensor3 Reading

{

Sensor3 = ADC0;

AMX0SL = 0x04; //-- Select AIN0.3

channel = 3;

}

else if (channel == 3) //-- Sensor4 Reading

{

Sensor4 = ADC0;

AMX0SL = 0x01; //-- Select AIN0.4

channel = 0;

}

Page 65: Wireless Intelligent Bed Sensing System

64

}

//----------------------------- LCD related Functions -------------------

----------

#pragma OPTIMIZE (7)

void lcd_init(void)

{

LCD_CTRL_PORT = LCD_CTRL_PORT & ~RS_MASK; // RS = 0

LCD_CTRL_PORT = LCD_CTRL_PORT & ~RW_MASK; // RW = 0

LCD_CTRL_PORT = LCD_CTRL_PORT & ~E_MASK; // E = 0

large_delay(200); // 16ms delay

LCD_DAT_PORT = 0x38; // set 8-bit mode

pulse_E();

large_delay(50); // 4.1ms delay

LCD_DAT_PORT = 0x38; // set 8-bit mode

pulse_E();

large_delay(2); // 1.5ms delay

LCD_DAT_PORT = 0x38; // set 8-bit mode

pulse_E();

large_delay(2); // 1.5ms delay

lcd_cmd(0x06); // curser moves right

lcd_clear();

lcd_cmd(0x0E); // display and curser

on

}

#pragma OPTIMIZE (9)

//-----------------------------------------------------------------------

-------------

// lcd_busy_wait

//-----------------------------------------------------------------------

-------------

//

// wait for the busy bit to drop

//

void lcd_busy_wait(void)

{

LCD_DAT_PORT = 0xFF;

LCD_CTRL_PORT = LCD_CTRL_PORT & ~RS_MASK; // RS = 0

LCD_CTRL_PORT = LCD_CTRL_PORT | RW_MASK; // RW = 1

small_delay(1);

LCD_CTRL_PORT = LCD_CTRL_PORT | E_MASK; // E = 1

// TB_GREEN_LED = 1;

do

{ // wait for busy

flag to drop

small_delay(1);

} while ((LCD_DAT_PORT & 0x80) != 0);

// TB_GREEN_LED = 0;

}

Page 66: Wireless Intelligent Bed Sensing System

65

//-----------------------------------------------------------------------

-------------

// lcd_dat (putchar)

//-----------------------------------------------------------------------

-------------

//

// write a character to the lcd screen

//

char putchar(char dat)

{

lcd_busy_wait();

LCD_CTRL_PORT = LCD_CTRL_PORT | RS_MASK; // RS = 1

LCD_CTRL_PORT = LCD_CTRL_PORT & ~RW_MASK; // RW = 0

LCD_DAT_PORT = dat;

pulse_E();

return 1;

}

//-----------------------------------------------------------------------

-------------

// lcd_cmd

//-----------------------------------------------------------------------

-------------

//

// write a command to the lcd controller

//

void lcd_cmd(char cmd)

{

lcd_busy_wait();

LCD_CTRL_PORT = LCD_CTRL_PORT & ~RS_MASK; // RS = 0

LCD_CTRL_PORT = LCD_CTRL_PORT & ~RW_MASK; // RW = 0

LCD_DAT_PORT = cmd;

pulse_E();

}

//-----------------------------------------------------------------------

-------------

// lcd_goto

//-----------------------------------------------------------------------

-------------

void lcd_goto(char addr)

{

lcd_cmd(addr | 0x80);

}

//-----------------------------------------------------------------------

-------------

// lcd_clear

//-----------------------------------------------------------------------

-------------

void lcd_clear(void)

{

lcd_cmd(0x01); //-- clear LCD display

Page 67: Wireless Intelligent Bed Sensing System

66

lcd_cmd(0x80); //-- curser go to 0x00

}

//-----------------------------------------------------------------------

-------------

// lcd_curser

//-----------------------------------------------------------------------

-------------

void lcd_curser(bit on) // 1 displays curser, 0 hides it

{

if (on)

lcd_cmd(0x0E);

else

lcd_cmd(0x0C);

}

//-----------------------------------------------------------------------

-------------

// delay routines

//-----------------------------------------------------------------------

-------------

//

// delay using spin wait

//

void small_delay(char d)

{

while (d--);

}

void large_delay(char d)

{

while (d--)

small_delay(255);

}

void huge_delay(char d)

{

while (d--)

large_delay(255);

}