REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

135
REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER Automation of Industries, Automation of home appliances has been rapidly developing these days. The concept of automation was implemented to the Hospitals also. Automation plays an important role in monitoring the patient’s status. Nowadays, the average lifespan has increased, due to the improvement of medical care, resulting in an increase of the disabled population. Also, due to social development, the number of disabilities as a result of various diseased or due to accidents is increasing. So the needs for a rehabilitation system to assist patients in developing their physical, mental, social ability and independence increased. And it is common that rehabilitation patients’ vital signs are not monitored during physical therapy in a rehabilitation center. The purpose of this study is to develop a monitoring system that can monitor heart rates of rehabilitation patients’ who are taking physical therapy inside a rehabilitation center so that it gives physical therapist early warning if necessary. This system transmits the patient's heart rate to the (Central Monitoring System) CMS’s PC through wireless communication. Therefore, patients are not restricted in their movements during treatment. The whole system consists of the patient’s side device (PSD) and central monitoring system (CMS). The PSD was designed to be wearable and low power consumption. The CMS was designed to

Transcript of REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Page 1: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Automation of Industries, Automation of home appliances has been rapidly developing these

days. The concept of automation was implemented to the Hospitals also. Automation plays an

important role in monitoring the patient’s status.

Nowadays, the average lifespan has increased, due to the improvement of medical care, resulting

in an increase of the disabled population. Also, due to social development, the number of

disabilities as a result of various diseased or due to accidents is increasing. So the needs for a

rehabilitation system to assist patients in developing their physical, mental, social ability and

independence increased. And it is common that rehabilitation patients’ vital signs are not

monitored during physical therapy in a rehabilitation center.

The purpose of this study is to develop a monitoring system that can monitor heart rates of

rehabilitation patients’ who are taking physical therapy inside a rehabilitation center so that it

gives physical therapist early warning if necessary.

This system transmits the patient's heart rate to the (Central Monitoring System) CMS’s PC

through wireless communication. Therefore, patients are not restricted in their movements

during treatment.

The whole system consists of the patient’s side device (PSD) and central monitoring

system (CMS). The PSD was designed to be wearable and low power consumption. The CMS

was designed to monitor multiple patients simultaneously and generate a warning signal if

necessary. The CMS and PSDs are linked by a wireless network using Control Area Network

(CAN) protocol.

The PSD consists of a contact-type microphone to detect patient's heart sound, a signal

processing hardware for signal conditioning of heart sound and calculating heart rate. The PSB’s

connected using CAN protocol for serial communication uses radio-frequency (RF) transmitter

and receiver module to communicate with the CMS periodically.

A small foot-print microcontroller with a built-in analog-to-digital converter (ADC) and low-

power consumption was incorporated in the PSD. The heart sound signal captured by the

contact-type microphone is filtered by a band pass filter and amplified to the level which

corresponds to a full-scale input voltage range of the ADC built-in a microcontroller. The CMS

Page 2: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

was designed to monitor multiple patients simultaneously and generate a warning signal if

necessary.

It consists of an RF transmitter and receiver module to communicate with all PSDs

periodically through serial communication and a Microsoft Windows- based personal computer

(PC). The heart rate information for each patient are collected by an RF module and transferred

to monitoring software in the PC that displays the heart rates for all patients and generates

warning signal if the heart rate is out of pre-defined range.

INTRODUCTION TO EMBEDDED SYSTEM

An embedded system is a special-purpose computer system designed to perform one or a few

dedicated functions, sometimes with real-time computing constraints. It is usually embedded as

part of a complete device including hardware and mechanical parts. In contrast, a general-

purpose computer, such as a personal computer, can do many different tasks depending on

programming. Embedded systems have become very important today as they control many of the

common devices we use.

Since the embedded system is dedicated to specific tasks, design engineers can optimize

it, reducing the size and cost of the product, or increasing the reliability and performance. Some

embedded systems are mass-produced, benefiting from economies of scale.

Physically, embedded systems range from portable devices such as digital watches and

MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems

controlling nuclear power plants. Complexity varies from low, with a single microcontroller

chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or

enclosure.

In general, "embedded system" is not an exactly defined term, as many systems have

some element of programmability. For example, Handheld computers share some elements with

embedded systems — such as the operating systems and microprocessors which power them —

Page 3: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

but are not truly embedded systems, because they allow different applications to be loaded and

peripherals to be connected.

An embedded system is some combination of computer hardware and software, either

fixed in capability or programmable, that is specifically designed for a particular kind of

application device. Industrial machines, automobiles, medical equipment, cameras, household

appliances, airplanes, vending machines, and toys (as well as the more obvious cellular phone

and PDA) are among the myriad possible hosts of an embedded system. Embedded systems that

are programmable are provided with a programming interface, and embedded systems

programming is a specialized occupation.

Certain operating systems or language platforms are tailored for the embedded market,

such as Embedded Java and Windows XP Embedded. However, some low-end consumer

products use very inexpensive microprocessors and limited storage, with the application and

operating system both part of a single program. The program is written permanently into the

system's memory in this case, rather than being loaded into RAM (random access memory), as

programs on a personal computer are.

APPLICATIONS OF EMBEDDED SYSTEM

We are living in the Embedded World. You are surrounded with many embedded

products and your daily life largely depends on the proper functioning of these gadgets.

Television, Radio, CD player of your living room, Washing Machine or Microwave Oven in

your kitchen, Card readers, Access Controllers, Palm devices of your work space enable you to

do many of your tasks very effectively. Apart from all these, many controllers embedded in your

car take care of car operations between the bumpers and most of the times you tend to ignore all

these controllers.

Page 4: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

In recent days, you are showered with variety of information about these embedded

controllers in many places. All kinds of magazines and journals regularly dish out details about

latest technologies, new devices; fast applications which make you believe that your basic

survival is controlled by these embedded products. Now you can agree to the fact that these

embedded products have successfully invaded into our world. You must be wondering about

these embedded controllers or systems. What is this Embedded System?

The computer you use to compose your mails, or create a document or analyze the

database is known as the standard desktop computer. These desktop computers are manufactured

to serve many purposes and applications.

You need to install the relevant software to get the required processing facility. So, these

desktop computers can do many things. In contrast, embedded controllers carryout a specific

work for which they are designed. Most of the time, engineers design these embedded controllers

with a specific goal in mind. So these controllers cannot be used in any other place.

Theoretically, an embedded controller is a combination of a piece of microprocessor based

hardware and the suitable software to undertake a specific task.

These days designers have many choices in microprocessors/microcontrollers. Especially,

in 8 bit and 32 bit, the available variety really may overwhelm even an experienced designer.

Selecting a right microprocessor may turn out as a most difficult first step and it is getting

complicated as new devices continue to pop-up very often.

In the 8 bit segment, the most popular and used architecture is Intel's 8031. Market

acceptance of this particular family has driven many semiconductor manufacturers to develop

something new based on this particular architecture. Even after 25 years of existence,

semiconductor manufacturers still come out with some kind of device using this 8031 core.

Military and aerospace software applications

Page 5: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

From in-orbit embedded systems to jumbo jets to vital battlefield networks, designers of

mission-critical aerospace and defense systems requiring real-time performance, scalability, and

high-availability facilities consistently turn to the LynxOS® RTOS and the LynxOS-178 RTOS

for software certification to DO-178B.

Rich in system resources and networking services, LynxOS provides an off-the-shelf

software platform with hard real-time response backed by powerful distributed computing

(CORBA), high reliability, software certification, and long-term support options.

The LynxOS-178 RTOS for software certification, based on the RTCA DO-178B standard,

assists developers in gaining certification for their mission- and safety-critical systems. Real-time

systems programmers get a boost with LynuxWorks' DO-178B RTOS training courses.

LynxOS-178 is the first DO-178B and EUROCAE/ED-12B certifiable, POSIX®-compatible

RTOS solution.

Communications applications

"Five-nines" availability, CompactPCI hot swap support, and hard real-time response—

LynxOS delivers on these key requirements and more for today's carrier-class systems. Scalable

kernel configurations, distributed computing capabilities, integrated communications stacks, and

fault-management facilities make LynxOS the ideal choice for companies looking for a single

operating system for all embedded telecommunications applications—from complex central

controllers to simple line/trunk cards.

LynuxWorks Jumpstart for Communications package enables OEMs to rapidly develop

mission-critical communications equipment, with pre-integrated, state-of-the-art, data

networking and porting software components—including source code for easy customization.

The Lynx Certifiable Stack (LCS) is a secure TCP/IP protocol stack designed especially for

applications where standards certification is required.

Electronics applications and consumer devices

Page 6: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

As the number of powerful embedded processors in consumer devices continues to rise, the

BlueCat® Linux® operating system provides a highly reliable and royalty-free option for

systems designers.

And as the wireless appliance revolution rolls on, web-enabled navigation systems, radios,

personal communication devices, phones and PDAs all benefit from the cost-effective

dependability, proven stability and full product life-cycle support opportunities associated with

BlueCat embedded Linux. BlueCat has teamed up with industry leaders to make it easier to build

Linux mobile phones with Java integration.

For makers of low-cost consumer electronic devices who wish to integrate the LynxOS real-

time operating system into their products, we offer special MSRP-based pricing to reduce royalty

fees to a negligible portion of the device's MSRP.

Industrial automation and process control software

Designers of industrial and process control systems know from experience that LynuxWorks

operating systems provide the security and reliability that their industrial applications require.

From ISO 9001 certification to fault-tolerance, POSIX conformance, secure partitioning and

high availability, we've got it all. Take advantage of our 20 years of experience.

MICROCONTROLLER VERSUS MICROPROCESSOR

What is the difference between a Microprocessor and Microcontroller? By

microprocessor is meant the general purpose Microprocessors such as Intel's X86 family (8086,

80286, 80386, 80486, and the Pentium) or Motorola's 680X0 family (68000, 68010, 68020,

68030, 68040, etc). These microprocessors contain no RAM, no ROM, and no I/O ports on the

chip itself. For this reason, they are commonly referred to as general-purpose Microprocessors.

Page 7: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

A system designer using a general-purpose microprocessor such as the Pentium or the

68040 must add RAM, ROM, I/O ports, and timers externally to make them functional. Although

the addition of external RAM, ROM, and I/O ports makes these systems bulkier and much more

expensive, they have the advantage of versatility such that the designer can decide on the amount

of RAM, ROM and I/O ports needed to fit the task at hand. This is not the case with

Microcontrollers.

A Microcontroller has a CPU (a microprocessor) in addition to a fixed amount of RAM,

ROM, I/O ports, and a timer all on a single chip. In other words, the processor, the RAM, ROM,

I/O ports and the timer are all embedded together on one chip; therefore, the designer cannot add

any external memory, I/O ports, or timer to it. The fixed amount of on-chip ROM, RAM, and

number of I/O ports in Microcontrollers makes them ideal for many applications in which cost

and space are critical.

In many applications, for example a TV remote control, there is no need for the

computing power of a 486 or even an 8086 microprocessor. These applications most often

require some I/O operations to read signals and turn on and off certain bits.

Page 8: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

MICROCONTROLLERS FOR EMBEDDED SYSTEMS

In the Literature discussing microprocessors, we often see the term Embedded System.

Microprocessors and Microcontrollers are widely used in embedded system products. An

embedded system product uses a microprocessor (or Microcontroller) to do one task only. A

printer is an example of embedded system since the processor inside it performs one task only;

namely getting the data and printing it. Contrast this with a Pentium based PC. A PC can be used

for any number of applications such as word processor, print-server, bank teller terminal, Video

game, network server, or Internet terminal. Software for a variety of applications can be loaded

and run. Of course the reason a pc can perform myriad tasks is that it has RAM memory and an

operating system that loads the application software into RAM memory and lets the CPU run it.

In an Embedded system, there is only one application software that is typically burned

into ROM. An x86 PC contains or is connected to various embedded products such as keyboard,

printer, modem, disk controller, sound card, CD-ROM drives, mouse, and so on. Each one of

these peripherals has a Microcontroller inside it that performs only one task. For example, inside

every mouse there is a Microcontroller to perform the task of finding the mouse position and

sending it to the PC. Table 1-1 lists some embedded products.

Page 9: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

BLOCK DIAGRAM:

PSD1

POWER SUPPLY

TEMP SENSOR

MICROCONTROLLERLCD

CAN BUSHUMIDITY SENSOR

A

D

C

Page 10: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

PSD2

RECEIVER:

POWER SUPPLY

TEMP SENSOR

MICROCONTROLLERLCD

CAN BUS

HUMIDITY SENSOR

M

A

X

2

3

2

ZIGBEE

ZIGBEEMAX232 PC

A

