You are on page 1of 57

1.

INTRODUCTION
1.1 Introduction to project
The Scope of the project is power management for shopping malls with bidirectional visitors counting. The project provides a method for automatic control of devices (lights, fans, or AC s) throughout a shopping mall. A unique architecture of occupancy sensors includes entry/exit sensors for detecting movement through doorways. The bidirectional sensors are used to sense the entry and exit. This project is designed around a microcontroller which forms the control unit of the project. The central embedded controller controls the devices according to the no.of persons entered into the shopping mall in response to the entry/exit sensors. The present project provides a system for saving power of a shopping mall. The hall of the mall is provided with bidirectional entry and exit way sensors. All the input devices such as sensors and output devices such as relays are interfaced to microcontroller. The microcontroller controls the devices according to the inputs from the IR sensors.

Block diagram:
Regulated power supply
MICRO Hyper Terminal

Hall with IR Sensors

CONTROLLER

Devices

Fig 1.1 Block diagram

1.2 Project Overview


This Project Power management for shopping mall with bidirectional visitors counting using Microcontroller is a reliable circuit that takes over the task of controlling the room lights as well us counting number of persons/ visitors in the room very accurately. When somebody enters into the room then the counter is incremented by one and the light in the room will be switched ON and when any one leaves the room then the counter is decremented by one. The light will be only switched OFF until all the persons in the room go out. The total number of persons inside the room is also displayed on the seven segment displays. The microcontroller does the above job. It receives the signals from the sensors, and this signal is operated under the control of software which is stored in ROM. Microcontroller AT89S52 continuously monitor the Infrared Receivers, When any object pass through the IR Receivers then the IR Rays falling on the receiver are obstructed , this obstruction is sensed by the Microcontroller.

2. INTRODUCTION TO EMBEDDED SYSTEMS


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 generalpurpose 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 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.

2.1 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. 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 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 Linux OS RTOS and the LynxOS-178 RTOS for software certification to DO-178B. Rich in system resources and networking services, Linux OS 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 LynxOS178 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 Linux Works' 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, Compact PCI hot swap support, and hard real-time response Linux OS 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 Linux OS 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. Linux Works Jumpstarts for Communications package enables OEMs to rapidly develop mission-critical communications equipment, with pre-integrated, state-of-the-art,datanetworking 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

As the number of powerful embedded processors in consumer devices continues to rise, the Blue Cat 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 Blue Cat embedded Linux. Blue Cat 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 Linux OS 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 Linux Works 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.

3. CONTROLLER DATA MICROCONTROLLER Vs 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. 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. 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. 3.1 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
7

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. 3.2 Microcontroller Architecture and Features The basic internal designs of microcontrollers are pretty similar. Figure1 shows the block diagram of a typical microcontroller. All components are connected via an internal bus and are all integrated on one chip. The modules are connected to the outside world via I/O pins.

Fig 3.2.1: Basic Layout of Microcontroller The following list contains the modules typically found in a microcontroller. You can find a more detailed description of these components in later sections.

Processor Core: The CPU of the controller. It contains the arithmetic logic unit, the control unit, and the registers (stack pointer, program counter, accumulator register, register file . . .). Memory: The memory is sometimes split into program memory and data memory. In larger controllers, a DMA controller handles data transfers between peripheral components and the memory. Interrupt Controller: Interrupts are useful for interrupting the normal program flow in case of (important) external or internal events. In conjunction with sleep modes, they help to conserve power. Timer/Counter: Most controllers have at least one and more likely 2-3 Timer/Counters, which can be used to timestamp events, measure intervals, or count events. Many controllers also contain PWM (pulse width modulation) outputs, which can be used to drive motors or for safe breaking (antilock brake system, ABS). Furthermore the PWM output can, in conjunction with an external filter, be used to realize a cheap digital/analog converter. Digital I/O: Parallel digital I/O ports are one of the main features of microcontrollers. The number of I/O pins varies from 3-4 to over 90, depending on the controller family and the controller type. Analog I/O: Apart from a few small controllers, most microcontrollers have integrated analog/digital converters, which differ in the number of channels (2-16) and their resolution (812 bits). The analog module also generally features an analog comparator. In some cases, the microcontroller includes digital/analog converters. 3.3 The UART The Universal Asynchronous Receiver/Transmitter (UART) controller is the key component of the serial communications subsystem of a computer. The UART takes bytes of data and transmits the individual bits in a sequential fashion. At the destination, a second UART re-assembles the bits into complete bytes.

Serial transmission is commonly used with modems and for non-networked communication between computers, terminals and other devices. There are two primary forms of serial transmission: Synchronous and Asynchronous. Depending on the modes that are supported by the hardware, the name of the communication sub-system will usually include a A if it supports Asynchronous communications, and a S if it supports Synchronous communications. Both forms are described below. 3.4 Synchronous Serial Transmission Synchronous serial transmission requires that the sender and receiver share a clock with one another, or that the sender provide a strobe or other timing signal so that the receiver knows when to read the next bit of the data. In most forms of serial Synchronous communication, if there is no data available at a given instant to transmit, a fill character must be sent instead so that data is always being transmitted. Synchronous communication is usually more efficient because only data bits are transmitted between sender and receiver, and synchronous communication can be more costly if extra wiring and circuits are required to share a clock signal between the sender and receiver. A form of Synchronous transmission is used with printers and fixed disk devices in that the data is sent on one set of wires while a clock or strobe is sent on a different wire. Printers and fixed disk devices are not normally serial devices because most fixed disk interface standards send an entire word of data for each clock or strobe signal by using a separate wire for each bit of the word. In the PC industry, these are known as Parallel devices. The standard serial communications hardware in the PC does not support Synchronous operations. This mode is described here for comparison purposes only 3.5 Asynchronous Serial Transmission Asynchronous transmission allows data to be transmitted without the sender having to send a clock signal to the receiver. Instead, the sender and receiver must agree on timing parameters in advance and special bits are added to each word which are used to synchronize the sending and receiving units.

10

