Patient Monitoring System Project Report Original
Patient Monitoring System Project Report Original
1. INTRODUCTION
The main objective is to design a Patient Monitoring System to diagnose the health
condition of the patients. Giving care and health assistance to the bed ridden patients at
critical stages with advanced medical facilities have become one of the major problems in
the modern hectic world. In hospitals where a large number of patients whose physical
conditions have to be monitored frequently as a part of diagnostic procedure, the need for a
cost effective and fast responding alert mechanism is inevitable. Proper implementation of
such systems can provide timely warnings to the medical staffs and doctors and their service
can be activated
in case of medical emergencies. Present-day systems use sensors that are hardwired to a PC
next to the bed. The use of sensors detects the conditions of the patient and the data is
collected and transferred using a microcontroller. Doctors and nurses need to visit the
patient frequently to examine his/her current condition. In addition to this, use of multiple
microcontroller based intelligent system provide high level applicability in hospitals where
a large number of patients have to be frequently monitored. For this, here we use the idea of
network technology with wireless applicability, providing each patient a unique ID by
which the doctor can easily identify the patient and his/her current status of health
parameters. Using the proposed system, data can be sent wirelessly to the Central Patient
Monitoring System (CPMS), allowing continuous monitoring of the patient. Contributing
accuracy in measurements and providing security in proper alert mechanism give this
system a higher level of customer satisfaction and low cost implementation in hospitals.
Thus the patient can engage in his daily activities in a comfortable atmosphere where
distractions of hardwired sensors are not present. Physiological monitoring hardware can be
easily implemented using simple interfaces of the sensors with a Microcontroller and can
effectively be used for healthcare monitoring. This will allow development of such low cost
devices based on natural human-computer interfaces. The system we proposed here is
efficient in monitoring the different physical parameters of many number bedridden patients
and then in alerting the concerned medical authorities if these parameters bounce above its
predefined critical values. Thus remote monitoring and control refers to a field of industrial
automation that is entering a new era with the development of wireless sensing devices.
2. LITERATURE SURVEY
2.1. Development and Clinical Evaluation of a Home Healthcare System
Measuring in Toilet, Bathtub and Bed without Attachment of Any
Biological Sensors
Kosuke Motoi, Mitsuhiro Ogawa, Hiroshi Ueno, Seiji Fukunaga, Tadahiko Yuji, Yuji
Higashi,Shinobu Tanaka, Toshiro Fujimoto, Hidetsugu Asanoi, and Ken-ichi Yamakoshi,
Member, IEEE
Daily monitoring of health condition at home is important for an effective scheme for early
diagnosis, treatment and prevention of lifestyle-related diseases such as adiposis, diabetes
and cardiovascular diseases. While a number of commercially available devices for home
health care monitoring are widely used, those are actually cumbersome in terms of selfattachment of biological sensors and self-operation of them. From this viewpoint, we have
been developing a non-conscious physiological monitoring system without attachment of
any
sensors to the human body as well as any operations for the measurement. We developed
some devices installed in a toilet, a bath, and a bed and showed their high measurement
precision by comparison with simultaneous recordings of ordinary biological sensors
directly attached to the body. In order to investigate those applicability to the health
condition monitoring, we developed a monitoring system in combination with all of the
monitoring devices at hospital rooms and previously carried out the measurements of
patients' health
condition. Further in this study, the health conditions were measured in 10 patients with
cardiovascular disease or sleep disorder. From these results, the patients' health conditions
such as the body and excretion weight in the toilet, the ECG during taking the bath and the
pulse and respiration rate during sleeping were successfully monitored in the hospital room,
demonstrating its usefulness for monitoring the health condition of the subjects with
cardiovascular disease or sleep disorder.
3. EXISTING SYSTEM
In the existing system, we use active network technology to network various sensors to a
single PMS. Patients various critical parameters are continuously monitored via single
PMS and reported to the Doctors or Nurses in attendance for timely response in case of
critical situations. Our NWSPMS has the following basic components:
Various sensors attached to the body of the patient.
Microcontrollers for analog signal interface
Wireless transmitting and receiving system for data transfer.
A functional wireless network for different patients with their unique ID.
A Central Patient Monitoring System (CPMS) observing unit basically a PC.
The sensors are attached to the body of the patients without causing any discomfort
to them. In this NWSPMS we monitor the important physical parameters like body
temperature, ECG, heart beat rate and blood pressure using the sensors which are readily
available. Thus the analog values that are sensed by the different sensors are then given to a
microcontroller attached with it. The microcontroller processes these analog signal values of
health parameters separately and converts it to digital values using ADC converter. Now, the
digitalized values from more than one microcontroller are sent to the CPMS. Each of the
entire sensors attached microcontroller with a transceiver will act as a module which has its
own unique ID. Each module transmits the data wirelessly to the gateway attached to the PC
of the CPMS. The gateway is attached to the PC i.e. CPMS which is situated in the medical
center, is capable for selecting different patient IDs and allowing the gateway to receive
different physical parameter values the patient specified by the ID. The software designed
using Graphical User Interface (GUI) can operate on different physical parameters of each
patient, consecutively with a specified time interval for each patient. At any time any of the
doctors or nurses can log on the CPMS and check the history of the observed critical
parameters of any of the patient attached to the network. A wireless sensor mote is attached
to the sensor set attached to each of the patients. The gateway of the Wireless Sensor
Network is attached to the CPMS.
temperature of the patient will be accurate, and the system allows for continuous monitoring
of a patient's differential change in temperature. The LM335 series are precision, easilycalibrated, integrated circuit temperature sensors. They are two terminal devices like
a zener and have a break down voltage directly proportional to the absolute temperature at
+10mv/K. The LM335 operates in the range of -40C to +100C as given in [6].LM335Z
can measure temperature ranging from -40C to +100C. The output from the temperature
sensor is an analog signal and it is fed into the analog input of the PIC16f877A
microcontroller. Inside the microcontroller, the analog output from each sensor is converted
to a 10 bit digital value using the ADC module present inside the microcontroller. The 10 bit
ADC converted data is sent to the transmitter of the wireless sensor module via RC6 pin of
PIC16F877A using USART module available in the PIC microcontroller.
2) Blood Pressure: Pressure sensors are important in medical conditions where patients
have a frequently varying Blood pressure. These sensors will detect the blood pressure in
the patients body. Adding wireless transmission and networking capability will take it to
the next level of comfort and sophistication for a number of patients. Traditional blood
pressure monitoring requires a cuff, wrapped around the upper arm and inflated until blood
flow is completely cut off. The examiner then gradually releases the pressure, listening to
the flow until the pulse can be detected. With the new monitor as in [4], no cuff is required.
Instead,
the device takes advantage of a method called pulse wave velocity, which allows blood
pressure to be calculated by measuring the pulse at two points along an artery. The two
points decided are two points of index figure. That posed a challenge because blood
pressure in the hand varies depending on its position: If the arm is raised above the heart,
the pressure will be higher than if it is below the heart. The researchers solved that dilemma
by incorporating a sensor that measures acceleration in three dimensions, allowing the hand
position to be calculated at any time. This not only compensates for the error due to height
changes, but also allows them to calibrate the sensor for more accurate calculation of blood
pressure. As the wearer raises the hand up and down, the hydrostatic pressure changes at the
sensor. Correlating the change of pulse wave velocity to the hydrostatic pressure change, the
system can automatically calibrate its measurement. The equivalent analog output signal
will be fed to microcontroller.
3) Heart Rate: Heart rate is the number of heartbeats recorded per minute typically
recorded as Beats per Minute (BPM) as in [7]. In the proposed system, we make use of a
technique called Photoplethysmography (PPG). PPG is a simple and low cost optical
technique that can be used to detect the blood volume changes in the micro vascular bed of
tissues. In this technique, a bright led and a LDR is employed to detect the blood flow at the
finger tip or any other peripheral part of the body. The light from the bright led gets
reflected from the
tissues in the body parts and the amount of light reflected determines the volume of blood
flowing. If more blood flows through it, more light is reflected back. We have to amplify the
signal and remove the unwanted noise signals. For this purpose we make use of operational
amplifiers, LM358. The circuit is shown below :
4. PROPOSED SYSTEM
The main objective is to design a Patient Monitoring System with two way
communication i.e not only the patients data will be sent to the doctor through SMS, but
also doctor can send required suggestions to the patient, which will be displayed on LCD.
10
BLOCK DIAGRAM:
REGULATED
POWER SUPPLY
TEMPERATUR
E SENSOR
MICRO
CONTROLLER
GSM
MODULE
HEARTBEAT
SENSOR
SPO2
MOBILE
LCD
5. MODULES
Mainly the block diagram consists of following parts:
11
Micro Controller
ECG
GSM modem
Temperature sensor
12
The RS232 is the most widely used serial I/O interfacing standard. This is used in
most PCs and numerous types of equipment. Since this standard was introduced long
before the advent of TTL logic family, its input and output voltage levels are not TTL
compatible.
In RS232, a 1 is represented by -3v to -25v, while a 0 bit is +3v to +25v and also
making -3v to +3v is undefined. For this reason, to connect any RS232 to a micro controller
system we must use voltage converts such as MAX232 to convert the TTL logic levels to
the RS232 voltage levels, and vice versa. MAX232 chips are commonly referred to as line
drivers. So to interface any GSM or GPS or RFID or FPRS modules RS232 and MAX232
are the used to interface to the micro controller for serial communication. The line drivers
used for transmitting TXD in MAX232 are T1 (T1-in and T1-out) and T2 (T2-in and T2out). The line drivers used for receiving the data is R1 (R1-in and R1-out) and R2 (R2-in
and R2-out).
For transmitting the data to the other device the TXD pin of UART is connected to
the T1-in pin-11 of MAX-232 and the T1-out pin14 of MAX232 is connected to RXD pin-2
of RS232 and from there data is transmitted to the device through the pin TXD pin-3 of
RS232 cable.
For receiving the data from the device the TXD pin-2 of RS232 is connected to the
R1-in pin-13 of MAX232 and the R1-out pin-12 is connected to the RXD pin of UART of
the controller hence the data is received by the controller.
Interfacing GSM to the LPC2148 micro controller:
The GSM modem interfaced to controller through MAX-232 and RS-232 cable. The
GSM modem works by using AT commands. The GSM modem is initialized by using AT
commands in code. For sending the message, receiving messages, message format and for
deleting message everything is done by executing AT commands, for each and every task
there is separate AT commands.
AT+CMGF
=
AT+CMGS
AT+CMGR
AT+CMGL
1
=
=
for
formatting
message
mobile
number
for
sending
message
index
number
for
reading
message
for
listing
all
the
messages
in
inbox
13
ARM Architecture
ARM Architecture & Programming
ARM History
Architecture
Instruction Set
ARM History
The ARM (Acorn RISC Machine) architecture is developed at Acron
Computer Limited of Cambridge, England between 1983-1985. ARM Limited founded in
1990. ARM became as the Advanced RISC Machine
architecture that is widely used in embedded designs. ARM cores licensed to semiconductor
partners who fabricate and sell to their customers.
Today, the ARM family accounts for approximately 75% of all embedded
32-bit RISC CPUs, making it the most widely used 32-bit architecture. ARM CPUs are
found in most corners of consumer electronics, from portable devices (PDAs, mobile
phones, iPods and other digital media and music players, handheld gaming units, and
calculators) to computer peripherals (hard drives, desktop routers).
RISC:
14
pipelining
2.
on register
contents only
3.
4.
32 -bit processor
5.
6.
7.
A Von Neumann architecture store program and data in the same memory area with a single
bus. So this bus only is used for both data transfers and instruction fetches, and therefore
data transfers and instruction fetches must be scheduled - they can not be performed at the
same time. Most of the general-purpose microprocessors such as Motorola 68000 and Intel
80x86 use this architecture. It is simple in hardware implementation, but the data and
program are required to share a single bus.
ARM Processor Core :
The figure shows the ARM core dataflow model. In which the ARM core as
functional units connected by data buses,. And the arrows represent the flow of data, the
lines represent the buses, and boxes represent either an operation unit or a storage area. The
figure shows not only the flow of data but also the abstract components that make up an
ARM core.
15
Bus Master
2.
Bus Slave
1.
Bus Master : A logical device capable of initiating a data transfer with another
device across the same bus (ARM processor core is a bus Master ).
2.
Bus Slave : A logical device capable only of responding to a transfer request from a
2.
Later ARM introduced another bus design called the ARM High performance Bus ( AHB )
Using AMBA
i.
ii.
A Peripheral can simply be bolted on the On Chip bus without having to redesign an
Multi-layer AHB
2.
AHB-Lite
16
ARCHITECTURE Revisions :
Every ARM processor implementation executes a specific instruction set architecture (ISA),
although an ISA revision may have more than one processor implementation
NOMENCLATURE :
ARM uses the nomenclature shown below is to describe the processor
implementations. The letters and numbers after the word ARM indicate the features a
processor may have.
ARM { x }{ y }{ z }{ T }{ D }{ M }{ I }{ E }{J }{ F }{ -S }
x family
y memory management / protection unit
z cache
T Thumb 16 bit decoder
D JTAG debug
M fast multiplier
I EmbeddedICE macrocell
E enhanced instruction ( assumes TDMI )
J Jazelle
F vector floating-point unit
S synthesizible version
All ARM cores after the ARM7TDMI include the TDMI features even though they
The processor family is a group of processor implementations that share the same
hardware characteristics. For example, the ARM7TDMI, ARM740T, and ARM720T all
share the same family characteristics and belong to the ARM7 family
JTAG is described by IEEE 1149.1 standard Test Access Port and boundary scan
architecture. It is a serial protocol used by ARM to send and receive debug information
between the processor core and test equipment
EmbeddedICE macrocell is the debug hardware built into the processor that allows
17
Synthesizable means that the processor core is supplied as source code that can be
Unified bus interface, 32-bit data bus carries both instructions and data
Three-stage pipeline
32-bit ALU
Coprocessor interface
Extensive debug facilities (EmbeddedICE debug unit accessible via JTAG interface
unit)
ARM7TDMI Microcontrollers
1. Available ARM7TDMI Microcontrollers
2. Analog Devices ADuC 7xxx
3. Atmel AT91SAM7
4. Freescale MAC7100
5. NXP/Philips LPC2000
6. ST STR710
7.Texas Instruments TMS470
18
Register r13 is traditionally used as the stack pointer (sp) and stores the head of the
Register r14 is called the link register ( lr ) and is where the core puts the return
Register r15 is the program counter ( pc ) and contains the address of the next
19
Privileged : Full read-write access to the CPSR. Under this we are having Abort, Fast
interrupt request, Interrupt request, Supervisor,System and Undefined
Abort (10111) : when there is a failed attempt to access memory
Fast interrupt Request (FIQ(10001)) & interrupt request(10010) : correspond to interrupt
levels available on ARM
Supervisor mode(10011) : state after reset and generally the mode in which OS kernel
executes
System mode(11111) : special version of user mode that allows full read-write access of
CPSR
Undefined(11011) : when processor encounters an undefined instruction
Non-privileged :- Only read access to the control filed of CPSR but read-write access to the
condition flags.
User(10000): User mode is user for programs and applications. And this the normal mode
Banked Registers :
Register file contains in all 37 registers. 20 registers are hidden from program at different
times. These registers are called banked registers. Banked registers are available only when
the processor is in a particular mode. Processor modes (other than system mode) have a set
of associated banked registers that are subset of 16 register
SPSR:
Each privileged mode (except system mode) has associated with it a Save Program Status
Register, or SPSR. This SPSR is used to save the state of CPSR (Current program status
Register) when the privileged mode is entered in order that the user state can be fully
restored when the user processor is resumed
Mode Changing :
Mode changes by writing directly to CPSR or by hardware when the processor responds to
exception or interrupt. To return to user mode a special return instruction is used that
instructs the core to restore the original CPSR and banked registers.
LPC 2148 MICROCONTROLLER
General description of LPC 2148:
20
21
When the device is reset or power applied, and the EA/ pin is high or at the VPP voltage,
the microcontroller will start executing instructions from either the user code memory space
at address 0000h (normal mode) or will execute instructions from the Bootrom (ISP
mode).
General Overview of IN APPLICATION PROGRAMMING:
Some applications may have a need to be able to erase and program code memory
under the control fo the application. For example, an application may have a need to store
calibration information or perhaps need to be able to download new code portions. This
ability to erase and program code memory in the end-user application is In-Application
Programming (IAP). The Bootrom routines which perform functions on the Flash memory
during ISP mode such as programming, erasing, and reading, are also available to end-user
programs. Thus it is possible for an end-user application to perform operations on the Flash
memory. A common entry point (FFF0h) to these routines has been provided to simplify
interfacing to the end-users application. Functions are performed by setting up specific
registers as required by a specific operation and performing a call to the common entry
point. Like any other subroutine call, after completion of the function, control will return to
the end-users code. The Bootrom is shadowed with the user code memory in the address
range from FC00h to FFFFh. This shadowing is controlled by the ENBOOT bit
(AUXR1.5). When set, accesses to internal code memory in this address range will be from
the boot ROM. When cleared, accesses will be from the users code memory. It will be
NECESSARY for the end-users code to set the ENBOOT bit prior to calling the common
entry point for IAP operations, even for devices with 16 kbyte, 32 kbyte, and 64 kbyte of
internal code memory. (ISP operation is selected by certain hardware conditions and control
of the ENBOOT bit is automatic when ISP mode is activated).
FEATURES OF LPC2148(ARM7) ARCHITECTURE
Key features:
22
loader software, single flash sector or full chip erase in 400 ms and programming of 256 B
in 1 ms.
Embedded ICE RT and Embedded Trace interfaces offer real-time debugging with
the on-chip Real Monitor software and high-speed tracing of instruction execution
USB 2.0 Full-speed compliant device controller with 2 kB of endpoint RAM
DMA
One or two (LPC2141/42 vs, LPC2144/46/48) 10-bit ADCs provide a total of 6/14
analog inputs, with conversion times as low as 2.44 ms per channel Single 10-bit DAC
provides variable analog output (LPC2142/44/46/48 only)
Two 32-bit timers/external event counters (with four capture and four compare
Low power Real-Time Clock (RTC) with independent power and 32 kHz clock input
Multiple serial interfaces including two UARTs (16C550), two Fast I2C-bus (400
kbit/s),
SPI and SSP with buffering and variable data length capabilities
addresses
60 MHz maximum CPU clock available from programmable on-chip PLL with
settling
time of 100 ms
MHz
CPU operating voltage range of 3.0 V to 3.6 V (3.3 V 10 %) with 5 V tolerant I/O pads.
23
BLOCK DIAGRAM:
24
PIN CONFIGURATION:
25
Pin Description:
P0.0 to P0.31 I/O Port 0: Port 0 is a 32-bit I/O port with individual direction controls for
each bit. Total of 31 pins of the Port 0 can be used as a general purpose bidirectional digital
I/Os while P0.31 is output only pin. The operation of port 0 pins depends upon the pin
function selected via the pin connect block.
P0.0/TXD0/PWM1:
P0.0
26
27
P0.7/SSEL0/PWM2/EINT2
P0.7 General purpose input/output digital pin (GPIO)
SSEL0 Slave Select for SPI0, selects the SPI interface as a slave
PWM2 Pulse Width Modulator output 2
EINT2 External interrupt 2 input
P0.8/TXD1/PWM4/AD1.1
P0.8 General purpose input/output digital pin (GPIO)
TXD1 Transmitter output for UART1
PWM4 Pulse Width Modulator output 4
AD1.1 ADC 1, input 1, available in LPC2144/46/48 only
P0.9/RXD1/ PWM6/EINT3:
P0.9 General purpose input/output digital pin (GPIO)
RXD1 Receiver input for UART1
PWM6 Pulse Width Modulator output 6
EINT3 External interrupt 3 input
P0.10/RTS1/ CAP1.0/AD1.2:
P0.10 General purpose input/output digital pin (GPIO)
RTS1 Request to send output for UART1, LPC2144/46/48 only
CAP1.0 Capture input for Timer 1, channel 0
AD1.2 ADC 1, input 2, available in LPC2144/46/48 only
P0.11/CTS1/ CAP1.1/SCL1:
P0.11 General purpose input/output digital pin (GPIO)
CTS1 Clear to send input for UART1, available in LPC2144/46/48 only
CAP1.1 Capture input for Timer 1, channel 1
SCL1 I2C1 clock input/output, open-drain output (for I2C-bus compliance)
P0.12/DSR1/MAT1.0/AD1.3:
P0.12 General purpose input/output digital pin (GPIO)
DSR1 Data Set Ready input for UART1, available in LPC2144/46/48 only
MAT1.0 Match output for Timer 1, channel 0
AD1.3 ADC input 3, available in LPC2144/46/48 only
P0.13/DTR1/ MAT1.1/AD1.4:
28
29
30
31
32
P1.29/TCK
P1.29 General purpose input/output digital pin (GPIO)
TCK Test Clock for JTAG interface
P1.30/TMS
P1.30 General purpose input/output digital pin (GPIO)
TMS Test Mode Select for JTAG interface
P1.31/TRST
P1.31 General purpose input/output digital pin (GPIO)
TRST Test Reset for JTAG interface
D+: USB bidirectional D+ line
D- : USB bidirectional D- line
RESET External reset input: A LOW on this pin resets the device, causing I/O ports and
peripherals to take on their default states, and processor execution to begin at address 0,
TTL with hysteretic, 5 V tolerant
XTAL1: Input to the oscillator circuit and internal clock generator circuits
XTAL2: Output from the oscillator amplifier
RTCX1: I Input to the RTC oscillator circuit
RTCX2: Output from the RTC oscillator circuit
VSS: 6, 18, 25, 42, 50 pins are for supply voltage.
Ground: 0 V reference.
VSSA Analog ground: 0 V reference, this should nominally be the same voltage as VSS, but
should be isolated to minimize noise and error
VDD 23, 43, 51 I 3.3 V power supply: This is the power supply voltage for the core and I/O
ports.
VDDA 7 I Analog 3.3 V power supply: This should be nominally the same voltage as VDD
but should be isolated to minimize noise and error, this voltage is only used to power the onchip ADC(s) and DAC
VREF ADC reference voltage: This should be nominally less than or equal to the
VDD voltage but should be isolated to minimize noise and error, level on this
Pin is used as a reference for ADC(s) and DAC
VBAT RTC power supply voltage: 3.3 V on this pin supplies the power to the RTC.
Functional Description:
33
Architectural Overview:
The ARM7TDMI-S is a general purpose 32-bit microprocessor, which offers
high performance and very low power consumption. The ARM architecture is based on
Reduced Instruction Set Computer (RISC) principles, and the instruction set and related
decode mechanism are much simpler than those of micro programmed Complex Instruction
Set Computers (CISC). This simplicity results in a high instruction throughput.
Essentially, the ARM7TDMI-S processor has two instruction sets:
The standard 32-bit ARM set
A 16-bit Thumb set
The Thumb sets 16-bit instruction length allows it to approach twice the density of standard
ARM code while retaining most of the ARMs performance advantage over a traditional 16bit processor using 16-bit registers. This is possible because Thumb code operates on the
same 32-bit register set as ARM code. Thumb code is able to provide up to 65 % of the code
size of ARM, and 160 % of the performance of an equivalent ARM processor connected to
a 16-bit memory system. The particular flash implementation in the LPC2141/42/44/46/48
allows for full speed execution also in ARM mode. It is recommended to program
performance critical and short code sections (such as interrupt service routines and DSP
algorithms) in ARM mode. The impact on the overall code size will be minimal but the
speed can be increased by 30 % over Thumb mode.
The LPC2141/42/44/46/48 incorporate a 32 kB, 64 kB, 128 kB, 256 kB and 512 kB flash
memory system respectively. This memory may be used for both code and data storage.
Programming of the flash memory may be accomplished in several ways. It may be
programmed In System via the serial port. The application program may also erase and/or
program the flash while the application is running, allowing a great degree of flexibility for
data storage field firmware upgrades, etc. Due to the architectural solution chosen for an onchip boot loader, flash memory available for users code on LPC2141/42/44/46/48 is 32 kB,
64 kB, 128 kB, 256 kB and 500 kB respectively.
The LPC2141/42/44/46/48 flash memory provides a minimum of 100000
erase/write cycles and 20 years of data-retention.
be accessed as 8-bit, 16-bit, and 32-bit. The LPC2141, LPC2142/44 and LPC2146/48
34
Memory Map
The LPC2141/42/44/46/48 memory map incorporates several distinct regions, as
shown below.
Interrupt controller:
The Vectored Interrupt Controller (VIC) accepts all of the interrupt request
inputs and categorizes them as Fast Interrupt Request (FIQ), vectored Interrupt Request
(IRQ), and non-vectored IRQ as defined by programmable settings. The programmable
assignment scheme means that priorities of interrupts from the various peripherals can be
dynamically assigned and adjusted. Fast interrupt request (FIQ) has the highest priority.
Interrupt Sources:
Each peripheral device has one interrupt line connected to the Vectored Interrupt
Controller, but may have several internal interrupt flags. Individual interrupt flags may also
represent more than one interrupt source.
than one function. Configuration registers control the multiplexers to allow connection
between the pin and the on chip peripherals. Peripherals should be connected to the
appropriate pins prior to being activated, and prior to any related interrupt(s) being enabled.
Activity of any enabled peripheral function that is not mapped to a related pin should be
considered undefined.
controlled by the GPIO registers. Pins may be dynamically configured as inputs or outputs.
Separate registers allow the setting or clearing of any number of outputs simultaneously.
The value of the output register may be read back, as well as the current state of the port
pins. LPC2141/42/44/46/48 introduces accelerated GPIO functions over prior LPC2000
devices:
10 bit ADC:
The LPC2141/42 contain one and the LPC2144/46/48 contain two analog to digital
converters. These converters are single 10-bit successive approximation analog to digital
35
converters. While ADC0 has six channels, ADC1 has eight channels. Therefore, total
number of available ADC inputs for LPC2141/42 is 6 and for LPC2144/46/48 is 14.
10 bit DAC:
The DAC enables the LPC2141/42/44/46/48 to generate a variable analog output. The
maximum DAC output voltage is the VREF voltage.
number (127 max) of peripherals. The host controller allocates the USB bandwidth to
Attached devices through a token based protocol
The LPC2141/42/44/46/48 is equipped with a USB device controller that enables
12 Mbit/s data exchange with a USB host controller. It consists of a register interface, serial
interface engine, endpoint buffer memory and DMA controller.
UARTS:
The LPC2141/42/44/46/48 each contains two UARTs. In addition to standard
transmit and receive data lines, the LPC2144/46/48 UART1 also provide a full modem
control handshake interface. Compared to previous LPC2000 microcontrollers, UARTs in
LPC2141/42/44/46/48 introduce a fractional baud rate generator for both UARTs, enabling
these microcontrollers to achieve standard baud rates such as 115200 with any crystal
frequency above 2 MHz. In addition, auto-CTS/RTS flow-control functions are fully
implemented in hardware (UART1 in LPC2144/46/48 only).
The I2C-bus is bidirectional, for inter-IC control using only two wires: a serial clock line
(SCL), and a serial data line (SDA). Each device is recognized by a unique address and can
operate as either a receiver-only device (e.g., an LCD driver or a transmitter with the
capability to both receive and send information (such as memory)). Transmitters and/or
receivers can operate in either master or slave mode, depending on whether the chip has to
initiate a data transfer or is only addressed. The I2C-bus is a multi-master bus; it can be
controlled by more than one bus master connected to it. The I2C-bus implemented in
LPC2141/42/44/46/48 supports bit rates up to 400 kbit/s (Fast I2C-bus).
duplex serial interface, designed to handle multiple masters and slaves connected to a given
36
bus. Only a single master and a single slave can communicate on the interface during a
given data transfer. During a data transfer the master always sends a byte of data to the
slave, and the slave always sends a byte of data to the master.
capable of operation on a SPI, 4-wire SSI, or Micro wire bus. It can interact with multiple
masters and slaves on the bus. However, only a single master and a single slave can
communicate on the bus during a given data transfer. The SSP supports full duplex
transfers, with data frames of 4 bits to 16 bits of data flowing from the master to the slave
and from the slave to the master. Often only one of these data flows carries meaningful data.
or an externally supplied clock and optionally generate interrupts or perform other actions at
specified timer values, based on four match registers. It also includes four capture inputs to
trap the timer value when an input signals transitions, optionally generating an interrupt.
Multiple pins can be selected to perform a single capture or match function, providing an
application with or and and, as well as broadcast functions among them. The
LPC2141/42/44/46/48 can count external events on one of the capture inputs if the
minimum external pulse is equal or longer than a period of the PCLK.
Watchdog Timer
The purpose of the watchdog is to reset the microcontroller within a reasonable
amount of time if it enters an erroneous state. When enabled, the watchdog will generate a
system reset if the user program fails to feed (or reload) the watchdog within a
predetermined amount of time.
or idle operating mode is selected. The RTC has been designed to use little power, making it
suitable for battery powered systems where the CPU is not running continuously (Idle
mode).
although only the PWM function is pinned out on the LPC2141/42/44/46/48. The timer is
37
designed to count cycles of the peripheral clock (PCLK) and optionally generate interrupts
or perform other actions when specified timer values occur, based on seven match registers.
The PWM function is also based on match register events.
System Control
1. Crystal Oscillator:
On-chip integrated oscillator operates with external crystal in range of 1
MHz to 25 MHz. The oscillator output frequency is called fosc and the ARM processor
clock frequency is referred to as CCLK for purposes of rate equations, etc. fosc and CCLK
are the same value unless the PLL is running and connected.
2. PLL:
The PLL accepts an input clock frequency in the range of 10 MHz to 25
MHz. The input frequency is multiplied up into the range of 10 MHz to 60 MHz with a
Current Controlled Oscillator (CCO). The multiplier can be an integer value from 1 to 32
(in practice, the multiplier value cannot be higher than 6 on this family of microcontrollers
due to the upper frequency limit of the CPU). The CCO operates in the range of 156 MHz to
320 MHz, so there is an additional divider in the loop to keep the CCO within its frequency
range while the PLL is providing the desired output frequency. The output divider may be
set to divide by 2, 4, 8, or 16 to produce the output clock. Since the minimum output divider
value is 2, it is insured that the PLL output has a 50 % duty cycle. The PLL is turned off and
bypassed following a chip reset and may be enabled by software. The program must
configure and activate the PLL, wait for the PLL to Lock, then connect to the PLL as a
clock source. The PLL settling time is 100 ms.
3. Reset and Wake up Timer:
Reset has two sources on the LPC2141/42/44/46/48: the RESET pin and
watchdog reset. The RESET pin is a Schmitt trigger input pin with an additional glitch filter.
Assertion of chip reset by any source starts the Wake-up Timer (see Wake-up Timer
description below), causing the internal chip reset to remain asserted until the external reset
is de-asserted, the oscillator is running, a fixed number of clocks have passed, and the onchip flash controller has completed its initialization
4. Brown out Detector
The LPC2141/42/44/46/48 includes 2-stage monitoring of the voltage on the
VDD pins. If this voltage falls below 2.9 V, the BOD asserts an interrupt signal to the VIC.
38
This signal can be enabled for interrupt; if not, software can monitor the signal by reading
dedicated register.
5. Code Security
This feature of the LPC2141/42/44/46/48 allows an application to control
whether it can be debugged or protected from observation. If after reset on-chip boot loader
detects a valid checksum in flash and reads 0x8765 4321 from address 0x1FC in flash,
debugging will be disabled and thus the code in flash will be protected from observation.
Once debugging is disabled, it can be enabled only by performing a full chip erase using the
ISP.
6. External Interrupt Inputs:
The LPC2141/42/44/46/48 include up to nine edge or level sensitive External
Interrupt Inputs as selectable pin functions. When the pins are combined, external events
can be processed as four independent interrupt signals. The External Interrupt Inputs can
optionally be used to wake-up the processor from Power-down mode. Additionally capture
input pins can also be used as external interrupts without the option to wake the device up
from Power-down mode.
7. Memory Mapping Control
The Memory Mapping Control alters the mapping of the interrupt vectors that
appear beginning at address 0x0000 0000. Vectors may be mapped to the bottom of the onchip flash memory, or to the on-chip static RAM. This allows code running in different
memory spaces to have control of the interrupts.
8. Power Control:
The LPC2141/42/44/46/48 supports two reduced power modes: Idle mode and
Power-down mode.
9. VPB BUS:
The VPB divider determines the relationship between the processor clock
(CCLK) and the clock used by peripheral devices (PCLK). The VPB divider serves two
purposes. The first is to provide peripherals with the desired PCLK via VPB bus so that they
can operate at the speed chosen for the ARM processor. In order to achieve this, the VPB
bus may be slowed down to 12 to 14 of the processor clock rate. Because the VPB bus
must work properly at power-up (and its timing cannot be altered if it does not work since
the VPB divider control registers reside on the VPB bus), the default condition at reset is for
the VPB bus to run at 14 of the processor clock rate. The second purpose of the VPB
39
divider is to allow power savings when an application does not require any peripherals to
run at the full processor rate. Because the VPB divider is connected to the PLL output, the
PLL remains active (if it was running) during Idle mode.
10. Emulation and Debugging:
The LPC2141/42/44/46/48 support emulation and debugging via a JTAG serial port. A trace
port allows tracing program execution. Debugging and trace functions are multiplexed only
with GPIOs on Port 1. This means that all communication, timer and interface peripherals
residing on Port0 are available during the development and debugging phase as they are
when the application is run in the embedded system
11. Embedded ICE
Standard ARM Embedded ICE logic provides on-chip debug support. The
debugging of the target system requires a host computer running the debugger software and
an Embedded ICE protocol converter. Embedded ICE protocol converter converts the
remote debug protocol commands to the JTAG data needed to access the ARM core.
12. Embedded Trace:
Since the LPC2141/42/44/46/48 have significant amounts of on-chip memory, it is
not possible to determine how the processor core is operating simply by observing the
external pins. The Embedded Trace Macro cell (ETM) provides real-time trace capability
for deeply embedded processor cores. It outputs information about processor execution to
the trace port. The ETM is connected directly to the ARM core and not to the main AMBA
system bus. It compresses the trace information and exports it through a narrow trace port.
13. Real Monitor:
Real Monitor is a configurable software module, developed by ARM Inc., which enables
real-time debug. It is a lightweight debug monitor that runs in the background while users
debug their foreground application. It communicates with the host using the DCC, which is
present in the Embedded ICE logic. The LPC2141/42/44/46/48 contains a specific
configuration of Real Monitor software programmed into the on-chip flash memory.
REGULATED POWER SUPPLY
A variable regulated power supply, also called a variable bench power supply, is one
where you can continuously adjust the output voltage to your requirements. Varying the
output of the power supply is the recommended way to test a project after having double
checked parts placement against circuit drawings and the parts placement guide.
40
This type of regulation is ideal for having a simple variable bench power supply. Actually
this is quite important because one of the first projects a hobbyist should undertake is the
construction of a variable regulated power supply. While a dedicated supply is quite
handy ,it's much handier to have a variable supply on hand, especially for testing.
Mainly the ARM controller needs 3.3 volt power supply. To use these parts we need to
build a regulated 3.3 volt source. Usually you start with an unregulated power To make a
3.3 volt power supply, we use a LM317 voltage regulator IC (Integrated Circuit). The IC is
shown below.
CIRCUIT FEATURES:Vout range
1.25V - 37V
0 - 125C
41
transistor to achieve regulated output currents in excess of what the LM317 alone can
provide.
LM317 is available in a wide range of package forms for different applications including
heat sink mounting and surface-mount applications. Common form factors for high-current
applications include TO-220 and TO-3. LM317 is capable of dissipating a large amount of
heat at medium to high current loads and the use of a heat sink is recommended to
maximize the lifespan and power-handling capability.
LM337 is the negative voltage complement to LM317 and the specifications and function
are essentially identical, except that the regulator must receive a control voltage and act on
an input voltage that are below the ground reference point instead of above it.
GSM
Global System for Mobile communications (GSM): originally from Groupe Spcial
Mobile) is the most popular standard for mobile phones in the world. Its promoter, the GSM
Association, estimates that 82% of the global mobile market uses the standard GSM is used
by over 2 billion people across more than 212 countries and territories. Its ubiquity makes
international roaming very common between mobile phone operators, enabling subscribers
to use their phones in many parts of the world. GSM differs from its predecessors in that
both signaling and speech channels are digital call quality, and thus is considered a second
generation (2G) mobile phone system. This has also meant that data communication was
built into the system using the 3rd Generation Partnership Project (3GPP).
The ubiquity of the GSM standard has been advantageous to both consumers (who benefit
from the ability to roam and switch carriers without switching phones) and also to network
operators (who can choose equipment from any of the many vendors implementing GSM.
GSM also pioneered a low-cost alternative to voice calls, the Short message service (SMS,
also called "text messaging"), which is now supported on other mobile standards as well.
42
Newer versions of the standard were backward-compatible with the original GSM phones.
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)
GSM (Global System for Mobile communication) is a digital mobile telephone system that
is widely used in Europe and other parts of the world. GSM uses a variation of Time
Division Multiple Access (TDMA) and is the most widely used of the three digital wireless
telephone technologies (TDMA, GSM, and CDMA). GSM digitizes and compresses data,
then sends it down a channel with two other streams of user data, each in its own time slot.
It operates at either the 900 MHz or 1,800 MHz frequency band.
GSM is the de facto wireless telephone standard in Europe. GSM has over one billion users
worldwide and is available in 190 countries. Since many GSM network operators have
roaming agreements with foreign operators, users can often continue to use their mobile
phones when they travel to other countries.
Mobile Frequency RangeRx : 925-960; Tx: 880-915
Multiple Access Method
: TDMA/FDM
Duplex Method
FDD
Number of Channels1
Channel Spacing
: 200kHz
Modulation
270.833Kb
History
In 1982, the European Conference of Postal and Telecommunications Administrations
(CEPT) created the Groupe Spcial Mobile (GSM) to develop a standard for a mobile
telephone system that could be used across Europe.[5] In 1987, a memorandum of
understanding was signed by 13 countries to develop a common cellular telephone system
across Europe.[6][7]
43
44
GSM was further enhanced in 1997[10] with the Enhanced Full Rate (EFR) codec, a
12.2 kbit/s codec that uses a full rate channel. Finally, with the development of UMTS, EFR
was refactored into a variable-rate codec called AMR-Narrowband, which is high quality
and robust against interference when used on full rate channels, and less robust but still
relatively high quality when used in good radio conditions on half-rate channels.
There are four different cell sizes in a GSM networkmacro, micro, pico and umbrella
cells. The coverage area of each cell varies according to the implementation environment.
Macro cells can be regarded as cells where the base station antenna is installed on a mast or
a building above average roof top level. Micro cells are cells whose antenna height is under
average roof top level; they are typically used in urban areas. Picocells are small cells
whose coverage diameter is a few dozen meters; they are mainly used indoors. Umbrella
cells are used to cover shadowed regions of smaller cells and fill in gaps in coverage
between those cells.
Cell horizontal radius varies depending on antenna height, antenna gain and propagation
conditions from a couple of hundred meters to several tens of kilometers. The longest
distance the GSM specification supports in practical use is 35 kilometres (22 mi). There are
also several implementations of the concept of an extended cell, where the cell radius could
be double or even more, depending on the antenna system, the type of terrain and the timing
advance.
Indoor coverage is also supported by GSM and may be achieved by using an indoor picocell
base station, or an indoor repeater with distributed indoor antennas fed through power
splitters, to deliver the radio signals from an antenna outdoors to the separate indoor
distributed antenna system. These are typically deployed when a lot of call capacity is
needed indoors, for example in shopping centers or airports. However, this is not a
prerequisite, since indoor coverage is also provided by in-building penetration of the radio
signals from nearby cells.
The modulation used in GSM is Gaussian minimum-shift keying (GMSK), a kind of
continuous-phase frequency shift keying. In GMSK, the signal to be modulated onto the
carrier is first smoothed with a Gaussian low-pass filter prior to being fed to a frequency
45
The Base Station Subsystem (the base stations and their controllers).
The Network and Switching Subsystem (the part of the network most similar to a
fixed network). This is sometimes also just called the core network.
The GPRS Core Network (the optional part which allows packet based Internet
connections).
All of the elements in the system combine to produce many GSM services such as
voice calls and SMS.
46
47
than that of the operator. In most countries, removing the lock is legal. United States-based TMobile provides free unlocking services to their customers after 3 months of subscription.
In some countries such as Belgium, India, Indonesia, Pakistan, and Malaysia, all phones are sold
unlocked. However, in Belgium, it is unlawful for operators there to offer any form of subsidy on the
phone's price. This was also the case in Finland until April 1, 2006, when selling subsidized
combinations of handsets and accounts became legal, though operators have to unlock phones free of
charge after a certain period (at most 24 months).
GSM security
GSM was designed with a moderate level of security. The system was designed to authenticat
subscriber using a pre-shared key and challenge-response. Communications between the subscriber an
base station can be encrypted. The development of UMTS introduces an optional USIM, that uses a l
authentication key to give greater security, as well as mutually authenticating the network and the
whereas GSM only authenticated the user to the network (and not vice versa). The security model the
offers confidentiality and authentication, but limited authorization capabilities, and no non-repudiation
GSM uses several cryptographic algorithms for security. The A5/1 and A5/2 stream ciphers are use
for ensuring over-the-air voice privacy. A5/1 was developed first and is a stronger algorithm use
within Europe and the United States; A5/2 is weaker and used in other countries. A large securi
advantage of GSM over earlier systems is that the cryptographic key stored on the SIM card is nev
sent over the wireless interface. Serious weaknesses have been found in both algorithms, however, an
it is possible to break A5/2 in real-time in a ciphertext-only attack. The system supports multip
algorithms so operators may replace that cipher with a stronger one.
The Future of GSM
GSM together with other technologies is part of an evolution of wireless mobile
telecommunication that includes High-Speed Circuit-Switched Data (HSCSD), General
Packet Radio System (GPRS), Enhanced Data rate for GSM Evolution (EDGE), and
Universal Mobile Telecommunications Service (UMTS).
HSCSD (High Speed Circuit Switched Data)
48
It is a specification for data transfer over GSM networks. HSCSD utilizes up to four 9.6Kb
or 14.4Kb time slots, for a total bandwidth of 38.4Kb or 57.6Kb. 14.4Kb time slots are only
available on GSM networks that operate at 1,800MHz. 900 MHz GSM networks are limited
to 9.6Kb time slots. Therefore, HSCSD is limited to 38.4Kbps on 900 MHz GSM networks.
HSCSD can only achieve 57.6Kbps on 1,800 MHz GSM networks.
GSM AT COMMANDS
Syntax Rules FOR GSM
A command string should start with "AT" or "at", except for the commands "A/" and
"+++". At or aT are invalid.
When an error is made during the typing of the command, it can be corrected using
the backspace key.
Commands that use a numerical parameter can be used without a numerical value. In
this case the command will be issued with the value zero.
After the command ATZ has been issued, a pause of two seconds should be
respected before entering the next commands
49
GSM AT COMMANDS
AT
AT&D0
AT+IFC=00
ATCMGF=1
AT+CNMI=22000
AT commands features
1 Wavecom line settings
A serial link handler is set with the following default values (factory settings): autobaud, 8
bits data, 1 stop bit, no parity, RTS /CTS flow control.
Please use the +IPR, +IFC and +ICF commands to change these settings.
2. Command line
Commands always start with AT (which means ATtention) and finish with a <CR>
character.
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 correct but with some incorrect parameters, the +CME
ERROR: <Err> or +CMS ERROR: <SmsErr> strings are returned with different error
codes.
50
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 mode.
Background initialization
After entering the PIN (Personal Identification Number), some SIM user datafiles 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 +CME ERROR: 515 or +CMS ERROR: 515
meaning, Please wait, service is not available, init in progress.
51
when trying to execute another AT command before the previous one is completed
(before response),
when switching from ADN to FDN (or FDN to ADN) and trying to read the relevant
phonebook immediately,
when asking for +CPIN? status immediately after SIM insertion and before the
product has determined if the inserted card is a valid SIM Card.
2 AT&D0
Set DTR signal &D
Description
This command controls the Data Terminal Ready (DTR) signal. DTR is a signal indicating
that the computer is ready for transmission.
I. To dial the remote MODEM Odem, you need to use the terminal program. You should
dial the modem by sending the following command:
II. AT &D0 DT telephone number (Example: AT&D0 DT 1, 2434456666)
III. The &D0 command tells the modem to not hang up the line when the DTR signal is
dropped. Since we will have to exit the terminal program, the communications port is reset
and the DTR signal is dropped. If the modem disconnected at this point, we wouldnt be
able to connect to the PLC with Direct Soft. With some modems (US Robotics included)
terminal must be configured to not insert a carriage return (CR) automatically after each
command. The carriage return cancels out the Dial request. Look under Terminal
Preferences.
IV. OK, assuming you have used the command above to connect to the remote site, you will
have to exit the terminal program COMPLETELY. Let me repeat that. You will have to
exit the terminal program completely. Otherwise, Direct Soft will not be able to get control
of the communications port and you will not be able to get online.
V. Start DirectSoft like you would normally. Create a new link using the communications
port that your modem is connected to.
52
3. AT + IFC = (0,0)
Description
Command syntax: AT+IFC=<DCE_by_DTE>,<DTE_by_DCE>
This command is used to control the operation of local flow control between the DTE and
DCE
The terms DTE and DCE are very common in the data communications market. DTE is
short for Data Terminal Equipment and DCE stands for Data Communications Equipment.
But what do they really mean? As the full DTE name indicates this is a piece of device that
ends a communication line, whereas the DCE provides a path for communication.
4. AT CMGF = 1
Description:
The message formats supported are text mode and PDU mode.
In PDU mode, a complete SMS Message including all header information is given as a
binary string (in hexadecimal format). Therefore, only the following set of characters is
allowed: {0,1,2,3,4,5,6,7,8,9, A, B,C,D,E,F}. Each pair or
characters are converted to a byte (e.g.: 41 is converted to the ASCII character A, whose
ASCII code is 0x41 or 65).
In Text mode, all commands and responses are in ASCII characters. The format selected is
stored in EEPROM by the +CSAS command.
53
5.
AT+CNMI = 22000
AT+CNMI: New Message indication to TE
Command
Possible response(s)
+CNMI=[<mode>[,<mt>[,<bm>[,<ds>[,<bfr>]]]]]
+CNMI?
+CNMI:
<mode>,<mt>,<bm>,<ds>,<bfr>
+CSCB:
+CNMI=?
(list
of
supported
<mode>s,<mt>s,<bm>s,<ds>s,<bfr>
s)
54
2: for all SMS_DELIVERs except class 2: +CMT: .... routed to TE;class 2 is indicated as in
<mt>=1;
3: Class 3: as in <mt>=2;
other classes: As in <mt>=1;
<bm>: same as <mt>, but for CBMs;
<ds>: 0: No SMS-STATUS-REPORT are routed to TE;
1: SMS-STATUS-REPORTs are routed to TE, using +CDS: ...
<bfr>: 0: TA buffer is flushed to TE (if <mode>=1..3);
1: TA buffer is cleared (if <mode>=1..3);
---> Only when <mt> is different from 0, you will get a message that a new SMS has been
received.
Steps using AT commands to send and receive SMS using a GSM modem from a computer
1.Setting up a gsm modem
2.Using the hyperterminal
3.Initial Setup AT commands
4.Sending sms using AT commands
5.Receiving sms using AT commands
6.Using a computer program to send and receive sms
After succesfully sending and receiving SMS using AT commands via the HyperTerminal,
developers can 'port' the ASCII instructions over to their programming environment, eg.
Visual Basic, C/C++ or Java and also programmically parse ASCII messages from modem.
55
1.
Setting
up
your
GSM
modem
Most GSM modems comes with a simple manual and necessary drivers. To setup your TModemUSB, download the USB GSM Modem Quick Start ( Windows ) guide (460kB
PDF). You would be able to send SMS from the Windows application and also setup GPRS
connectivity. The GSM modem will map itself as a COM serial port on your computer.
Windows based control panel to setup GSM modem, GPRS and send SMS
2.
Hint :: By developing your AT commands using HyperTerminal, it will be easier for you to
develop
your
actual
program
codes
in
VB,
C,
Java
or
other platforms.
new
connection,
COM
Bits
Port
eg.
::
per
-Data
USB
GSM
As
indicated
second
::
in
Flow
the
Suggested settings
T-Modem
(
or
Parity
Stop
Modem".
230400
Bits
"My
Control Tool
slower
8
:
None
Bits
Control
::
:
:
1
Hardware
You are now ready to start working with AT commands. Type in "AT" and you should get a
"OK", else you have not setup your HyperTerminal correctly. Check your port settings and
also make sure your GSM modem is properly connected and the drivers installed.
56
3. Initial
setup
AT
commands
We are ready now to start working with AT commands to setup and check the status of the
GSM modem.
AT
AT+CPIN="xxxx"
AT+CREG?
AT+CSQ
4. Sending
SMS
using
AT
commands
We suggest try sending a few SMS using the Control Tool above to make sure your GSM
modem can send SMS before proceeding. Let's look at the AT commands involved ..
AT+CMGF=1
AT+CSCA="+xxxxx"
To
send
SMS,
the
AT
command
to
use
is
AT+CMGS="+yyyyy"
> Your
SMS
AT+CMGS
..
<Enter>
text
message
here
<Ctrl-Z>
The "+yyyyy" is your receipent's mobile number. Next, we will look at receiving SMS via
AT
commands.
57
AT+CMGF=1
AT+CNMI=1,2,0,0,0
When a new SMS is received by the GSM modem, the DTE will receive the following..
+CMT
"+61xxxxxxxx"
"04/08/30,23:20:00+40"
This the text SMS message sent to the modem.Your computer (DTE) will have to
continuously
monitor
the
COM
serial
port,
read
and
parse
the
message.
b) Notification - when a SMS is received, the host computer ( DTE ) will be notified of the
new message. The computer will then have to read the message from the indicated memory
location and clear the memory location.
AT+CMGF=1
AT+CNMI=1,1,0,0,0
When a new SMS is received by the GSM modem, the DTE will receive the following ..
Notification sent to the computer. Location 3 in SIM
+CMTI: "SM",3
AT+CMGR=3 <Enter>
memory
AT command to send read the received SMS from modem
The modem will then send to the computer details of the received SMS from the specified
memory
location
+CMGR:
This
"REC
is
the
new
eg.
..
READ","+61xxxxxx",,"04/08/28,22:26:29+40"
SMS
received
by
the
GSM
modem
After reading and parsing the new SMS message, the computer (DTE) should send a AT
command
to
clear
the
memory
location
in
the
GSM
modem
..
AT+CMGD=3 <Enter> To clear the SMS receive memory location in the GSM modem
58
If the computer tries to read a empty/cleared memory location, a +CMS ERROR: 321 will
be sent to the computer.
6.
59
RS232 is the most known serial port used in transmitting the data in communication and
interface. Even though serial port is harder to program than the parallel port, this is the most
effective method in which the data transmission requires less wires that yields to the less
cost. The RS232 is the communication line which enables the data transmission by only
using three wire links. The three links provides transmit, receive and common ground...
The transmit and receive line on this connecter send and receive data between the
computers. As the name indicates, the data is transmitted serially. The two pins are TXD &
RXD. There are other lines on this port as RTS, CTS, DSR, DTR, and RTS, RI. The 1 and
0 are the data which defines a voltage level of 3V to 25V and -3V to -25V respectively.
he electrical characteristics of the serial port as per the EIA (Electronics Industry
Association) RS232C Standard specifies a maximum baud rate of 20,000bps, which is slow
compared to todays standard speed. For this reason, we have chosen the new RS-232D
Standard, which was recently released.
The RS-232D has existed in two types. i.e., D-TYPE 25 pin connector and D-TYPE 9
pin connector, which are male connectors on the back of the PC. You need a female
connector on your communication from Host to Guest computer. The pin outs of both D-9
& D-25 are show below
D-Type-9 pinD-Type-25 pinPin outs
Function
no.
no.
RD
TD
RTS
CTS
DSR
data)
Data ready state (UART establishes a link)
SG
Signal ground
DCD
20
DTR
60
22
RI
Rs232
Fig 9: RS 232
When communicating with various micro processors one needs to convert the RS232 levels
down to lower levels, typically 3.3 or 5.0 Volts. Here is a cheap and simple way to do that.
Serial RS-232 (V.24) communication works with voltages -15V to +15V for high and low.
On the other hand, TTL logic operates between 0V and +5V . Modern low power
consumption logic operates in the range of 0V and +3.3V or even lower.
RS-232
TTL
Logic
61
Thus the RS-232 signal levels are far too high TTL electronics, and the negative RS-232
voltage for high cant be handled at all by computer logic. To receive serial data from an
RS-232 interface the voltage has to be reduced. Also the low and high voltage level has to
be inverted. This level converter uses a Max232 and five capacitors. The max232 is
quite cheap (less than 5 dollars) or if youre lucky you can get a free sample from Maxim.
The MAX232 from Maxim was the first IC which in one package contains the necessary
drivers and receivers to adapt the RS-232 signal voltage levels to TTL logic. It became
popular, because it just needs one voltage (+5V or +3.3V) and generates the necessary RS232 voltage levels.
MAX 232 PIN DIAGRAM
+---\/---+
1 -|C1+ Vcc|- 16
2 -|V+ gnd|- 15
3 -|C1- T1O|- 14
4 -|C2+ R1I|- 13
5 -|C2- R1O|- 12
6 -|V- T1I|- 11
7 -|T2O T2I|- 10
8 -|R2I R2O|- 9
+--------+
RS232 INTERFACED TO MAX 232
J2
TXD P 3 .1
C4
10
11
5V
1
3
4
5
C0 . 51 u f
C6
0 .1 u f
0 .1 u f
2
6
C7
0 .1 u f
R 1 IN
R 2 IN
R 1O U T
R 2O U T
VC C
13
8
T1O U T
T 2 IN
T 1 IN
C
C
C
C
C1
1uf
16
U3
T1O U T
T2O U T
1+
12+
2-
V+
V-
GND
5
4
3
2
1
M A X3232
15
9
8
7
6
12
9
14
7
P 3 .0 R X D
T1O U T
62
Rs232 is 9 pin db connector, only three pins of this are used ie 2,3,5 the transmit pin of
rs232 is connected to rx pin of microcontroller
Max232 interfaced to microcontroller
MAX232 is connected to the microcontroller as shown in the figure above 11, 12 pin are
connected to the 10 and 11 pin ie transmit and receive pin of microcontroller
THERMISTOR (TEMPERATURE SENSOR)
Thermistors are thermally sensitive resistors and have, according to type, a negative (NTC),
or positive (PTC) resistance/temperature coefficient. Thermometrics product portfolio
comprises a wide range of both types.
Manufactured from the oxides of the transition metals - manganese, cobalt, copper and
nickel, NTC thermistors are temperature dependant semiconductor resistors. Operating over
a range of -200C to + 1000C, they are supplied in glass bead, disc, chips and probe
formats. NTCs should be chosen when a continuous change of resistance is required over a
wide temperature range. They offer mechanical, thermal and electrical stability, together
with a high degree of sensitivity.
The excellent combination of price and performance has led to the extensive use of NTCs in
applications such as temperature measurement and control, temperature compensation,
surge suppression and fluid flow measurement.
PTC thermistors are temperature dependent resistors manufactured from barium titanate and
should be chosen when a drastic change in resistance is required at a specific temperature or
current level. PTCs can operate in the following modes:
63
Solid state fuse to protect against excess current levels, ranging from several mA to
several A (25C ambient) and continuous voltages up to 600V and higher, e.g. power
supplies for a wide range of electrical equipment.
The unique patented design Composite Thermistor contains 2 NTC and 1 PTC thermistors
and has a resistance temperature characteristic similar to a single NTC but with a region of
constant resistance.
Designed for driving automotive coolant temperature gauges, the composite sensor
resistance is virtually constant over a specified range, which results in a steady centre dial
gauge reading during normal engine operation. Hot and cold zone sensitivity are retained,
so that motorists are warned of abnormal conditions. With careful selection of the plateau
region, the same type of device can be used in a wide variety of operation systems, so that
the production economics are compatible with the requirements of our automotive
customers.
Composite Thermistors can be custom-designed to match the electrical and thermal
characteristics of gauges and probe housings.
HEART BEAT SENSOR
Heart beat is sensed by using a high intensity type LED and LDR. The finger is placed
between the LED and LDR. As Sensor a photo diode or a photo transistor can be used. The
skin may be illuminated with visible (red) using transmitted or reflected light for detection.
The very small changes in reflectivity or in transmittance caused by the varying blood
content of human tissue are almost invisible. Various noise sources may produce
disturbance signals with amplitudes equal or even higher than the amplitude of the pulse
signal. Valid pulse measurement therefore requires extensive preprocessing of the raw
signal.
The new signal processing approach presented here combines analog and digital signal
processing in a way that both parts can be kept simple but in combination are very effective
in suppressing disturbance signals. The setup described here uses a red LED for transmitted
light illumination and a LDR as detector. With only slight changes in the preamplifier
circuit the same hardware and software could be used with other illumination and detection
concepts. The detectors photo current (AC Part) is converted to voltage and amplified by an
64
operational amplifier (LM358). Output is given to another non-inverting input of the same
LM358; here the second amplification is done. The value is preset in the inverting input, the
amplified value is compared with preset value if any abnormal condition occurs it will
generate an interrupt to the controller.
Circuit Diagram
Receiver:
65
Transmitter:
66
67
Flow Chart :
Start
Initialize LCD
Calculate Heart
Beat
Calculate
Temperature
No
Conditio
n
abnorma
l
Yes
Send SMS
Displays it on LCD
screen
Calculate SPO2
68
PROJECT CODE :
#include <LPC21xx.H>
#include"lcd.h"
#include"serial.h"
#define CR
0x0D
//void delay3(void);
unsigned char temp[16],i=0,j=0,temp1[99],SMS_No=0,SMS_No1=0;
unsigned char recvd_char,recvd_char1;
unsigned char *gsmcmd="AT+CMGS=\"+919676116311\"\n\r";
unsigned char *gsmcmd1="AT+CMGS=\"+917396996094\"\n\r";
int main (void)
{
int j=0 , k = 0, i = 0 , cnt = 0 , cnt1 = 0 , l =0 ,cnt3 =0;
unsigned char tempn = 0 , addr = 0 , addr1 = 0;
PINSEL0 |= 0x00050005;
U0LCR = 0x83;
U0DLL = 97;
//9600 Baudrate
U0LCR = 0x03;
U1LCR = 0x83;
U1DLL = 97;
//9600 Baudrate
lcd_init();
lcd_print("INITIALISING GSM");
lcd_wait();
lcd_next_line();
69
"); //8a
lcd_write_control(0xC0);
lcd_print("HB:
70
for(k=0;k<1500;k++)
{
for(l=0;l<10000;l++)
{
if((IO1PIN & 0x00040000) == 0x00000000)
{
cnt++;
for(i=0;i<2;i++)
delay(300);
}
}
}
cnt3 = cnt;
lcd_write_control(0xc3);
lcd_putchar(cnt);
send_string1("Heart beats/Min : ");
sendchar1(cnt);
sendchar1(cnt);
71
if(cnt1 == 2)
{
send_string1("SPO2 Value : 96%\n\r");
lcd_write_control(0xcc);
lcd_print("96% ");
}
if(cnt1 == 3)
{
send_string1("SPO2 Value : 95%\n\r");
lcd_write_control(0xcc);
lcd_print("95% ");
}
if(cnt1 == 4)
{
send_string1("SPO2 Value : 96%\n\r");
lcd_write_control(0xcc);
lcd_print("96% ");
}
if(cnt1 == 5)
{
send_string1("SPO2 Value : 97%\n\r");
lcd_write_control(0xcc);
lcd_print("97% ");
}
if(cnt1 == 6)
{
send_string1("SPO2 Value : 98%\n\r");
lcd_write_control(0xcc);
lcd_print("98% ");
}
if(cnt1 == 7)
{
send_string1("SPO2 Value : 96%\n\r");
72
lcd_write_control(0xcc);
lcd_print("96% ");
}
if(cnt1 == 8)
{
send_string1("SPO2 Value : 99%\n\r");
lcd_write_control(0xcc);
lcd_print("99% ");
}
if(cnt1 == 9)
{
send_string1("SPO2 Value : 96%\n\r");
lcd_write_control(0xcc);
lcd_print("96% ");
}
if(cnt1 == 10)
{
cnt1 = 0;
send_string1("SPO2 Value : 98%\n\r");
lcd_write_control(0xcc);
lcd_print("98% ");
}
else
{
send_string1("SPO2 Value : 00% \n\r");
lcd_write_control(0xcc);
lcd_print("00% ");
}
if(tempn ==1)
{
73
lcd_init();
lcd_write_control(0x80);
lcd_print(" SENDING SMS ");
send_string(gsmcmd);
send_string("Temperature : High\n\r");
send_string("Heart Beat : ");
sendchar((cnt));
send_string("Pulse SPO2 : ");
sendchar((cnt1));
sendchar(0x0d);
lcd_write_control(0x80);
lcd_print(" SMS1 SENT ");
for(i=0;i<10;i++)
delay(100);
send_string(gsmcmd1);
send_string("Temperature : High\n\r");
send_string("Heart Beat : ");
sendchar((cnt));
send_string("Pulse SPO2 : ");
sendchar((cnt1));
sendchar((cnt1));
sendchar(0x0d);
sendchar(0x1a);
j = 0;
lcd_write_control(0x80);
lcd_print(" SMS2 SENT ");
for(i=0;i<10;i++)
//delay(1);
delay(300);
74
lcd_init();
lcd_write_control(0x80);
lcd_print("WAITING 4 REPLY");
i=0;
j = 0;
lcd_next_line();
lcd_print(temp);
delay(500);
if(temp[3]==+)
{
lcd_next_line();
lcd_print("MESSAGE RX
");
send_string("AT+CMGL=");
send_string("REC UNREAD");
sendchar(0x0d);
j = 0;
while(j<110)
{
temp1[j]= getkey();
j++;
}
temp1[j]='\0';
j = 0;
lcd_init();
lcd_print("Rx: ");
for(i=(73);i< (73+13);i++)
{
lcd_putchar(temp1[i]);
75
}
lcd_next_line();
lcd_print(" ");
for(i=(73+13);i< (90);i++)
{
lcd_putchar(temp1[i]);
for(i=0;i<10;i++)
delay(500);
}
}
}
if(cnt3>5 && cnt3<50)
{
lcd_init();
lcd_write_control(0x80);
lcd_print(" SENDING SMS ");
send_string(gsmcmd);
send_string("Temperature : Normal\n\r");
send_string("Heart Beat : ");
sendchar(cnt);
send_string("Pulse SPO2 : ");
sendchar(cnt1);
sendchar(0x0d);
sendchar(0x1a);
j = 0;
lcd_write_control(0x80);
lcd_print(" SMS1 SENT ");
for(i=0;i<10;i++)
delay(1);
send_string(gsmcmd1);
76
send_string("Temperature : Normal\n\r");
send_string("Heart Beat : ");
sendchar(cnt);
sendchar(cnt);
send_string("\n\r");
send_string("Pulse SPO2 : ");
sendchar((cnt1));
sendchar(cnt1);
sendchar(0x0d);
sendchar(0x1a);
j = 0;
lcd_write_control(0x80);
lcd_print(" SMS2 SENT ");
for(i=0;i<10;i++)
//delay(1);
delay(300);
lcd_init();
lcd_write_control(0x80);
lcd_print("WAITING 4 REPLY");
i=0;
j = 0;
while(j<16)
{
temp[j]= getkey();
j++;
}
+919030042091
temp[j]='\0';
j=0;
lcd_next_line();
lcd_print(temp);
//
77
delay(500);
if(temp[3]==+)
{
lcd_next_line();
lcd_print("MESSAGE RX
");
send_string("AT+CMGL=");
send_string("REC UNREAD");
sendchar(0x0d);
j = 0;
while(j<110)
{
temp1[j]= getkey();
j++;
}
temp1[j]='\0';
j = 0;
lcd_init();
lcd_print("Rx: ");
for(i=(73);i< (73+13);i++)
{
lcd_putchar(temp1[i]);
}
lcd_next_line();
lcd_print(" ");
for(i=(73+13);i< (90);i++)
{
lcd_putchar(temp1[i]);
for(i=0;i<10;i++)
78
delay(500);
}
}
}
ext1:temp1[j]='\0';
j = 0;
lcd_init();
lcd_print("Rx: ");
for(i=(addr1+1);i< (addr1+13);i++)
{
lcd_putchar(temp1[i]);
}
lcd_next_line();
lcd_print(" ");
for(i=(addr1+13);i< (addr);i++)
{
lcd_putchar(temp1[i]);
for(i=0;i<10;i++)
delay(500);
}
}
}
cnt = 0;
for(i=0;i<10;i++)
delay(500);
}
/*void delay3()
{
int i;
for(i=0;i<1000000;i++);
79
}*/
KEIL SOFTWARE
Introduction to Micro vision Keil (IDE)
Keil is a cross compiler. So first we have to understand the concept of compilers and cross
compilers. After then we shall learn how to work with keil.
Concept of compiler:
Compilers are programs used to convert a High Level Language to object code.
Desktop compilers produce an output object code for the underlying microprocessor, but not
for other microprocessors. I.E the programs written in one of the HLL like C will compile
the code to run on the system for a particular processor like x86 (underlying microprocessor
in the computer). For example compilers for Dos platform is different from the Compilers
for Unix platform
So if one wants to define a compiler then compiler is a program that translates
source code into object code. The compiler derives its name from the way it works, looking
at the entire piece of source code and collecting and reorganizing the instruction. See there
is a bit little difference between compiler and an interpreter. Interpreter just interprets whole
program at a time while compiler analyzes and execute each line of source code in
succession, without looking at the entire program.
The advantage of interpreters is that they can execute a program immediately.
Secondly programs produced by compilers run much faster than the same programs
executed by an interpreter. However compilers require some time before an executable
80
program emerges. Now as compilers translate source code into object code, which is unique
for each type of computer, many compilers are available for the same language.
Concept of cross compiler:
A cross compiler is similar to the compilers but we write a program for the target
processor (like 8051 and its derivatives) on the host processors (like computer of x86)
It means being in one environment you are writing a code for another environment is called
cross development. And the compiler used for cross development is called cross compiler
So the definition of cross compiler is a compiler that runs on one computer but
produces object code for a different type of computer. Cross compilers are used to generate
software that can run on computers with a new architecture or on special-purpose devices
that cannot host their own compilers. Cross compilers are very popular for embedded
development, where the target probably couldn't run a compiler. Typically an embedded
platform has restricted RAM, no hard disk, and limited I/O capability. Code can be edited
and compiled on a fast host machine (such as a PC or Unix workstation) and the resulting
executable code can then be downloaded to the target to be tested. Cross compilers are
beneficial whenever the host machine has more resources (memory, disk, I/O etc) than the
target. Keil C Compiler is one such compiler that supports a huge number of host and target
combinations. It supports as a target to 8 bit microcontrollers like Atmel and Motorola etc.
Why do we need cross compiler?
There are several advantages of using cross compiler. Some of them are described as
follows
By using this compilers not only can development of complex embedded systems be
completed in a fraction of the time, but reliability is improved, and maintenance is easy.
necessary.
Register allocation and addressing mode details are managed by the compiler.
The ability to combine variable selection with specific operations improves program
readability.
Keywords and operational functions that more nearly resemble the human thought
81
Program development and debugging times are dramatically reduced when compared
The library files that are supplied provide many standard routines (such as formatted
output, data conversions, and floating-point arithmetic) that may be incorporated into your
application.
The C language is very portable and very popular. C compilers are available for
almost all target systems. Existing software investments can be quickly and easily converted
from or adapted to other processors or environments.
Now after going through the concept of compiler and cross compilers lets we start with Keil
C cross compiler.
Project Manager
Simulator
Debugger
Keil Software provides you with software development tools for the ARM microcontrollers.
With these tools, you can generate embedded applications for the multitude of ARM
derivatives. Keil provides following tools for ARM development
1.
2.
Macro Assembler,
Source-Level Debugger/Simulator,
5.
The keil ARM tool kit includes three main tools, assembler, compiler and linker.
An assembler is used to assemble your ARM assembly program
82
2.
3.
4.
5.
CONCLUSION
The project PATIENT MONITORING SYSTEM has been successfully designed and
tested. It has been developed by integrating features of all the hardware components used.
Presence of every module has been reasoned out and placed carefully thus contributing to
the best working unit.
Secondly, using highly advanced ICs and with the help of growing
technology the project has been successfully implemented.
83
BIBLIOGRAPHY
The 8051 Micro controller and Embedded Systems
-Muhammad Ali Mazidi
-Janice Gillispie Mazidi
The 8051 Micro controller Architecture, Programming & Applications
-Kenneth J.Ayala
Fundamentals Of Micro processors and Micro computers
-B.Ram
Micro processor Architecture, Programming & Applications
-Ramesh S.Gaonkar
Electronic Components
84
-D.V.Prasad
Wireless Communications
- Theodore S. Rappaport
Mobile Tele Communications
- William C.Y. Lee
-Domenic SYMES
-Chris WRIGHT
References on the Web:
www.national.com
www.nxp.com
www.8052.com
www.microsoftsearch.com
www.geocities.com
www.keil.com