D

C

D

B

9

C

Page 11: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

BLOCK DIAGRAM EXPLINATION

In the above block diagram we can see the block of can, MICRO CONTROLLER, SENSORS

and POWER SUPPLY.

Let us discuses about each block in detail.

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. 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 e.g. 5V or 12V, it's much handier to have a

variable supply on hand, especially for testing. Most digital logic circuits and processors need a 5

volt power supply. To use these parts we need to build a regulated 5 volt source. Usually you

start with an unregulated power supply ranging from 9 volts to 24 volts DC (A 12 volt power

supply is included with the Beginner Kit and the Microcontroller Beginner Kit.). To make a 5

volt power supply, we use a LM7805 voltage regulator IC.

The LM7805 is simple to use. You simply connect the positive lead of your unregulated

DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to

the Common pin and then when you turn on the power, you get a 5 volt supply from the Output

pin.

SENSORS:

A sensor is a device that measures a physical quantity and converts it into a signal which can be

read by an observer or by an instrument. For example, a mercury-in-glass thermometer converts

Page 12: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

the measured temperature into expansion and contraction of a liquid which can be read on a

calibrated glass tube. A thermocouple converts temperature to an output voltage which can be

read by a voltmeter. For accuracy, most sensors are calibrated against known standards.

CAN:

Controller–area network (CAN or CAN-bus) is a vehicle bus standard designed to allow

microcontrollers and devices to communicate with each other within a vehicle without a host

computer.

CAN is a message based protocol, designed specifically for automotive applications but now also

used in other areas such as industrial automation and medical equipment.

Development of the CAN-bus started originally in 1983 at Robert Bosch GmbH.[1] The protocol

was officially released in 1986 at the Society of Automotive Engineers (SAE) congress in

Detroit, Michigan. The first CAN controller chips, produced by Intel and Philips, came on the

market in 1987. Bosch published the CAN 2.0 specification in 1991.

MAX- 232

To allow compatibility among data communication equipment made by various

manufactures, an interfacing standard called RS232 was set by the Electronic Industries

Association (EIA).This RS-232 standard is used in PCs and numerous types of

equipment .However, since the standard was set long before the advent of the TTL logic family,

its input and output voltage levels are not TTL compatible. In RS-232 ,a 1 is represented by -3

to -25V,while a 0 bit is +3 to +25V,making -3 to +3 undefined. For this reason, to connect any

RS-232 to a microcontroller system we must use voltage converters such as MAX232 to convert

the TTL logic levels to the RS-232 voltage levels and vice versa.

So here we are using this MAX-232 to have compatibility between the zigbee and

microcontroller.

Page 13: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

ZIGBEE:

ZigBee is a specification for a suite of high level communication protocols using small,

low-power digital radios based on the IEEE 802.15.4-2003 standard for Low-Rate Wireless

Personal Area Networks (LR-WPANs), such as wireless light switches with lamps, electrical

meters with in-home-displays, consumer electronics equipment via short-range radio needing

low rates of data transfer. The technology defined by the ZigBee specification is intended to be

simpler and less expensive than other WPANs, such as Bluetooth. ZigBee is targeted at radio-

frequency (RF) applications that require a low data rate, long battery life, and secure networking

Page 14: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

SCHEMATIC:

Page 15: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER
Page 16: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER
Page 17: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

HARD WARE COMPONENTS EXPLANATION:

Power supply

The power supplies are designed to convert high voltage AC mains electricity to a

suitable low voltage supply for electronics circuits and other devices. A power supply can by

broken down into a series of blocks, each of which performs a particular function. A d.c power

supply which maintains the output voltage constant irrespective of a.c mains fluctuations or load

variations is known as “Regulated D.C Power Supply”

Transformer:

A transformer is an electrical device which is used to convert electrical power from one

electrical circuit to another without change in frequency.

Transformers convert AC electricity from one voltage to another with little loss of power.

Transformers work only with AC and this is one of the reasons why mains electricity is AC.

Step-up transformers increase in output voltage, step-down transformers decrease in output

voltage. Most power supplies use a step-down transformer to reduce the dangerously high mains

voltage to a safer low voltage. The input coil is called the primary and the output coil is called

the secondary. There is no electrical connection between the two coils; instead they are linked by

an alternating magnetic field created in the soft-iron core of the transformer. The two lines in the

middle of the circuit symbol represent the core. Transformers waste very little power so the

power out is (almost) equal to the power in. Note that as voltage is stepped down current is

stepped up. The ratio of the number of turns on each coil, called the turn’s ratio, determines the

ratio of the voltages. A step-down transformer has a large number of turns on its primary (input)

coil which is connected to the high voltage mains supply, and a small number of turns on its

secondary (output) coil to give a low output voltage.

Page 18: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

RECTIFIER:

A circuit which is used to convert a.c to dc is known as RECTIFIER. The process of

conversion a.c to d.c is called “rectification”

TYPES OF RECTIFIERS:

Half wave Rectifier

Full wave rectifier

1. Centre tap full wave rectifier.

2. Bridge type full bridge rectifier.

Full-wave Rectifier:

From the above comparison we came to know that full wave bridge rectifier as more

advantages than the other two rectifiers. So, in our project we are using full wave bridge rectifier

circuit.

Bridge Rectifier: A bridge rectifier makes use of four diodes in a bridge arrangement to achieve

full-wave rectification. This is a widely used configuration, both with individual diodes wired as

shown and with single component bridges where the diode bridge is wiredinternally.

Page 19: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Filter:

A Filter is a device which removes the a.c component of rectifier output

but allows the d.c component to reach the load

Capacitor Filter:

We have seen that the ripple content in the rectified output of half wave rectifier is 121%

or that of full-wave or bridge rectifier or bridge rectifier is 48% such high percentages of ripples

is not acceptable for most of the applications. Ripples can be removed by one of the following

methods of filtering.

(a) A capacitor, in parallel to the load, provides an easier by –pass for the ripples voltage though

it due to low impedance. At ripple frequency and leave the d.c.to appears the load.

(b) An inductor, in series with the load, prevents the passage of the ripple current (due to high

impedance at ripple frequency) while allowing the d.c (due to low resistance to d.c)

(c) various combinations of capacitor and inductor, such as L-section filter section filter,

multiple section filter etc. which make use of both the properties mentioned in (a) and (b) above.

Two cases of capacitor filter, one applied on half wave rectifier and another with full wave

rectifier.

Filtering is performed by a large value electrolytic capacitor connected across the DC

supply to act as a reservoir, supplying current to the output when the varying DC voltage from

Page 20: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

the rectifier is falling. The capacitor charges quickly near the peak of the varying DC, and then

discharges as it supplies current to the output. Filtering significantly increases the average DC

voltage to almost the peak value (1.4 × RMS value).

Regulator:

Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or variable output

voltages. The maximum current they can pass also rates them. Negative voltage regulators are

available, mainly for use in dual supplies. Most regulators include some automatic protection

from excessive current ('overload protection') and overheating ('thermal protection'). Many of

the fixed voltage regulator ICs have 3 leads and look like power transistors, such as the 7805

+5V 1A regulator shown on the right. The LM7805 is simple to use. You simply connect the

positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the

Input pin, connect the negative lead to the Common pin and then when you turn on the power,

you get a 5 volt supply from the output pin.

78XX:

The Bay Linear LM78XX is integrated linear positive regulator with three terminals. The

LM78XX offer several fixed output voltages making them useful in wide range of applications.

When used as a zener diode/resistor combination replacement, the LM78XX usually results in an

effective output impedance improvement of two orders of magnitude, lower quiescent current.

The LM78XX is available in the TO-252, TO-220 & TO-263packages,

Page 21: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Features:

• Output Current of 1.5A

• Output Voltage Tolerance of 5%

• Internal thermal overload protection

• Internal Short-Circuit Limited

• No External Component

• Output Voltage 5.0V, 6V, 8V, 9V, 10V,12V, 15V, 18V, 24V

• Offer in plastic TO-252, TO-220 & TO-263

• Direct Replacement for LM78XX

MICROCONTROLLER

INTRODUCTION:

A Micro controller consists of a powerful CPU tightly coupled with memory RAM, ROM

or EPROM), various I / O features such as Serial ports, Parallel Ports, Timer/Counters, Interrupt

Controller, Data Acquisition interfaces-Analog to Digital Converter (ADC), Digital to Analog

Converter (ADC), everything integrated onto a single Silicon Chip.

It does not mean that any micro controller should have all the above said features on chip,

Depending on the need and area of application for which it is designed, The ON-CHIP features present in

it may or may not include all the individual section said above.

Any microcomputer system requires memory to store a sequence of instructions making up a

program, parallel port or serial port for communicating with an external system, timer / counter for

control purposes like generating time delays, Baud rate for the serial port, apart from the controlling

unit called the Central Processing Unit.

Page 22: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

INTRODUCTION TO 8051MICROCONTROLLER

In 1981,Intel corporation introduced an 8 bit microcontroller called the 8051.This

microcontroller had 128 bytes of RAM,4K bytes of on-chip ROM, two timers, one serial port and 4

ports(each 8-bits wide)all on single chip. At that time it was also referred to as a “system on a chip”.

INTRODUCTION TO ATMEL MICROCONTROLLER

The major Features of 8-bit Micro controller ATMEL 89C51:

8 Bit CPU optimized for control applications

Extensive Boolean processing (Single - bit Logic) Capabilities.

On - Chip Flash Program Memory

On - Chip Data RAM

Bi-directional and Individually Addressable I/O Lines

Multiple 16-Bit Timer/Counters

Full Duplex UART

Multiple Source / Vector / Priority Interrupt Structure

On - Chip Oscillator and Clock circuitry.

On - Chip EEPROM

One Serial communication port

Block Diagram

ON-CHIP

RAM

Page 23: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

COUNTER

INPUTS

EXTERNAL

INTERRUPTS

INTERRUPT

CONTROL

ON-CHIPON-CHIP

TIMER 1

TIMER 0

CPU

OSC BUS

CONTROL

4 I/O PORTS SERIL

PORT

PO P2 P1 P3 TXD RXD

Page 24: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Fig.1 Oscillator Connection.

The P89C51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32

I/O lines, two 16-bit timer/counters, five vector two-level interrupt architecture, a full duplex serial port,

and on-chip oscillator and clock circuitry. In addition, the P89C51 is designed with static logic for

operation down to zero frequency and supports two software selectable power saving modes. The Idle

Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to

continue functioning. The Power-down Mode saves the RAM contents but freezes the oscillator

disabling all other chip functions until the next hardware reset.

Memory Organization

Program Memory

Below Fig shows a map of the lower part of the program memory. After reset, the CPU

begins execution from location 0000H. As shown in fig.4, each interrupt is assigned a fixed location in

program memory. The interrupt causes the CPU to jump to that location, where it executes the service

routine. External Interrupt 0, for example, is assigned to location 0003H. If External Interrupt 0 is used,

its service routine must begin at location 0003H. If the interrupt is not used, its service location is

available as general purpose.

Page 25: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Program Memory.

Program memory addresses are always 16 bits wide, even though the actual amount o program memory

used may be less than 64Kbytes. External program execution sacrifices two of the 8-bit ports, P0 and P2,

to the function of addressing the program memory.

Data Memory

The right half of Figure 3 shows the internal and external data memory spaces available on

Philips Flash microcontrollers. Fig.6 shows a hardware configuration for accessing up to 2K bytes of

external RAM. In this case, the CPU executes from internal flash. Port0 serves as a multiplexed

address/data bus to the RAM, and 3 lines of Port 2 are used to page the RAM. The CPU generates RD

and WR signals as needed during external RAM accesses. You can assign up to 64K bytes of external data

memory. External data memory addresses can be either 1 or 2bytes wide.

Internal data memory addresses are always 1 byte wide, which implies an address space of only

256bytes. However, the addressing modes for internal RAM can infact accommodate 384 bytes. Direct

addresses higher than 7FH access one memory space and indirect addresses higher than 7FH access a

different memory space. Thus, Figure.7 shows the Upper 128 and SFR space occupying the same block of

addresses, 80H through FFH, although they are physically separate entities. The lowest 32 bytes are

grouped into 4 banks of 8 registers. Program instructions call out these registers as R0 through R7.

(0033)H

002BH

0023H

001BH

0013H

000BH

0003H

0000H

8 bytesINTERRUPT LOCATIONS

RESET

Page 26: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

The next 16 bytes above the register banks form a block of bit-addressable memory space. The

microcontroller instruction set includes a wide selection of single-bit instructions, and these instructions

can directly address the 128 bits in this area. These bit addresses are 00H through 7FH. All of the bytes

in the Lower 128 can be accessed by either direct or indirect addressing.