When a word is given to the UART for Asynchronous transmissions, a bit called the "Start Bit" is added to the beginning of each word that is to be transmitted. The Start Bit is used to alert the receiver that a word of data is about to be sent, and to force the clock in the receiver into synchronization with the clock in the transmitter. These two clocks must be accurate enough to not have the frequency drift by more than 10% during the transmission of the remaining bits in the word. (This requirement was set in the days of mechanical teleprinters and is easily met by modern electronic equipment.) After the Start Bit, the individual bits of the word of data are sent, with the Least Significant Bit (LSB) being sent first. Each bit in the transmission is transmitted for exactly the same amount of time as all of the other bits, and the receiver looks at the wire at approximately halfway through the period assigned to each bit to determine if the bit is a 1 or a 0. For example, if it takes two seconds to send each bit, the receiver will examine the signal to determine if it is a 1 or a 0 after one second has passed, then it will wait two seconds and then examine the value of the next bit, and so on. The sender does not know when the receiver has looked at the value of the bit. The sender only knows when the clock says to begin transmitting the next bit of the word.When the entire data word has been sent, the transmitter may add a Parity Bit that the transmitter generates. The Parity Bit may be used by the receiver to perform simple error checking. Then at least one Stop Bit is sent by the transmitter. When the receiver has received all of the bits in the data word, it may check for the Parity Bits (both sender and receiver must agree on whether a Parity Bit is to be used), and then the receiver looks for a Stop Bit. If the Stop Bit does not appear when it is supposed to, the UART considers the entire word to be garbled and will report a Framing Error to the host processor when the data word is read. The usual cause of a Framing Error is that the sender and receiver clocks were not running at the same speed, or that the signal was interrupted.Regardless of whether the data was received correctly or not, the UART automatically discards the Start, Parityand Stop bits. If the sender and receiver are configured identically, these bits are not passed

11

to the host.If another word is ready for transmission, the Start Bit for the new word can be sent as soon as the Stop Bit for the previous word has been sent. Because asynchronous data is self synchronizing, if there is no data to transmit, the transmission line can be idle. 3.6 MICROCONTROLLER ATmega8 The ATmega8 is a low-power CMOS 8-bit microcontroller, based on the AVR enhanced RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega8 achieves throughputs approaching 1 MIPS per MHz allowing the system designer to optimize power consumption versus processing speed.

Fig. 3.6.1 Pin Out of ATmega8 AVR core combines a rich instruction set with 32 general-purpose working registers. All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent registers to be accessed in one single instruction executed in one clock cycle. The

12

resulting architecture is more code efficient while achieving throughputs up to ten times faster than conventional CISC microcontrollers. 3.6.1 ATmega8 features High-performance, Low-power AVR 8-bit Microcontroller Advanced RISC Architecture 130 Powerful Instructions Most Single-clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static Operation Up to 16 MIPS Throughput at 16 MHz On-chip 2-cycle Multiplier

High Endurance Non-volatile Memory segments 8K Bytes of In-System Self-programmable Flash program memory 512 Bytes EEPROM 1K Byte Internal SRAM Write/Erase Cycles: 10,000 Flash/100,000 EEPROM Data retention: 20 years at 85C/100 years at 25C Optional Boot Code Section with Independent Lock Bits In-System Programming by On-chip Boot Program True Read-While-Write Operation Programming Lock for Software Security

Peripheral Features Two 8-bit Timer/Counters with Separate Prescaler, one Compare Mode One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture Mode Real Time Counter with Separate Oscillator Three PWM Channels
13

8-channel ADC in TQFP and QFN/MLF package Eight Channels 10-bit Accuracy 6-channel ADC in PDIP package Six Channels 10-bit Accuracy Byte-oriented Two-wire Serial Interface Programmable Serial USART Master/Slave SPI Serial Interface Programmable Watchdog Timer with Separate On-chip Oscillator On-chip Analog Comparator

Special Microcontroller Features Power-on Reset and Programmable Brown-out Detection Internal Calibrated RC Oscillator External and Internal Interrupt Sources Five Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, and Standby

I/O and Packages 23 Programmable I/O Lines 28-lead PDIP, 32-lead TQFP, and 32-pad QFN/MLF

Operating Voltages 2.7 - 5.5V (ATmega8L) 4.5 - 5.5V (ATmega8)

Speed Grades

0 - 8 MHz (ATmega8L) 0 - 16 MHz (ATmega8)

Power Consumption at 4 Mhz, 3V, 25C Active: 3.6 mA Idle Mode: 1.0 mA Power-down Mode: 0.5 A
14

The Idle mode stops the CPU while allowing the USART, Two-wire interface, A/D Converter, SRAM, Timer/Counters, SPI port, and interrupt system to continue functioning. The Power-down mode saves the register contents but freezes the Oscillator, disabling all other chip functions until the next External Interrupt or Hardware Reset. In Power-save mode, the Asynchronous Timer continues to run, allowing the user to maintain a timer base while the rest of the device is sleeping. The ADC Noise Reduction mode stops the CPU and all I/O modules except Asynchronous Timer and ADC, to minimize switching noise during ADC conversions. By combining an 8-bit RISC CPU with In-System Self-Programmable Flash on a monolithic chip, the Atmel ATmega8 is a powerful microcontroller that provides a highly flexible and cost-effective solution to many embedded control applications. 3.6.2 Pin Descriptions VCC- Digital supply voltage. GND- Ground. Port B (PB7-PB0) XTAL1/XTAL2/TOSC1/TOSC2 Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even if the clock is not running. Depending on the clock selection fuse settings, PB6 can be used as input to the inverting Oscillator amplifier and input to the internal clock operating circuit. Depending on the clock selection fuse settings, PB7 can be used as output from the inverting Oscillator amplifier. If the Internal Calibrated RC Oscillator is used as chip clock source, PB7..6 is used as TOSC2..1 input for the Asynchronous Timer/Counter2 if the AS2 bit in ASSR is set. Port C (PC5-PC0)
15

Port C is an 7-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port C output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if the clock is not running. PC6/RESET If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that the electrical characteristics of PC6 differ from those of the other pins of Port C. If the RSTDISBL Fuse is unprogrammed, PC6 is used as a Reset input. A low level on this pin for longer than the minimum pulse length will generate a Reset, even if the clock is not running Port D (PD7-PD0) Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port D output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset condition becomes active, even if the clock is not running. RESET Reset input. A low level on this pin for longer than the minimum pulse length will generate a reset, even if the clock is not running. Shorter pulses are not guaranteed to generate a reset. AVCC AVCC is the supply voltage pin for the A/D Converter, Port C (3.0), and ADC (7.6). It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter. Note that Port C (5.4) use digital supply voltage, VCC.

AREF
16

AREF is the analog reference pin for the A/D Converter. ADC7.6 (TQFP and QFN/MLF Package Only) In the TQFP and QFN/MLF package, ADC7.6 serve as analog inputs to the A/D converter. These pins are powered from the analog supply and serve as 10-bit ADC channels.

