BME 499 Capstone Project
In Singapore, the elderly population is growing. Caring for them all day is impossible as family members have their personal commitments. Nursing homes also lack staff to monitor them. Therefore, most of the time an elderly is left to care for self. An elderly who is weak and fragile is prone to falls and this will cause undesirable consequences such as paralysis.
Alert systems similar to the ones used in hospital have been introduced in nursing homes but it requires the activation by the elderly.
The Elderly Activity Monitoring System is developed to monitor the elderly and does not require any participation of the elder. This assures that should any mishap happen there will be notification. The elderly will be able to receive immediate necessary attention. This monitoring system is designed to alert the family members or nursing staff via Smart-
Messaging Services (SMS) or HyperTerminal messages of any inactivity. For example, when the elder enters a room with this system, an SMS is received as an assurance but in the case that there is no activity, no SMS is received. A panic button is also implemented to alert the community should the elder require urgent attention. This monitoring system uses microcontroller technology to control the device, motion sensor to detect the movements and
Global System for Mobile (GSM) modem to send out messages.
This report covers the project objectives and provides design and implementation specifications. It then illustrates the development of the prototype from construction to testing through accounts of software programming, hardware components used and its interface as well as the overall integrating process to create this monitoring system prototype. ii
BME 499 Capstone Project
I would like to express my greatest gratitude to Mr Kumbar Shankarappa, the supervisor of this project for his guidance throughout the development of the prototype. He provided feedbacks on improvements that can be made to the system and always ready to offer his help especially when I encountered problems in the hardware and software designs. He imparted his knowledge of microcontroller technology which is really useful as I gained better understanding of C programming.
I also would like to take this opportunity to thank Mr Din, a former UniSIM student who willingly lent me the GSM modem and Microchip development kit (MPLAB ICD2 &
PICDEM board). Without his help, time and cost incurred would be a factor.
Finally, I would like to thank Miss Tan Min Yu for spending the time to read this report and giving suggestions from a layman point of view. iii
BME 499 Capstone Project
Proposed approach and method to be employed
Existing Products in the Market
eNeighbour Remote Monitoring System Existing Products in the Market
QuietCare Home Security System
Comparison of Existing Systems
Programming Languages to be used
Hardware Design and Implementation
Microcontroller Microchip PIC18F4520
Microchip In-Circuit Debugger 2
iv
BME 499 Capstone Project
INTEGRATION OF HARDWARE/SOFTWARE AND TESTING
Integration of the Elderly Activity Monitoring System
PROBLEMS ENCOUNTERED AND RECOMMENDATIONS
Problems Encountered and Solutions
Recommendations for Future Developments
CRITICAL REVIEW AND REFLECTION
APPENDIX A: Program Source Code
APPENDIX B: Schematic Diagram of Hardware
v
BME 499 Capstone Project
Figure 3.3: Power Supply Layout & Schematic Diagram ....................................................... 17
Figure 3.4: PIC18F4520 Microcontroller ................................................................................ 18
Figure 3.7: Reset Button Layout .............................................................................................. 20
Figure 3.8: Panic Button Layout .............................................................................................. 21
Figure 3.9: LEDs Layout ......................................................................................................... 21
Figure 3.10: Buzzer Layout ..................................................................................................... 22
Figure 3.12: Layout of RS-232 ................................................................................................ 24
Figure 3.13: DB-09 Connector Pins Layout ............................................................................ 24
Figure 3.14: Insertion of SIM Card into GSM Modem ........................................................... 25
Figure 3.16: Completed Prototype ........................................................................................... 26
Figure 4.1: Flow of Software Development ............................................................................ 27
Figure 4.4: Configuration Bits ................................................................................................. 29
Figure 4.5: LEDs program ....................................................................................................... 30
Figure 4.6: Buzzer program ..................................................................................................... 30
Figure 4.7: Panic button program ............................................................................................ 31
Figure 4.11: Modem program .................................................................................................. 34
Figure 4.12: Flow chart of Software Programming ................................................................. 35
Figure 4.13: Completed Program Code ................................................................................... 37
Figure 5.3: Motion Sensor Testing .......................................................................................... 40
Figure 5.4: GSM modem testing with panic button and motion sensor .................................. 41
Figure 5.6: Elderly Activity Monitoring System ..................................................................... 43
Figure 7.1: Pert Chart ............................................................................................................... 51
Figure 7.2: Gantt Chart ............................................................................................................ 52 vi
BME 499 Capstone Project
Table 4.1: Types of AT commands.......................................................................................... 33
Table 7.1: Project Tasks (First & Second Phase) .................................................................... 48
Table 7.2: Project Tasks (Third & Fourth Phase) .................................................................... 49
Table 7.3: Project Tasks (Final Phase) .................................................................................... 50 vii
BME 499 Capstone Project
1.
1.1
Project Objectives
The objective of this project is to develop a system to monitor movement of elderly people when they are alone, thus the title ‘Activity Monitoring System for Elderly’. The data such as the routine of the elderly is to be logged in the system for feature use. The device function includes automatic detection and monitoring. This information is then either sent to a phone via Smart-Messaging Services (SMS), or stored in the PC at the care centre.
1.2
Overall Objectives
When no activity is detected, the next-of-kin is not alerted. This denotes an emergency situation and they will be able to react appropriately. When the ‘panic’ button is activated, the next-of-kin is alerted immediately. The use of a sound alarm in this monitoring system allows neighbours or people nearby the elderly to react to the situation. The device function includes automatic detection and monitoring. This information is then either sent to a phone via SMS, or stored in the PC at the care centre.
It is important to ensure good stability and functionality that is basic and easy for the elderly to use. These can be achieved by designing the device to be compact by selecting and using minimal components and operational methods. It is small in size and it can also be powered by a battery, thus making it portable. This allows the user to ‘unstick’ and ‘stick’ from an existing location to another location (e.g. toilet, bedroom, kitchen).
1.3
Overview
The activity monitoring system for the elderly is aimed to be ergonomical, user-friendly and cost-efficient. They are generally compact and portable thus it would be easy to place them onto the walls of the designated rooms. It can also be linked to the nursing home’s call centre.
The product presented in this project is different from the other monitoring systems available
1
BME 499 Capstone Project in the market. Instead of sending emergency alarms, an alert which assures that the elderly is safe is sent. With the use of a motion sensor, motion of an activity is detected and alert is sent. There is also a ‘panic’ button which the elderly can use should he/she needs emergency help. The alert system can send the alerts through SMS or the Internet which are widely used networking systems.
The design of the elderly activity monitoring system consists of three stages. The first stage is the completion of the individual hardware components. The second stage is the programming of the software for the individual components. And, the third stage is the integration of both the first and second stages. This interfacing process makes up the final operational device.
The software component consists of C programming via MPLab and HyperTerminal for the monitoring and alert system. The hardware components consist of microcontroller, motion sensor, switches, light-emitting diodes (LEDs), buzzer and modem. The 40-pin microcontroller is the brain in this system, controlling the outputs and inputs. The motion sensor aids in monitoring the activity of the elderly. It serves as an input for the ‘motion detected’ alert whereas the ‘PANIC’ button serves as an input for the ‘panic’ alert. These alerts are sent out via the GSM modem. Mobile technology consisting of Global System for
Mobile (GSM) and General Packet Radio Service (GPRS) and wireless technology consisting of TCP/IP is incorporated to send these data alerts.
1.4
Proposed approach and method to be employed
The system consists of the following modules:
1) Microcontroller which is the brain of the monitoring system. It will be programmed to send and receive data of motion detection, to respond to the alarm panel and to send data to PC or mobile phone via the modem. It is crucial for the system to have a well programmed microcontroller as inaccuracy to work would mean failure to the system.
2) Panic alarm panel consists of a buzzer, LEDs and a ‘panic’ button. This panel is included should there be a need for immediate attention. If this alarm is activated, the neighbours will be alerted by the loud ‘siren’ and the next-of-kin will be contacted.
3) Alert system is activated after the device detects motion and the assurance alert is sent. Data will be sent through the modem to alert a family member or care center regarding the emergency situation.
2
BME 499 Capstone Project
4) Motion sensor detects the motion of human beings or objects. When motion is detected, it will send data to the microcontroller and the alert system activates.
5) Modem is used to receive data from the microcontroller to be sent to a mobile phone or PC. This data will then be received in the form of SMS or PC software.
Mod em
Alert System
Reset Bu tton
LED
Mi crocontrol ler
Pani c Alarm
Panel
Motion S ens or
Pani c Bu tton
Figure 1.1: Block diagram of Proposed Elderly Activity Monitoring System
3
BME 499 Capstone Project
Research and analysis of existing monitoring systems
Evaluate on the pros and cons of existing systems
Design and implement improvements of the system onto the project
Decide on the suitable components needed for the units
Develop the Activity Monitoring System
Assess the functionality and quality of the device
Troubleshoot the device Discuss on any enrichment that can be employed
Figure 1.2: Flowchart of Proposed Project Methodology
4
BME 499 Capstone Project
2.1
Introduction
In Singapore whereby the ageing population is rapidly growing, most of the elderly people tend to be left alone at home while the rest of the family members are at work or at school.
Some of the elderly are becoming more independent, moving in to nursing homes or living alone. These elderly people tend to be weak and diagnosed with illnesses making them vulnerable to falls. Medication is also partly the cause of elderly falls due to the side effects such as drowsiness and affecting the gauge of balance. Studies have shown that at least 30% of the elderly fall each year and the rate is higher for those over 80 years of age [28]. Falls may in turn lead to injuries, disabilities or even death. It can also affect the elderly socially and physically, with a possible psychological effect [26]. The elderly may restrict his/her active lifestyle to avoid falling again and the dependency on others increases. Therefore, falls have a huge impact on the person’s health, daily activities and increase financial burden to the family [26].
For those without a caregiver, the idea of a monitoring system comes in. While unable to prevent falls, it gives the elderly confidence and security of moving around independently. It can however alert the next-of-kin or institution nurse to react immediately to the emergency situation should a fall occur [29]. While monitoring systems are widely used in countries such as USA, it is less popular in Singapore because of factors such as the cost of the device and availability in the market.
These monitoring systems works by alerting family members should a mishap happen to the elderly such as falls. A standard activity monitoring system will consist of a microcontroller with devices such as motion sensor, GSM modem and receiving of data with phone and PC.
A more sophisticated system may include wireless sensor network, remote control, LCD display panel, alarm panel and location details in the data received [30].
5
BME 499 Capstone Project
2.2
Existing Products in the Market
Elderly individuals may have purchased walking aids to assist and to prevent them from falling. However accidents may occur even in the safest possible environment. There are a number of systems that are available providing to the needs of assistance for elderly who needs them when required [25].
2.2.1
eNeighbour Remote Monitoring System Existing Products in the Market
The eNeighbour monitoring system [5] provides automatic detection whenever there is a need for assistance and customized alerts specific to needs and risk factors for the individual. It can be used in home care or nursing home setting. There are pressure sensors in beds, motion detectors on walls, toilet sensors, contact sensors and door sensors that alert when the resident tries to leave the residence or enter potentially hazardous areas, such as stairways. The system automatically issues assistive prompts or alerts via any phone when the data indicate help is needed. Information and reports collected can be accessed from a secure web portal.
Cost: $300 for a basic package or $700 for 10 sensors system, plus $60 per month for emergency call center service.
Figure 2.1: eNeighbour Remote Monitoring System
Source: www.healthsense.com
2.2.2
QuietCare Home Security System
QuietCare [4] uses a series of wireless sensors to monitor activities such as meal preparation, sleep and bathroom habits, wake-up time, and medication usage. The sensors are placed around the home and information is sent to QuietCare computers.
The computers compare a person’s usual behavior to what the sensors are telling them. If there is a significant change in habits of daily living, such as when a person gets out of bed or
6
BME 499 Capstone Project how much time he or she spends in the kitchen or bathroom, the system sends out an alarm to caregivers by phone, email, text message, or pager. Caregivers can also log into a Web site to view activities which are colour coded for current status — green for normal, yellow for
“keep an eye on this,” and red for alert. A red alert triggers an emergency response operator to call the senior to determine if he or she is all right. If there is no answer, an operator calls a number that the caregiver or senior has designated.
Cost: $199 for a basic package, plus $99.95 a month for monitoring (may be higher depending on area).
Figure 2.2: QuietCare Home Monitoring System
Source: www.quietcare.com
2.2.3
Comparison of Existing Systems
Systems Installation
Monthly
Subscription
Annual Total
Cost
Wireless eNeighbour sensors
Healthsense call centre
QuietCare
USD 60 USD 720
Wireless sensors
QuietCare computers
USD 99.95 USD 1200
Table 0.1: Comparison of Elderly Fall Detection System
Approximate in
SGD
(USD 1 = SGD 1.3)
936
1560
7
BME 499 Capstone Project
From the comparison in Table 0.1, it shows that these existing systems would cause financial
burden to the consumer over the years. The aim of this project is to be able to provide a similar standard of care at an affordable cost.
2.3
Microcontroller technology
Microcontrollers have been in the market for the last 3 decades. The first microprocessor was developed by a small company called Intel (short for Integrated Electronics) in the early
1970s.
A microcontroller is a small computer on a single integrated circuit consisting internally of a relatively simple Central processing unit (CPU),serial communication, clock, timers, Input and Output unit (I/O ports), BUS (address and data), memory units (RAM and ROM) and program[17]. Microcontrollers contain a small amount of RAM so they are designed for small dedicated applications.
Figure 2.3: Basic architecture of a Microcontroller
Source: www.pictutorials.com
There are a large number of brands and types of microcontrollers in the market including
Microchip, Intel, Zilog, Toshiba, Rabbit and etc. We will need to select a suitable
8
BME 499 Capstone Project microcontroller for the project. As it is too impractical to compare all of them, I have decided to weigh against a few brands which have adequate technology for the project. The advantages and disadvantages are shown in the table below.
Microchip
wide availability
extensive collection of application notes
debugger unit is costly
serial programming capability, supports
C, C++, Assembly
most familiar with use
low cost
Rabbit
high-performance
free software
debugger unit not required
unfamiliar with use
expensive
Intel
reliable brand
serial programming capability, supports
C, C++, Assembly
unfamiliar with use
most expensive
Table 2.2: Comparisons of Microcontrollers
From this comparison of pros and cons, I have decided to use the Microchip microcontroller with the MPLAB IDE development kit.
2.4
Programming Languages to be used
A programming language is designed to express computations that can be performed by machines. The most commonly used languages in Microcontroller are C, C++ and Assembly languages.
2.4.1
C Language
C language was developed in 1970s and was designed for implementing system software.
Now, it is also widely used for developing portable application software. It is an imperative systems implementation language. It was designed to be compiled using a relatively
9
BME 499 Capstone Project straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support [18]. C was therefore useful for many applications that had formerly been coded in assembly language. It has code portability and efficiency, able to access specific hardware addresses, "pun" types to match externally imposed data access requirements, and has low runtime demand on system resources. C is also preferred over other languages over its speed, stability and less susceptibility to changes in operating environments due to its compiled nature.
2.4.2
Assembly Language
The assembly languages was developed in the 1950s, They eliminated much of the errorprone and time-consuming first-generation programming needed with the earliest computers, freeing the programmer from tedium such as remembering numeric codes and calculating addresses. They implement a symbolic representation of the numeric machine codes and other constants needed to program a particular CPU architecture. This representation is usually defined by the hardware manufacturer, and is based on abbreviations (called mnemonics) that help the programmer remember individual instructions, registers, etc. An assembly language is thus specific to certain physical (or virtual) computer architecture. This is in contrast to most high-level languages, which are portable.
A utility program called an assembler is used to translate assembly language statements into the target computer's machine code. The assembler performs a more or less isomorphic translation (a one-to-one mapping) from mnemonic statements into machine instructions and data. This is a disadvantage to high-level languages in which a single statement generally results in many machine instructions.
2.5
Motion Detector
A motion detector contains a motion sensor that detects motion and transforms it into an electric signal. An occupancy sensor is a motion detector that is integrated with a timing device. It senses when motion has stopped for a specified time period in order to trigger a signal. There are three types of motion detectors; passive infrared, ultrasonic and microwave.
Passive infrared sensors (PIR) senses body heat and does not emit energy [2]. Ultrasonic sensor sends out pulses and measures the reflection of a moving object. Microwave sensor
10
BME 499 Capstone Project sends out microwave pulses and measures the reflection of a moving object [8]. Sometimes, dual technology is used, PIR sensors will be paired with another model to maximize accuracy and reduce energy usage. For example, when the PIR sensor is tripped, it activates a microwave sensor.
Passive Infrared (PIR)
angle (parallax) distance measurement
shorter range
affected by sunlight
affected by colour of object
cheap
longer range than IR
affected by wind
object
Ultrasonic time of flight distance measurement affected by hardness of expensive
Microwave
less false alarm
best range of penetration
affected by objects such as metal/water
expensive
Table 2.3: Comparison of Motion Sensors
From the comparison made above, I have decided that using an infrared sensor is most viable for the project considering the cost and the functioning of the sensor is adequate for the project use.
2.6
GSM/GPRS Modem
A GSM modem is a specialized type of modem which is wireless, accepts a SIM card, and operates over a subscription to a mobile operator, just like a mobile phone. It can be a dedicated modem device with a serial, USB or Bluetooth connection, or it may be a mobile phone that provides GSM modem capabilities [9]. An external GSM modem is connected to a computer through a serial cable or a USB cable. It supports a set of standard AT commands which are classified in the GSM standards. The extended AT commands allow reading, writing, sending and deleting SMS messages. They also monitor the signal strength.
However, the number of SMS messages that can be processed by a GSM modem per minute is very low -- only about six to ten SMS messages per minute.
A GPRS modem is a GSM modem with additional support for GPRS technology for data transmission. GPRS means 'General Packet Radio Service'. It is based on a packet-switched
11
BME 499 Capstone Project technology, as an extension to GSM (GSM is a circuit-switched). An advantage of GPRS over GSM is that GPRS has a much higher data transmission speed. If SMS over GPRS is used, an SMS transmission speed of about 30 SMS messages per minute may be achieved which is a faster rate compared to GSM. A GPRS modem is required to send and receive
SMS via GPRS.
For this project, the modem will receive a signal from the microcontroller and produce a signal that can be transmitted. It will then be decoded to reproduce the digital data and send it to the PC or mobile of the caregiver via HyperTerminal or SMSes. Therefore, a GSM/GPRS modem will be suitable for use.
COMPUTER
TELEPHONE
NETWORK
TERMINAL modem modem
Figure 2.4: Connection of Terminal to computer via telephone lines
To view the data on the PC, a program called HyperTerminal is needed. As HyperTerminal has been terminated from Windows Vista, an alternative program Tera Term was used instead. This program is a free ready-to-use software which can be downloaded. It has the same functions as HyperTerminal although the interface is different.
2.7
Buzzer
A buzzer is an audio signalling device which may be mechanical or electronic. It can be used as an alarm, timer or confirmation of user input. The sound output from the buzzer may be continuous or intermittent. As the output is typically at least 75dB, it will provide sufficient sound aid for the elderly.
Figure 2.5: Buzzer
12
BME 499 Capstone Project
2.8
LEDs
LEDs are light-emitting diodes, which are used as indicators. Early LEDs emitted lowintensity red light, but modern versions are available across the visible, ultraviolet and wavelengths, with very high brightness.
It is based on the semiconductor diode [16]. When switched on, electrons recombine with holes within the device and release energy in the form of photons. This effect is called electroluminescence. LEDs will be used as part of the alarm status panel as they are cheap and small yet bright enough to be seen from a few metres away.
Figure 2.6: LED
2.9
RESET button
The reset button is a switch, found on circuit breakers to reset the circuit. When pressed, it can either reset the system or program. This button needs to be large on our device so it would be highly visible and easily located.
2.10
Power Supply
The power supply supplies electrical power to the device. In this project, a battery of 9V voltage is used for the prototyping circuit. Using a step-down regulator, this power is reduced to the output of 5V which is sufficient for the device.
13
BME 499 Capstone Project
2.11
Panic button
The panic button is a switch with similar configuration as the reset button. When pressed, it sends the ‘PANIC’ alert. This button also needs to be large and bright coloured on our device so it would be highly visible and easily located.
14
BME 499 Capstone Project
3.1
Hardware Design and Implementation
1) Power Supply: to supply voltage power
2) Micro-controller: to program and control device
3) Panic Button, Buzzer and LEDs: alert panel
4) Motion Sensor: to detect movement
5) Serial port circuit and GSM modem: to send out alerts
The flow movement of implementing each component together is illustrated in the flow chart shown in Figure 3.1. The hardware and software designs are developed while complementing each other. This flow chart is useful to update on the project’s status and ease troubleshooting.
15
BME 499 Capstone Project
Hardware Development
Regulate power supply from
9V to 5V.
Microcontroller and ICD connector setup with switches, buzzer and LEDs on board.
Motion sensor on board
Max232 serial port circuit and GSM modem setup on board
All components working, prototype complete
Software Development
Simple system programming to familiarize with MPLab. Integrate LEDs and buzzer into hardware.
Motion Sensor Program:
To check working sensor input/output
Modem Program:
To check if SMS/HyperTerminal messages can be sent.
Integrate and implement program towards the objectives of the project
Final Testing of system. Integration
Completed. System Completed.
Figure 3.1: Flow Diagram of Hardware and Software Implementation
16
BME 499 Capstone Project
After designing the hardware flowchart, a schematic diagram of the whole system is planned and drawn out as shown in Figure 3.2. This diagram helps in the purchase of components, troubleshooting and layout of the prototyping circuit. A larger diagram can be viewed under
Appendix B.
Figure 3.2: Schematic Diagram of Elderly Activity Monitoring System
3.2
Power Supply
As most of the integrated circuit chips and microcontroller need +5V power, the battery supply of 9V is regulated to 5V using a LM7805 voltage regulator, diode and two 10
F capacitors. In this project, the LM7805 regulator is used as shown in Figure 3.3.
Battery
LM7805 regulator
17
Figure 3.3: Power Supply Layout & Schematic Diagram
BME 499 Capstone Project
3.3
Microcontroller Microchip PIC18F4520
The PIC18F4520 [6] is selected for use in this project as it has enough function capabilities, low cost and it can be programmed using the C language. It is a 40 pin microchip, has 5 ports available for use (A/B/C/D/E) and an 8-bit processor. It also has high computational capabilities, high temperature endurance and enhanced flash program memory. The operational speed of this microcontroller is 40MHz. The microcontroller uses a 4MHz oscillator and two 22pF capacitors as shown in Figure 3.4.
PIC18F4520 microcontroller
XT crystal
Figure 3.4: PIC18F4520 Microcontroller
3.3.1
Microchip In-Circuit Debugger 2
Also known as ICD2, it acts as a connector between the microcontroller and computer to communicate with each other. It is used as a debugger/programmer for the selected microcontroller. It connects using USB and translates the C program onto the microcontroller such that the outputs can be seen on the prototype target board. In short, it can program the microcontroller to carry out the commands onto the device [23]. In Figure 3.5 below, the
ICD’s connections to the PC, microcontroller and prototype are shown.
18
BME 499 Capstone Project
PC
Prototype
ICD2
Figure 3.5: Connection of ICD2 to PC and Target Board
3.3.2
Microchip Development Kit
The PICDEM
TM
Plus Demonstration Board has the following hardware components: a) Power supply input for 100 mA AC/DC wall adapter or 9V battery b) RS-232 interface c) 18, 28 and 40-pin DIP sockets d) In-Circuit Debugger (ICD) connector. e) Reset button and 3 buttons for external inputs f) LEDs g) LCD display. h) Piezo buzzer.
These components can be used as a back-up target board in the event that the prototyping board needs troubleshooting to prevent delay in project development. The PIC Demo Board
(Figure 3.6) also acts as an example for the prototype’s interface as it has the necessary components.
19
BME 499 Capstone Project
Figure 3.6: PICDEM board
3.4
Buttons
There are two buttons used in this project; RESET and PANIC.
The reset button resets the device to the start of the program. It is useful as it acts as a calibrator for the motion sensor and monitoring system. It is connected to the ground (GND) and MCLR of the microcontroller as shown in Figure 3.7.
RESET button
Figure 3.7: Reset Button Layout
The panic button is pressed manually by the elderly in the case of emergency and to acquire immediate attention. The button is bright blue in colour so that it is distinctive enough for the elderly to see. One side of the switch is connected to two 470
Ω
resistors and two 22pF
20
BME 499 Capstone Project capacitors which have +5V connected and the other side is connected to ground. It is an input to Port C pin 3 of the microcontroller as shown in Figure 3.8.
Resistor
Panic
Button
Capacitor
Figure 3.8: Panic Button Layout
3.5
LEDs
There are four LEDs used in this project with three different colours; red, green and yellow.
They are used as indicators whenever an alert is sent out; either SMS, AT commands or alert panel output. When the panic button is pressed, the LEDs light up to assure the elderly that the alert has been sent. This is important in the event that the program ‘skips’ the loop and fails to detect the panic button input.
The LEDs are connected to common ground on the negative end (shorter) and output end
(longer) are connected to resistors of 1 kΩ
each. The other ends of the resistors are then connected to the Port D pins 0 to 3 of the microcontroller as shown in Figure 3.9.
Resistors
LEDs
Figure 3.9: LEDs Layout
21
BME 499 Capstone Project
3.6
Buzzer
The buzzer is used in this project to alert the community when the elderly needs attention. It is handy as people not within a new distance are able to hear the alert to assist. The sound output is loud enough to be heard over 10 metres away.
The buzzer is connected to Port D pin 4 of the microcontroller and uses a 270 Ω resistor as shown in Figure 3.10. The other end is connected to the ground.
Buzzer
Resistor
Figure 3.10: Buzzer Layout
3.7
Motion Sensor
The motion sensor is the focal point in the monitoring system. It is used to detect motion and this information can then be used to interpret the activities of the person. When motion is detected, an alert is sent to inform the person first-hand of the elder’s movement. A signal is sent from the sensor to the microcontroller.
The motion sensor uses infrared technology and is also known as passive infrared (PIR) sensor. It is mounted on a printed circuit board (PCB) with the necessary components to interpret detected motion signals from the pyroelectric device. It contains crystalline material that produces an electric charge when exposed to infrared radiation. The voltages generated are measured by an amplifier. As the infrared signals change rapidly, the amplifier trips the output to indicate motion. The sensor can be calibrated by turning the potentiometer and measuring the output via a voltmeter. Calibration is important as it determines the sensitivity
22
BME 499 Capstone Project of the motion detection. The sensor has a range of approximately 7 metres and is 180 degrees in terms of sensitivity width.
A plastic window which prevents insects or dust from obstructing motion detection is also implemented. It is transparent to infrared radiation and is useful in eliminating false alarms. A special filter called Fresnel lens which is molded onto this window focuses the infrared signals onto the element.
There are 3 pins on the motion sensor PCB; +, - and OUT which are interpreted and connected to +V, GND and output respectively. A ribbon cable is used to connect the 3 pins to the prototyping board to allow the motion sensor to be placed a distance (Figure 3.11).
Motion
Sensor
Ribbon
Cable
Figure 3.11: Motion Sensor Layout
3.8
Serial Port RS-232
The serial port panel consists of a MAX232 IC chip, four 0.1
F capacitors and two serial
DB-9 pin connectors. The RS-232 acts as a connector for the microcontroller to communicate to transmit and receive data [12].
Pins 11 (Tx) and 12 (Rx) of the MAX232 chip are connected to pins 25 and 26 of the microcontroller respectively. Pins 13 and 14 are connected to pins 2 and 3 of the DB-9 pin connectors. Input voltages of +5V and -5V are needed for the operation of this IC chip. Pin 2 is to receive data and pin 3 is to transmit data. Pin 5 of the DB-9 connectors are shorted to ground. The Max232 serves as a driver for the transmitting and receiving of data.
The male DB-9 connector and gives output to the PC and the female connector gives output to the modem. The RJ-11 is connected to the microcontroller as a gateway for the
23
BME 499 Capstone Project
PIC18F4520 and MPLAB ICD2 to communicate with each other. This setup can be seen in
Figure 3.12. Figure 3.13 shows a DB09 connector pin connections.
MAX23
2 circuit
RJ-11 connecto r
DB-09 connecto
FEMAL rs
E
MALE
Figure 3.12: Layout of RS-232
Figure 3.13: DB-09 Connector Pins Layout
3.9
GSM/GPRS Modem
The GSM modem chosen for this project is the BluOcean GSM/GPRS modem (Figure 3.14).
The reason for choosing this brand/type is because it uses a serial interface, provides GSM and is also dual band [13]. The components that come as the modem panel are: a) Dual band GSM modem (frequency at 900MHz or 1800MHz) b) Antenna c) Cable-RS232 (D-9 Male to Female)
The antenna has to be screwed onto the modem and with the cable provided the modem is then connected to the male DB-9 connector on the prototype as shown in Figure 3.15. In
24
BME 499 Capstone Project order to use this modem, a SIM card has to be inserted into the slot and allows the sending of
SMS. The modem requires a power supply of 5V to 24V and an external AC/DC adapter is used. The modem acts as a gateway between the target board to send out SMS to a mobile phone.
Figure 3.14: Insertion of SIM Card into GSM Modem
Modem
SIM card
Figure 3.15: Connection of GSM modem to Target Board
25
BME 499 Capstone Project
3.10
Prototype
All the required components are assembled and integrated on the board. Together with the modem, the completed prototype of the Elderly
Activity Monitoring System is produced as shown in Figure 3.16.
Voltage regulator
RESET
Button
RS-232 RJ-11 connector
9V battery
Motion
Sensor
Panic
Button
LEDs Buzzer
DB-09 connectors
Figure 3.16: Completed Prototype 26
BME 499 Capstone Project
This chapter will discuss on the software of the system. Individual components’ programs are tested out as separately as the prototype develops. Therefore, hardware and software developments can be done concurrently.
4.1
Software Design (Flow Chart)
Software development is done in stages and indirectly depends on the hardware development.
The flow chart below shows the process of the software development of the project.
Simple system programming to familiarize with MPLab. Integrate LEDs and buzzer into hardware.
Motion Sensor Program:
To check working sensor input/output
Modem Program:
To check if SMS/HyperTerminal messages can be sent.
Integrate and implement program towards the objectives of the project
Final Testing. Integration Complete. System
Complete.
Figure 4.1: Flow of Software Development
27
BME 499 Capstone Project
4.2
MPLAB IDE
MPLAB Integrated Development Environment (IDE) is a free software program used for the development of applications for Microchip microcontrollers and digital signal controllers. It runs on Windows operating system on PC. Software components that come with this program can be used for fast debugging and development of applications. Users can write and debug
PIC microcontroller applications through system programming languages such as C language, C++ language and assembly language and using MPLAB C compiler to convert into these languages.
4.2.1
Exploring MPLAB IDE
The MPLAB IDE main window (Figure 4.2) contains the following features: a) Workspace window; to display added program files and dialogs b) Output window; to display application development processes c) Menu toolbar; for users to interact and control d) Status bar; to display the status of the application
Figure 4.2 MPLAB IDE Main Window
4.2.2
MPLAB Configurations
The version of MPLAB IDE software used for this project is version 8.46. A few changes in the settings have to be configured before writing the application program. This is important
28
BME 499 Capstone Project as the prototype components will determine the type of configuration such as the PIC microcontroller model and type of oscillator used. Figure 4.3 shows the selection of microcontroller used for this project which is PIC18F4520.
Figure 4.3: Selection of Device Dialog
Next, the configuration bits are configured depending on the components of the prototype used. For example, as the project uses a 4MHz crystal (XT) oscillator, the setting is changed to XT and a few other changes are made as shown in Figure 4.4.
Figure 4.4: Configuration Bits
29
BME 499 Capstone Project
4.3
Software Programming
After the completion of the hardware of each prototype’s main components, software programming is done based on the hardware created.
4.3.1
LED
Programming the LEDs can be considered as the most basic in this project. Ports D pins 0 to
3 of the microcontroller control the output of the LEDs. Therefore, the program has to initialize the port before the writing of the main program. Figure 4.6 shows the setting of
TRISD pins 0 to 7 as outputs. To activate the lighting up of the LEDs, port D must be set to
‘1’ from ‘O’. This can be done as shown in Figure 4.5.
Start
#include <p18f4520.h>
#include <delays.h> void main () {
TRISD = 0x00; //Set PortD as output
PORTD=0xFF; //Set LEDs to light up
Delay10KTCYx(100); //Delay 100ms
}
Initialize Ports
Send logic ‘1’ to LED
Call delay
End
Figure 4.5: LEDs program
4.3.2
Buzzer
As the buzzer has a similar functional output as the LEDs, the same program can be used to test it. The buzzer is connected to Port D pin 4 of the microcontroller. To trigger the buzzer alarm, TRISD is first set as outputs ‘0x00’ and ‘0xFF’ is input to the port as shown in Figure
4.6.
#include <p18f4520.h>
#include <delays.h> void main () {
TRISD = 0x00; //Set PortD as output
PORTD=0xFF; //Set Buzzer to sound
Delay10KTCYx(100); //Delay 100ms
}
Start
Initialize Ports
Send logic ‘1’ to buzzer
Call delay
End
Figure 4.6: Buzzer program
30
BME 499 Capstone Project
4.3.3
Panic Button
The panic button controls the output of the LEDs and buzzer and gives an input signal to send an alert. When the button is pressed, there is a switch from ‘0’ to ‘1’ for the outputs. The button is connected to Port C pin 3 of the microcontroller. Therefore, Ports C and D are initialized to 0 and TRISC as input ‘0xFF’ and TRISD as output ‘0x00’. The program recognizes the input as ‘0’ as the switch is connected to 5V (ACTIVE HIGH). When RC3
(button) is activated and has an input ‘0’, Port D outputs (LEDs and buzzer) are triggered as shown in Figure 4.7.
Start
Initialize Ports
#include <p18f4520.h>
#include <delays.h> unsigned char i; void main () {
PORTC = 0; // Initializing ports
PORTD = 0;
TRISC = 0xFF;
TRISD = 0x00;
// If button is pressed, toggle PORTD content while(1)
{
// Set RC3 as input
//Set RD0-RD4 as output if (PORTCbits.RC3==0)
{
PORTD = 0xFF;
}
}
} else
{
PORTD = 0x00;
}
Define inputs/outputs
Panic button program
Send Alert:
Light up LEDs
Sound Buzzer
Figure 4.7: Panic button program
Button pressed?
End
YES
NO
4.3.4
Motion Sensor
The motion sensor is the main element of the monitoring system. As it is very sensitive to movement, the voltage measurement during calibration setting (no movement) is subjective as lighting in the room can affect the measurement. Therefore, the voltage measurement ranges from between 3.3V to 3.7V. When there is movement, the voltage changes to approximately 4.3V. It is connected to Port C pin 2 of the microcontroller and gives an input signal to send SMS. For testing purposes, the sensor will signal the output of the LEDs and buzzer. Therefore, Ports C and D are initialized to 0 and TRISC as input ‘0b10111111;’ and
31
BME 499 Capstone Project
TRISD as output ‘0x00’. The program recognizes the input as ‘1’ and Port D outputs (LEDs and buzzer) are triggered as shown in Figure 4.8.
#include <p18f4520.h>
#include <delays.h> unsigned char i; void main () {
PORTC = 0; // Initializing ports
PORTD = 0;
TRISC = 0b10111111; // Set RC2 as input
TRISD = 0x00; //Set RD0-RD4 as output
// If motion is detected, toggle PORTD content while(1)
{ if (PORTCbits.RC2==1)
{
PORTD = 0xFF;
} else
{
PORTD = 0x00;
}
}
}
Figure 4.8: Motion Sensor program
Start
Initialize Ports
Define inputs/outputs
Motion sensor program
Motion detected?
Send Alert:
Light up LEDs
End
YES
NO
4.3.5
GSM/GPRS Modem
The GSM Modem receives the signal from the motion sensor or panic button via the
PIC18F4520 microcontroller. It then sends the SMS/HyperTerminal messages to the respective people involved. To communicate with the mobile phone, a SIM card is used. A
Universal Synchronous Asynchronous Receiver Transmitter (USART) module also known as
Serial Communication Interface (SCI) is used for this stage of programming. AT commands are implemented into the program in order to send the messages. The following Table 4.1 shows the different AT commands available and used in the programming of this project.
32
BME 499 Capstone Project
AT command Indication
+CMGS
+CNMI
+CMGC
+CMGW
+CMGL
Send message
Notify newly received messages
Send command
Write message to memory
Read message from memory
+CMSS Send message from storage
Table 4.1: Types of AT commands
Testing of the GSM modem and the AT commands is done by using the Tera Term software as HyperTerminal has been phased out of Windows Vista. The software has to be configured to the following settings shown in Figure 4.9. This testing process (Figure 4.10) enables the testing of the modem’s functionality and the suitable AT commands that can be incorporated to program the microcontroller. A part of the microcontroller programming is shown in
Figure 4.11.
Figure 4.9: Tera Term Serial Port Setup
33
BME 499 Capstone Project
Figure 4.10: Testing of GSM Modem putrsUSART((const far rom char *)"AT\r\n"); while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"AT+CMGF=1\r\n"); //check later can remove or not? while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"AT+CNMI=2,1,0,0,1\r\n"); //setting for reading SMS while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"AT+CMGS=\"93381842\"\r\n"); while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"Panic \x1A"); while(!BusyUSART());
Delay10KTCYx(30);
Figure 4.11: Modem program
4.3.6
Completed software design
After designing the software for the individual modules, the program is ready to be encoded into the microcontroller for the integration with the completed hardware. First, the input/output ports are initialised. Then, it checks the type of condition met. If motion sensor
34
BME 499 Capstone Project is pressed, LEDs light up and SMS is sent. If not, it checks if panic button is pressed, LEDs and buzzer are triggered and SMS is sent. If both conditions are not met, the program goes into a loop and checks the conditions again. Figure 4.12 below illustrates the flow process of the program for this project. The complete program code can be seen in Figure 4.13.
Start
Light up
LEDs
Send SMS
Send Alert
Yes
Initialization of I/O ports
Motion Sensor
Pressed?
No
Yes
Light up
LEDs
Sound Buzzer
Send SMS
Send Alert
Panic Button
Pressed?
No
LOOP
Figure 4.12: Flow chart of Software Programming
35
BME 499 Capstone Project
#include<p18f4520.h>
#include<delays.h>
#include <stdio.h>
#include <string.h>
#include <usart.h>
#include <stdlib.h>
#pragma config WDT = OFF void init(void); void motion(void); void panic(void); void main(){ int result, a=0; unsigned char i;
ADCON0=0b00000101;
ADCON1=0b00001101;
ADCON2=0b00000100;
TRISA =0b11111111;
TRISD =0b00000000;
PORTB = 0x00;
TRISC = 0b10111111;
SPBRG = 25;
TXSTA = 0b00100100;
RCSTA = 0b10010000;
ADCON1= 0x0F;
//initialization of ports while(1) {
if (PORTCbits.RC3 == 0)
panic();
else if (PORTCbits.RC2 == 1){
Delay10KTCYx(200);
motion();
else
PORTD = 0b00000000;
}
}
}
void panic(void){
//RC3 is for panic button (pin 18) putrsUSART((const far rom char *)"AT\r\n"); while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"AT+CMGF=1\r\n"); while(!BusyUSART());
Delay10KTCYx(30); while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"AT+CNMI=2,1,0,0,1\r\n");
//check system condition
//panic button pressed?
//motion detected?
//check later can remove?
//setting for reading SMS putrsUSART((const far rom char *)"AT+CMGS=\"93381842\"\r\n"); //mobile number to send to while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"Panic \x1A"); //message to be sent
36
BME 499 Capstone Project while(!BusyUSART());
}
Delay10KTCYx(30);
TRISA = 0b11110001;
PORTD = 0b11111111; void motion(void){
// RC2 (pin 17) is for Motion Sensor
PORTCbits.RC2 = 1; putrsUSART((const far rom char *)"AT\r\n"); while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"AT+CMGF=1\r\n"); while(!BusyUSART());
Delay10KTCYx(30);
//led and buzzer trigger
//check later can remove? putrsUSART((const far rom char *)"AT+CNMI=2,1,0,0,1\r\n"); //setting for reading SMS while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"AT+CMGS=\"93381842\"\r\n"); //mobile number to send to while(!BusyUSART());
Delay10KTCYx(100); putrsUSART((const far rom char *)"Motion detected! \x1A"); while(!BusyUSART());
//message to be sent
Delay10KTCYx(200);
TRISA = 0b11110001;
PORTD= 0b00001111;
PORTCbits.RC2 = 0;
Delay10KTCYx(100);
}
//led and buzzer trigger
//reset motion sensor
Figure 4.13: Completed Program Code
37
BME 499 Capstone Project
This chapter will discuss on the integration of the hardware and software of the system.
Components such as the power supply, LEDs, buzzer, motion sensor and GSM modem are first integrated and tested individually followed by as a whole system.
5.1
MPLAB IDE
The integration of the hardware and software of the system is accomplished by the use of
MPLAB IDE software, a PC, the ICD 2 device and the completed prototyping board. These components are connected properly before programming of the microcontroller can proceed or else an error of target device detection is shown. Figure 5.1 shows a successful connection was established. The ports for each modules of the system are selected and initialized as either input/output (Table 5.1).
Figure 5.1: MPLAB successful connection with target board
38
BME 499 Capstone Project
Port Pin
MCLR 1
VDD 11/32
VSS 12/31
OSC1 13
Component
Reset button
5V
GND
XT
Port
RD0 19
RD1 20
RD2
RD3
Pin
21
22
Component
LED (red)
LED (green)
LED (yellow)
LED (red)
OSC2 14
RC6
RC7
25
26
XT
TX
RX
RD4
RC2
RC3
23
17
18
Table 5.1: Components and corresponding ports/pins
Buzzer
Motion Sensor
Panic Button
5.2
LEDs and Buzzer
The LEDs and buzzer are part of the alert module of the system. They are triggered whenever the panic button or motion sensor is activated. They were tested using the panic button by executing the program previously stated in Chapter 4. The program runs under debugging mode. The four LEDs lit up and the buzzer sounded the alarm successfully when the panic button is pressed as shown in Figure 5.2.
Figure 5.2: LEDs and Buzzer Testing
5.3
Motion Sensor
To test the functioning of the motion sensor, the LEDs and buzzer are used. When the program is executed, the LEDs and buzzer are triggered successfully (Figure 5.3). Tuning to
39
BME 499 Capstone Project the potentiometer on the motion sensor PCB was done as the LEDs and buzzer were triggered too frequently because of the sensitivity of the sensor.
Figure 5.3: Motion Sensor Testing
5.4
GSM modem
The purpose of the GSM modem is to send out SMS and HyperTerminal messages successfully. It receives the signal from the activation of the panic button when it is pressed and the motion sensor when motion is detected. To test, two different programs are created; panic button and motion sensor. If panic button is pressed, the LEDs and buzzer are triggered and an SMS is sent out. The same scenario happens when motion is detected.
After successfully executing the two programs, an ‘else if’ command is incorporated into the
C program. This allows the two conditions to be tested on a ‘loop’ (Figure 5.4). Two types of
SMS are sent; ‘PANIC’ and ‘Motion detected’ corresponding to the different activations
(Figure 5.5).
40
BME 499 Capstone Project while(1) {
if (PORTCbits.RC3 == 0)
panic();
else if (PORTCbits.RC2 == 1){
Delay10KTCYx(200);
motion();
}
else
PORTD = 0b00000000;
}
}
void panic(void){
//RC3 is for panic button (pin 18) putrsUSART((const far rom char *)"AT\r\n"); while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"AT+CMGF=1\r\n"); while(!BusyUSART());
Delay10KTCYx(30);
//check later can remove or not? putrsUSART((const far rom char *)"AT+CNMI=2,1,0,0,1\r\n"); //setting for reading SMS while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"AT+CMGS=\"93381842\"\r\n"); while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"Panic \x1A"); while(!BusyUSART());
Delay10KTCYx(30);
TRISA = 0b11110001;
PORTD = 0b11111111;
} void motion(void){
// RC2 (pin 17) is for Motion Sensor
PORTCbits.RC2 = 1; putrsUSART((const far rom char *)"AT\r\n"); while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"AT+CMGF=1\r\n"); while(!BusyUSART());
Delay10KTCYx(30);
//check later can remove or not? putrsUSART((const far rom char *)"AT+CNMI=2,1,0,0,1\r\n"); //setting for reading SMS while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"AT+CMGS=\"93381842\"\r\n"); while(!BusyUSART());
Delay10KTCYx(100); putrsUSART((const far rom char *)"Motion detected! \x1A"); while(!BusyUSART());
Delay10KTCYx(200);
TRISA = 0b11110001;
PORTD= 0b00001111;
PORTCbits.RC2 = 0;
Delay10KTCYx(100);
}
Figure 5.4: GSM modem testing with panic button and motion sensor
41
BME 499 Capstone Project
Figure 5.5: ‘Panic’ and ‘Motion detected!’ messages received
5.5
Integration of the Elderly Activity Monitoring System
The different modules of the system are assembled and tested out separately for easy troubleshooting. After this process, the program is programmed into the microcontroller so debugging mode will not be required. First, when panic button is pressed, the LEDs light up and buzzer alarms off and ‘Panic’ SMS is sent. Then, when motion is detected, the LEDs light up and buzzer alarms off and ‘Motion is detected’ SMS is sent. The software program goes into a loop so that it is able to determine the type of execution to be carried out by distinguishing the conditions of the inputs. Figure 5.6 shows a demonstration of how the system works with the following modules:
1) Power Supply
2) Panic Button
3) Motion Sensor
4) GSM Modem
5) LEDs and Buzzer
42
BME 499 Capstone Project
3
1
4
2
5
Figure 5.6: Elderly Activity Monitoring System
43
BME 499 Capstone Project
Designing the hardware from scratch is a tedious process. First, the schematics of each module’s circuit are drawn out. Then, the components are sourced and purchased. Finally, the modules’ components are planned out on the prototyping board and soldered. The software development was delayed due to unavailable components for the modules and troubleshooting.
6.1
Problems Encountered and Solutions
Problem 1:
PIC18F4520 microcontroller was unavailable.
Solution:
As this model of the PIC18F family of microcontrollers is popular among the students, it was out of stock during the period of sourcing. Order was placed and item only arrived a week later.
Problem 2:
Hardware components were unavailable. Online orders delayed.
Solution:
Some of the hardware components needed were not sold at the retail shops in Sim Lim
Tower. These components had to be purchased from online stores such as Farnell [7]. The order process took a few days before the delivery. Hardware development was delayed and indirectly affected the software development. Time for designing the hardware and soldering was adjusted to fit into the dateline.
44
BME 499 Capstone Project
Problem 3:
MPLAB ICD2 cannot connect with target device.
Solution:
After connecting the prototyping board to the computer via the ICD2 device, the connection stated on the MPLAB IDE software was ‘Failed Self Test. See ICD2 Settings (status tab) for details’ and under the Settings display was ‘Target Vdd: Low, Module Vpp: Pass, MCLR
Gnd: Pass, MCLR Vdd: Low, MCLR Vpp: Pass’. Troubleshooting was done by comparing connectivity between ICD2 and the PICDEM board and it was successful. After researching online, it was found out that it is a common problem because the pins of the RJ-11 connector were not connected properly and resoldering was done to wire the correct connections.
Problem 4:
Motion sensor was not working properly.
Solution:
During the testing of motion sensor, the LEDs and buzzer were integrated as part of the module. The LEDs did not light up and the buzzer failed to alarm off. Troubleshooting begins with reading up on the motion sensor PCB board. Apparently, there is a potentiometer which can be adjusted to calibrate the sensitivity of the motion sensor. After adjusting, the module was tested and worked successfully.
Problem 5:
GSM modem connection cannot be established.
Solution:
During testing of the GSM modem, Tera Term and AT commands were used. The Tera Term program did not detect the serial connection despite the cable connectors already plugged in and settings configured. A digimeter was used to eliminate short circuits and making sure the connections between the two ports were correct. It was found out that pins 2 and 3 were connected wrongly. Resoldering of the wires connection was done and the serial connection was successful.
45
BME 499 Capstone Project
Problem 6:
Motion detected SMS keeps sending.
Solution:
After integrating the completed hardware prototype and software program, the motion sensor was tested. However, instead of just one SMS, over 10 SMS for ‘Motion detected’ were received even though delay was introduced to the program. After a discussion with the supervisor, it was found out that the motion sensor has a wide range and can detect any slight movement in the room. A slight adjustment to the potentiometer to reduce the sensitivity was done and problem is solved. Changes were also made to the software program when two
SMS messages were received instead of the intended one SMS. The motion sensor input value was set to ‘0’ immediately after the command of sending SMS.
6.2
Recommendations for Future Developments
Recommendation 1:
A LCD display on the monitoring system can provide visual aids to the elderly. Simple operational commands can be displayed to guide the person using the system.
Recommendation 2:
As the sound of the buzzer is deemed soft for the community to hear, an amplifier can be introduced to make it louder. Implementing frequency based sound waves by software programming can also make the sound more distinctive.
Recommendation 3:
A DC power supply via an AC/DC adapter can be used in the case that the battery runs out and the monitoring system stops working.
Recommendation 4:
A false alarm panel which excludes false positive alerts can be included in the system so the elderly can initiate to stop the sending of alert.
46
BME 499 Capstone Project
Recommendation 5:
Instead of sending SMS when a motion is detected, the system can implement a different mode which sends SMS when a motion is not detected within a certain period of time. This eliminates false positive sending of alerts as the motion sensor is very sensitive to movement.
47
BME 499 Capstone Project
The project is targeted to be completed by November 2010 with final report to be submitted by November 2010. The initial agreed date of submission and presentation was
November/December 2010 but was brought forward. Therefore, the scheduled plan is compressed overlapping some tasks to be done concurrently. The project tasks checklist was planned out. With the help of a Gantt chart and Pert chart, it is easier to keep track on the project’s development. Troubleshooting the hardware and software delayed the progress and affected the charts. Therefore, it is important to update the charts on as the project progresses.
7.1
PROJECT TASKS
1
TASKS
First Phase
Capstone Project Briefing.
Supervisor Session: Discussion about the project, its objectives
2 Research on programming languages, microcontrollers
3 Research on available monitoring systems in the market
4 Literature review: Journals, books & online websites
5 Supervisor Session: Discussion on project proposal
6 Preparation of Project Proposal
7 Submission of Project Proposal
8
Second Phase
Supervisor Session: Development of project after submission of Project Proposal & Components confirmation and introduction into Software Development
9 Source for prototype components & Purchase
10 Source for PICkit (debugger) & GSM modem
11 Source for Microcontroller & Purchase
12 Design the layout of the PCB and solder the components
13
Supervisor Session: Interim Report, Designing Hardware and
Software Development
14 Source for Motion Sensor
START
8
6
7
8
13
END th Feb 13 th Feb th Feb 13 th Feb
10 th th
Feb 20 th
16 th Feb 8
Mar 8 th
Feb th Feb 13 th Feb th Mar
Mar
20 th Mar 20 th Mar
21 st Mar 3 rd Apr
27 th Mar 27 th Mar
3 rd Apr 3 rd Apr
2 nd Apr 20 th Apr
20 th th
Feb
Apr
6
20 th th
Feb
Apr
22 nd Apr 22 nd Apr
TIME
1
1
14
1
1
19
1
1
1
21
1
7
6
11
Table 7.1: Project Tasks (First & Second Phase)
48
BME 499 Capstone Project
Third Phase
15 Preparation of Interim Report
16 Submission of Interim Report
Learn the Microcontroller software and implement basic
17 programs onto prototype
18 Supervisor Session: Project Development
19
20
21
Implementation of software using basic programs with the following hardware components:
Microcontroller, Panic Button, LEDs & Buzzer
Fourth Phase
Implementation of software using basic programs with the following hardware components:
Microcontroller, Motion sensor, LEDs & Buzzer
Supervisor Session: Development of project
Discussion: Troubleshooting of prototype, software programming
22
Implementation of software using basic programs with the following hardware components:
Microcontroller, Motion sensor, GSM modem, PC
23 Source for Serial to USB Cable
24
Capstone Briefing
Supervisor Session:
Troubleshooting of prototype
Discussion: Preparation of Final Report
25 Preparation of Final Report: Chapters 1, 2 & References
26
27
Supervisor Session:
Troubleshooting of prototype
Discussion: Preparation of Final Report
Solder DB-09 connector for PC interface with prototype
Integrate and test for connection and ability to read message
28
Supervisor Session:Troubleshooting of prototype (Tera
Term)
Discussion: Preparation & Review of Final Report
1 st May 8 th May
10 th May 10 th May
11 th May 20 th May
21
28
20
9
10
7
14
15
24
15
25 st May 21 th th th th th th th th
May 30
June 10
July 9
July 20
Aug 7
Aug 14 st May th th th July th th
Aug 15
Aug 24 th Sep 20 th Sep 25 th th th
June
July
July
Aug
Aug
Sep
Aug th Sep th Sep
1
32
20
1
10
1
1
30
1
5
1
8
1
10
Table 7.2: Project Tasks (Third & Fourth Phase)
49
BME 499 Capstone Project
Final Phase
30 Preparation of Final Report: Chapters 3, 4 & 5
31 Final troubleshooting and improvement of prototype
32 Preparation of Final Report: Chapters 6, 7, 8 & 9
33
Supervisor Session:
Troubleshooting of prototype (Serial PC to prototype board)
Discussion: Review of Final Report and Poster Presentation
34 Finalize final report & send for binding
35 Submission of Final Report
36 Design poster & send for printing
37 Design poster & send for printing
36 Poster Presentation
25
25
13
26 th Sep 10 th Sep 25 th th
Oct 23
Oct 26 th Oct th Sep rd th
Oct
Oct
26 th Oct 7 th Nov
15 th Nov 15 th Nov
30 th Oct 10 th Nov
15 th Nov 15 th Nov
27 th Nov 27 th Nov
Table 7.3: Project Tasks (Final Phase)
15
1
10
1
11
1
10
1
1
50
BME 499 Capstone Project
7.2
PERT CHART
Figure 7.1: Pert Chart
51
BME 499 Capstone Project
7.3
GANTT CHART
Figure 0.2: Gantt Chart
52
BME 499 Capstone Project
The main reason for this project choice was because the objectives interest me. After the project objectives were further discussed, research on elderly activity monitoring systems available in the market began. Comparisons were made to give ideas on how to further improve the project.
As microcontroller programming is involved, reading up on programming languages was the next step. I am not well versed in programming and have lost touch with it since polytechnic.
Therefore, I spent most of the time researching on programs’ sample codes. Resources used for this project came mainly from the Internet, journals and electronics books. C programming language is quite an old language as most are using C++ instead making sourcing for books on C programming difficult. I only managed to borrow a few books from the library and journals which offer free viewing are limited, making Internet the main source instead for the hardware schematics and C programming codes.
For the hardware part, I read notes and books on Microcontroller Technology and Circuits
Analysis from polytechnic. References from the Internet were not reliable enough as they can be edited without authorization. Schematic diagrams from various sources were compiled and analyzed on the suitability for the project. Careful soldering and wire connection were done to avoid damaging the circuit.
Integrating the hardware and software did not go smoothly. Troubleshooting was hard as it had to be done separately. I have lack of sources for troubleshooting such as digimeter and wire-wrapping tool which were not purchased due to cost restraint. They are available only at
UniSIM but since I stay quite a distance from UniSIM, it was difficult due to time constraints.
Progress of the project development was rough initially due to unfamiliarity and prototype was not working properly at times. During the later stages, I was more confident of the
53
BME 499 Capstone Project working prototype and the development falls back on track with the help of my supervisor.
After many trials and errors and months of developing and troubleshooting, the prototype of the Elderly Activity Monitoring System was successfully created.
54
BME 499 Capstone Project
This project has given me quite an experience. It was draining both physically and mentally but the final product was a reward in the end. Although I am taking two modules for this semester’s course of study, I also have other activities including work which take up a lot of my time. Therefore, targets to be met were set on the Gantt chart for easier tracking.
Given more time and resources, this project can expand with better innovations such as LCD display, timer and a more visual and amplified alarm system. However, there are benefits that can be gained from this project which include project and time management skills, better understanding of monitoring systems and improved knowledge of C programming, electronics and hardware design.
Overall, due to the project’s interesting objectives, there were many facts like the types of monitoring systems available, engineering of motion sensors and use of the GSM/GPRS modem that can be learnt. The exposure to hardware and software design can be applied to general knowledge and practical use. The use of project management software for planning learnt from this project can be utilized in the future for work.
Total number of words: 8898 words
55
BME 499 Capstone Project
[1] Sensors Help keep the Elderly Safe, and at Home http://www.nytimes.com/2009/02/13/us/13senior.html?_r=3
Accessed on: 09 th
February 2010
[2] How Infrared detector components work http://www.glolab.com
Accessed on: 11 th
February 2010
[3] Elderly Monitoring http://www.williamson-labs.com/elderly-main.htm
Accessed on: 12 th
February 2010
[4] GE Healthcare http://www.gehealthcare.com
Accessed on: 12 th
February 2010
[5] Healthsense Technology http://www.healthsense.com
Accessed on: 12 th
February 2010
[6] Microchip Technology Inc. http://www.microchip.com
Accessed on: 13 th February 2010
[7] Farnell Electronics http://www.farnell.com
Accessed on: 15 th
February 2010
[8] Motion Sensor Reference http://www.euclidres.com
Accessed on: 20 th
February 2010
56
BME 499 Capstone Project
[9] SMS Tutorial: Introduction to wireless modems, GSM modems and GPRS modems http://www.developershome.com
Accessed on: 10 th
March 2010
[10] PC serial port http://pinouts.ru/SerialPorts/Serial9_pinout.shtml
Accessed on: 20 th March 2010
[11] The PIC Tutorial http://www.pictutorials.com
Accessed on: 8 th
April 2010
[12] Test & Measurement World http://www.tmworld.com
Accessed on: 20 th
April 2010
[13] Bluocean http://www.bluocean.biz
Accessed on: 25 th
April 2010
[14] The RS-232 Standard http://www.camiresearch.com/Data_Com_Basics/RS232_standard.html
Accessed on: 17 th
July 2010
[15] C for Dummies 2 nd Edition, Dan Gookin: For Dummies, 2004
[16] Microelectronics : circuit analysis and design, Donald A. Neamen, New York:
McGraw-Hill, 2010
[17] PIC microcontroller, an introduction to software and hardware interfacing, Han-Way
Huang, Clifton Park, N.Y.: Thomson/Delmar Learning,2005
57
BME 499 Capstone Project
[18] Problem solving and program design in C, Jeri R. Hanly, Elliot B. Koffman,
Boston Singapore : Addison-Wesley, 2010
[19] The Quintessential PIC Micro-controller (Computer, Communications and Networks),
Sidney J. Katsen, Ireland: Springer, 2003
[20] The PIC Microcontroller: Your Personal Introductory Course, Third Edition, John
Morton: Newnes, 2005
[21]
MPLAB IDE, User’s Guide, Microchip Technology Incorporated, 2007
[22] MPLAB IDE, Quick Start Guide, Microchip Technology Incorporated, 2007
[23] MPLAB ICD 2 In-Circuit Debugger User’s Guide, Microchip Technology
Incorporated, 2007
[24] Home Monitoring Systems for the Elderly and Handicapped
Author: Cindy Wright 2006
[25] Domestic Behavior Monitoring System for Elderly People
Author: Matsuda Hiroshi, Yamaguchi Shoichi, Arakawa Tadahiro (Matsushita Electric
Works, Ltd., JPN) 2003
[26] Muscle strength, activity, housing and the risk of falls in elderly people
Author: Wickham C, Cooper C, Margetts BM, Barker DJP 1989
[27] Falls Among Institutionalised Psycho-Geriatric Patients
Author: K D Lim, K C Ng, S K Ng, L L Ng (Institute of Mental Health), Vol.42, 2001
[28] Epidemiology of Falls Among the Elderly Community Dwellers in Singapore
Author: K M Chan, W S Pang, C H Ee, Y Y Ding, P Choo (Singapore Medical
Journal) 1997
58
BME 499 Capstone Project
[29] Implementation of a Physical Activity Monitoring System for the Elderly People with
Built in Vital Sign and Fall Detection
Author: Anh Dinh Teng, D. Li Chen Yang Shi McCrosky, C. Basran, J. Del Bello-
Hass,V (Univ. of Saskatchewan, Saskatoon, SK) 2009
[30] An Advanced Wireless Sensor Network for Health Monitoring
Author: G. Virone, A. Wood, L. Selavo, Q. Cao, L. Fang, T. Doan, Z. He, R. Stoleru,
S. Lin, and J.A. Stankovic (Department of Computer Science, University of Virginia)
2006
59
BME 499 Capstone Project
S/N
1
2
5
6
3
4
7
8
9
10
Items
GSM Modem
Motion Sensor
Components (resistors, capacitors and etc.)
PIC18F4520
Wires(wrapping and solder)
9V Batteries
Connectors (DIP sockets, DB-09 and RJ-11)
Serial-to-USB cable
SIM card
PICDEM Board and ICD2
Total
Price
$200
$25
$23
$20
$6
$6
$7
$23
$10
$200
$510
60
BME 499 Capstone Project
APPENDIX A: Program Source Code
Program Source Code (Part 1)
#include<p18f4520.h>
#include<delays.h>
#include <stdio.h>
#include <string.h>
#include <usart.h>
#include <stdlib.h>
#pragma config WDT = OFF void init(void); void motion(void); void panic(void); void main(){ int result, a=0; unsigned char i;
ADCON0=0b00000101;
ADCON1=0b00001101;
ADCON2=0b00000100;
TRISA =0b11111111;
TRISD =0b00000000;
PORTB = 0x00;
TRISC = 0b10111111;
SPBRG = 25;
TXSTA = 0b00100100;
RCSTA = 0b10010000;
ADCON1= 0x0F; while(1) {
if (PORTCbits.RC3 == 0)
panic();
else if (PORTCbits.RC2 == 1){
Delay10KTCYx(200);
motion();
}
else
PORTD = 0b00000000;
}
}
//initialization of ports
//check system condition
//panic button pressed?
//motion detected?
61
BME 499 Capstone Project
Program Source Code (Part 2)
}
void panic(void){
//RC3 is for panic button (pin 18) putrsUSART((const far rom char *)"AT\r\n"); while(!BusyUSART());
Delay10KTCYx(30); while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"AT+CMGF=1\r\n"); //check later can remove or not? putrsUSART((const far rom char *)"AT+CNMI=2,1,0,0,1\r\n"); while(!BusyUSART());
Delay10KTCYx(30);
//setting for reading SMS putrsUSART((const far rom char *)"AT+CMGS=\"93381842\"\r\n"); //mobile number to send to while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"Panic \x1A"); while(!BusyUSART());
Delay10KTCYx(30);
//message to be sent
TRISA = 0b11110001;
PORTD = 0b11111111; //led and buzzer trigger void motion(void){
// RC2 (pin 17) is for Motion Sensor
PORTCbits.RC2 = 1; putrsUSART((const far rom char *)"AT\r\n"); while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"AT+CMGF=1\r\n"); while(!BusyUSART());
Delay10KTCYx(30); putrsUSART((const far rom char *)"AT+CNMI=2,1,0,0,1\r\n"); while(!BusyUSART());
Delay10KTCYx(30);
//check later can remove or not?
//setting for reading SMS putrsUSART((const far rom char *)"Motion detected! \x1A"); while(!BusyUSART());
Delay10KTCYx(200);
TRISA = 0b11110001;
PORTD= 0b00001111;
PORTCbits.RC2 = 0;
Delay10KTCYx(100);
} putrsUSART((const far rom char *)"AT+CMGS=\"93381842\"\r\n"); //mobile number to send to while(!BusyUSART());
Delay10KTCYx(100);
//message to be sent
//led and buzzer trigger
//reset motion sensor
62
BME 499 Capstone Project
APPENDIX B: Schematic Diagram of Hardware
63
BME 499 Capstone Project
APPENDIX C: Datasheets
PIC18F5420 Microcontroller
64
BME 499 Capstone Project
Enhanced Universal Synchronous Asynchronous Receiver Transmitter (EUSART) module
Transmitter:
Receiver:
65
BME 499 Capstone Project
Motion Sensor
66
BME 499 Capstone Project
67
BME 499 Capstone Project
MAX232
68
BME 499 Capstone Project
69
BME 499 Capstone Project
GSM Modem
70
BME 499 Capstone Project
PICDEM
TM
Demonstration Board
71
BME 499 Capstone Project
72
BME 499 Capstone Project
APPENDIX D: Meeting Logs
Meeting No: 01
Venue: UniSIM
Date: 06/02/2010
Time: 12:15PM
Discussion:
Objective of project was to develop a monitor system for the elderly when they are alone.
Data such as routines would be logged, activated before use and information would be sent via SMS or PC.
To build a working prototype using motion sensor, modem, microcontroller and software such as C program and Visual Basic.
Action items:
To build a working prototype of motion sensor using microcontroller and circuitry e.g resistors, capacitors
To buy components
To program a motion sensor using C program
To retrieve data using Visual Basic
Areas to improve:
Prototype must use minimal components to fit onto the wall/ceiling
Sensor used is either ultrasound/infrared, cost must be considered (ultrasound>infrared)
Meeting No:
02 Date: 19/02/2010
Venue: TP Time: 5:45PM
Discussion:
Preparation of Project Proposal (guidelines such as it should be technical, provide an overall understanding of the activity monitoring system, analysis of components, use of flowcharts/tables/Gantt chart)
Discussion of units such as LCD, motion sensor, microcontroller, modem, serial phone/PC, programming languages etc.
Discussion on project targets.
Action items:
To research on LCD, motion sensors, microcontrollers and other components. Analyze, compare and decide compatibility and suitability of each unit.
To complete and submit Project Proposal by 8 th
March 2010
Creating Gantt Chart
Selecting and sourcing of components to commence soon
Meeting No: 03 Date: 20/03/2010
Venue: UniSIM Time: 10:30AM
Discussion:
Research on MPLAB software, components list (e.g resistors, capacitors, ICs, modem) needed was done.
Discussion of units such as motion sensor, microcontroller, modem, component ts, programming languages etc. Discussion on hardware circuits schematics and project targets.
Action items:
To purchase hardware components from Sim Lim Tower and Farnell.
Solder components onto prototyping board.
Download software (MPLAB) and create basic programs such as LED, Reset and Motion
Sensor detection.
Programming skills, and integration of hardware and software to be improved.
73
BME 499 Capstone Project
Meeting No: 04
Venue: TP
Date: 20/04/2010
Time: 18:00PM
Discussion:
Research on MPLAB software, components list (e.g resistors, capacitors, ICs, modem) needed was done.
Discussion on project targets, change in project objective.
Interim report preparation.
Action items:
Create basic programs such as LED, Reset and Motion Sensor detection and implement on hardware.
Interim report submission.
Meeting No:
05 Date: 21/05/2010
Venue: TP Time: 16:00PM
Discussion:
Research on MPLAB software, components list needed was done.
Hardware components bought and soldered.
Discussion on project targets.
Possible short circuit of prototype circuit board.
Claims form preparation.
Action items:
Eliminate the source of short circuit in the prototyping board.
Create and integrate basic programs such as LED, Reset and Motion Sensor detection and implement on hardware
Meeting No: 06 Date: 09/07/2010
Venue: TP Time: 16:00PM
Discussion:
Hardware & software integration was done.
Discussion on project targets.
Software integration for LEDs and Buzzer onto prototyping board.
Programming of sending alert SMS and HyperTerminal through TMAS modem.
Action items:
Discussion on project targets.
Software integration for LEDs and Buzzer onto prototyping board.
Programming of sending alert SMS and HyperTerminal through TMAS modem.
Integrate Motion Sensor detection and TMAS modem with hardware/software.
Complete the prototyping circuit and test if it is working properly.
Final year report preparation.
74
BME 499 Capstone Project
Meeting No: 07
Venue: UniSIM
Date: 14/08/2010
Time: 11:00AM
Discussion:
Troubleshooting on prototype.
Motion sensor was not detecting movement and sending SMSes.
Working motion sensor, panic alarm and modem.
Program was edited and prototype was able to work.
Programming of sending alert SMS and HyperTerminal through TMAS modem.
Action items:
Integrate Motion Sensor detection and TMAS modem with hardware/software.
Test the prototyping board if it is working properly.
Final year report preparation.
Meeting No: 08 Date: 24/08/2010
Venue: TP Time: 16:00PM
Discussion:
Troubleshooting on prototype. Motion sensor keeps sending SMSes.
Working motion sensor, panic alarm and modem.
Program was edited; delay introduced, forced motion sensor input reset and prototype was able to work.
Programming of sending alert SMS and HyperTerminal through TMAS modem.
Preparation of Final Report.
Action items:
Integrate Motion Sensor detection and TMAS modem with hardware/software.
Test the prototyping board if it is working properly.
Final year report preparation.
Meeting No: 09 Date: 25/09/2010
Venue: UniSIM Time: 10:30AM
Discussion:
Introducing sending of SMS to PC: Tera Term software was downloaded.
Connection between PC and GSM modem successful established.
Able to send SMS from PC.
Preparation of Final Report. Review of final report progress (chapter 1 & 2)
Action items:
Solder DB-09 connector onto prototyping board. Integrate PC with prototype via serial-USB cable. Test the prototyping board if message can be read from Tera Term.
Final year report preparation.
Meeting No:
10 Date: 26/10/2010
Venue: TP Time: 17:00PM
Discussion:
Troubleshooting of prototype. Cannot receive HyperTerminal messages through Tera Term.
Review of Final Report
Action items:
Check connections and test the prototyping board if message can be read from Tera Term.
Final year report preparation.
Poster preparation.
75
BME 499 Capstone Project
GLOSSARY
CPU
EEPROM
EUSART
IDE
GSM
GPRS
I/O
ICD
PIR
LED
PC
RXD
Serial Port
SIM
TXD
VDD
Central Processing unit
Electrically Erasable Programmable Read-Only Memory
Enhanced Universal Asynchronous Receiver Transmitter
Integrated Development Environment
Global System for Mobile
General Packet Radio Service
Input or Output
In-Circuit Debugger
Passive Infrared Radiation
Light Emitting Diode
Personal Computer
Receiving Data
Serial communication interface
Subscriber Identity Module
Transmitting Data
Voltage Drain Drain
76