REGISTERS:

In the CPU, registers are used to store information temporarily. That information could be a

byte of data to be processed, or an address pointing to the data to be fetched. The vast majority of

8051 registers are 8–bit registers. In the 8051 there is only one data type: 8bits. The 8bits of a register

are should in the diagram from the MSB (most significant bit) D7 to the LSB (least significant bit) D0.

With an 8-bit data type, any data larger than 8bits must be broken into 8-bit chunks before it is

processed.

The most widely used registers of the 8051 are A(accumulator), B, R0, R1, R2, R3, R4, R5, R6, R7,

DPTR(data pointer), and PC(program counter). All of the above registers are 8-bits, except DPTR and the

program counter. The accumulator, register A, is used for all arithmetic and logic instructions.

SFRs (Special Function Registers)

Among the registers R0-R7 are part of the 128 bytes of RAM memory . what about registers A,B,

PSW, and DPTR? Do they also have addresses? The answer is yes. In the 8051, registers A, B, PSW and

DPTR are part of the group of registers commonly referred to as SFR (special function registers). There

are many special function registers and they are widely used. The SFR can be accessed by the names

(which is much easier) or by their addresses. For example, register A has address E0h, and register B has

been ignited the address F0H.

D7 D6 D5 D4 D3 D2 D1 D0

Page 27: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

PIN CONFIGURATION:

Pin Diagram of AT89C51

Pin Description

VCC: Pin 40 provides supply voltage to the chip. The voltage source is +5v.

GND: Pin 20 is the ground.

Ports 0, 1, 2 and 3

As shown in pin diagram, the four ports P0, P1, P2, and P3 each use of 8 pins, making the 8-bit

ports. All the ports upon Reset are configured as input, since P0-P3 have FFH on them.

Page 28: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Port 0

Port 0 occupies a total of 8 pins (pins 32-33). It can be used for input or output. Port0 is

also designated as AD0-AD7, allowing it to be used for both address and data. When connecting

an 8051/31 to an external memory, port 0 provides both address and data. The 8051 multiplexes

address and data through port 0 to save pins. ALE=0, it provides data D0-D7, but when ALE=1,

it has address A0-A7. Therefore, ALE is used for demultiplexing address address and data with

the help of a 74LS373 latch. In the 8051-based systems where there is no external memory

connection, the pins of P0 must be connected externally to a 10k –ohm pull-up resistor.

This is due to the fact that P0 is an Open drain, Unlike P1, P2, P3. Open drain is a term

used for Mos chips in the same way that open collector is used for TTL chips. In many systems

usig the 8751, 89C51, or DS89C4x0 chips, we normally connect P0 to pull-up resistors. With

external pull-up resistors connected to P0, it can be used as a simple I/O port, just like P1 and P2.

In contrast to Port 0, ports p1, p2, and p3 do not need any pull-up resistors since they already

have pull-up resistors internally. Upon reset, ports p1, p2, ad p3 are configured as input ports.

Port 1

Port 1 occupies a total of 8-pins (pins1-8). It can be used as input or output. In contrast to port

0, this port does not need any pull-up resistors since it already has pull-up resistors internally. Upon

reset, port1 is configured as an input port.

Port 2

Port 2 occupies a total 8 pins (pins 21-28). It can be used as input or output. However, in

8031-based systems, port2 is also designated as A8-A15, indicating its dual function. Since an

8051/31 is capable of accessing 64K bytes of external memory, it needs a path for the 16 bits of

the address. While P0 provides the lower 8 bits via A0-A7, it is the job of p2 is used for the

upper 8 bits of the 16-bit address, and it cannot be used for I/O. Just like P1, port 2 does not

need any pull-up resistors since it already has pull-up resistors internally. Upon reset, port2 is

configured as an input port.

Page 29: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Port 3

Port 3 occupies a total of 8 pins (pins 10-17). It can be used as input or output. P3 does not

need any pull-up resistors, just as P1 and P2 did not. Although Port 3 is configured as an input port upon

reset, this is not the way it is most commonly used. Port 3 has the additional function of providing some

extremely important signals such as interrupts. The below table provides these alternate functions of

P3. This is information applies to both 8051 and 8031 chips.

Alternate Functions of PORT3

Port 3 also receives some control signals for Flash programming and verification.

RST

Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.

ALE/PROG

Prior to each reading from external memory, the microcontroller will set the lower address byte

(A0-A7) on P0 and immediately after that activates the output ALE. Upon receiving signal from the ALE

pin, the external register (74HCT373 or 74HCT375 circuit is usually embedded ) memorizes the state of

P0 and uses it as an address for memory chip. In the second part of the microcontroller’s machine cycle,

a signal on this pin stops being emitted and P0 is used now for data transmission (Data Bus). In this way,

by means of only one additional (and cheap) integrated circuit, data multiplexing from the port is

performed. This port at the same time used for data and address transmission.

PSEN

Program Store Enable is the read strobe to external program memory. When the AT89C51 is executing

code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN

activations are skipped during each access to external data memory.

EA/VPP

External Access Enable. EA must be strapped to GND in order to enable the device to fetch code

from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit

1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal

Page 30: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash

programming, for parts that require 12-volt VPP.

XTAL1 and XTAL2

The 8051 has an on-chip oscillator but requires an external clock to run it. Most often a quartz

crystal oscillator is connected to inputs XTAL1 (pin19) and XTAL2 (pin18). The quartz crystal oscillator

connected to XTAL1 and XTAL2 also needs two capacitors of 30pf value. One side of each capacitor is

connected to the ground as shown in fig1.

It must be noted that there are various speeds of the 8051 family. Speed refers to the maximum

oscillator frequency connected to XTAL. For example, a 12-MHz chip must be connected to a crystal

with 12 MHz frequency of no more than 20 MHz. When the 8051 is connected to a crystal oscillator and

is powered up, we can observe the frequency on the XTAL2 pin using the oscilloscope.

TIMERS

On-chip timing/counting facility has proved the capabilities of the microcontroller for

implementing the real time application. These includes pulse counting, frequency measurement, pulse

width measurement, baud rate generation, etc,. Having sufficient number of timer/counters may be a

need in a certain design application. The 8051 has two timers/counters. They can be used either as

timers to generate a time delay or as counters to count events happening outside the microcontroller.

Let discuss how these timers are used to generate time delays and we will also discuss how they are

been used as event counters.

BASIC RIGISTERS OF THE TIMER

Both Timer 0 and Timer 1 are 16 bits wide. Since the 8051 has an 8-bit architecture, each 16-bit

timer is accessed as two separate registers of low byte and high byte.

TIMER 0 REGISTERS

Page 31: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

The 16-bit register of Timer 0 is accessed as low byte and high byte. the low byte register is

called TL0(Timer 0 low byte)and the high byte register is referred to as TH0(Timer 0 high byte).These

register can be accessed like any other register, such as A,B,R0,R1,R2,etc.for example, the instruction

”MOV TL0, #4F”moves the value 4FH into TL0,the low byte of Timer 0.These registers can also be read

like any other register.

TIMER 1 REGISTERS

Timer 1 is also 16-bit register is split into two bytes, referred to as TL1 (Timer 1 low byte) and

TH1(Timer 1 high byte).these registers are accessible n the same way as the register of Timer 0.

TMOD (timer mode) REGISTER

Both timers 0 and 1 use the same register, called TMOD, to set the various timer operation modes.

TMOD is an 8-bit register in which the lower 4 bits are set aside for Timer 0 and the upper 4 bits for

Timer 1.in each case; the lower 2 bits are used to set the timer mode and the upper 2 bits to specify the

operation.

TCON Register:

Page 32: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

TCON controls the timer/counter operations. The lower four bits of TCON cater to interrupt functions,

but the upper four bits are for timer operations. The details of the TCON register are shown below.

MSB LSB

INTERRUPTS:

A single microcontroller can serve several devices. There are two ways to do that: INTERRUPTS or

POLLING.

POLLING:

In polling the microcontroller continuously monitors the status of a given device; when the status

condition is met, it performs the service .After that, it moves on to monitor the next device until

each one is serviced. Although polling can monitor the status of several devices and serve each of them

as certain condition are met.

INTERRUPTS:

In the interrupts method, whenever any device needs its service, the device notifies the

microcontroller by sending it an interrupts signal. Upon receiving an interrupt signal, the microcontroller

TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0

Page 33: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

interrupts whatever it is doing and serves the device. The program associated with the interrupts is

called the interrupt service routine (ISR).or interrupt handler.

Six Interrupts in the 8051:

In reality, only five interrupts are available to the user in the 8051, but many manufacturers’ data

sheets state that there are six interrupts since they include reset .the six interrupts in the 8051 are

allocated as above.

1. Reset. When the reset pin is activated, the 8051 jumps to address location 0000.this is the

power-up reset.

2. Two interrupts are set aside for the timers: one for Timer 0 and one for Timer 1.Memory

location 000BH and 001BH in the interrupt vector table belong to Timer 0 and Timer 1,

respectively.

3. Two interrupts are set aside for hardware external harder interrupts. Pin number 12(P3.2) and

13(P3.3) in port 3 are for the external hardware interrupts INT0 and INT1,respectively.These

external interrupts are also referred to as EX1 and EX2.Memory location 0003H and 0013H in

the interrupt vector table are assigned to INT0 and INT1, respectively.

4. Serial communication has a single interrupt that belongs to both receive and transmit. The

interrupt vector table location 0023H belongs to this interrupt.

8051/52 Interrupt Priority upon Reset

Page 34: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Highest to Lowest Priority

External Interrupt 0 (INT0)

Timer Interrupt 0 (TF0)

External Interrupt 1 (INT1)

Timer Interrupt 1 (TF1)

Serial Communication (RI+TI)

Timer 2(8052 only) TF2

SERIAL COMMUNICATION

Computers can transfer data in two ways: parallel and serial. In parallel data transfers,

often 8 or more lines (wire conductors) are used to transfer data to a device that is only a few feet away.

An example of parallel transfers a printers and hard disks; each uses cables with many wire strips.

Although in such cases a lot of data can be transferred in a short amount of time by using many wires in

parallel, the distance cannot be great.

To transfer to a device located many meters away, the serial method is used. In serial

communication, the data is sent one bit at a time, in contrast to parallel communication, in which the

data is sent a byte or more at a time. Serial communication of the 8051 is the topic of this chapter. The

8051 has serial communication capability built into it, there by making possible fast data transfer using

only a few wires.

If data is to be transferred on the telephone line, it must be converted from 0s and 1s to audio

tones, which are sinusoidal-shaped signals. This conversion is performed by a peripheral device called a

modem, which stands for “modulator/demodulator.”

Page 35: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Serial data communication uses two methods, asynchronous and synchronous. The

synchronous method transfers a block of data at a time, while the asynchronous method transfers a

single byte at a time.

In data transmission if the data can be transmitted and received, it is a duplex transmission. This

is in contrast to simplex transmissions such as with printers, in which the computer only sends data.

Duplex transmissions can be half or full duplex, depending on whether or not the data transfer can be

simultaneous.

Asynchronous serial communication and data framing

The data coming in at the receiving end of the data line in a serial data transfer is all 0s and 1s; it

is difficult to make sense of the data unless the sender and receiver agree on a set of rules, a protocol,

on how the data is packed, how many bits constitute a character, and when the data begins and ends.

Start and stop bits

Asynchronous serial data communication is widely used for character-oriented transmissions,

while block-oriented data transfers use the synchronous method. In the asynchronous method, each

character is placed between start and stop bits. This is called framing. In the data framing for

asynchronous communications, the data, such as ASCII characters, are packed between a start bit and a

stop bit. The start bit is always one bit, but the stop bit can be one or two bits. The start bit is always a 0

(low) and the stop bit (s) is 1 (high).

Data transfer rate

The rate of data transfer in serial data communication is stated in bps (bits per second).

Another widely used terminology for bps is baud rate. The data transfer rate of given computer system

depends on communication ports incorporated into that system. For example, the early IBMPC/XT

could transfer data at the rate of 100 to 9600 bps. In recent years, however, Pentium based PCS

transfer data at rates as high as 56K bps. It must be noted that in asynchronous serial data

communication, the baud rate is generally limited to 100,000bps.

Page 36: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Baud rate in the 8051

The 8051 transfers and receives data serially at many different baud rates. The baud rate in the

8051 is programmable. The is done with the help of Timer1. The 8051 divides the crystal frequency by

12 to get the machine cycle frequency. In the case of XTAL=11.0592MHZ, the machine cycle frequency

is 921.6 KHz (11.0592MHz/12=921.6KHz). the 8051’s serial communication UART circuitry divides the