Fig 3.6.2.1 BLOCK DIAGRAM OF AT mega 8 The ATmega8 AVR is supported with a full suite of program and system development tools including: C compilers, macro assemblers, program debugger/simulators, in-circuit emulators, and evaluation kits.
17

A flexible interrupt module has its control registers in the I/O space with an additional global interrupt enable bit in the Status Register. All interrupts have a separate interrupt vector in the interrupt vector table. The interrupts have priority in accordance with their interrupt vector position. The lower the interrupt vector address, the higher the priority. The I/O Memory can be accessed directly, or as the Data Space locations following those of the Register File, 20h - 5Fh 3.6.3 I/O PORTS All AVR ports have true Read-Modify-Write functionality when used as general digital I/O ports. This means that the direction of one port pin can be changed without unintentionally changing the direction of any other pin with the SBI and CBI instructions. The same applies when changing drive value (if configured as output) or enabling/disabling of pull-up resistors (if configured as input). Each output buffer has symmetrical drive characteristics with both high sink and source capability. The pin driver is strong enough to drive LED displays directly. All port pins have individually selectable pull-up resistors with a supply-voltage invariant resistance. All I/O pins have protection diodes to both VCC and Ground. All registers and bit references in this section are written in general form. Three I/O memory address locations are allocated for each port, one each for the Data Register PORTx, Data Direction Register DDRx, and the Port Input Pins PINx. The Port Input Pins I/O location is read only, while the Data Register and the Data Direction Register are read/write. In addition, the Pull-up Disable PUD bit in SFIOR disables the pull-up function for all pins in all ports when set. Most port pins are multiplexed with alternate functions for the peripheral features on the device. Enabling the alternate function of some of the port pins does not affect the use of the other pins in the port as general digital I/O. 3.6.3.1 Ports as general purpose I/O: The ports are bi-directional I/O ports with optional internal pull-ups. Each port pin consists of three register bits: DDxn, PORTxn, and PINxn. The DDxn bits are accessed at the DDRx I/O address, the PORTxn bits at the PORTx I/O address, and the PINxn bits at the PINxI/O address. The DDxn bit in the DDRx Register selects the direction of this pin. If DDxn is written logic one, Pxn is configured as an output pin. If DDxn is written logic zero, Pxn is configured as an input pin. If PORTxn is written logic one when the pin is configured as an input
18

pin, the pull-up resistor is activated. To switch the pull-up resistor off, PORTxn has to be written logic zero or the pin has to be configured as an output pin. The port pins are tri-stated when a reset condition becomes active, even if no clocks are running. If PORTxn is written logic one when the pin is configured as an output pin, the port pin is driven high (one). If PORTxn is written logic zero when the pin is configured as an output pin, the port pin is driven low (zero). Normally, the pull-up enabled state is fully acceptable, as a high-impedance environment will not notice the difference between a strong high driver and a pull-up. If this is not the case, the PUD bit in the SFIOR Register can be set to disable all pull-ups in all ports.

Table 3.6.3.1 Selection Table

19

Fig 3.6.3.1 General

I/O Block diagram

Independent of the setting of Data Direction bit DDxn, the port pin can be read through the PINxn Register bit. The PINxn Register bit and the preceding latch constitute a synchronizer. This is needed to avoid meta stability if the physical pin changes value near the edge of the internal clock, but it also introduces a delay. The maximum and minimum propagation delays are denoted tpd, max and tpd, min respectively.

20

Fig 3.6.3.2 Timing Diagram while Reading an 1 Consider the clock period starting shortly after the first falling edge of the system clock. The latch is closed when the clock is low, and goes transparent when the clock is high, as indicated by the shaded region of the SYNC LATCH signal. The signal value is latched when the system clock goes low. It is clocked into the PINxn Register at the succeeding positive clock edge. As indicated by the two arrows tpd, max and tpd, min, a single signal transition on the pin will be delayed between and 1 system clock period depending upon the time of assertion.When reading back a software assigned pin value, a nop instruction must be inserted. The out instruction sets the SYNC LATCH signal at the positive edge of the clock. In this case, the delay tpd through the synchronizer is one system clock period.

3.7 8-bit Timer/Counter Register Description Timer/Counter Control Register TCCR2

Fig 3.7.1 TCCR 1

21

Bit 7 FOC2: Force Output Compare The FOC2 bit is only active when the WGM bits specify a non-PWM mode. However, for ensuring compatibility with future devices, this bit must be set to zero when TCCR2 is written when operating in PWM mode. When writing a logical one to the FOC2 bit, an immediate Compare Match is forced on the waveform generation unit. The OC2 output is changed according to its COM21:0 bits setting. Note that the FOC2 bit is implemented as a strobe. Therefore it is the value present in the COM21:0 bits that determines the effect of the forced compare. A FOC2 strobe will not generate any interrupt, nor will it clear the timer in CTC mode using OCR2 as TOP. The FOC2 bit is always read as zero. Bit 6,3 WGM21:0: Waveform Generation Mode These bits control the counting sequence of the counter, the source for the maximum (TOP) counter value, and what type of waveform generation to be used. Modes of operation supported by the Timer/Counter unit are: Normal mode, Clear Timer on Compare Match (CTC) mode, and two types of Pulse Width Modulation (PWM) modes

table 3.7.1 TCCR modes Bit 5:4 COM21:0: Compare Match Output Mode These bits control the Output Compare Pin (OC2) behavior. If one or both of the COM21:0 bits are set, the OC2 output overrides the normal port functionality of the I/O pin it is

connected to.However, note that the Data Direction Register (DDR) bit
22

corresponding to OC2 pin must be setin order to enable the output driver. When OC2 is connected to the pin, the function of the COM21:0 bits depends on the WGM21:0 bit setting. Timer/Counter Register TCNT2

Fig 3.7.2 TCNT The Timer/Counter Register gives direct access, both for read and write operations, to the Timer/Counter unit 8-bit counter. Writing to the TCNT2 Register blocks (removes) the Compare Match on the following timer clock. Modifying the counter (TCNT2) while the counter is running, introduces a risk of missing a Compare Match between TCNT2 and the OCR2 Register. Output Compare Register OCR2

Fig 3.7.3 OCR2 The Output Compare Register contains an 8-bit value that is continuously compared with the counter value (TCNT2). A match can be used to generate an Output Compare interrupt, or to generate a waveform output on the OC2 pin. 3.8 8-bit Timer/Counter0 Timer/Counter0 is a general purpose, single channel, 8-bit Timer/Counter module. The main features are:

Single Channel Counter


23

