Documente Academic
Documente Profesional
Documente Cultură
FROM:
Engr Rana Muhammad Shakeel
Engnr.shakeel@gmail.com
https://www.facebook.com/EngnrShakeel
plz like my page:
https://www.facebook.com/Electrical4Electronics
For MORE PROJECTS:
http://electro-technolgy.blogspot.com
CHAPTER 1
INTRODUCTION
Cardiovascular disease is one of the main causes of death in the many countries and
in 1999, it accounted for over 15 million deaths worldwide. In addition, several million
people are disabled by cardiovascular disease (WHO, 1999). The delay between the first
symptom of any cardiac ailment and the call for medical assistance has a large variation
among different patients and can have fatal consequences. One critical inference drawn
from epidemiological data is that deployment of resources for early detection and
treatment of heart disease has a higher potential of reducing fatality associated with
cardiac disease than improved care after hospitalization. Hence new strategies are needed
in order to reduce time before treatment. Monitoring of patients is one possible solution.
Also, the trend towards an independent lifestyle has also increased the demand for
personalized non-hospital based care.
This project Heart beat monitoring by GSM technology can be used in hospitals
and also for patients who can be under continues monitoring while traveling from place to
place. Since the system is continuously monitoring the patient and in case of any
abnormal in the heart beat rate of the patient the system will immediately message to the
concerned doctors and relatives about the condition of the patient and abnormal details.
To perform these operations the system uses heart beat sensor, GSM modem, and to
control all these devices the heart of the system micro controller (P89V51RD2) is used.
Page
Page
CHAPTER 2
SYSTEM DESCRIPTION
2.1 INTRODUCTION
Embedded systems are one of the emerging technologies which are touching every
nook and corner of the mind. It is impossible to live without these embedded gadgetssays ELECTRONICS magazine. From the above statement, the liveliness of embedded
system can be understood. Data communications is one of the most rapidly growing
commercial market areas today, especially wireless communications. In the past few
years, wireless data communications has grown from an obscure and expensive curiosity
into a practical and affordable communication and networking technology.The
convenience of wireless is very appealing as not to deal with running cables to and from
devices in order to interconnect them, and wireless devices can be moved to any location
within the transmission range, while still being able to communicate and broadcast data.
Due to this, it is expected that wireless data communications will become even more
popular and more extensively used in the medical field. Currently the most popular
method of wireless communications is radio frequency transmission. As these devices
have a very low power consumption and power output, perhaps more importantly devices
can achieve good data transmission rates.
Micro controller
P89V51RD2
Heart Beat
Sensor
B.L.D.E.As College of Engg & Tech.,Dept. of E&C
Page
Oscillato
r
RS 232
Serial
Switcher
GSM
Modem
Regulate
DC Power
Supply
Receiver
Mobile
2.2.2 MICROCONTROLLER
The microcontroller used is P89V51RD2 operates at 11.0592 MHz at 5V D.C.
Microcontroller controls all the operation. The microcontroller obtains the input from the
heart beat sensors and monitors the heart beat rate.
Page
Page
CHAPTER 3
HARDWARE DESCRIPTION
3.1 POWER SUPPLY
The transformer 230Volts will be stepped down to 12-0-12 one side of the 12V is
given to the 7805 and Lm317.In this project the microcontroller requires +5V power
supply. The design description of power supply is given below.
The +5 Volt and 3.8V power supply is based on the commercial 7805 & Lm317
voltage regulator IC. This IC contains all the circuitry needed to accept any input voltage
from 8 to 18 volts and produce a steady +5 volt & 3.8volt output, accurate to within 5%
(0.25 volt). It also contains current-limiting circuitry and thermal overload protection, so
that the IC won't be damaged in case of excessive load current; it will reduce its output
voltage instead.
B.L.D.E.As College of Engg & Tech.,Dept. of E&C
Page
Page
Page
80C51 CPU
5 V operating voltage from 0 MHz to 40 MHz
16/32/64 kB of on-chip flash user code memory with ISP and IAP
Supports 12-clock (default) or 6-clock mode selection via software or ISP
SPI and enhanced UART
PCA with PWM and capture/compare functions
Four 8-bit I/O ports with three high-current port 1 pins (16 mA each)
Three 16-bit timers/counters
Programmable watchdog timer
Eight interrupt sources with four priority levels
Second DPTR register
Low EMI mode (ALE inhibit)
Brownout detection
Low power modes
Power-down mode with external interrupt wake-up
Idle mode
Page
P89V51RB2/RC2/RD2
Page
Page
Access to the IAP routines in block 1 may be enabled by clearing the BSEL bit
(FCF.0), provided that the SWR bit (FCF.1) is cleared. Following a power-on sequence,
the boot code is automatically executed and attempts to auto baud to a host. If no auto
baud occurs within approximately 400 ms and the SoftICE flag is not set, control will be
passed to the user code. A software reset is used to accomplish this control transfer and as
a result the SWR bit will remain set. Therefore the user's code will need to clear the SWR
bit in order to access the IAP routines in block 1. However, caution must be taken when
dynamically changing the BSEL bit. Since this will cause different physical memory to be
mapped to the logical program address space, the user must avoid clearing the BSEL bit
when executing user code within the address range 0000H to 1FFFH.
Power-on reset code execution
At initial power up, the port pins will be in a random state until the oscillator has
started and the internal reset algorithm has weakly pulled all pins high. Powering up the
B.L.D.E.As College of Engg & Tech.,Dept. of E&C
Page
cleared
by
software.
Following
power-on
or
external
reset
the
P89V51RB2/RC2/RD2 will force the SWR and BSEL bits (FCF[1:0]) = 00. This causes
the boot block to be mapped into the lower 8 kB of code memory and the device will
execute the ISP code in the boot block and attempt to auto baud to the host. If the auto
baud is successful the device will remain in ISP mode. If, after approximately 400 ms, the
auto baud is unsuccessful the boot block code will check to see if the SoftICE flag is set
(from a previous programming operation). If the SoftICE flag is set the device will enter
SoftICE mode. If the SoftICE flag is cleared, the boot code will execute a software reset
causing the device to execute the user code from block 0 starting at address 0000H. Note
that an external reset applied to the RST pin has the same effect as a power-on reset.
Page
Software reset
A software reset is executed by changing the SWR bit (FCF.1) from 0 to 1. A
software reset will reset the program counter to address 0000H and force both the SWR
and BSEL bits (FCF[1:0]) = 10. This will result in the lower 8 kB of the user code
memory being mapped into the user code memory space. Thus the user's code will be
executed starting at address 0000H. A software reset will not change WDTC.2 or RAM
data. Other SFRs will be set to their reset values.
Brownout detect reset
The device includes a brownout detection circuit to protect the system from severe
supply voltage fluctuations. The P89V51RB2/RC2/RD2's brownout detection threshold is
2.35 V. When VDD drops below this voltage threshold, the brownout detect triggers the
circuit to generate a brownout interrupt but the CPU still runs until the supplied voltage
returns to the brownout detection voltage VBOD. The default operation for a brownout
detection is to cause a processor reset. VDD must stay below VBOD at least four
oscillator clock periods before the brownout detection circuit will respond. Brownout
interrupt can be enabled by setting the EBO bit (IEA.3). If EBO bit is set and a brownout
condition occurs, a brownout interrupt will be generated to execute the program at
location 004BH. It is required that the EBO bit be cleared by software after the brownout
interrupt is serviced. Clearing EBO bit when the brownout condition is active will
properly reset the device. If brownout interrupt is not enabled, a brownout condition will
reset the program to resume execution at location 0000H. A brownout detect reset will
Page
Page
Page
Page
SPI
SPI features
Master or slave operation
10 MHz bit frequency (max)
LSB first or MSB first data transfer
Four programmable bit rates
B.L.D.E.As College of Engg & Tech.,Dept. of E&C
Page
SPI
allows
high-speed
synchronous
data
transfer
between
the
Watchdog timer
The device offers a programmable Watchdog Timer (WDT) for fail safe protection
against software deadlock and automatic recovery. To protect the system against software
deadlock, the user software must refresh the WDT within a user-defined time period. If
the software fails to do this periodical refresh, an internal hardware reset will be initiated
if enabled (WDRE = 1). The software can be designed such that the WDT times out if the
program does not work properly.
B.L.D.E.As College of Engg & Tech.,Dept. of E&C
Page
Power-saving modes
The device provides two power saving modes of operation for applications where
power consumption is critical. The two modes are Idle and Power-down.
Idle mode
Idle mode is entered setting the IDL bit in the PCON register. In Idle mode, the
program counter (PC) is stopped. The system clock continues to run and all interrupts and
peripherals remain active. The on-chip RAM and the special function registers hold their
data during this mode The device exits Idle mode through either a system interrupt or a
hardware reset. Exiting Idle mode via system interrupt, the start of the interrupt clears the
IDL bit and exits Idle mode. After exit the Interrupt Service Routine, the interrupted
program resumes execution beginning at the instruction immediately following the
instruction which invoked the Idle mode. A hardware reset starts the device similar to a
power-on reset.
Power-down mode
The Power-down mode is entered by setting the PD bit in the PCON register. In
the Power-down mode, the clock is stopped and external interrupts are active for level
B.L.D.E.As College of Engg & Tech.,Dept. of E&C
Page
By default, the device runs at 12 clocks per machine cycle (X1 mode). The device
has a clock doubling option to speed up to 6 clocks per machine cycle . Clock double
mode can be enabled either by an external programmer or using IAP. When set, the EDC
bit in FST register will indicate 6-clock mode. The clock double mode is only for
doubling the internal system clock and the internal flash memory, i.e. EA = 1. To access
B.L.D.E.As College of Engg & Tech.,Dept. of E&C
Page
Page
action
of
the
heart
can
be
seen
on
the
graph.
Page
APPLICATIONS
Page
PIN DETAILS:
Board has 3-pin connector for using the sensor. Details are marked on PCB as below.
Page
WORKING
The sensor consists of a super bright red LED and light detector. The LED needs
to be super bright as the maximum light must pass spread in finger and detected by
detector. Now, when the heart pumps a pulse of blood through the blood vessels, the
finger becomes slightly more opaque and so less light reached the detector. With each
heart pulse the detector signal varies. This variation is converted to electrical pulse. This
signal is amplified and triggered through an amplifier which outputs +5V logic level
signal. The output signal is also indicated by a LED which blinks on each heart beat.
Page
The pulse signal is applied to the P1.0 input of U2 that is AT89S52 (Can be any
8051 type) which is monitored by the program whenever this input goes high. Internally
to U2, there is a counter which counts how many 1ms intervals there are between two
high going heart beat pulses. This number is then divided by 60,000 and the result is the
pulse rate. For example, if the pulse rate is 60 BPM (beats per minute) there will be a
pulse every second. The duration of one heart beat will be one seconds or 1000 x 1ms.
Dividing 60,000 by 1000 will give the correct result of 60 which is shown on the display.
If there is invalid result (BPM>200) it is invalid and waits for next cycle.
Page
P 0.5
D7
P 0.4
D6
P 0.3
D5
P 0.2
P 0.1
D4
LCD
EN
P 0.0
RS
Microcontroller
Page
Page
3.5. GSM
GSM (Global System for Mobile Communications originally from Group Special
Mobile) is the most popular standard for mobile telephony systems in the world. The
GSM Association, its promoting industry trade organization of mobile phone carriers and
manufacturers, estimates that 80% of the global mobile market uses the standard.
The ubiquity of implementation of the GSM standard has been an advantage to
both consumers, who may benefit from the ability to roam and switch carriers without
replacing phones, and also to network operators, who can choose equipment from many
GSM equipment vendors.
Newer versions of the standard were backward-compatible with the original GSM
system. For example, Release '97 of the standard added packet data capabilities by means
of General Packet Radio Service (GPRS). Release '99 introduced higher speed data
transmission using Enhanced Data Rates for GSM Evolution (EDGE).
3.5.1The GSM Network Circuit Switching Domain:
The GSM network was designed keeping in mind the voice activities of the user
and its main purpose was to provide voice connectivity like Public Switched Telephone
Networks but with mobility. The data communication was of secondary importance to this
network but to support this also, designers have considered the circuit switching itself the
mechanism for transmitting data packets.
Page
Handset
HLR/
VLR
UM
A-bis
BSC
MSC
SS7
PSTN
BTS
X.25
OMC
(Operation & Maintenance
Center)
Operation
Terminal
SIM
card
Mobile
station
Radio
sub-system
Network sub-system
Data Terminal
PSTN
Page
OFF
ON
Flashing Slowly
Flashing rapidly
Now every embedded system is used to communicate with other system using
GSM and GPRS technology, In this project MODEM is used to access the message sent
by the user to display in doctors mobile.
3.5.4 AT COMMANDS:
1 AT commands features:1.1 Wavecom line settings
A serial link handler is set with the following default values (factory settings):
auto baud, 8 bits data, 1 stop bit, no parity, RTS/CTS flow control. Please use the +IPR,
+IFC and +ICF commands to change these settings.
1.2 Command line
Commands always start with AT (which means ATtention) and finish with a <CR>
character.
1.3 Information responses and result codes
Responses start and end with <CR><LF>, except for the ATV0 DCE response format)
and the ATQ1 (result code suppression) commands.
If command syntax is incorrect, an ERROR string is returned.
If command syntax is correct but with some incorrect parameters, the +CME
ERROR: <Err> or +CMS ERROR: <SmsErr> strings are returned with
different error codes.
Page
If the SIM detect pin indicates absent, the response to AT+CPIN? is +CME
ERROR 10 (SIM not inserted).
If the SIM detect pin indicates present, and the inserted Card is a SIM Card, the
Response to AT+CPIN? is +CPIN: xxx depending on SIM PIN state.
If the SIM detect pin indicates present, and the inserted Card is not a SIM Card,
the response to AT+CPIN? is CME ERROR 10.
These last two states are not given immediately due to background initialization.
Between the hardware SIM detect pin indicating present and the previous results the
AT+CPIN? Sends +CME ERROR: 515 (Please wait, init in progress). When the SIM
detect pin indicates card absence, and if a SIM Card was previously inserted, an IMSI
detach procedure is performed, all user data is removed from the product (Phonebooks,
SMS etc.). The product then switches to emergency mode.
2.2 Background initialization
After entering the PIN (Personal Identification Number), some SIM user data files are
loaded into the product (Phonebooks, SMS status, etc.). Please be aware that it might take
some time to read a large phonebook. The AT+CPIN? Command response comes just
after the PIN is checked. After this response user data is loaded (in background). This
means that some data may not be available just after PIN entry is confirmed by OK. The
reading of phonebooks will then be refused by
B.L.D.E.As College of Engg & Tech.,Dept. of E&C
Page
3 General commands
3.1 Select TE character set +CSCS
3.1.1 Description:
This command informs the ME which character set is used by the TE. The ME can
convert each character of entered or displayed strings. This is used to send, read or write
short messages. See also +WPCS for the phonebooks character sets.
3.1.2 Syntax:
Command Syntax: AT+CSCS=<Character Set>
COMMAND
POSSIBLE
RESPONSES
AT+CSCS=GSM
OK
OK
Page
Page
4.2.2 Syntax:
Command Syntax: AT+CREG= <mode>
Response Syntax: +CREG : <mode>, <stat> [ ,<lac>,<ci> ] for AT+CREG? Command only
COMMAND
POSSIBLE
RESPONSES
AT+CREG?
+CREG: <mode>,<stat>
OK
OK
OK
OK
Note: Command valid
+CREG: (0-2)
Description:
This command is used by the application to send the text message of the product.
5.1 Syntax:
Command Syntax: AT+CMGS= <mode>
Page
COMMAND
POSSIBLERESPONSES
AT+CMGS?
+ CMGS: <mode>,<stat>
OK
OK
OK
CHAPTER 4
SOFTWARE DESCRIPTION
4.1 SOFTWARE USED
4.1.1 KEIL SOFTWARE
The KEIL 8051 Development Tools are designed to solve the complex problems
facing embedded software developers.In this project we select the KEIL software of
B.L.D.E.As College of Engg & Tech.,Dept. of E&C
Page
4.1.2 EMBEDDED C
The C programming language is perhaps the most popular programming language
for programming embedded systems. Most C programmers are spoiled because they
program in environments where not only there is a standard library implementation, but
there are frequently a number of other libraries available for use. The cold fact is, that in
embedded systems, there rarely are many of the libraries that programmers have grown
used to, but occasionally an embedded system might not have a complete standard library,
if there is a standard library at all. Few embedded systems have capability for dynamic
linking, so if standard library functions are to be available at all, they often need to be
directly linked into the executable. Oftentimes, because of space concerns, it is not
possible to link in an entire library file, and programmers are often forced to "brew their
own" standard c library implementations if they want to use them at all. While some
libraries are bulky and not well suited for use on microcontrollers, many development
systems still include the standard libraries which are the most common for C
programmers.
C remains a very popular language for micro-controller developers due to the code
efficiency and reduced overhead and development time. C offers low-level control and is
considered more readable than assembly. Many free C compilers are available for a wide
variety of development platforms. The compilers are part of an IDEs with ICD support,
breakpoints, single-stepping and an assembly window. The performance of C compilers
has improved considerably in recent years, and they are claimed to be more or less as
good as assembly, depending on who you ask. Most tools now offer options for
B.L.D.E.As College of Engg & Tech.,Dept. of E&C
Page
4.2 PROGRAM
#include<p89v51rd2.h>
//#include<Reverse.c>
#define LINE1_ADDR
#define LINE2_ADDR
sbit LCD_CS
sbit REG_SELECT
#define NULL_00
#define CONTRL_Z
#define RELOADLOW0
#define RELOADHI0
sbit ext =P3^2;
sbit TEST =P2^0;
0x80
0xC0
= P3^4;
= P3^5;
'\0'
0x1A
0x59
0xDC
#define MAX_RECD_CHAR
120
#define NULL_00
'\0'
#define CARRIAGE_RETURN
0X0D
#define END_OF_LINE
'\n'
#include<define.h>
static unsigned char ucsthreadState = INIT_STATE;
unsigned char code ucOwnerMGMTNum1[] = "AT+CMGS=\"+919686044657\"\r";
unsigned char code ucOwnerMGMTNum2[] = "AT+CMGS=\"+919945345959\"\r";
void ClearRecdCharArray(void);
void TxdCommandToModem(unsigned char *s);
void Sms_CommandToModem(unsigned char *s, unsigned char ucMGMTIndex);
bit mystr_recdchar_ncmp(unsigned char *chkString, unsigned char StrLength);
void check_Modem(void);
void check_SIM_SIMPIN(void);
void SIM_REG(void);
void SIM_MODEM_INIT_CHECK(void);
void LCD_INIT(void);
void write_instr_bit(unsigned char value);
void Prep_lcd_Write_Data(unsigned char *line1, unsigned char Line1Addr, unsigned char *line2,
unsigned char Line2Addr);
void MSDelay(unsigned int delay);
void MSDelay_lcd(unsigned int delay);
unsigned char i,j,ucbcd100,ucbcd10,ucbcd1,buffer[15]=" ";
void serial_Init(void);
void byte_hex_to_bcd_conversion(unsigned int);
unsigned char Actual_KeyData,temp100,temp10,temp1;
static unsigned int xttemp;
static unsigned char xdata ucpulseCount=0,timecount=0,stop=0;
unsigned char recd_count = 0;
bit gbok_flag = 0;
unsigned char xdata ABNORM[15]="ABNORMAL ";
unsigned char xdata NORM[15]="NORMAL ";
Page
Page
Page
Page
Page
Page
}
void TxdCommand(unsigned char *s)
{
while(*s!=NULL_00)
{
SBUF = *s;
MSDelay(1);
s++;
}
SBUF = CARRIAGE_RETURN;
SBUF = END_OF_LINE;
MSDelay(10);
}
Page
void check_Modem(void)
{
unsigned char count = 0;
gbok_flag = 0;
while(1)
{
ClearRecdCharArray();
recd_count=0;
TxdCommandToModem("AT\r\n");
gbok_flag = mystr_recdchar_ncmp("OK",2);
if(gbok_flag)
break;
count++;
if(count == 10)
{
Prep_lcd_Write_Data("Modem init",LINE1_ADDR, "Fail", LINE2_ADDR);
}
}
}
void SIM_REG(void)
{
unsigned char count = 0;
gbok_flag = 0;
ClearRecdCharArray();
recd_count = 0;
while(1)
{
MSDelay(100);
Prep_lcd_Write_Data("Network",LINE1_ADDR, "Searching.......", LINE2_ADDR);
TxdCommandToModem("AT+CREG?\r\n");
MSDelay(20);
gbok_flag = mystr_recdchar_ncmp("+CREG:0,1",9);
if(gbok_flag)
break;
gbok_flag = mystr_recdchar_ncmp("+CREG:0,5",9);
if(gbok_flag)
break;
ClearRecdCharArray();
recd_count = 0;
count++;
if(count == 180)
Prep_lcd_Write_Data("Network",LINE1_ADDR, "Reg Failed", LINE2_ADDR);
}
}
Page
void ClearRecdCharArray(void)
{
unsigned char gucloop;
for(gucloop=0; gucloop<=MAX_RECD_CHAR; gucloop++)
recd_char[gucloop] = NULL_00;
}
void Sms_CommandToModem(unsigned char *s, unsigned char ucMGMTIndex)
{
Prep_lcd_Write_Data("Sending.SMS.....",LINE1_ADDR,"", LINE2_ADDR);
if(ucMGMTIndex == 1)
{
Prep_lcd_Write_Data("Sending.SMS.....",LINE1_ADDR,&ucOwnerMGMTNum1[9],
LINE2_ADDR);
TxdCommandToModem(&ucOwnerMGMTNum1[0]);
}
if(ucMGMTIndex == 2)
{
Prep_lcd_Write_Data("Sending.SMS.....",LINE1_ADDR,&ucOwnerMGMTNum2[9],
LINE2_ADDR);
TxdCommandToModem(&ucOwnerMGMTNum2[0]);
}
MSDelay(50);
ClearRecdCharArray();
recd_count = 0;
while(*s!=NULL_00)
{
SBUF = *s;
MSDelay(1);
s++;
}
SBUF = CONTRL_Z;
Page
", LINE2_ADDR);
MSDelay(50);
ClearRecdCharArray();
recd_count = 0;
}
void TxdCommandToModem(unsigned char *s)
{
while(*s!=NULL_00)
{
SBUF = *s;
MSDelay(1);
s++;
}
SBUF = CARRIAGE_RETURN;
SBUF = END_OF_LINE;
MSDelay(10);
}
PUL SEC
PULSTR
Page
4.4.APPLICATIONS
It can be used in hospitals, may be in ICU or general wards so that always a bulky
ECG unit is not required.
It can also be employed in the houses so that the doctor can come to know about
the abnormalities when away.
The use of GSM technology simplifies the delivery of health care services and
enhances communication between health care providers and their patients.
CHAPTER 5
Page
Page
Page
CHAPTER 6
Page
7.REFERENCES
Kenneth J. Ayala The 8051 Microcontroller Architecture, Programming and
Applicatins, 2nd Edition, Penarm International, 1996
Muhammad Ali Mazidi an Janice Gillispie The 8051 Microcontroller
Architecture and Embedded systems, Pearson Education, pearson Eduction, 2003
Boylested and Nashelsky- Electronic Devices and Circuit Theory, EEE, 8th
Edition 2002
Gsm Technology By Lokesh Raghavan
Electronics For You - Magazine
www.Wikipidea.com
www.google.com
Page