machine cycle frequency of 921.6khz divided by 32 once more before it is used by Timer 1 to set the

Baud rate. Therefore, 921.6 kHz divided by 32 gives 28,800 Hz. This is the number well use to find the

Timer 1 value to set baud rate.

Baud rate TH1(Decimal) TH1(Hex)

9600 -3 FD

4800 -6 FA

2400 -12 F4

1200 -24 E8

NOTE: XTAL=11...592MHz

SBUF register

SBUF is an 8-bit register used solely for serial communication in the 8051. for a byte of data to

be transferred via the TXD line, it must be placed in the SBUF register. Similarly, SBUF holds the byte of

data when it is received by the 8051’s RXD line. SBUF can be accessed like any other register in the

8051. Look at the following the examples of how this register is accessed.

MOV SBUF, #’D’ ; load SBUF=44h, ASCII for ‘D’

MOV SBUF, A ; copy accumulator into SBUF

MOV A, SBUF ; copy SBUF into accumulator

The moment a byte is written into SBUF, it is framed with the start and stop bits and transferred

serially via the TXD pin. Similarly, when the bits are received serially via RXD, the 8051 defames it by

Page 37: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

eliminating the stop and start bits, making a byte out of the data received, and then placing it in the

SBUF.

SCON (serial control) register

The SCON register is an 8-bit register used to program the start bit, stop bit, and data bits of

data framing, among other things.

The following describes various bits of the SCON register.

SM0 SM1 SM2 REN TB8 RB8 TI RI

SM0 SCON.7 Serial port mode specifier

SM1 SCON.6 Serial port mode specifier

SM2 SCON.5 Used for multiprocessor communication. (make it 0.)

REN SCON.4 Set/cleared by software to enable/disable reception

TB8 SCON.3 Not widely used

RB8 SCON.2 Not widely used

TI SCON.1 Transmit interrupt flag. Set by hardware at the beginning

Of the stop bit in mode 1. Must be cleared by software.

RI SCON.0 Receive interrupt flag. Set by hardware halfway through

the stop bit time mode 1. Must be cleared by software.

Page 38: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Note: Make SM2, TB8, and RB8=0.

SM0, SM1

SM0 and SM1 are D7 and D6 of the SCON register, respectively. These two bits determine the

framing of data by specifying the number of bits per character and the start and stop bits. They take the

following combinations.

SM0 SM1 FUNCTION

0 0 Serial Mode 0

0 1 Serial Mode 1, 8-bit data, 1 stop bit, 1 start bit

1 0 Serial Mode 2

1 1 Serial Mode 3

Of the 4 serial modes, only mode 1 is of interest to us. In the SCON register, when serial mode 1

is chosen, the data framing is 8 bits, 1 stop bit, and 1 start bit, which makes it compatible with the COM

port of IBM/compatible PCs. More importantly, serial mode 1 allows the baud rate to be variable and is

set by Timer 1 of the 8051. In serial mode 1, for each character a total of 10 bits are transferred, where

the first bit is the start bit, followed by 8 bits of data, and finally 1 stop bit.

MAX-232:

The MAX232 from Maxim was the first IC which in one package contains the necessary

drivers (two) and receivers (also two), to adapt the RS-232 signal voltage levels to TTL logic. It

became popular, because it just needs one voltage (+5V) and generates the necessary RS-232

voltage levels (approx. -10V and +10V) internally. This greatly simplified the design of circuitry.

Page 39: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Circuitry designers no longer need to design and build a power supply with three voltages (e.g. -

12V, +5V, and +12V), but could just provide one +5V power supply, e.g. with the help of a

simple 78x05 voltage converter.

The MAX232 has a successor, the MAX232A. The ICs are almost identical, however, the

MAX232A is much more often used (and easier to get) than the original MAX232, and the

MAX232A only needs external capacitors 1/10th the capacity of what the original MAX232

needs.

The MAX232 and MAX232A were once rather expensive ICs, but today they are cheap.

It has also helped that many companies now produce clones (ie. Sipex). The original

manufacturer (and now some clone manufacturers, too) offers a large series of similar ICs, with

different numbers of receivers and drivers, voltages, built-in or external capacitors, etc. E.g. The

MAX232 and MAX232A need external capacitors for the internal voltage pump, while the

MAX233 has these capacitors built-in. The MAX233 is also between three and ten times more

expensive in electronic shops than the MAX232A because of its internal capacitors. It is also

more difficult to get the MAX233 than the garden variety MAX232A.

A Typical Application

The MAX 232(A) has two receivers (converts from RS-232 to TTL voltage levels) and

two drivers (converts from TTL logic to RS-232 voltage levels). This means only two of the RS-

232 signals can be converted in each direction. The old MC1488/1498 combo provided four

drivers and receivers.

Typically a pair of a driver/receiver of the MAX232 is used for

TX and RX

And the second one for

CTS and RTS.

Page 40: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

There are not enough drivers/receivers in the MAX232 to also connect the DTR, DSR, and

DCD signals. Usually these signals can be omitted when e.g. communicating with a PC's serial

interface. If the DTE really requires these signals either a second MAX232 is needed, or some

other IC from the MAX232 family can be used (if it can be found in consumer electronic shops

at all).

An alternative for DTR/DSR is also given below.Maxim's data sheet explains the MAX232

family in great detail, including the pin configuration and how to connect such an IC to external

circuitry. This information can be used as-is in own design to get a working RS-232 interface.

Maxim's data just misses one critical piece of information: How exactly to connect the RS-232

signals to the IC. So here is one possible example

In addition one can directly wire DTR (DB9 pin 4) to DSR (DB9 pin 6) without going

through any circuitry. This gives automatic (brain dead) DSR acknowledgment of an incoming

DTR signal.

Sometimes pin 6 of the MAX232 is hard wired to DCD (DB9 pin 1). This is not

recommended. Pin 6 is the raw output of the voltage pump and inverter for the -10V voltage.

Drawing currents from the pin leads to a rapid breakdown of the voltage, and as a consequence

to a breakdown of the output voltage of the two RS-232 drivers. It is better to use software which

doesn't care about DCD, but does hardware-handshaking via CTS/RTS only.

The circuitry is completed by connecting five capacitors to the IC as it follows. The

MAX232 needs 1.0µF capacitors, the MAX232A needs 0.1µF capacitors. MAX232 clones show

similar differences. It is recommended to consult the corresponding data sheet. At least 16V

capacitor types should be used. If electrolytic or tantalic capacitors are used, the polarity has to

be observed. The first pin as listed in the following table is always where the plus pole of the

capacitor should be connected to.

The 5V power supply is connected to

+5V: Pin 16

GND: Pin 15

Page 41: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Description/ordering information

The MAX232 is a dual driver/receiver that includes a capacitive voltage generator to supply EIA-232

voltage levels from a single 5-V supply. Each receiver converts EIA-232 inputs to 5-V TTL/CMOS levels.

These receivers have a typical threshold of 1.3 V and a typical hysteresis of 0.5 V, and can accept 30-V

inputs. Each driver converts TTL/CMOS input levels into EIA-232 levels. The driver, receiver, and voltage-

generator functions are available as cells in the Texas Instruments Lin ASIClibrary.

LCD (Liquid Cristal Display)

Introduction:

A liquid crystal display (LCD) is a thin, flat display device made up of any number of

color or monochrome pixels arrayed in front of a light source or reflector. Each pixel consists of a

column of liquid crystal molecules suspended between two transparent electrodes, and two polarizing

filters, the axes of polarity of which are perpendicular to each other. Without the liquid crystals

between them, light passing through one would be blocked by the other. The liquid crystal twists the

polarization of light entering one filter to allow it to pass through the other.

A program must interact with the outside world using input and output devices that

communicate directly with a human being. One of the most common devices attached to an controller is

an LCD display. Some of the most common LCDs connected to the contollers are 16X1, 16x2 and 20x2

displays. This means 16 characters per line by 1 line 16 characters per line by 2 lines and 20 characters

per line by 2 lines, respectively.

Page 42: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

available. Line lengths of 8, 16, 20, 24, 32 and 40 characters are all standard, in one, two

Page 43: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Many microcontroller devices use 'smart LCD' displays to output visual information. LCD displays

designed around LCD NT-C1611 module, are inexpensive, easy to use, and it is even possible to produce

a readout using the 5X7 dots plus cursor of the display. They have a standard ASCII set of characters and

mathematical symbols. For an 8-bit data bus, the display requires a +5V supply plus 10 I/O lines ( RS RW

D7 D6 D5 D4 D3 D2 D1 D0). For a 4-bit data bus it only requires the supply lines plus 6 extra lines( RS

RW D7 D6 D5 D4). When the LCD display is not enabled, data lines are tri-state and they do not interfere

with the operation of the microcontroller.

Features:

(1) Interface with either 4-bit or 8-bit microprocessor.

(2) Display data RAM

(3) 80x8 bits (80 characters).

(4) Character generator ROM

(5). 160 different 5 7 dot-matrix character patterns.

(6). Character generator RAM

(7) 8 different user programmed 5 7 dot-matrix patterns.

(8).Display data RAM and character generator RAM may be

Accessed by the microprocessor.

(9) Numerous instructions

(10) .Clear Display, Cursor Home, Display ON/OFF, Cursor ON/OFF,

Blink Character, Cursor Shift, Display Shift.

(11). Built-in reset circuit is triggered at power ON.

(12). Built-in oscillator.

Page 44: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Data can be placed at any location on the LCD. For 16×1 LCD, the address locations are:

Fig : Address locations for a 1x16 line LCD

Shapes and sizes:

Page 45: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Even limited to character based modules,there is still a wide variety of shapes and sizes available.

Line lenghs of 8,16,20,24,32 and 40 charecters are all standard, in one, two and four line versions.

Several different LC technologies exists. “supertwist” types, for example, offer Improved contrast and

viewing angle over the older “twisted nematic” types. Some modules are available with back lighting, so

so that they can be viewed in dimly-lit conditions. The back lighting may be either “electro-

luminescent”, requiring a high voltage inverter circuit, or simple LED illumination.

Page 46: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Electrical blockdiagram:

Power supply for lcd driving:

PIN DESCRIPTION:

Page 47: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two pins are

extra in both for back-light LED connections).

Fig: pin diagram of 1x16 lines lcd

Page 48: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

CONTROL LINES:

EN:

Line is called "Enable." This control line is used to tell the LCD that you are sending it

data. To send data to the LCD, your program should make sure this line is low (0) and then set

the other two control lines and/or put data on the data bus. When the other lines are completely

ready, bring EN high (1) and wait for the minimum amount of time required by the LCD

datasheet (this varies from LCD to LCD), and end by bringing it low (0) again.

RS:

Line is the "Register Select" line. When RS is low (0), the data is to be treated as a

command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1),

the data being sent is text data which sould be displayed on the screen. For example, to display

the letter "T" on the screen you would set RS high.

RW:

Page 49: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Line is the "Read/Write" control line. When RW is low (0), the information on the data

bus is being written to the LCD. When RW is high (1), the program is effectively querying (or

reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are

write commands, so RW will almost always be low.

Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected

by the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3,

DB4, DB5, DB6, and DB7.

Logic status on control lines:

• E - 0 Access to LCD disabled

- 1 Access to LCD enabled

• R/W - 0 Writing data to LCD

- 1 Reading data from LCD

• RS - 0 Instructions

- 1 Character

Writing data to the LCD:

1) Set R/W bit to low

2) Set RS bit to logic 0 or 1 (instruction or character)

3) Set data to data lines (if it is writing)

4) Set E line to high

5) Set E line to low

Read data from data lines (if it is reading)on LCD:

Page 50: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

1) Set R/W bit to high

2) Set RS bit to logic 0 or 1 (instruction or character)

3) Set data to data lines (if it is writing)

4) Set E line to high

5) Set E line to low

Entering Text:

First, a little tip: it is manually a lot easier to enter characters and commands in hexadecimal

rather than binary (although, of course, you will need to translate commands from binary couple of sub-

miniature hexadecimal rotary switches is a simple matter, although a little bit into hex so that you know

which bits you are setting). Replacing the d.i.l. switch pack with a of re-wiring is necessary.

The switches must be the type where On = 0, so that when they are turned to the zero position,

all four outputs are shorted to the common pin, and in position “F”, all four outputs are open circuit.

All the available characters that are built into the module are shown in Table 3. Studying the

table, you will see that codes associated with the characters are quoted in binary and hexadecimal, most

significant bits (“left-hand” four bits) across the top, and least significant bits (“right-hand” four bits)

down the left.

Most of the characters conform to the ASCII standard, although the Japanese and Greek

characters (and a few other things) are obvious exceptions. Since these intelligent modules were