Frequency Generator External Event Counter 10-bit Clock Prescaler Overview A simplified block diagram of the 8-bit Timer/Counter is shown in Fig 3.8.1. For the actual placement of I/O pins CPU accessible I/O Registers, including I/O bits and I/O pins, are shown in bold. The device-specific I/O Register and bit locations are listed in the 8-bit Timer/Counter Register Description.

Fig 3.8.1 8-bit Timer/Counter Registers The Timer/Counter (TCNT0) is an 8-bit register. Interrupt request (abbreviated to Int. Req. in the figure) signals are all visible in the Timer Interrupt Flag Register (TIFR). All interrupts are individually masked with the Timer Interrupt Mask Register (TIMSK). TIFR and TIMSK are not shown in the figure since these registers are shared by other timer units. The Timer/Counter can be clocked internally or via the prescaler, or by an external clock source on the T0 pin. The Clock Select logic block controls which clock source and edge the
24

Timer/Counter uses to increment its value. The Timer/Counter is inactive when no clock source is selected. The output from the clock select logic is referred to as the timer clock (clkT0). Definitions Many register and bit references in this document are written in general form. A lower case n replaces the Timer/Counter number, in this case 0. However, when using the register or bit defines in a program, the precise form must be used i.e. TCNT0 for accessing Timer/Counter0 counter value and so on. Timer/Counter Clock Sources The Timer/Counter can be clocked by an internal or an external clock source. The clock source is selected by the clock select logic which is controlled by the clock select (CS02:0) bits located in the Timer/Counter Control Register (TCCR0). Counter Unit

Fig 3.8.2 Counter Unit Block Diagram

Operation

25

The counting direction is always up (incrementing), and no counter clear is performed. The counter simply overruns when it passes its maximum 8-bit value (MAX = 0xFF) and then restarts from the bottom (0x00). In normal operation the Timer/Counter Overflow Flag (TOV0) will be set in the same timer clock cycle as the TCNT0 becomes zero. The TOV0 Flag in this case behaves like a ninth bit, except that it is only set, not cleared. However, combined with the timer overflow interrupt that automatically clears the TOV0 Flag, the timer resolution can be increased by software. A new counter value can be written anytime. Timing Diagrams The Timer/Counter is a synchronous design and the timer clock (clkT0) is therefore shown as a clock enable signal in the following figures. The figures include information on when Interrupt Flags are set. Figure contains timing data for basic Timer/Counter operation. The figure shows the count sequence close to the MAX value.

Fig 3.8.3 Timing diagrams 1

26

Shows the same timing data,but with the prescalar enabled

Fig 3.8.4 Timing diagrams 2

27

4. SPECIFIC TECHNOLOGY
4.1 Introduction As next-generation electronic information systems evolve, it is critical that all people have access to the information available via these systems. Examples of developing and future information systems include interactive television, touch screen-based information kiosks, and advanced Internet programs. Infrared technology, increasingly present in mainstream applications, holds great potential for enabling people with a variety of disabilities to access a growing list of information resources. Already commonly used in remote control of TVs, VCRs and CD players, infrared technology is also being used and developed for remote control of environmental control systems, personal computers, and talking signs. For individuals with mobility impairments, the use of infrared or other wireless technology can facilitate the operation of information kiosks, environmental control systems, personal computers and associated peripheral devices. For individuals with visual impairments, infrared or other wireless communication technology can enable users to locate and access talking building directories, street signs, or other assistive navigation devices. For individuals using augmentative and alternative communication (AAC) devices, infrared or other wireless technology can provide an alternate, more portable, more independent means of accessing computers and other electronic information systems. In this presentation/paper, an introduction to wireless communication in general is first presented. A discussion specific to infrared technology then follows, with advantages and disadvantages of the technology presented along with security, health and safety issues. The importance of establishing a standard is also discussed with relevance to the disability field, and future uses of infrared technology are presented. 4.2 Wireless Communication Wireless communication, as the term implies, allows information to be exchanged between two devices without the use of wire or cable. A wireless keyboard sends information to the computer without the use of a keyboard cable; a cellular telephone sends information to another telephone without the use of a telephone cable. Changing television channels, opening

28

and closing a garage door, and transferring a file from one computer to another can all be accomplished using wireless technology. In all such cases, information is being transmitted and received using electromagnetic energy, also referred to as electromagnetic radiation. One of the most familiar sources of electromagnetic radiation is the sun; other common sources include TV and radio signals, light bulbs and microwaves. To provide background information in understanding wireless technology, the electromagnetic spectrum is first presented and some basic terminology defined. The electromagnetic spectrum classifies electromagnetic energy according to frequency or wavelength (both described below). As shown in Figure 1, the electromagnetic spectrum ranges from energy waves having extremely low frequency (ELF) to energy waves having much higher frequency, such as x-rays.