designed in the “Land of the Rising Sun,” it seems only fair that their Katakana phonetic symbols should

also be incorporated. The more extensive Kanji character set, which the Japanese share with the Chinese,

consisting of several thousand different characters, is not included!

Using the switches, of whatever type, and referring to Table 3, enter a few characters onto the

display, both letters and numbers. The RS switch (S10) must be “up” (logic 1) when sending the

characters, and switch E (S9) must be pressed for each of them. Thus the operational order is: set RS high,

Page 51: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

enter character, trigger E, leave RS high, enter another character, trigger E, and so on.

The first 16 codes in Table 3, 00000000 to 00001111, ($00 to $0F) refer to the CGRAM. This is the

Character Generator RAM (random access memory), which can be used to hold user-defined graphics

characters. This is where these modules really start to show their potential, offering such capabilities as

bar graphs, flashing symbols, even animated characters. Before the user-defined characters are set up,

these codes will just bring up strange looking symbols.

Codes 00010000 to 00011111 ($10 to $1F) are not used and just display blank characters. ASCII

codes “proper” start at 00100000 ($20) and end with 01111111 ($7F). Codes 10000000 to 10011111 ($80

to $9F) are not used, and 10100000 to 11011111 ($A0 to $DF) are the Japanese characters.

Page 52: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER
Page 53: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Initialization by Instructions:

Page 54: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

If the power conditions for the normal operation of the internal reset circuit are

not satisfied, then executing a series of instructions must initialize LCD unit. The procedure

for this initialization process is as above show.

SENSORS:

Thermocouple sensor for high temperature measurement

A sensor is a device that measures a physical quantity and converts it into a signal which can be

read by an observer or by an instrument. For example, a mercury-in-glass thermometer converts

the measured temperature into expansion and contraction of a liquid which can be read on a

calibrated glass tube. A thermocouple converts temperature to an output voltage which can be

read by a voltmeter. For accuracy, most sensors are calibrated against known standards.

Use

Sensors are used in everyday objects such as touch-sensitive elevator buttons (tactile sensor) and

lamps which dim or brighten by touching the base. There are also innumerable applications for

sensors of which most people are never aware. Applications include cars, machines, aerospace,

medicine, manufacturing and robotics.

A sensor is a device which receives and responds to a signal. A sensor's sensitivity indicates how

much the sensor's output changes when the measured quantity changes. For instance, if the

mercury in a thermometer moves 1 cm when the temperature changes by 1 °C, the sensitivity is

Page 55: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

1 cm/°C (it is basically the slope Dy/Dx assuming a linear characteristic). Sensors that measure

very small changes must have very high sensitivities. Sensors also have an impact on what they

measure; for instance, a room temperature thermometer inserted into a hot cup of liquid cools the

liquid while the liquid heats the thermometer. Sensors need to be designed to have a small effect

on what is measured, making the sensor smaller often improves this and may introduce other

advantages. Technological progress allows more and more sensors to be manufactured on a

microscopic scale as microsensors using MEMS technology. In most cases, a microsensor

reaches a significantly higher speed and sensitivity compared with macroscopic approaches.

Classification of measurement errors

A good sensor obeys the following rules:

Is sensitive to the measured property

Is insensitive to any other property likely to be encountered in its application

Does not influence the measured property

Ideal sensors are designed to be linear or linear to some simple mathematical function of the

measurement, typically logarithmic. The output signal of such a sensor is linearly proportional to

the value or simple function of the measured property. The sensitivity is then defined as the ratio

between output signal and measured property. For example, if a sensor measures temperature

and has a voltage output, the sensitivity is a constant with the unit [V/K]; this sensor is linear

because the ratio is constant at all points of measurement.

Sensor deviations

If the sensor is not ideal, several types of deviations can be observed:

The sensitivity may in practice differ from the value specified. This is called a sensitivity

error, but the sensor is still linear.

Since the range of the output signal is always limited, the output signal will eventually

reach a minimum or maximum when the measured property exceeds the limits. The full

scale range defines the maximum and minimum values of the measured property.

Page 56: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

If the output signal is not zero when the measured property is zero, the sensor has an

offset or bias. This is defined as the output of the sensor at zero input.

If the sensitivity is not constant over the range of the sensor, this is called nonlinearity.

Usually this is defined by the amount the output differs from ideal behavior over the full

range of the sensor, often noted as a percentage of the full range.

If the deviation is caused by a rapid change of the measured property over time, there is a

dynamic error. Often, this behaviour is described with a bode plot showing sensitivity

error and phase shift as function of the frequency of a periodic input signal.

If the output signal slowly changes independent of the measured property, this is defined

as drift (telecommunication).

Long term drift usually indicates a slow degradation of sensor properties over a long

period of time.

Noise is a random deviation of the signal that varies in time.

Hysteresis is an error caused by when the measured property reverses direction, but there

is some finite lag in time for the sensor to respond, creating a different offset error in one

direction than in the other.

If the sensor has a digital output, the output is essentially an approximation of the

measured property. The approximation error is also called digitization error.

If the signal is monitored digitally, limitation of the sampling frequency also can cause a

dynamic error, or if the variable or added noise noise changes periodically at a frequency

near a multiple of the sampling rate may induce aliasing errors.

The sensor may to some extent be sensitive to properties other than the property being

measured. For example, most sensors are influenced by the temperature of their

environment.

All these deviations can be classified as systematic errors or random errors. Systematic errors

can sometimes be compensated for by means of some kind of calibration strategy. Noise is a

Page 57: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

random error that can be reduced by signal processing, such as filtering, usually at the expense of

the dynamic behaviour of the sensor.

Resolution

The resolution of a sensor is the smallest change it can detect in the quantity that it is measuring.

Often in a digital display, the least significant digit will fluctuate, indicating that changes of that

magnitude are only just resolved. The resolution is related to the precision with which the

measurement is made. For example, a scanning tunneling probe (a fine tip near a surface collects

an electron tunnelling current) can resolve atoms and molecules.actuator is something that

converts energy into motion

Types

Sensors in Nature

All living organisms contain biological sensors with functions similar to those of the mechanical

devices described. Most of these are specialized cells that are sensitive to:

Light, motion, temperature, magnetic fields, gravity, humidity, vibration, pressure,

electrical fields, sound, and other physical aspects of the external environment

Physical aspects of the internal environment, such as stretch, motion of the organism, and

position of appendages (proprioception)

Environmental molecules, including toxins, nutrients, and pheromones

Estimation of biomolecules interaction and some kinetics parameters

Internal metabolic milieu, such as glucose level, oxygen level, or osmolality

Internal signal molecules, such as hormones, neurotransmitters, and cytokines

Differences between proteins of the organism itself and of the environment or alien

creatures.

Biosensor

Page 58: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

In biomedicine and biotechnology, sensors which detect analytes thanks to a biological

component, such as cells, protein, nucleic acid or biomimetic polymers, are called biosensors.

Whereas a non-biological sensor, even organic (=carbon chemistry), for biological analytes is

referred to as sensor or nanosensor (such a microcantilevers). This terminology applies for both

in vitro and in vivo applications. The encapsulation of the biological component in biosensors,

presents with a slightly different problem that ordinary sensors, this can either be done by means

of a semipermeable barrier, such as a dialysis membrane or a hydrogel, a 3D polymer matrix,

which either physically constrains the sensing macromolecule or chemically (macromolecule is

bound to the scaffold)

Temperature Sensors (LM35)Introduction:

The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is

linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over

linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant

voltage from its output to obtain convenient centigrade scaling. The LM35 does not require any external

calibration or trimming to provide typical accuracies of ±1/4°C at room temperature and ±3/4°C over a

full -55 to +150°C temperature range. Low cost is assured by trimming and calibration at the wafer level.

The LM35’s low output impedance, linear output, and precise inherent calibration make interfacing to

readout or control circuitry especially easy. It can be used with single power supplies, or with plus and

minus supplies. As it draws only 60 µA from its supply, it has very low self-heating, less than 0.1°C in still

air. The LM35 is rated to operate over a -55° to +150°C temperature range, while the LM35C is rated for

a -40° to +110°C range (-10° with improved accuracy). The LM35 series is available packaged plastic TO-

92 transistor package. The LM35D is also available in an 8-lead surface mount small outline package and

a plastic TO-220 package.

Features:

1. Calibrated directly in ° Celsius (Centigrade)

2. Linear + 10.0 mV/°C scale factor

Page 59: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

3. 0.5°C accuracy guaranteeable (at +25°C)

4. Rated for full -55° to +150°C range

5. Suitable for remote applications

6. Low cost due to wafer-level trimming

7. Operates from 4 to 30 volts

8. Less than 60 µA current drain

9. Low self-heating, 0.08°C in still air

10. Nonlinearity only ±1/4°C typical

11. Low impedance output, 0.1 for 1 mA load

Pin diagram:

Applications:

The LM35 can be applied easily in the same way as other integrated-circuit temperature sensors.

It can be glued or cemented to a surface and its temperature will be within about 0.01°C of the surface

temperature. This presumes that the ambient air temperature is almost the same as the surface

temperature; if the air temperature were much higher or lower than the surface temperature, the

actual temperature of the LM35 die would be at an intermediate temperature between the surface

temperature and the air temperature. This is expecially true for the TO-92 plastic package, where the

copper leads are the principal thermal path to carry heat into the device, so its temperature might be

Page 60: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

closer to the air temperature than to the surface temperature. To minimize this problem, be sure that

the wiring to the LM35, as it leaves the device, is held at the same temperature as the surface of

interest. The easiest way to do this is to cover up these wires with a bead of epoxy which will insure that

the leads and wires are all at the same temperature as the surface, and that the LM35 die’s temperature

will not be affected by the air temperature. The TO-46 metal package can also be soldered to a metal

surface or pipe without damage. Of course, in that case the V- terminal of the circuit will be grounded to

that metal. Alternatively, the LM35 can be mounted inside a sealed-end metal tube, and can then be

dipped into a bath or screwed into a threaded hole in a tank. As with any IC, the LM35 and

accompanying wiring and circuits must be kept insulated and dry, to avoid leakage and corrosion. This is

especially true if the circuit may operate at cold temperatures where condensation can occur. Printed-

circuit coatings and varnishes such as Humiseal and epoxy paints or dips are often used to insure that

moisture cannot corrode the LM35 or its connections. These devices are sometimes soldered to a small

light-weight heat fin, to decrease the thermal time constant and speed up the response in slowly-

moving air. On the other hand, a small thermal mass may be added to the sensor, to give the steadiest

reading despite small deviations in the air temperature.

Controller area network

Controller–area network (CAN or CAN-bus) is a vehicle bus standard designed to allow

microcontrollers and devices to communicate with each other within a vehicle without a host

computer.

CAN is a message based protocol, designed specifically for automotive applications but now also

used in other areas such as industrial automation and medical equipment.

Development of the CAN-bus started originally in 1983 at Robert Bosch GmbH.[1] The protocol

was officially released in 1986 at the Society of Automotive Engineers (SAE) congress in

Detroit, Michigan. The first CAN controller chips, produced by Intel and Philips, came on the

market in 1987. Bosch published the CAN 2.0 specification in 1991.

Page 61: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

CAN is one of five protocols used in the OBD-II vehicle diagnostics standard. The OBD

standard has been mandatory for all cars and light trucks sold in the United States since 1996,

and the EOBD standard, mandatory for all petrol vehicles sold in the European Union since 2001

and all diesel vehicles since 2004.[2]

Applications

Automotive

A modern automobile may have as many as 70 electronic control units (ECU) for various

subsystems.[3] Typically the biggest processor is the engine control unit (also engine control

module/ECM in automobiles); others are used for transmission, airbags, antilock braking, cruise

control, audio systems, windows, doors, mirror adjustment, etc. Some of these form independent

subsystems, but communications among others are essential. A subsystem may need to control

actuators or receive feedback from sensors. The CAN standard was devised to fill this need.

The CAN bus may be used in vehicles to connect engine control unit and transmission, or (on a

different bus) to connect the door locks, climate control, seat control, etc. Today the CAN bus is

also used as a fieldbus in general automation environments, primarily due to the low cost of

some CAN Controllers and processors.

Bosch holds patents on the technology, and manufacturers of CAN-compatible microprocessors

pay license fees to Bosch, which are normally passed on to the customer in the price of the chip.

Manufacturers of products with custom ASICs or FPGAs containing CAN-compatible modules

may need to pay a fee for the CAN Protocol License.

Technology

CAN is a multi-master broadcast serial bus standard for connecting electronic control units

(ECUs).

Each node is able to send and receive messages, but not simultaneously. A message consists

primarily of an id, which represents the priority of the message, and up to eight data bytes. It is

Page 62: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

transmitted serially onto the bus. This signal pattern is encoded in non-return-to-zero (NRZ) and

is sensed by all nodes.

The devices that are connected by a CAN network are typically sensors, actuators, and other

control devices. These devices are not connected directly to the bus, but through a host processor

and a CAN controller.

If the bus is free, any node may begin to transmit. If two or more nodes begin sending messages

at the same time, the message with the more dominant id (which has more dominant bits, i.e.,

zeroes) will overwrite other nodes' less dominant id's, so that eventually (after this arbitration on

the id.) only the dominant message remains and is received by all nodes. This mechanism is

referred to as priority based bus arbitration. Messages with numerically smaller values of id.

have higher priority and are transmitted first.

Each node requires a

Host processor

o The host processor decides what received messages mean and which messages it

wants to transmit itself.

o Sensors, actuators and control devices can be connected to the host processor.

CAN controller (hardware with a synchronous clock).

o Receiving: the CAN controller stores received bits serially from the bus until an

entire message is available, which can then be fetched by the host processor

(usually after the CAN controller has triggered an interrupt).

o Sending: the host processor stores its transmit messages to a CAN controller,

which transmits the bits serially onto the bus.

Transceiver (possibly integrated into the CAN controller)

o Receiving: it adapts signal levels from the bus to levels that the CAN controller

expects and has protective circuitry that protects the CAN controller.

Page 63: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

o Sending: it converts the transmit-bit signal received from the CAN controller into

a signal that is sent onto the bus.

Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate

allows longer network distances (e.g., 500 m at 125 kbit/s).

The CAN data link layer protocol is standardized in ISO 11898-1 (2003). This standard describes

mainly the data link layer (composed of the logical link control (LLC) sublayer and the media

access control (MAC) sublayer) and some aspects of the physical layer of the OSI reference

model. All the other protocol layers are the network designer's choice.

Data transmission

CAN features an automatic arbitration-free transmission. A CAN message that is transmitted

with highest priority will succeed, and the node transmitting the lower priority message will

sense this and back off and wait.

This is achieved by CAN transmitting data through a binary model of "dominant" bits and

"recessive" bits where dominant is a logical 0 and recessive is a logical 1. This means open

collector, or wired or physical implementation of the bus (but since dominant is 0 this is

sometimes referred to as wired and). If one node transmits a dominant bit and another node

transmits a recessive bit then the dominant bit "wins" (a logical AND between the two).

So, if you are transmitting a recessive bit, and someone sends a dominant bit, you see a dominant

bit, and you know there was a collision. (All other collisions are invisible.) A dominant bit is

asserted by creating a voltage across the wires while a recessive bit is simply not asserted on the

bus. If any node sets a voltage difference, all nodes will see it. Thus there is no delay to the

higher priority messages, and the node transmitting the lower priority message automatically

attempts to re-transmit 6 bit clocks after the end of the dominant message.

Page 64: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

When used with a differential bus, a carrier sense multiple access/bitwise arbitration

(CSMA/BA) scheme is often implemented: if two or more devices start transmitting at the same

time, there is a priority based arbitration scheme to decide which one will be granted permission

to continue transmitting. The CAN solution to this is prioritized arbitration (and for the dominant

message delay free), making CAN very suitable for real time prioritised communications

systems.

During arbitration, each transmitting node monitors the bus state and compares the received bit

with the transmitted bit. If a dominant bit is received when a recessive bit is transmitted then the

node stops transmitting (i.e., it lost arbitration). Arbitration is performed during the transmission

of the identifier field. Each node starting to transmit at the same time sends an id. with dominant

as binary 0, starting from the high bit. As soon as their id. is a larger number (lower priority)

they'll be sending 1 (recessive) and see 0 (dominant), so they back off. At the end of id.

transmission, all nodes but one have backed off, and the highest priority message gets through

unimpeded.

For example, consider an 11-bit id. CAN network, with two nodes with id's of 15 (binary

representation, 00000001111) and 16 (binary representation, 00000010000). If these two nodes

transmit at the same time, each will transmit the first 6 zeros of their id. with no arbitration

decision being made. When the 7th bit is transmitted, the node with the id. of 16 transmit a 1

(recessive) for its id., and the node with the id. of 15 transmits a 0 (dominant) for its id.. When

this happens, the node with the id. of 16 will realize that it lost its arbitration, and allow the node

with id. of 15 to continue its transmission. This ensures that the node with the lower bit value

will always win the arbitration. The id. with the smaller number will win the right to use.

Id. allocation

Messages id's must be unique on a single CAN bus, otherwise two nodes would continue

transmission beyond the end of the arbitration field (id.) causing an error.

The choice of id's for messages is often done simply on the basis of identifying the type of data

and the sending node; however, as the id. is also used as the message priority, this can lead to

poor real-time performance. For example, if an urgent message with a short deadline has a

Page 65: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

numerically high id. (low priority) then its transmission can be delayed by other messages with

lower numerical id's (higher priority), even though these messages may have much longer

deadlines.

In the early 1990s, CAN messages in automotive systems were typically given id's based only on

the type of data and sending node, and this led to the widely held but incorrect belief that a low

CAN bus utilization of circa 30% was required to ensure that all messages would meet their

deadlines. However, if id's are instead determined based on the deadline of the message, so the

shorter the deadline, the lower the numerical id. and hence the higher the message priority, then

bus utilizations of 70 to 80% can typically be achieved before any message deadlines are missed.

Bit timing

Each node in a CAN network has its own clock, and no clock is sent during data transmission.

Synchronization is done by dividing each bit of the frame into a number of segments:

Synchronization, Propagation, Phase 1 and Phase 2. The Length of each phase segment can be

adjusted based on network and node conditions. The sample point falls between Phase Buffer

Segment 1 and Phase Buffer Segment 2, which helps facilitate continuous synchronization.

Continuous synchronization in turn enables the receiver to be able to properly read the messages.

CAN Bit Timing

Layers

Based on levels of abstraction, the structure of the CAN protocol can be described in terms of the

following layers:

Page 66: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Application Layer

Object Layer

o Message Filtering

o Message and Status Handling

Transfer Layer

The Transfer Layer represents the kernel of the CAN protocol. It presents messages

received to the object layer and accepts messages to be transmitted from the object layer.

The transfer layer is responsible for bit timing and synchronization, message framing,

arbitration, acknowledgement, error detection and signalling, and fault confinement. It

performs:

Fault Confinement

Error Detection

Message Validation

Acknowledgement

Arbitration

Message Framing

Transfer Rate and Timing

Information Routing

Physical Layer

CAN bus in its original form was a link layer protocol specification that made reference to the

physical layer only in abstract terms. (IE as a medium that supported multiple access at the

individual bit level by providing dominant and recessive states). In recent times the ISO11898-2

standard went some distance towards providing a candidate concrete class definition for the

electrical part of the physical layer and is now widely adopted as a standard solution. The

mechanical aspects of the physical layer however (connector type, pin-outs etc.) continue to lack

Page 67: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

formal treatment and it is from this background that we see the emergence of several de-facto

standards for mechanical implementation with the 9 Way ‘D’ type CAN-(2), CAN+(7), OV (3),

Supply(9) configuration as one of the most common.

[Tip for node designers here wishing to standardise on the de-facto mechanical interface:- Make

sure each node is provided with 1 male and 1 female 9 Way D connector electrically wired in

parallel. – Assume power is fed to the male and drawn from the female – Adoption of this

strategy allows buses to be constructed using standard cable sets and avoids the use of the

dreaded ‘ hand built 2 cables into 1 D type’ scenario which over the years has made a significant

contribution to bus unreliability, cable incompatibility and per network cost.]

The absence of a formal definition for the physical layer had the original advantage of freeing the

scope of CAN bus from the constraints of any one particular physical implementation however

its legacy has been to leave CAN bus implementations open to inter-operability issues in the

physical domain.

The very high noise immunity on ISO11898-2 is achieved by ensuring that the differential

impedance of the bus is maintained at a very low level using low value resistors (120 ohms)

mounted at each end of the bus. The low impedance draws more current (and power) than other

voltage based signalling specifications during the dominant state. On CAN bus systems,

balanced line operation, where current in one signal line is exactly balanced by current in the

opposite direction in the other signal leg becomes an essential facility to provide an independant

stable 0 V reference for the receivers. Best practice determines that CAN bus balanced pair

signals be carried in twisted pair form within a shielded cable and it is this precaution that helps

to keep RF emissions to a minimum.

Whilst ISO11898-2 provides a small degree of immunity to common mode voltage between

transmitter and receiver it is usual to implement networks with a high degree of voltage

association between the transceivers of different nodes by having a 0 V rail running along the

bus. Also, in the de-facto configuration, a supply rail is also included to distribute power to each

of the participating CAN bus transceiver nodes. The design intention here is to provide a

common supply for all the transceivers rather than as a convenient method of powering all the

Page 68: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

nodes. It should be noted however, that the actual Voltage to be applied, which nodes apply it (if

any) are application specific and not formally specified. Common ‘good practice’ node design

might provide each node with transceivers which are optically isolated from their node host and

derive a 5 V linearly regulated supply voltage for the transceivers from the universal supply rail

provided by the bus. This configuration generally allows a sufficiently wide operating margin on

the supply rail to provide interoperability across a broad spectrum of different node types.

Typical values of supply voltage on such networks range between 7 and 30 Volts however lack

of standardisation means that ultimately it is up to the individual system designer to check out all

aspects of supply rail compatibility.

The standard (ISO11898-2) describes the electrical implementation formed from a multi-dropped

single-ended balanced line configuration with resistor termination at each end of the bus. In this

configuration a dominant state is asserted by 1 or more transmitters switching the CAN- to

supply 0 V and (simultaneously) switching CAN+ to the +5 V bus voltage thereby forming a

current path through the resistors that terminate the bus. As such the terminating resistors form

an essential component of the signalling system and are included not just to limit wave reflection

at high frequency. During a recessive state the signal lines and resistor(s) remain in a high

impedances state with respect to both rails. Voltages on both CAN+ and CAN- tend (weakly)

towards ½ rail voltage. During a dominant state the signal lines and resistor(s) move to a low

impedance state with respect to the rails so that current flows through the resistor. CAN+ voltage

tends to +5 V and CAN- tends to 0 V. A recessive state is only present on the bus when none of

the transmitters on the bus is asserting a dominant state. Irrespective of signal state the signals

lines are always in low impedance state with respect to one another by virtue of the terminating

resistors at the end of the bus.

It should be noted that this signalling strategy differs significantly from other balanced line

transmission technologies such as RS-422/3, RS-485, etc. which employ differential line drivers/

receivers and use a signalling system based on the differential mode voltage of the balanced line

crossing a notional 0 V. Multiple access on such systems normally relies on the media supporting

3 states (active high, active low and inactive tri-state)and is dealt with in the time domain.

Multiple access on CAN bus is achieved by the electrical logic of the system supporting just 2

states that are conceptually analagous to a ‘wired OR’ network.

Page 69: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Frames

A CAN network can be configured to work with two different message (or "frame") formats: the

standard or base frame format (or CAN 2.0 A), and the extended frame format (or CAN 2.0 B).

The only difference between the two formats is that the "CAN base frame" supports a length of

11 bits for the identifier, and the "CAN extended frame" supports a length of 29 bits for the