Fig4.2.1 The electromagnetic spectrum [Figure 4.2.1 description: The electromagnetic spectrum is depicted in Figure 4.2.1. A horizontal bar represents a range of frequencies from 10 Hertz(cycles per second) to 10 to the 18th power Hertz. Some familiar allocated frequency bands are labeled on the spectrum. Approximate locations are as follows. (Exponential powers of 10 are abbreviated as 10exp.) 10 Hertz: extremely low frequency or ELF. 10exp5 Hertz: AM radio. 10exp8 Hertz: FM radio. 10exp10 Hertz: Television. 10exp11 Hertz: Microwave. 10exp16 Hertz: Infrared (frequency range is below the visible light spectrum).
29

10exp16 Hertz: Visible Light. 10exp16 Hertz: Ultraviolet (frequency range is above the visible light spectrum). 10exp18 Hertz: X-rays. A typical electromagnetic wave is depicted in Figure 2, where the vertical axis represents the amplitude or strength of the wave, and the horizontal axis represents time. In relation to electromagnetic energy, frequency is: 1. the number of cycles a wave completes (or the number of times a wave repeats itself) in one second 2. expressed as Hertz (Hz), which equals once cycle per second 3. commonly indicated by prefixes such as a. Kilo (KHz) one thousand b. Mega (MHz) one million c. Giga (GHz) one billion 4. directly related to the amount of information that can be transmitted on the wave

Fig4.2.2: sine wave [Figure 4.2.2 description: A sine wave is depicted in the graph in Figure 4.2.2. The horizontal axis of the graph represents time, and the vertical axis of the graph represents amplitude. One cycle (or one complete sine wave) is labeled on the graph.]

30

Fig4.2.3: Graphs of three different sine waves [Figure 4.2.3 description: Graphs of three different sine waves are depicted in Figure 4.2.3. The horizontal axis, with values ranging from 0 to 1, represents time in seconds. The vertical axis, with values ranging from -1 to 1, represents arbitrary amplitude. The first graph in the figure depicts a sine wave with a frequency of 1 cycle per second. As shown, the energy wave makes a complete cycle from 0 to its maximum positive value, then through to its maximum negative value, then back to 0. The second graph in the figure depicts a sine wave with a frequency of 2 cycles per second. The sine wave therefore makes 2 complete cycles of moving from 0 to its maximum positive value, through to its maximum negative value, and back to 0, in the same time that the wave in the first graph completes 1 cycle. The third graph in the figure depicts a sine wave with a frequency of 3 cycles per second. The sine wave therefore completes 3 full cycles in the same amount of time that the wave in the first graph completes 1 cycle.] Figure 4.2.3 illustrates energy waves completing one cycle, two cycles and three cycles per second. Generally, the higher the range of frequencies (or bandwidth), the more information can be carried per unit of time. The term wavelength is used almost interchangeably with frequency. In relation to electromagnetic energy, wavelength is:

31

the shortest distance at which the wave pattern fully repeats itself 1. expressed as meters 2. commonly indicated by prefixes such as
3. a. Kilo (km) 10exp3 b. Milli (mm) 10exp-3 c. Nano (nm) 10exp-9

4. inversely proportional to frequency Figure 4.2.4 depicts an infrared energy wave and a radio energy wave, and illustrates the two different energy wavelengths. As is expected based on the electromagnetic spectrum, the infrared wave is higher frequency and therefore shorter wavelength than the radio wave. Conversely, the radio wave is lower frequency and therefore longer wavelength than the infrared wave. Anyone who has listened to the radio while driving long distances can appreciate that longer wavelength AM radio waves carry further than the shorter wavelength FM radio waves.

Fig4.2.4: A radio frequency energy wave [Figure 4.2.4 description: Figure 4.2.4 depicts a radio frequency energy wave superimposed upon an infrared energy wave, and illustrates the inverse relationship between frequency and wavelength. The infrared energy wave completes nearly 5 and a half cycles in the time that the radio frequency wave completes 2 cycles. The wavelengths of the infrared wave and the radio wave are labeled, and the infrared wavelength is less than half the wavelength of the radio wave.]

32

Other terms commonly used in describing wireless communication include transmitter, receiver, and transceiver. In any type of wireless technology, information must be sent (or transmitted) by one device and captured (or received) by another device. The transmitter takes its input - a voice or stream of data bits for example, creates an energy wave that contains the information, and sends the wave using an appropriate output device. As an example, a radio transmitter outputs its energy waves using an antenna, while an infrared transmitter uses an infrared light- emitting diode (LED) or laser diode. The electromagnetic energy waves are captured by the receiver, which then processes the waves to retrieve and output the information in its original form. Any wireless device having the circuitry to both transmit and receive energy signals is referred to as a transceiver. Depending on the communication protocol being used, a device may be capable of only transmitting or receiving information at one time, or it may be capable of both transmitting and receiving information at the same time. The above described terminology is relevant in all forms of wireless communication, regardless of the band of electromagnetic energy (radio, infrared, etc.) being used. Although radio and ultrasound waves have frequent application in wireless communication, the remainder of the presentation/paper is devoted more specifically to infrared (IR) technology. Infrared technology is highlighted because of its increasing presence in mainstream applications, its current and potential usage in disability-related applications, and its advantages over other forms of wireless communication. 4.3 Infrared Technology As depicted in Fig. 4.2.1, infrared radiation is the region of the electromagnetic spectrum between microwaves and visible light. In infrared communication an LED transmits the infrared signal as bursts of non-visible light. At the receiving end a photodiode or photoreceptor detects and captures the light pulses, which are then processed to retrieve the information they contain. Some common applications of infrared technology are listed below. 1. Augmentative communication devices 2. Car locking systems

33

3. Computers a. Mouse b. Keyboards c. Floppy disk drives d. Printers 4. Emergency response systems 5. Environmental control systems a. Windows b. Doors c. Lights d. Curtains e. Beds f. Radios 6. Headphones 7. Home security systems 8. Signage 9. Telephones 10. TVs, VCRs, CD players, stereos 11. Toys Infrared technology offers several important advantages as a form of wireless communication. Advantages and disadvantages of IR are first presented, followed by a comparative listing of radio frequency (RF) advantages and disadvantages. IR Advantages: 1. Low power requirements: therefore ideal for laptops, telephones, personal digital assistants 2. Low circuitry costs: $2-$5 for the entire coding/decoding circuitry
3. Simple circuitry: no special or proprietary hardware is required, can be incorporated into

the integrated circuit of a product

34

4. Higher security: directionality of the beam helps ensure that data isn't leaked or spilled to nearby devices as it's transmitted 5. Portable 6. Few international regulatory constraints: IrDA (Infrared Data Association) functional devices will ideally be usable by international travelers, no matter where they may be 7. High noise immunity: not as likely to have interference from signals from other devices IR Disadvantages: 1. Line of sight: transmitters and receivers must be almost directly aligned (i.e. able to see each other) to communicate 2. Blocked by common materials: people, walls, plants, etc. can block transmission 3. Short range: performance drops off with longer distances 4. Light, weather sensitive: direct sunlight, rain, fog, dust, pollution can affect transmission 5. Speed: data rate transmission is lower than typical wired transmission Health Risks Imagine for a moment going about your daily routine without electricity. You probably awoke to an electric clock radio/alarm, showered under warm water supplied via an electric hot water heater, drank a couple of cups of coffee from your automatic electric coffee maker, listened to the weather on the electric powered TV or radio and the list goes on and on. We live in an electrical environment. Electricity is all around you and while you cannot see electricity, you can certainly appreciate the results. However, any time electric current travels through a wire, the air, or runs an appliance, it produces an electromagnetic field. It is important to remember that electromagnetic fields are found everywhere that electricity is in use. While researchers have not established an ironclad link between the exposure to electromagnetic fields and ailments such as leukemia, the circumstantial evidence concerns many people.

35

The evidence also suggests that we need to use some common sense when dealing with electricity. In scientific terms, your body can act as an antenna, as it has a higher conductivity for electricity than does air. Therefore, when conditions are right you may have experienced a small "tingle" of electric current from a poorly grounded electric appliance. As long as these currents are very small there isn't much danger from electric fields, except for potential shocks. Your body, however, also has a permeability almost equal to air, thus allowing a magnetic field to easily enter the body. Unfortunately your body cannot detect the presence of a strong magnetic field, which could potentially do much more harm. In terms of wireless technology, there are no confirmed health risks or scientific dangers from infrared or radio frequency, with two known exceptions: 1. point-to-point lasers which can cause burns or blindness 2. prolonged microwave exposure which has been linked to cancer and leukemia Therefore, most health concerns related to electromagnetic fields are due to electricity in our day-to-day use, such as computer monitors and TVs. These dangers, if any, are already in the home and work place, and the addition of wireless technology should not be seen as an exceptional risk. We might be rightfully worried or concerned about the electric power grid two blocks from our home or school, but at the same time, we sleep each night with our head only a few feet from an AC powered clock radio, which may be far worse due simply to proximity. We might be also be worried about the magnetic radiation or magnetically induced electrical fields which surround us from the fluorescent light fixtures and high voltage, high frequency lighting we sit under at work and at home. The real danger, however, is that we normally position ourselves too close to the electromagnetic field source (computer monitor, TV, etc.). Remember that the strength of the electromagnetic field (EMF) decreases as the square of the distance from the field source. Therefore, if we are 2 meters away from the source, the EMF strength is reduced to 1/4, but if we move 8 meters away from the source, the EMF strength is reduced to 1/64 of its original strength.

36

Safety There are a few things you can do to make your home and work environment a safer "electronic" place. The first thing to consider when possible is to buy Federal Communications Commission (FCC) Class B rated equipment. The FCC classifies computer equipment for its potential to generate radio frequency pollution. Class B emits less radio frequency pollution than Class A, and is more suitable for the residential environment. Unfortunately, while Class B emits less radio frequency pollution, there is nothing in the FCC classes regarding magnitude or level of the pollution. Other potential risks exist in high voltage (e.g. power) components such as display monitors, computer power supplies, etc. If possible select low power units, shielded units, etc. and operate them at lower resolutions. For example, VGA resolution has a lower refresh scan rate than SVGA, and thus lower magnetic field pollution. If you are adding internal cards to your computers, don't tamper with the computer by removing any internal shielding, covers, etc. Any metal shielding inside your computer was probably put there for a purpose, although to you it may look like a harmless spacer. If you are really concerned, you can purchase formal safety testing tools or hire a consultant to do formal testing for EMF. There are also cheap tools you can utilize to test for the presence of strong radio or magnetic fields. For example, the presence of a strong magnetic field will deflect a compass needle from pointing north, or the presence of a strong radio frequency field will distort an AM radio's ability to clearly tune in a station. Simple tools like these can be used to screen for strong EMF. Security Electromagnetic frequencies currently have little legal status for protection and as such, can be freely intercepted by motivated individuals. This doesn't mean wireless transmission is easily breached, as security varies by the type of wireless transmission method. As presented earlier in the advantages and disadvantages of infrared versus radio frequency transmission, what might be considered an advantage to one method for transmission could turn out to be a

37

disadvantage for security. For example, because infrared is line-of-sight it has less transmission range but is also more difficult to intercept when compared to radio frequency. Radio frequency can penetrate walls, making it much easier to transmit a message, but also more susceptible to tapping. A possible solution to security issues will likely be some form of data encryption. Data encryption standards (DES) are also being quickly developed for the exchange of information over the Internet, and many of these same DES will be applied to wireless technology. Importance of Standards Several of the wireless devices demonstrated during the presentation (see Appendix A) have benefited to some degree from standardization. For example, a universal IR remote was once priced at roughly $100.00. It is now possible, for under $15.00, to purchase a universal remote that will learn the IR codes for all of your electronic appliances - not just the TV or VCR. Another example of a device that has benefited from standardization is the Macintosh IR mouse. The compatibility of this mouse to the Apple Desktop Bus (ADB) Standard has certainly contributed to its inexpensive price and availability. As you look around the exhibit hall, think of all the assistive devices that have proliferated due to the ADB (IntelliKeys, Ke:nx, etc.). Additionally, the X10 devices that were demonstrated in the presentation not only rely on but have benefited from the 60 HZ AC standard which applies to most of North America. As a result these devices are now numerous and inexpensive. One final example demonstrating the importance of standards is the relationship of augmentative alternative communication (AAC) devices to the General Input Device Emulating Interface (GIDEI) standard. Any AAC device programmed to use the GIDEI protocol can access any PC or Macintosh running either the DOS, Windows, or Macintosh version of Serial Keys. The collaboration of the rehabilitation field to create the GIDEI standard has allowed AAC users to access multiple computers without the need to reprogram their devices or purchase expensive, proprietary hardware. Likewise, there is an urgent need to develop standards regarding the use of wireless technology in accessing electronic appliances of all kinds. Without such a standard, it may be

38

difficult if not impossible for those using assistive devices to communicate with all available information systems. Examples of current or developing appliances which can or may potentially be accessed via wireless technology include: 1. ATMs 2. Information Kiosks 3. Building Directories 4. TV Set Top Boxes 5. Bus Stops (Electronic Interactive) 6. Fare Machines (ticket machines, etc.)
7. Home Appliances (especially touch screens)

8. Informational Telephones, Screen Based Telephones 9. POS (point of sale) equipment 10. Home environmental controls 11. Home security systems 12. Whiteboards, for classroom / interactive office use 13. Games and entertainment

4.4 Relays
A relay is an electrical switch that opens and closes under the control of another electronic circuit. In the original form, the switch is operated by an electro magnet to open or close one or many sets of contacts. It was invented by Joseph Henry in 1835. Because a relay is able to control an output circuit of higher power than the input circuit, it can be considered to be, in a broad sense, a form of an electrical amplifier. Operation When a current flows through the coil, the resulting magnetic field attracts an armature that is mechanically linked to a moving contact. The movement either makes or breaks a connection with a fixed contact. When the current to the coil is switched off, the armature is returned by a force approximately half as strong as the magnetic force to its relaxed position. Usually this is a spring, but gravity is also used commonly in industrial motor starters. Most
39

relays are manufactured to operate quickly. In a low voltage application, this is to reduce noise. In a high voltage or high current application, this is to reduce arcing. If the coil is energized with DC, a diode is frequently installed across the coil, to dissipate the energy from the collapsing magnetic field at deactivation, which would otherwise generate a with AC, a small copper ring can be crimped to the end of the solenoid. This "shading ring" creates a small out-of-phase current, which increases the minimum pull on the armature during the AC cycle. By analogy with the functions of the original electromagnetic device, a solid-state relay is made with a thyristor or other solid-state switching device. To achieve electrical isolation an optocoupler can be used which is a light-emitting diode (LED) coupled with a photo transistor

Fig4.4.1 Circuit symbol for a relay

Fig 4.4.2 Relays (Courtesy: Rapid Electronics) In the above diagram pin 3 is connected to pin 5, by default. By sending +12V between pin 1 and pin 2, you will turn on a switch. Pin 1 and pin 2 will disconnect, and pin 5 and pin 4 will connect.

40

Relays more Info:

A relay is an electrically operated switch. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so relays have two switch positions and they are double throw (changeover) switches. Relays allow one circuit to switch a second circuit which can be completely separate from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. There is no electrical connection inside the relay between the two circuits, the link is magnetic and mechanical. The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can be as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips) cannot provide this current and transistor is usually used to amplify the small IC current to the larger value required for the relay coil. The maximum output current for the popular 555 timer IC is 200mA so these devices can supply relay coils directly without amplification. Relays are usually SPDT or DPDT but they can have many more sets of switch contacts, for example relays with 4 sets of changeover contacts are readily available. For further information about switch contacts and the terms used to describe them please see the page on switches. Most relays are designed for PCB mounting but you can solder wires directly to the pins providing you take care to avoid melting the plastic case of the relay.
41