identifier, made up of the 11-bit identifier ("base identifier") and an 18-bit extension ("identifier

extension"). The distinction between CAN base frame format and CAN extended frame format is

made by using the IDE bit, which is transmitted as dominant in case of an 11-bit frame, and

transmitted as recessive in case of a 29-bit frame. CAN controllers that support extended frame

format messages are also able to send and receive messages in CAN base frame format. All

frames begin with a start-of-frame (SOF) bit that denotes the start of the frame transmission.

CAN has four frame types:

Data frame: a frame containing node data for transmission

Remote frame: a frame requesting the transmission of a specific identifier

Error frame: a frame transmitted by any node detecting an error

Overload frame: a frame to inject a delay between data and/or remote frame

Data frame

The data frame is the only frame for actual data transmission. There are two message formats:

Base frame format: with 11 identifier bits

Extended frame format: with 29 identifier bits

The CAN standard requires the implementation must accept the base frame format and may

accept the extended frame format, but must tolerate the extended frame format.

ZigBee

Page 70: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

ZigBee module. The €1 coin, shown for size reference, is about 23 mm (0.9 inch) in diameter.

ZigBee is a specification for a suite of high level communication protocols using small, low-

power digital radios based on the IEEE 802.15.4-2003 standard for Low-Rate Wireless Personal

Area Networks (LR-WPANs), such as wireless light switches with lamps, electrical meters with

in-home-displays, consumer electronics equipment via short-range radio needing low rates of

data transfer. The technology defined by the ZigBee specification is intended to be simpler and

less expensive than other WPANs, such as Bluetooth. ZigBee is targeted at radio-frequency (RF)

applications that require a low data rate, long battery life, and secure networking.

Technical overview

ZigBee is a low-cost, low-power, wireless mesh networking standard. First, the low cost allows

the technology to be widely deployed in wireless control and monitoring applications. Second,

the low power-usage allows longer life with smaller batteries. Third, the mesh networking

provides high reliability and more extensive range.

It is not capable of powerline networking though other elements of the OpenHAN standards suite

promoted by openAMI [1] and UtilityAMI [2] deal with communications co-extant with AC

power outlets. In other words, ZigBee is intended not to support powerline networking but to

interface with it at least for smart metering and smart appliance purposes. Utilities, e.g. Penn

Energy, have declared the intent to require them to interoperate [3] again via the openHAN

standards.

Trademark and Alliance

Page 71: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

The ZigBee Alliance is an association of companies working together to enable reliable, cost-

effective, and low-power wirelessly networked monitoring and control products based on an

open global standard.[1]

The ZigBee Alliance is a group of companies that maintain and publish the ZigBee standard. The

term ZigBee is a registered trademark of this group, not a single technical standard.

As per its main role, it standardizes the body that defines ZigBee, and also publishes application

profiles that allow multiple OEM vendors to create interoperable products. The current list of

application profiles either published, or in the works are:

Released specifications

ZigBee Home Automation

ZigBee Smart Energy 1.0

ZigBee Telecommunication Services

ZigBee Health Care

ZigBee Remote Control

Specifications under development

ZigBee Smart Energy 2.0

ZigBee Building Automation

ZigBee Retail Services

The relationship between IEEE 802.15.4 and ZigBee[2] is similar to that between IEEE 802.11

and the Wi-Fi Alliance. The ZigBee 1.0 specification was ratified on 14 December 2004 and is

available to members of the ZigBee Alliance. Most recently, the ZigBee 2007 specification was

posted on 30 October 2007. The first ZigBee Application Profile, Home Automation, was

announced 2 November 2007. As amended by NIST, the Smart Energy Profile 2.0 specification

Page 72: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

will remove the dependency on IEEE 802.15.4. Device manufacturers will be able to implement

any MAC/PHY, such as IEEE 802.15.4(x) and IEEE P1901, under an IP layer based on

6LoWPAN.

ZigBee operates in the industrial, scientific and medical (ISM) radio bands; 868 MHz in Europe,

915 MHz in the USA and Australia, and 2.4 GHz in most jurisdictions worldwide. The

technology is intended to be simpler and less expensive than other WPANs such as Bluetooth.

ZigBee chip vendors typically sell integrated radios and microcontrollers with between 60 KB

and 256 KB flash memory.

Chip vendors/devices include

Atmel ATmega128RFA1

Digi International XBee XB24CZ7PIS-004

Freescale MC13213

Ember EM250

Jennic JN5148

Renesas uPD78F8056/57/58, M16C/6B3 and R8C/3MQ

STMicroelectronics STM32W

Samsung Electro-Mechanics ZBS240

Texas Instruments CC2530 and CC2520

Radios are also available as stand-alone components to be used with any processor or

microcontroller. Generally, the chip vendors also offer the ZigBee software stack, although

independent ones are also available.

Because ZigBee can activate (go from sleep to active mode) in 30 msec or less, the latency can

be very low and devices can be very responsive — particularly compared to Bluetooth wake-up

Page 73: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

delays, which are typically around three seconds. [3] Because ZigBees can sleep most of the time,

average power consumption can be very low, resulting in long battery life.

The first stack release is now called ZigBee 2004. The second stack release is called ZigBee

2006, and mainly replaces the MSG/KVP structure used in 2004 with a "cluster library". The

2004 stack is now more or less obsolete.[citation needed]

ZigBee 2007, now the current stack release, contains two stack profiles, stack profile 1 (simply

called ZigBee), for home and light commercial use, and stack profile 2 (called ZigBee Pro).

ZigBee Pro offers more features, such as multi-casting, many-to-one routing and high security

with Symmetric-Key Key Exchange (SKKE), while ZigBee (stack profile 1) offers a smaller

footprint in RAM and flash. Both offer full mesh networking and work with all ZigBee

application profiles.[citation needed]

ZigBee 2007 is fully backward compatible with ZigBee 2006 devices: A ZigBee 2007 device

may join and operate on a ZigBee 2006 network and vice versa. Due to differences in routing

options, ZigBee Pro devices must become non-routing ZigBee End-Devices (ZEDs) on a ZigBee

2006 network, the same as for ZigBee 2006 devices on a ZigBee 2007 network must become

ZEDs on a ZigBee Pro network. The applications running on those devices work the same,

regardless of the stack profile beneath them.

Licensing

For non-commercial purposes, the ZigBee specification is available free to the general public. [4]

An entry level membership in the ZigBee Alliance, called Adopter, provides access to the as-yet

unpublished specifications and permission to create products for market using the specifications.

The click through license on the ZigBee specification requires a commercial developer to join

the ZigBee Alliance. "No part of this specification may be used in development of a product for

sale without becoming a member of ZigBee Alliance." This causes problems for open-source

developers because the annual fee conflicts with the GNU General Public License. From the

GPL v2, "b) You must cause any work that you distribute or publish, that in whole or in part

contains or is derived from the Program or any part thereof, to be licensed as a whole at no

Page 74: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

charge to all third parties under the terms of this License." Since the GPL makes no distinction

between commercial and non-commercial use it is impossible to implement a GPL licensed

ZigBee stack or combine a ZigBee implementation with GPL licensed code. The requirement for

the developer to join the ZigBee Alliance similarly conflicts with most other Free software

licenses.[5]

Uses

ZigBee protocols are intended for use in embedded applications requiring low data rates and low

power consumption. ZigBee's current focus is to define a general-purpose, inexpensive, self-

organizing mesh network that can be used for industrial control, embedded sensing, medical data

collection, smoke and intruder warning, building automation, home automation, etc. The

resulting network will use very small amounts of power — individual devices must have a

battery life of at least two years to pass ZigBee certification.[6]

Typical application areas include[7]

Home Entertainment and Control — Smart lighting, advanced temperature control,

safety and security, movies and music

Wireless Sensor Networks' — Starting with individual sensors like Telosb/Tmote and

Iris from Memsic.

Device types

There are three different types of ZigBee devices:

ZigBee coordinator (ZC): The most capable device, the coordinator forms the root of the

network tree and might bridge to other networks. There is exactly one ZigBee coordinator

in each network since it is the device that started the network originally. It is able to store

information about the network, including acting as the Trust Center & repository for

security keys[8][9].

ZigBee Router (ZR): As well as running an application function, a router can act as an

intermediate router, passing on data from other devices.

Page 75: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

ZigBee End Device (ZED): Contains just enough functionality to talk to the parent node

(either the coordinator or a router); it cannot relay data from other devices. This

relationship allows the node to be asleep a significant amount of the time thereby giving

long battery life. A ZED requires the least amount of memory, and therefore can be less

expensive to manufacture than a ZR or ZC.

Protocols

The protocols build on recent algorithmic research (Ad-hoc On-demand Distance Vector,

neuRFon) to automatically construct a low-speed ad-hoc network of nodes. In most large

network instances, the network will be a cluster of clusters. It can also form a mesh or a single

cluster. The current profiles derived from the ZigBee protocols support beacon and non-beacon

enabled networks.

In non-beacon-enabled networks (those whose beacon order is 15), an unslotted CSMA/CA

channel access mechanism is used. In this type of network, ZigBee Routers typically have their

receivers continuously active, requiring a more robust power supply. However, this allows for

heterogeneous networks in which some devices receive continuously, while others only transmit

when an external stimulus is detected. The typical example of a heterogeneous network is a

wireless light switch: The ZigBee node at the lamp may receive constantly, since it is connected

to the mains supply, while a battery-powered light switch would remain asleep until the switch is

thrown. The switch then wakes up, sends a command to the lamp, receives an acknowledgment,

and returns to sleep. In such a network the lamp node will be at least a ZigBee Router, if not the

ZigBee Coordinator; the switch node is typically a ZigBee End Device.

In beacon-enabled networks, the special network nodes called ZigBee Routers transmit periodic

beacons to confirm their presence to other network nodes. Nodes may sleep between beacons,

thus lowering their duty cycle and extending their battery life. Beacon intervals may range from

15.36 milliseconds to 15.36 ms * 214 = 251.65824 seconds at 250 kbit/s, from 24 milliseconds to

Page 76: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

24 ms * 214 = 393.216 seconds at 40 kbit/s and from 48 milliseconds to 48 ms * 214 = 786.432

seconds at 20 kbit/s. However, low duty cycle operation with long beacon intervals requires

precise timing, which can conflict with the need for low product cost.

In general, the ZigBee protocols minimize the time the radio is on so as to reduce power use. In

beaconing networks, nodes only need to be active while a beacon is being transmitted. In non-

beacon-enabled networks, power consumption is decidedly asymmetrical: some devices are

always active, while others spend most of their time sleeping.

Except for the Smart Energy Profile 2.0, which will be MAC/PHY agnostic, ZigBee devices are

required to conform to the IEEE 802.15.4-2003 Low-Rate Wireless Personal Area Network

(WPAN) standard. The standard specifies the lower protocol layers—the physical layer (PHY),

and the media access control (MAC) portion of the data link layer (DLL). This standard specifies

operation in the unlicensed 2.4 GHz (worldwide), 915 MHz (Americas) and 868 MHz (Europe)

ISM bands. In the 2.4 GHz band there are 16 ZigBee channels, with each channel requiring

5 MHz of bandwidth. The center frequency for each channel can be calculated as, FC = (2405 + 5

* (ch - 11)) MHz, where ch = 11, 12, ..., 26.

The radios use direct-sequence spread spectrum coding, which is managed by the digital stream

into the modulator. BPSK is used in the 868 and 915 MHz bands, and OQPSK that transmits

four bits per symbol is used in the 2.4 GHz band. The raw, over-the-air data rate is 250 kbit/s per

channel in the 2.4 GHz band, 40 kbit/s per channel in the 915 MHz band, and 20 kbit/s in the

868 MHz band. Transmission range is between 10 and 75 meters (33 and 246 feet) and up to

1500 meters for zigbee pro, although it is heavily dependent on the particular environment. The

output power of the radios is generally 0 dBm (1 mW).

The basic channel access mode is "carrier sense, multiple access/collision avoidance"

(CSMA/CA). That is, the nodes talk in the same way that people converse; they briefly check to

see that no one is talking before they start. There are three notable exceptions to the use of

CSMA. Beacons are sent on a fixed timing schedule, and do not use CSMA. Message

acknowledgments also do not use CSMA. Finally, devices in Beacon Oriented networks that

Page 77: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

have low latency real-time requirements may also use Guaranteed Time Slots (GTS), which by

definition do not use CSMA.

ZigBee RF4CE

On March 3, 2009 the RF4CE (Radio Frequency for Consumer Electronics) Consortium agreed

to work with the ZigBee Alliance to jointly deliver a standardized specification for radio

frequency-based remote controls. ZigBee RF4CE is designed to be deployed in a wide range of

remotely-controlled audio/visual consumer electronics products, such as TVs and set-top boxes.

It promises many advantages over existing remote control solutions, including richer

communication and increased reliability, enhanced features and flexibility, interoperability, and

no line-of-sight barrier.[10]

Software and hardware

The software is designed to be easy to develop on small, inexpensive microprocessors. The radio

design used by ZigBee has been carefully optimized for low cost in large scale production. It has

few analog stages and uses digital circuits wherever possible.

Even though the radios themselves are inexpensive, the ZigBee Qualification Process involves a

full validation of the requirements of the physical layer. This amount of concern about the

Physical Layer has multiple benefits, since all radios derived from that semiconductor mask set

would enjoy the same RF characteristics. On the other hand, an uncertified physical layer that

malfunctions could cripple the battery lifespan of other devices on a ZigBee network. Where

other protocols can mask poor sensitivity or other esoteric problems in a fade compensation

response, ZigBee radios have very tight engineering constraints: they are both power and

bandwidth constrained. Thus, radios are tested to the ISO 17025 standard with guidance given by

Clause 6 of the 802.15.4-2006 Standard. Most vendors plan to integrate the radio and

microcontroller onto a single chip [4] getting smaller devices [5].

History

Page 78: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

ZigBee-style networks began to be conceived around 1998, when many installers realized

that both Wi-Fi and Bluetooth were going to be unsuitable for many applications. In

particular, many engineers[by whom?] saw a need for self-organizing ad-hoc digital radio

networks.[citation needed]

The IEEE 802.15.4-2003 standard was completed in May 2003 and has been superseded

by the publication of IEEE 802.15.4-2006. [6]

In the summer of 2003, Philips Semiconductors, a major mesh network supporter, ceased

the investment. Philips Lighting has, however, continued Philips' participation, and

Philips remains a promoter member on the ZigBee Alliance Board of Directors.[citation needed]

The ZigBee Alliance announced in October 2004 that the membership had more than

doubled in the preceding year and had grown to more than 100 member companies, in 22

countries. By April 2005 membership had grown to more than 150 companies, and by

December 2005 membership had passed 200 companies.[citation needed]

The ZigBee specifications were ratified on 14 December 2004.[citation needed]

The ZigBee Alliance announces public availability of Specification 1.0 on 13 June 2005,

known as ZigBee 2004 Specification.

The ZigBee Alliance announces the completion and immediate member availability of

the enhanced version of the ZigBee Standard in September 2006, known as ZigBee 2006

Specification.

During the last quarter of 2007, ZigBee PRO, the enhanced ZigBee specification was

finalized.[citation needed]

Origin of the ZigBee name

The name of the brand is originated with reference to the behaviour of honey bees after their

return to the beehive

Page 79: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Buzzer

A buzzer or beeper is an audio signaling device, which may be mechanical, electromechanical,

or Piezoelectric. Typical uses of buzzers and beepers include alarms, timers and confirmation of

user input such as a mouse click or keystroke.

Mechanical

A joy buzzer is an example of a purely mechanical buzzer.

Electromechanical

Early devices were based on an electromechanical system identical to an electric bell without the

metal gong. Similarly, a relay may be connected to interrupt its own actuating current, causing

the contacts to buzz. Often these units were anchored to a wall or ceiling to use it as a sounding

board. The word "buzzer" comes from the rasping noise that electromechanical buzzers made.

Piezoelectric

Piezoelectric disk beeper

A piezoelectric element may be driven by an oscillating electronic circuit or other audio signal

source, driven with a piezoelectric audio amplifier. Sounds commonly used to indicate that a

button has been pressed are a click, a ring or a beep.

Uses

Page 80: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Annunciator panels

Electronic metronomes

Game shows

Microwave ovens and other household appliances

Sporting events such as basketball games

.

An alarm gives an audible or visual warning about a problem or condition.

Alarms include:

burglar alarms, designed to warn of burglaries; this is often a silent alarm: the police or

guards are warned without indication to the burglar, which increases the chances of

catching him or her.

alarm clocks can produce an alarm at a given time

distributed control manufacturing systems or DCSs, found in nuclear power plants,

refineries and chemical facilities also generate alarms to direct the operator's attention to

an important event that he or she needs to address.

alarms in an operation and maintenance (O&M) monitoring system, which informs the

bad working state of (a particular part of) the system under monitoring.

o first-out alarm

safety alarms, which go off if a dangerous condition occurs. Common public safety

alarms include:

o tornado sirens

o fire alarms

"Multiple-alarm fire", a locally-specific measure of the severity of a fire

and the fire-department reaction required.

Page 81: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

o car alarms

o community Alarm or autodialer alarm (medical alarms)

o air raid sirens

o personal alarm

o tocsins — a historical method of raising an alarm

Alarms have the capability of causing a fight-or-flight response in humans; a person under this

mindset will panic and either flee the perceived danger or attempt to eliminate it, often ignoring

rational thought in either case. We can characterise a person in such a state as "alarmed".

With any kind of alarm, the need exists to balance between on the one hand the danger of false

alarms (called "false positives") — the signal going off in the absence of a problem — and on the

other hand failing to signal an actual problem (called a "false negative"). False alarms can waste

resources expensively and can even be dangerous. For example, false alarms of a fire can waste

firefighter manpower, making them unavailable for a real fire, and risk injury to firefighters and

others as the fire engines race to the alleged fire's location. In addition, false alarms may

acclimatise people to ignore alarm signals, and thus possibly to ignore an actual emergency:

Aesop's fable of The Boy Who Cried Wolf exemplifies this problem.

Etymology

The word comes from the Old French À l'arme meaning "To the arms", "To the weapons",

telling armed men to pick up their weapons and get ready for action, because an enemy may have

suddenly appeared.

Page 82: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Software components

Configuring the Simulator

Open the Keil Vision2

Go to Project – Open Project and browse for Hello in Ch03_00 in Pont and open it.

Go to Project – Select Device for Target ‘Target1’

Page 83: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Select 8052(all variants) and click OK

Now we need to check the oscillator frequency:

Page 84: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Go to project – Options for Target ‘Target1’

Make sure that the oscillator frequency is 12MHz.

Building the Target

Page 85: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Build the target as illustrated in the figure below

Running the Simulation

Having successfully built the target, we are now ready to start the debug session and run the

simulator.

First start a debug session

Page 86: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

The flashing LED we will view will be connected to Port 1. We therefore want to observe the activity on

this port

Page 87: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

To ensure that the port activity is visible, we need to start the ‘periodic window update’ flag

Go to Debug - Go

Page 88: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

While the simulation is running, view the performance analyzer to check the delay durations.

Page 89: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Go to

Debug – Performance Analyzer and click on it

Page 90: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Double click on DELAY_LOOP_Wait in Function Symbols: and click Define button

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

 

Page 91: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

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 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

Page 92: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

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.

•         Knowledge of the processor instruction set is not required.

•         A rudimentary knowledge of the 8051’s memory architecture is desirable

but not 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 process can be used.

•         Program development and debugging times are dramatically reduced

when compared to assembly language programming.

Page 93: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

•         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.

•         Existing routine can be reused in new programs by utilizing the modular

programming techniques available with C.

•         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.

 

Keil C cross compiler: -

Keil is a German based Software development company. It provides several

development tools like

•         IDE (Integrated Development environment)

•         Project Manager

•         Simulator

•         Debugger

•         C Cross Compiler, Cross Assembler, Locator/Linker

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.     ARM Optimizing C Cross Compiler,

2.     Macro Assembler,

Page 94: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

3.    ARM Utilities (linker, object file converter, library manager),

4.     Source-Level Debugger/Simulator,

5.     µVision for Windows Integrated Development Environment.

The keil ARM tool kit includes three main tools, assembler, compiler and linker.

An assembler is used to assemble your ARM assembly program

A compiler is used to compile your C source code into an object file

A linker is used to create an absolute object module suitable for your in-circuit

emulator.

Embedded C:

Data Types:

U people have already come across the word “Data types” in C- Language. Here also the

functionality and the meaning of the word is same except a small change in the prefix of their labels.

Now we will discuss some of the widely used data types for embedded C- programming.

Data Types Size in Bits Data Range/Usage

unsigned char 8-bit 0-255

signed char 8-bit -128 to +127

unsigned int 16-bit 0 to 65535

signed int 16-bit -32,768 to +32,767

sbit 1-bit SFR bit addressable only

Bit 1-bit RAM bit addressable only

sfr 8-bit RAM addresses 80-FFH

only

Sbit (single bit):

The sbit data type is widely used and designed specifically to access single bit

addressable registers. It allows access to the single bits of the SFR registers.

Page 95: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

Source code:

#include<reg52.h>#include<intrins.h>#include "lcd.h"void _nop_(void);

#define delay_us _nop_(); //generates 1 microsecond

sbit sck=P3^4;sbit dout=P3^5;sbit din=P3^6;sbit cs=P3^7;

unsigned char txrxbyte(unsigned char);

unsigned char byte1,byte2,byte3; float dcode1,dcode2,dcode3; float vref=4.096,output,output1,output2,output3; unsigned int i,j;

void integer_lcd(int);void timer(unsigned int);void init_lcd(void);void cmd_lcd(unsigned char);void write_lcd(unsigned char);void delay_ms(unsigned int);

bit flag=0;void transmit(unsigned char *);void integer_lcd1(int);

void main(void){unsigned int p=0,t=0; TMOD=0x20; SCON=0x50; TH1=0XFD; TR1=1; IE=0x90;

init_lcd(); display_lcd("real time patient"); cmd_lcd(0xc0); display_lcd("USING CAN BUS"); delay_ms(1000);

while(1) {

Page 96: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

cs=0; byte1=txrxbyte(0x06); byte2=txrxbyte(0x00); byte3=txrxbyte(0x00); i=(byte2&0x0f); i=(i<<8|byte3); dcode1=(((4.096*i)/4096)); //output1=dcode1; dcode1=dcode1/0.035; cs=1; delay_ms(10); cs=0; byte1=txrxbyte(0x06); byte2=txrxbyte(0x40); byte3=txrxbyte(0x00); i=(byte2&0x0f); i=(i<<8|byte3); dcode2=(((4.096*i)/4096)); //output1=dcode1; dcode2=dcode2*100; cs=1; delay_ms(10); if(dcode2>45) { SBUF='T'; while(!TI); TI=0; } else { SBUF='t'; while(!TI); TI=0; } if(dcode1>70) { SBUF='H'; while(!TI); TI=0; } else { SBUF='h'; while(!TI); TI=0; } cmd_lcd(0x01); display_lcd("TEMPARATURE: *C"); cmd_lcd(0xc0); integer_lcd(dcode2); delay_ms(1000); cmd_lcd(0x01); display_lcd("Humidity: %RH");

Page 97: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

cmd_lcd(0xc0); integer_lcd(dcode1); delay_ms(1000);

}}

void transmit(unsigned char *t_data){

while(*t_data!='\0'){SBUF = *t_data;while(!TI);TI=0;t_data++;}

}

unsigned char txrxbyte( unsigned char d) { char mask=0x80; unsigned char i,c=0x00; for(i=0;i<8;i++) { sck=1; if(d&mask) {din=1;} else {din=0;} sck=0; if(dout==1) {c=c|mask;} mask=mask>>1; } return c; }

}