The supplier's catalogue should show you the relay's connections. The coil will be obvious and it may be connected either way round. Relay coils produce brief high voltage 'spikes' when they are switched off and this can destroy transistors and ICs in the circuit. To prevent damage you must connect a protection diode across the relay coil. The relay's switch connections are usually labelled COM, NC and NO:

COM = Common, always connect to this, it is the moving part of the switch. NC = Normally Closed, COM is connected to this when the relay coil is off. NO = Normally Open, COM is connected to this when the relay coil is on. Connect to COM and NO if you want the switched circuit to be on when the relay coil is on. Connect to COM and NC if you want the switched circuit to be on when the relay coil is off.

Choosing a relay You need to consider several features when choosing a relay: Physical size and pin arrangement If you are choosing a relay for an existing PCB you will need to ensure that its dimensions and pin arrangement are suitable. You should find this information in the supplier's catalogue.
1. Coil voltage

The relay's coil voltage rating and resistance must suit the circuit powering the relay coil. Many relays have a coil rated for a 12V supply but 5V and 24V relays are also readily available. Some relays operate perfectly well with a supply voltage which is a little lower than their rated value.
2. Coil resistance

The circuit must be able to supply the current required by the relay coil. You can use Ohm's law to calculate the current:

42

3. For example: A 12V supply relay with a coil resistance of 400

passes a current of 30mA.

This is OK for a 555 timer IC (maximum output current 200mA), but it is too much for most ICs and they will require a transistor to amplify the current.
4. Switch ratings (voltage and current)

The relay's switch contacts must be suitable for the circuit they are to control. You will need to check the voltage and current ratings. Note that the voltage rating is usually higher for AC, for example: "5A at 24V DC or 125V AC".
5. Switch contact arrangement (SPDT, DPDT etc)

Most relays are SPDT or DPDT which are often described as "single pole changeover" (SPCO) or "double pole changeover" (DPCO). For further information please see the page on switches. Protection diodes for relays Transistors and ICs must be protected from the brief high voltage produced when a relay coil is switched off. The diagram shows how a signal diode (eg:1N4148) is connected 'backwards' across the relay coil to provide this protection. Current flowing through a relay coil creates a magnetic field which collapses suddenly when the current is switched off. The sudden collapse of the magnetic field induces a brief high voltage across the relay coil which is very likely to damage transistors and ICs. The protection diode allows the induced voltage to drive a brief current through the coil (and diode) so the magnetic field dies away quickly rather than instantly. This prevents the induced voltage becoming high enough to cause damage to transistors and ICs. Reed relays Reed relays consist of a coil surrounding a reed switch. Reed switches are normally operated with a magnet, but in a reed relay current flows through the coil to create a magnetic field and close the reed switch.

43

Fig4.4.3 Reed relay Reed relays generally have higher coil resistances than standard relays (1000 for

example) and a wide range of supply voltages (9-20V for example). They are capable of switching much more rapidly than standard relays, up to several hundred times per second; but they can only switch low currents (500mA maximum for example). The reed relay shown in the photograph will plug into a standard 14-pin DIL socket ('IC holder'). For further information about reed switches please see the page on switches. Relays and transistors compared Like relays, transistors can be used as an electrically operated switch. For switching small DC currents (< 1A) at low voltage they are usually a better choice than a relay. However transistors cannot switch AC or high voltages (such as mains electricity) and they are not usually a good choice for switching large currents (> 5A). In these cases a relay will be needed, but note that a low power transistor may still be needed to switch the current for the relay's coil.The main advantages and disadvantages of relays are listed below: Advantages of relays:

Relays can switch AC and DC, transistors can only switch DC. Relays can switch high voltages, transistors cannot. Relays are a better choice for switching large currents (> 5A). Relays can switch many contacts at once.

44

Disadvantages of relays:

Relays are bulkier than transistors for switching small currents. Relays cannot switch rapidly (except reed relays), transistors can switch many times per second. Relays use more power due to the current flowing through their coil. Relays require more current than many ICs can provide, so a low power transistor may be needed to switch the current for the relay's coil.

4.5 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 To make a 5 volt power supply, we use a LM7805 voltage regulator IC (Integrated Circuit). The IC is shown below.

45

Fig 4.5.1 LM7805 voltage regulator 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 4.5.1 CIRCUIT FEATURES Brief description of operation: Gives out well regulated +5V output, output current capability of 100 mA Circuit protection: Built-in overheating protection shuts down output when regulator IC gets too hot Circuit complexity: Very simple and easy to build Circuit performance: Very stable +5V output voltage, reliable operation Availability of components: Easy to get, uses only very common basic components Design testing: Based on datasheet example circuit, I have used this circuit successfully as part of many electronics projects Applications: Part of electronics devices, small laboratory power supply Power supply voltage: Unregulated DC 8-18V power supply

46

Power supply current: Needed output current + 5 mA Component costs: Few dollars for the electronics components + the input transformer cost

4.5.2 BLOCK DIAGRAM

Fig 4.5.2.1 BLOCK DIAGRAM of Power supply

4.5.3 EXAMPLE CIRCUIT DIAGRAM

47

Fig 4.5.3.1 Circuit diagram of Power supply