Receiver section:

//program to implement rs232 serial communication using loop back test

#include<reg51.h>

Page 98: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

#define LCD P2sbit AB =P1^0;

void init_lcd(void);void cmd_lcd(unsigned char);void write_lcd(unsigned char);void display_lcd(unsigned char *);void delay_ms(unsigned int);

void serial_intr(void) interrupt 4;

unsigned char *s="TARANG WORKING",*c;void main(void){ init_lcd();TMOD=0x20; //set timer1 to mode2SCON=0x50; //set serial communication parameters,

// mode1=1 start bit, 8 data bits, 1 stop bit, no parity & receive enableIE=0x90; //set global interrupt bit EA=1, serial interrupt bit ES=1TH1=0xfd; //set 9600 baud rateTR1=1; //start timer1c=s;

display_lcd(" CAN BASED "); cmd_lcd(0xc0); display_lcd("PATIENT MONITORING"); cmd_lcd(0x01);

display_lcd("TEMPARATURE:"); while(1);{

cmd_lcd(0xc0);while(*c){

SBUF=*c++; //transmit bytedelay_ms(100);

}delay_ms(1000);c=s;

}}

//interrupt service routine for serial interruptvoid serial_intr(void) interrupt 4{

if(TI) //if transmit interrupt, clear TITI=0;

if(RI) //if receive interrupt, clear RI{ if(SBUF=='T') { cmd_lcd(0x01); display_lcd("TEMPARATURE:"); } else if(SBUF=='H')

Page 99: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

{ cmd_lcd(0x01); display_lcd("humidity %rh:"); } else if(SBUF==' ') cmd_lcd(0xC0); else write_lcd(SBUF); //display received byte

RI=0;}

}

void init_lcd(void){ delay_ms(10);cmd_lcd(0x28);cmd_lcd(0x0e);cmd_lcd(0x06);cmd_lcd(0x01);}

void cmd_lcd(unsigned char c){ unsigned char temp;temp=c>>4;LCD=temp<<4|0x02;LCD=0;LCD=c<<4|0x02;LCD=0;delay_ms(2);}

void write_lcd(unsigned char c){unsigned char temp;temp=c>>4;LCD=temp<<4|0x03;LCD=0;LCD=c<<4|0x03;LCD=0;delay_ms(2);}

void display_lcd(unsigned char *s){while(*s)write_lcd(*s++);}

void delay_ms(unsigned int i){unsigned int j;

while(i-->0){

for(j=0;j<500;j++){

Page 100: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

;}

}}

Page 101: REAL TIME PATIENT MONITORING SYSTEM USING CAN CONTROLLER

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

-D.V.Prasad

Wireless Communications

- Theodore S. Rappaport

References on the Web:

www.national.com

www.nxp.com

www.8052.com

www.microsoftsearch.com

www.geocities.com