5. RESULT ANALYSIS
The project is Automatic power saving system for an shopping mall is a method for automatic control of devices (lights, fans, AC s). A unique architecture of occupancy sensor includes entry/exit sensors for detecting movements through doorways. Shopping mall room motion sensor for detecting room occupancy. A central embedded controlled communicates with the sensors and controls the device The present project provides a system for saving power of an shopping mall. This project is designed around a microcontroller which forms the control unit of the project. According to this project, the number of visitors entering into and exiting from the shopping mall is calculated and displayed. A part from this, the appliances are made ON and OFF according to number of persons present in the shopping mall by which power can be utilized with great efficiency. This is realized using IR sensors. This project finds its place in places where the things wanted to be done automatically with utilization of power in efficient and effective manner.

48

The programming language used for developing the software to the microcontroller is embedded/assembly. The KEIL cross compiler is used to edit, compile and debug this program. Here in our application we are using ATmega8 microcontroller which is flash programmable IC. AT represents Atmel corporation represents CMOS technology is used for designing the IC.

HARDWARE
For desigining of this project we are using some hardware components. The list of the hardware components are, Stepdown transformer, bridge rectifier, capacitive filter, IR sensors, ATmega8 microcontroller, klystron, relays.

5.1 STEPDOWN TRANSFORMER


Step down transformer is one whose secondary voltage is less than its primary voltage. It is designed to reduce the voltage from the primary winding to the secondary winding. This kind of transformer steps down the voltage applied to it. Here we are taking a 12-0-12 volts stepdown transformer, a 12 volts transformer input will be given to the rectifier circuit. As a step-down unit, the transformer converts high-voltage, low-current power into lowvoltage, high-current power. The larger-gauge wire used in the secondary winding is necessary due to the increase in current. The primary winding, which doesnt have to conduct as much current, may be made of smaller-gauge wire.

5.1.1 STEP-DOWN TRANFORMER CONSIDERATIONS

Fig5.1.1 Stepdown transformer


49

It is possible to operate either of these transformer types backwards (powering the secondary winding with an AC source and letting the primary winding power a load) to perform the opposite function a step-up can function as a step-down and vice-versa. One convention used in the electric power industry is the use of H designations for the higher-voltage winding (the primary winding in a step-down unit the secondary winding in a step-up) and X designations for the lower-voltage winding. One of the most important considerations to increase transformer efficiency and reduce heat is choosing the metal type of the windings. Copper windings are much more efficient than aluminum and many other winding metal choices, but it also costs more. Transformers with copper windings cost more to purchase initially, but save on electrical cost over time as the efficiency more than makes up for the initial cost. Step-down transformers are commonly used to convert the 220 volt electricity found in most parts of the world to the 110 volts required by North American equipment. 5.2 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 wired internally.

Fig 5.2 Bridge rectifier

50

The rectifier can converts an AC voltage into DC voltage. This DC voltage will be filtered by a capacitor filter, by this capacitor filter a pure DC output will be obtain.

5.2.1 CURRENT FLOW IN THE BRIDGE RECTIFIER For both positive and negative swings of the transformer, there is a forward path through the diode bridge. Both conduction paths cause current to flow in the same direction through the load resistor, accomplishing full-wave rectification.

Fig5.2.1

Fig5.2.2 While one set of diodes is forward biased, the other set is reverse biased and effectively eliminated from the circuit. This circuit output will be a dc output and this is given to the microcontroller. Vcc and ground will be connected to the port PADC. The first pin is the Vcc and second pin is the ground.

5.3 INPUT
51

The input is taken by the IR sensor. Two sensors will be taken, one is for entrance and and another is for exit. when the visitors are entered into the mall the IR sensors will be detecting the movements of the doorways. This input will be given to the port PD. PD0, PD1 will be the one input and PD4,PD5 will be the another input given by the sensors.

5.4 OUTPUT
The output will be taken by the port PB. PB2,PB3,PB4 pins are the output pins in the microcontroller section. A 12V DC output will be obtained in the port PB. This output will be given to the relays.

5.5 RELAY
A relay is an electrical switch that opens and closes under the control of another electronic circuit. In the original form, the switch is operated by an electro magnet to open or close one or many sets of contacts. It was invented by Joseph Henry in 1835. Because a relay is able to control an output circuit of higher power than the input circuit, it can be considered to be, in a broad sense, a form of an electrical amplifier. Operation When a current flows through the coil, the resulting magnetic field attracts an armature that is mechanically linked to a moving contact. The movement either makes or breaks a connection with a fixed contact. When the current to the coil is switched off, the armature is returned by a force approximately half as strong as the magnetic force to its relaxed position. Usually this is a spring, but gravity is also used commonly in industrial motor starters. Most relays are manufactured to operate quickly. In a low voltage application, this is to reduce noise. In a high voltage or high current application, this is to reduce arcing. If the coil is energized with DC, a diode is frequently installed across the coil, to dissipate the energy from the collapsing magnetic field at deactivation, which would otherwise generate a with AC, a small copper ring can be crimped to the end of the solenoid. This "shading ring" creates a small out-of-phase current, which increases the minimum pull on the armature during the AC cycle.
52

53

SNAP SHOT

54

CONCLUSION
Thus the project entitled Power management for shopping malls with Bidirectional Visitor Counting helps to measure the visitor entering and exiting a particular passage or way. The circuit counts both entering and exiting visitors and displays the number of visitors present inside the hall. Visitor counting is not limited to the entry/exit point of a company but has a wide range of applications that provide information to management on the volume and flow of people throughout a location. The visitor helps to maximize the efficiency and effectiveness of employees, floor area and sales potential of an organization. It can also be enhanced for long and accurate sensing range using a laser torch instead of IR transmission circuit. Thus the circuit can be used to monitor visitor flow in effective manner, where the visitors have to counted and controlled.

55

FUTURE SCOPE
Our project is applicable to shopping malls and hotels to save power consumption as well as man power. In future we can work out to implement same application in wireless by interfacing wireless modules like ASK-RF and ZIGBEE.

56

REFERENCE
1. Avtar Singh-"8086 Micro Processor-4th edition -Published by

Prentice Hall of India-2003 2. Das .J-"Principles of Digital Communication"-1st edition-Published by New Age International Publication 1986 3. Muhammad Ali Mazidi-"The 8051 Microcontroller and Embedded System Using Assemble C"-2nd edition-Published by Pearson Education 2006 4. Rajiv Kapadia-"8051 Micro Controllers and Embedded System"1st edition-Published by Jaico Books 2004 5. RAY.A.K -"Advanced Micro Processors and Peripherals"-2nd editionPublished by TATA McGraw-Hill 2006-07 6. Simon Hawkins-"Digital Communication"-1st edition-Published by Wiley India 2009

7. www.chetanasprojects.com

8. www.1000projects.com
9. www.microcontrollers.com

57

You might also like