Rao & Naidu Engg. College, Ongole: Certificate

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 60

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

RAO & NAIDU ENGG. COLLEGE, ONGOLE


(Affiliated to JNT University Kakinada, Kakinada)

CERTIFICATE
This is to certify that this is a bonafied record of Project Report on IMPLEMENTATION OF VOICE ENABLED HOME AUTOMATION USING PC, carried out by P.V.M.VIJAYABHASKAR T.NITISH P.VISHNU VARDHAN RAO P.HARIKA P.ANUSHA 07771A0462 07771A0461 07771A0463 07771A0464 07851A0463

Of final year B.Tech. In partial fulfillment of the requirements for award of BACHELOR 2010. OF TECHNOLOGY in ELECTRONICS & COMMUNICATION ENGINEERING during the academic year 2009

HOD Prof. T.RAMBABU M.TECH., (Ph.D)

Internal Guide Asst.Prof. B.V.MAHA LAKSHMI

External Examiner A MINI PROJECT REPORT ON

IMPLEMENTATION OF VOICE ENABLED HOME AUTOMATION USING PC

Submitted in partial fulfillment of the requirements for award of the degree of

BACHELOR OF TECHNOLOGY In ELECTRONICS & COMMUNICATION ENGINEERING


By
P.V.M.VIJAYABHASKAR T.NITISH P.VISHNU VARDHAN RAO P.HARIKA P.ANUSHA 07771A0462 07771A0461 07771A0463 07771A0464 07851A0463

Under the esteemed Guidance of Asst.Prof. B.V. MAHA LAKSHMI


H.O.D of Electronics & Communication Engineering

RAO & NAIDU ENGG. COLLEGE, ONGOLE-523001


2

2007-11

ACKNOWLEDGEMENT
I would like to express a deep sense of gratitude and thanks profusely to our guide B.V.MAHA LAKSHMI without the wise counsel and able guidance, it would have been impossible to complete the seminars manner. I express my deep sense of gratitude to Mr. T. RAMBABU Head of the Department, for his technical support and guidance. His critical evaluations of our work and suggestions have been great help to us. I also express my gratitude to Dr. P.S.V. SREENIVASA RAO, Principal of our college, for his guidance and cooperation during our course of study. I extend my sincere thanks to Mr. M. VENKATA RAO, Chairman of our college, for providing sufficient infrastructure and good environment in the college to complete our course. Great acknowledgement his expressed to coordinator, teaching and nonteaching staff members whose guidance cannot be ignored in completing this project in time. Special thanks to our Friends for their cooperation during my course of study. Last but not least, we wish to thank my parents and family members without whom it is impossible for me to stay in this level.

BY P.V.M.VIJAYABHASKAR T.NITISH P.VISHNU VARDHAN RAO P.HARIKA P.ANUSHA 07771A0462 07771A0461 07771A0463 07771A0464 07851A0463

CONTENTS
Acknowledgement Contents Chapter 1: Introduction
1.1 1.3 : Abstract 1.2 : Block diagram 2 3 3 4 5 6 7 10 10 10 10 11 11 11 12 12 13 13 13 14 : Modules in block diagram

III
IV 1 1 2

Chapter 2: Block diagram explanation


2.1 : Micro controller (P89V51RD2) 2.1.1 : Features 2.1.2 : Block diagram 2.1.3 : Pin configuration 2.1.4 : Pin description

Chapter 3: Functional description


3.1 3.2 3.3 : Power-on reset code execution : In-system programming : I/O ports

3.3.1 : Port-0 3.3.2 : Port-1 3.3.3 : Port-2 3.3.4 : Port-3 3.4 : Timers/counters 0&1 Bit allocation 3.4.2 : TMOD- timer/counter mode control register Bit description 3.4.3 : TMOD- timer/counter mode control register M1/M0 operating mode 3.4.4 :TCON-timer/counter control register 4 3.4.1 : TMOD- timer/counter mode control register

(Address 88h) bit allocation 3.4.5 :TCON-timer/counter control register (Address 88h) bit description 3.5 3.6 3.7 3.8 3.9 : Mode-0 : Mode-1 : Mode-2 : Mode-3 : TIMER-2 18 18 19 20 20 20 21 23 25 27 27 27 27 28 28 28 29 15 16 16 17 14

3.9.1 : Timer 2 Operating mode 3.9.2 : T2CON- timer/counter 2 control register (Address c8h) bit allocation 3.9.3 : T2CON- timer/counter 2 control register (Address c8h) bit description 3.9.4 : Timer 2 mode control register (Address c9h) bit allocation 3.9.5 : Timer 2 mode control register (Address c9h) bit description 3.10 : Capture mode 3.11 : Auto reload mode 3.12 : Baud rate generator mode 3.13 : Summary of baud rate equations

Chapter-4 : UART
4.1 4.2 4.3 4.4 4.5 : Mode-0 : Mode-1 : Mode-2 : Mode-3 : SCON- serial port control register (Address 98h) bit allocation 4.5.1 : SCON- serial port control register (Address 98h) bit description 4.5.2 : SCON- serial port control register 5

(Address 98h) sm0/sm1 mode definition 4.6: Framing error 4.7: Multiprocessor communications 29 30 31 32 32 36

Chapter-5: Relay Chapter-6: Code for the project


6.1: Microcontroller program

Chapter-7: Computer program Conclusion References

49
50

VOICE ENABLED HOME AUTOMATION USING PC


CHAPTER- 1 INTRODUCTION 1.1 ABSTRACT
The main objective of this project is to decrease the burden on human beings by automatically controlling any electrical appliance just by recognizing the voice tag. In day to day life we get in touch with vast number of electrical appliances for example take a TV, now a days TV has become the biggest entertainment for everyone. Sometimes we will be watching it till late nights, and when we are yet to sleep we switch it off with a remote instead of turning off the power supply. But switching off the TV with a remote will not cut off the total power supplied to the TV; some Components will be consuming the power unnecessarily. So by this system we could be able to turn off the total power supplied to the TV by just a voice tag. Physically disabled persons could be most benefitted with the usage of voice based automation technology.

1.2 BLOCK DIAGRAM:

Fan1 Light 1

Rela y Rela y P89V51 RD2 UAR T

Personal Computer

1.3 MODULES IN BLOCK DIAGRAM:


Microcontroller (P89V51RD2) UART Relays(12 V --- 1A)

CHAPTER -2 BLOCK DIAGRAM EXPLANATION


2.1 MICROCONTROLLER (P89V51RD2)
The P89V51RD2 is 80C51 microcontrollers with 64kB Flash and 1024 bytes of data RAM. A key feature of the P89V51RD2 is its X2 mode option. The design engineer can choose to run the application with the conventional 80C51 clock rate (12 clocks per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput at the same clock frequency. Another way to benefit from this feature is to keep the same performance by reducing the clock frequency by half, thus dramatically reducing the EMI. The Flash program memory supports both parallel programming and in serial In-System Programming (ISP). Parallel programming mode offers gang-programming at high speed, reducing programming costs and time to market. ISP allows a device to be reprogrammed in the end product under software control. The capability to field/update the application firmware makes a wide range of applications possible. The P89V51RD2 is also In-Application Programmable (IAP), allowing the Flash program memory to be reconfigured even while the application is running. 9

2.2 FEATURES
80C51 Central Processing Unit 5 V Operating voltage from 0 MHz to 40 MHz 16/32/64 kB of on-chip Flash user code memory with ISP (In-SystemProgramming) and IAP (In-Application Programming) Supports 12-clock (default) or 6-clock mode selection via software or ISP SPI (Serial Peripheral Interface) and enhanced UART PCA (Programmable Counter Array) with PWM and Capture/Compare functions Four 8-bit I/O ports with three high-current Port 1 pins (16 mA each) Three 16-bit timers/counters Programmable watchdog timer

10

Eight interrupt sources with four priority levels Second DPTR register Low EMI mode (ALE inhibit) TTL- and CMOS-compatible logic levels Brown-out detection Low power modes 1. Power-down mode with external interrupt wake-up 2. Idle mode PDIP40, PLCC44 and TQFP44 packages

2.3 BLOCK DIAGRAM:

11

2.4 PIN CONFIGURATION


12

2.5 PIN DESCRIPTION


13

14

15

16

CHAPTER 3 FUNCTIONAL DESCRIPTION


3.1 POWER-ON RESET CODE EXECUTION
Following reset, the P89V51RD2 will either enter the Soft ICE mode (if previously enabled via ISP command) or attempt to auto baud to the ISP boot loader. If this auto baud is not successful within about 400 ms, the device will begin execution of the user code.

3.2 IN-SYSTEM PROGRAMMING (ISP)


In-System Programming is performed without removing the microcontroller from the system. The In-System Programming facility consists of a series of internal hardware resources coupled with internal firmware to facilitate remote programming of the P89V51RD2 through the serial port. This firmware is provided by Philips and embedded within each P89V51RD2 device. The Philips In-System Programming facility has made in-circuit programming in an embedded application possible with a minimum of additional expense in components and circuit board area. The ISP function uses five pins (VDD, VSS, TxD, RxD, and RST). Only a small connector needs to be available to interface your application to an external circuit in order to use this feature.

3.3 INPUT/OUTPUT (I/O) PORTS


32 of the pins are arranged as four 8-bit I/O ports P0P3. Twentyfour of these pins are dual purpose with each capable of operating as a control line or part of the data/address bus in addition to the I/O functions. Details are as follows:

17

3.3.1 PORT 0 This is a dual-purpose port occupying pins 32 to 39 of the device. The port is an open-drain bidirectional I/O port with Schmitt trigger inputs. Pins that have 1s written to them float and can be used as high-impedance inputs. The port may be used with external memory to provide a multiplexed address and data bus. In this application internal pull-ups are used when emitting 1s. The port also outputs the code bytes during EPROM programming. External pull-ups are necessary during program verification. 3.3.2 PORT 1 This is a dedicated I/O port occupying pins 1 to 8 of the device. The pins are connected via internal pull-ups and Schmitt trigger input. Pins that have 1s written to them are pulled high by the internal pull-ups and can be used as inputs; as inputs, pins that are externally pulled low will source current via the internal pull-ups. The port also receives the low-order address byte during program memory verification. Pins P1.0 and P1.1 could also function as external inputs for the third timer/counter i.e.: (P1.0) T2 Timer/counter 2 external count input/clockout (P1.1) T2EX Timer/counter 2 reload/capture/direction control 3.3.3 PORT 2 This is a dual-purpose port occupying pins 21 to 28 of the device. The specification is similar to that of port 1. The port may be used to provide the high-order byte of the address bus for external program memory or external data memory that uses 16-bit 18

addresses. When accessing external data memory that uses 8-bit addresses, the port emits the contents of the P2 register. Some port 2 pins receive the high-order address bits during EPROM programming and verification. 3.3.4 PORT 3 This is a dual-purpose port occupying pins 10 to 17 of the device. The specification is similar to that of port 1. These pins, in addition to the I/O role, serve the special features of the 80C51 family; the alternate functions are summarized below: P3.0 RxD serial data input port P3.1 TxD serial data output port P3.2 INT0 external interrupt 0 P3.3 INT1 external interrupt 1 P3.4 T0 timer/counter 0 external input P3.5 T1 timer/counter 1 external input P3.6 WR external data memory writes strobe P3.7 RD external data memory read strobe.

3.4 TIMERS/COUNTERS 0 AND 1


The two 16-bit Timer/Counter registers: Timer 0 and Timer 1 can be configured to operate either as timers or event counters (see Table 12 and Table 13). In the Timer function, the register is incremented every machine cycle. Thus, one can think of it as counting machine cycles. Since a machine cycle consists of six oscillator periods, the count rate is 16 of the oscillator frequency. In the Counter function, the register is incremented in response to a 1-to-0 transition at its corresponding external input pin, T0 or T1. In this function, the external input is sampled once every machine cycle. When the samples show a high in one cycle and a low in the next cycle, the count is incremented. The new count value appears in 19

the register in the machine cycle following the one in which the transition was detected. Since it takes two machine cycles (12 oscillator periods) for 1-to-0 transition to be recognized, the maximum count rate is 112 of the oscillator frequency. There are no restrictions on the duty cycle of the external input signal, but to ensure that a given level is sampled at least once before it changes, it should be held for at least one full machine cycle. In addition to the Timer or Counter selection, Timer 0 and Timer 1 have four operating modes from which to select. The Timer or Counter function is selected by control bits C/T in the Special Function Register TMOD. These two Timer/Counters have four operating modes, which are selected by bit-pairs (M1, M0) in TMOD. Modes 0, 1, and 2 are the same for both Timers/Counters. Mode 3 is different. The four operating modes are described in the following text. 3.4.1 TMOD - Timer/Counter mode control register (address 89H) bit allocation Not bit addressable; Reset value: 00000000B; Reset source(s): any source

3.4.2 TMOD - Timer/Counter mode control register (address 89H) bit description

20

3.4.3 TMOD - Timer/Counter mode control register (address 89H) M1/M0 operating mode

3.4.4 TCON - Timer/Counter control register (address 88H) bit allocation Bit addressable; Reset value: 00000000B; Reset source(s): any reset

3.4.5 TCON - Timer/Counter control register (address 88H) bit description

21

3.5 MODE 0 Putting either Timer into Mode 0 makes it look like an 8048 Timer, which is an 8-bit Counter with a fixed divide-by-32 prescaler. Figure 7 shows Mode 0 operation.

22

In this mode, the Timer register is configured as a 13-bit register. As the count rolls over from all 1s to all 0s, it sets the Timer interrupt flag TFn. The count input is enabled to the Timer when TRn = 1 and either GATE = 0 or INTn = 1. (Setting GATE = 1 allows the Timer to be controlled by external input INTn, to facilitate pulse width measurements). TRn is a control bit in the Special Function Register TCON (Figure 6). The GATE bit is in the TMOD register. The 13-bit register consists of all 8 bits of THn and the lower 5 bits of TLn. The upper 3 bits of TLn are indeterminate and should be ignored. Setting the run flag (TRn) does not clear the registers. Mode 0 operation is the same for Timer 0 and Timer 1 (see Figure 7). There are two Different GATE bits, one for Timer 1 (TMOD.7) and one for Timer 0 (TMOD.3).

3.6 MODE 1

23

Mode 1 is the same as Mode 0, except that all 16 bits of the timer register (THn and TLn) are used. See Figure 8.

3.7 MODE 2 Mode 2 configures the Timer register as an 8-bit Counter (TLn) with automatic reload, as shown in Figure 9. Overflow from TLn not only sets TFn, but also reloads TLn with the contents of THn, which must be preset by software. The reload leaves THn unchanged. Mode 2 operation is the same for Timer 0 and Timer 1.

24

3.8 MODE 3 When timer 1 is in Mode 3 it is stopped (holds its count). The effect is the same as setting TR1 = 0. Timer 0 in Mode 3 establishes TL0 and TH0 as two separate 8-bit counters. The logic for Mode 3 and Timer 0 is shown in Figure 10. TL0 uses the Timer 0 control bits: T0C/T, T0GATE, TR0, INT0, and TF0. TH0 is locked into a timer function (counting machine cycles) and takes over the use of TR1 and TF1 from Timer 1. Thus, TH0 now controls the Timer 1 interrupt. Mode 3 is provided for applications that require an extra 8-bit timer. With Timer 0 in Mode 3, the P89V51RD2 can look like it has an additional Timer. Note: When Timer 0 is in Mode 3, Timer 1 can be turned on and off by switching it into and out of its own Mode 3. It can still be used by the serial port as a baud rate generator, or in any application not requiring an interrupt.

25

3.9 TIMER 2 Timer 2 is a 16-bit Timer/Counter which can operate as either an event timer or an event counter, as selected by C/T2 in the special function register T2CON. Timer 2 has four operating modes: Capture, Auto-reload (up or down counting), Clock-out, and Baud Rate Generator which are selected according to Table 17 using T2CON (Table 18 and Table 19) and T2MOD (Table 20 and Table 21). 3.9.1 Timer 2 operating mode

26

3.9.2 T2CON - Timer/Counter 2 control register (address C8H) bit allocation:

3.9.3 T2CON - Timer/Counter 2 control register (address C8H) bit description

27

3.9.4 T2MOD - Timer 2 mode control register (address C9H) bit allocation

28

3.9.5 T2MOD - Timer 2 mode control register (address C9H) bit description

3.10 CAPTURE MODE


In the Capture Mode there are two options which are selected by bit EXEN2 in T2CON. If EXEN2 = 0 Timer 2 is a 16-bit timer or counter (as selected by C/T2 in T2CON) which upon overflowing sets bit TF2, the Timer 2 overflow bit. The capture mode is illustrated in Figure 11.

This bit can be used to generate an interrupt (by enabling the Timer 2 interrupt bit in the IEN0 register). If EXEN2 = 1, Timer 2 operates as described above, but with the added feature that a 1- to -0 transition at external input T2EX causes the current value in the 29

Timer 2 registers, TL2 and TH2, to be captured into registers RCAP2L and RCAP2H, respectively. In addition, the transition at T2EX causes bit EXF2 in T2CON to be set, and EXF2 like TF2 can generate an interrupt (which vectors to the same location as Timer 2 overflow interrupt). The Timer 2 interrupt service routine can interrogate TF2 and EXF2 to determine which event caused the interrupt. There is no reload value for TL2 and TH2 in this mode. Even when a capture event occurs from T2EX, the counter keeps on counting T2 pin transitions or fosc/6 pulses. Since once loaded contents of RCAP2L and RCAP2H registers are not protected, once Timer2 interrupt is signalled it has to be serviced before new capture event on T2EX pin occurs. Otherwise, the next falling edge on T2EX pin will initiate reload of the current value from TL2 and TH2 to RCAP2L and RCAP2H and consequently corrupt their content related to previously reported interrupt.

3.11 AUTO-RELOAD MODE (UP OR DOWN COUNTER)


In the 16-bit auto-reload mode, Timer 2 can be configured as either a timer or counter (via C/T2 in T2CON), then programmed to count up or down. The counting direction is determined by bit DCEN (Down Counter Enable) which is located in the T2MOD register (see Table 20 and Table 21). When reset is applied, DCEN = 0 and Timer 2 will default to counting up. If the DCEN bit is set, Timer 2 can count up or down depending on the value of the T2EX pin. Figure 12 shows Timer 2 counting up automatically (DCEN = 0).

30

In this mode, there are two options selected by bit EXEN2 in T2CON register. If EXEN2 = 0, then Timer 2 counts up to 0FFFFH and sets the TF2 (Overflow Flag) bit upon overflow. This causes the Timer 2 registers to be reloaded with the 16-bit value in RCAP2L and RCAP2H. The values in RCAP2L and RCAP2H are preset by software means. Auto reload frequency when Timer 2 is counting up can be determined from this Formula:

Where Supply Frequency is either fosc (C/T2 = 0) or frequency of signal on T2 pin (C/T2 = 1). If EXEN2 = 1, a 16-bit reload can be triggered either by an overflow or by a 1-to-0 transition at input T2EX. This transition also sets the EXF2 bit. The Timer 2 interrupt, if enabled, can be generated when either TF2 or EXF2 is 1. Microcontrollers hardware will need three consecutive machine cycles in order to recognize falling edge on T2EX and set EXF2 = 1: in the first machine cycle pin T2EX has to be sampled as 1; in the second machine cycle it has to be sampled as 0, and in the third machine cycle EXF2 will be set to 1. 31

In Figure 13, DCEN = 1 and Timer 2 is enabled to count up or down. This mode allows pin T2EX to control the direction of count. When a logic 1 is applied at pin T2EX Timer 2 will count up. Timer 2 will overflow at 0FFFFH and set the TF2 flag, which can then generate an interrupt, if the interrupt is enabled. This timer overflow also causes the 16-bit value in RCAP2L and RCAP2H to be reloaded into the timer registers TL2 and TH2.

When a logic 0 is applied at pin T2EX this causes Timer 2 to count down. The timer will underflow when TL2 and TH2 become equal to the value stored in RCAP2L and RCAP2H. Timer 2 underflow sets the TF2 flag and causes 0FFFFH to be reloaded into the timer registers TL2 and TH2. The external flag EXF2 toggles when Timer 2 underflows or overflows. This EXF2 bit can be used as a 17th bit of resolution if needed.

3.12 BAUD RATE GENERATOR MODE

32

Bits TCLK and/or RCLK in T2CON allow the UART) transmit and receive baud rates to be derived from either Timer 1 or Timer 2 (See Section 7.5 UARTs on page 35 for details). When TCLK = 0, Timer 1 is used as the UART transmit baud rate generator. When TCLK = 1, Timer 2 is used as the UART transmit baud rate generator. RCLK has the same effect for the UART receive baud rate. With these two bits, the serial port can have different receive and transmit baud rates Timer 1 or Timer 2. Figure 14 shows Timer 2 in baud rate generator mode:

The baud rate generation mode is like the auto-reload mode, when a rollover in TH2 causes the Timer 2 registers to be reloaded with the 16-bit value in registers RCAP2H and RCAP2L, which are preset by software. The baud rates in modes 1 and 3 are determined by Timer 2s overflow rate given below: Modes 1 and 3 Baud Rates = Timer 2 Overflow Rate/16 The timer can be configured for either timer or counter operation. In many applications, it is configured for timer' operation (C/T2 = 0). Timer operation is different for Timer 2 when it is being used as a baud rate generator. Usually, as a timer it would increment every machine cycle (i.e., 16 the oscillator frequency). As a baud rate

33

generator, it increments at the oscillator frequency. Thus the baud rate formula is as follows: Modes 1 and 3 Baud Rates =

Where: (RCAP2H, RCAP2L) = The content of RCAP2H and RCAP2L taken as a 16-bit unsigned integer. The Timer 2 as a baud rate generator mode is valid only if RCLK and/or TCLK = 1 in T2CON register. Note that a rollover in TH2 does not set TF2, and will not generate an interrupt. Thus, the Timer 2 interrupt does not have to be disabled when Timer 2 is in the baud rate generator mode. Also if the EXEN2 (T2 external enable flag) is set, a 1-to-0 transition in T2EX (Timer/counter 2 trigger input) will set EXF2 (T2 external flag) but will not cause a reload from (RCAP2H, RCAP2L) to (TH2,TL2). Therefore when Timer 2 is in use as a baud rate generator, T2EX can be used as an additional external interrupt, if needed. When Timer 2 is in the baud rate generator mode, one should not try to read or write TH2 and TL2. Under these conditions, a read or write of TH2 or TL2 may not be accurate. The RCAP2 registers may be read, but should not be written to, because a write might overlap a reload and cause write and/or reload errors. The timer should be turned off (clear TR2) before accessing the Timer 2 or RCAP2 registers. Table 22 shows commonly used baud rates and how they can be OBTAINED FROM TIMER 2.

3.13 SUMMARY OF BAUD RATE EQUATIONS


Timer 2 is in baud rate generating mode. If Timer 2 is being clocked through pin T2(P1.0) the baud rate is: Baud rate = Timer 2 overflow rate / 16 34

If Timer 2 is being clocked internally, the baud rate is: Baud rate = fosc / (16 (65536 - (RCAP2H, RCAP2L))) Where fosc = oscillator frequency To obtain the reload value for RCAP2H and RCAP2L, the above equation can be rewritten as: RCAP2H, RCAP2L = 65536 - fosc / (16 baud rate)

Table 22: Timer 2 generated commonly used baud rates

35

CHAPTER - 4 UART
The UART operates in all standard modes. Enhancements over the standard 80C51 UART include Framing Error detection, and automatic address recognition. 4.1 Mode 0 Serial data enters and exits through RxD and TxD outputs the shift clock. Only 8 bits are transmitted or received, LSB first. The baud rate is fixed at 16 of the CPU clock frequency. UART configured to operate in this mode outputs serial clock on TxD line no matter whether it sends or receives data on RxD line. 4.2 Mode 1 36

10 bits are transmitted (through TxD) or received (through RxD): a start bit (logical 0), 8 data bits (LSB first), and a stop bit (logical 1). When data is received, the stop bit is stored in RB8 in Special Function Register SCON. The baud rate is variable and is determined by the Timer 12 overflow rate. 4.3 Mode 2 11 bits are transmitted (through TxD) or received (through RxD): start bit (logical 0), 8 data bits (LSB first), a programmable 9th data bit, and a stop bit (logical 1). When data is transmitted, the 9th data bit (TB8 in SCON) can be assigned the value of 0 or (e.g. the parity bit (P, in the PSW) could be moved into TB8). When data is received, the 9th data bit goes into RB8 in Special Function Register SCON, while the stop bit is ignored. The baud rate is programmable to either 116 or 132 of the CPU clock frequency, as determined by the SMOD1 bit in PCON.

4.4 Mode 3 11 bits are transmitted (through TxD) or received (through RxD): a start bit (logical 0), 8 data bits (LSB first), a programmable 9th data bit, and a stop bit (logical 1). In fact, Mode 3 is the same as Mode 2 in all respects except baud rate. The baud rate in Mode 3 is variable and is determined by the Timer 1/2 overflow rate. 4.5 Table 23: SCON - Serial port control register (address 98H) bit allocation

37

4.5.1 Table 24: SCON - Serial port control register (address 98H) bit description

4.5.2 Table 25: SCON - Serial port control register (address 98H) SM0/SM1 mode definition

4.6 FRAMING ERROR

38

Framing error (FE) is reported in the SCON.7 bit if SMOD0 (PCON.6) = 1. If SMOD0 = 0, SCON.7 is the SM0 bit for the UART, it is recommended that SM0 is set up before SMOD0 is set to 1. More about UART mode 1 Reception is initiated by a detected 1-to-0 transition at RxD. For this purpose RxD is sampled at a rate of 16 times whatever baud rate has been established. When a transition is detected, the divide-by16 counter is immediately reset to align its rollovers with the boundaries of the incoming bit times. The 16 states of the counter divide each bit time into 16ths. At the 7th, 8th, and 9th counter states of each bit time, the bit detector samples the value of RxD. The value accepted is the value that was seen in at least 2 of the 3 samples. This is done for noise rejection. If the value accepted during the first bit time is not 0, the receive circuits are reset and the unit goes back to looking for another 1-to0 transition. This is to provide rejection of false start bits. If the start bit proves valid, it is shifted into the input shift register, and reception of the rest of the frame will proceed. The signal to load SBUF and RB8, and to set RI, will be generated if, and only if, the following conditions are met at the time the final shift pulse is generated: (a) RI = 0, and (b) Either SM2 = 0, or the received stop bit = 1. If either of these two conditions is not met, the received frame is irretrievably lost. If both conditions are met, the stop bit goes into RB8, the 8 data bits go into SBUF, and RI is activated. More about UART modes 2 and 3 Reception is performed in the same manner as in mode 1. The signal to load SBUF and RB8, and to set RI, will be generated if, and only if, the following conditions are met at the time the final shift pulse is generated: (a) RI = 0, and (b) Either SM2 = 0, or the received 9th data bit = 1. If either of these conditions is not met, the received frame is irretrievably lost, and RI is not set. If both 39

conditions are met, the received 9th data bit goes into RB8, and the first 8 data bits go into SBUF.

4.7 MULTIPROCESSOR COMMUNICATIONS


UART modes 2 and 3 have a special provision for multiprocessor communications. In these modes, 9 data bits are received or transmitted. When data is received, the 9th bit is stored in RB8. The UART can be programmed so that when the stop bit is received, the serial port interrupt will be activated only if RB8 = 1. This feature is enabled by setting bit SM2 in SCON. One way to use this feature in multiprocessor systems is as follows: When the master processor wants to transmit a block of data to one of several slaves, it first sends out an address byte which identifies the target slave. An address byte differs from a data byte in a way that the 9th bit is 1 in an address byte and 0 in the data byte. With SM2 = 1, no slave will be interrupted by a data byte, i.e. the received 9th bit is 0. However, an address byte having the 9th bit set to 1 will interrupt all slaves, so that each slave can examine the received byte and see if it is being addressed or not. The addressed slave will clear its SM2 bit and prepare to receive the data (still 9 bits long) that follow. The slaves that werent being addressed leave their SM2 bits set and go on about their business, ignoring the subsequent data bytes. SM2 has no effect in Mode 0, and in Mode 1 can be used to check the validity of the stop bit, although this is better done with the Framing Error flag. When UART receives data in mode 1 and SM2 = 1, the receive interrupt will not be activated unless a valid stop bit is received.

CHAPTER - 5
40

RELAY
1. Here we are using relay as switch. To make device connected to it ON and OFF when the relay is trigged ON and OFF respectively by the Microcontroller.

CHAPTER - 6
41

/ *********************************************************************** ******************************** CODE FOR THE PROJECT **************************** *********************************************************************** ******/ /************** MICROCONTROLLER PROGRAM *************************/ #include <reg51f.H> #include"UART.c" sbit light1 = P1^0; sbit Fan1 =P1^1; sbit AC1 = P1^2; void main() { unsigned char ch; //int x; Init_Uart(); while(1) { ch=RX_CHAR(); if(ch == 'a') { light1= 1; } else if(ch == 'b') { light1= 0; } else if(ch == 'c') { Fan1= 1; 42

} else if(ch == 'd') { Fan1= 0; } else if(ch == 'e') { AC1= 1; } else if(ch == 'f') { AC1= 0; } } } //********************************************************************** *****/ //THIS FILE CONTAINS FUNCTIONS DEFINITIOS FOR SERIAL INTERFACE WITH 8051 //TARGET :=P89V51RD2 //AUTHOR : //DATE REVISION : //********************************************************************** ******/ #ifndef __USART_C #define __USART_C #include"UART.H" void send_char(unsigned char c) { SBUF=c; while(!TI); 43

TI=0; } //********************************************************************** ********/ void send_string(unsigned char *str) { while(*str) { send_char(*str++); } } //********************************************************************** **********/ unsigned char RX_CHAR() { unsigned char ch; while(!RI); ch=SBUF; RI=0; return(ch); } //********************************************************************** ***********/ void Init_Uart(void) { SCON=0x50; TMOD=0x22; TH1=0XFD; TR1=1; // EA=1; 44

// ES=1; } #endif //********************************************************************** ***********/ //End of file //********************************************************************** *****/ //THIS FILE CONTAINS FUNCTIONS PROTOTYPES FOR SERIAL INTERFACE WITH 8051 //TARGET :=P89V51RD2 //AUTHOR : //DATE REVISION : //********************************************************************** ******/ #ifndef __SERIAL_H #define __SERIAL_H void Send_Char(unsigned char); void Send_String(unsigned char *); unsigned char Recv_Char(void); void Init_Uart(void); #endif

45

CHAPTER - 7
/************************Computer ***********************/ using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using SpeechLib; namespace SpeechTest { /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.MenuItem menuItem3; private System.Windows.Forms.MenuItem menuItem4; private System.Windows.Forms.MenuItem menuItem5; 46

Program

private System.Windows.Forms.MenuItem menuItem6; private System.Windows.Forms.MenuItem menuItem7; private System.Windows.Forms.MenuItem menuItem8; private System.Windows.Forms.MenuItem menuItem9; private System.Windows.Forms.MenuItem menuItem10; private System.Windows.Forms.MenuItem menuItem11; private System.Windows.Forms.Button cmdEnable; private System.Windows.Forms.Button cmdDiable; private SpeechLib.SpSharedRecoContext objRecoContext = null; private SpeechLib.ISpeechRecoGrammar grammar = null; private SpeechLib.ISpeechGrammarRule menuRule=null; private System.Windows.Forms.TextBox txtHyp; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox txtReco; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private IContainer components; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // 47

// TODO: Add any constructor code after InitializeComponent call // }

/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() {

48

this.components = new System.ComponentModel.Container(); this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components); this.menuItem1 = new System.Windows.Forms.MenuItem(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.menuItem3 = new System.Windows.Forms.MenuItem(); this.menuItem4 = new System.Windows.Forms.MenuItem(); this.menuItem5 = new System.Windows.Forms.MenuItem(); this.menuItem6 = new System.Windows.Forms.MenuItem(); this.menuItem7 = new System.Windows.Forms.MenuItem(); this.menuItem8 = new System.Windows.Forms.MenuItem(); this.menuItem9 = new System.Windows.Forms.MenuItem(); this.menuItem10 = new System.Windows.Forms.MenuItem(); this.menuItem11 = new System.Windows.Forms.MenuItem(); this.cmdEnable = new System.Windows.Forms.Button(); this.cmdDiable = new System.Windows.Forms.Button(); this.txtHyp = new System.Windows.Forms.TextBox(); 49

this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.txtReco = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.SuspendLayout();

// // mainMenu1 // this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem1, this.menuItem7}); // // menuItem1 // this.menuItem1.Index = 0; this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem2, this.menuItem3, this.menuItem4, this.menuItem5, this.menuItem6}); this.menuItem1.Text = "&File"; // // menuItem2 // this.menuItem2.Index = 0; 50

this.menuItem2.Text = "New"; // // menuItem3 // this.menuItem3.Index = 1; this.menuItem3.Text = "Open"; // // menuItem4 // this.menuItem4.Index = 2; this.menuItem4.Text = "Cl&ose"; // // menuItem5 // this.menuItem5.Index = 3; this.menuItem5.Text = "-"; // // menuItem6 // this.menuItem6.Index = 4; this.menuItem6.Text = "E&xit"; // // menuItem7 // this.menuItem7.Index = 1; this.menuItem7.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem8, this.menuItem9, this.menuItem10, this.menuItem11}); this.menuItem7.Text = "&Edit"; 51

// // menuItem8 // this.menuItem8.Index = 0; this.menuItem8.Text = "Cu&t"; // // menuItem9 // this.menuItem9.Index = 1; this.menuItem9.Text = "&Copy"; // // menuItem10 // this.menuItem10.Index = 2; this.menuItem10.Text = "&Paste"; // // menuItem11 // this.menuItem11.Index = 3; this.menuItem11.Text = "D&elete"; // // cmdEnable // this.cmdEnable.Location = new System.Drawing.Point(16, 16); this.cmdEnable.Name = "cmdEnable"; this.cmdEnable.Size = new System.Drawing.Size(96, 23); this.cmdEnable.TabIndex = 0; this.cmdEnable.Text = "Enable Speech"; this.cmdEnable.Click += new System.EventHandler(this.cmdEnable_Click); 52

// // cmdDiable // this.cmdDiable.Location = new System.Drawing.Point(152, 16); this.cmdDiable.Name = "cmdDiable"; this.cmdDiable.Size = new System.Drawing.Size(96, 23); this.cmdDiable.TabIndex = 0; this.cmdDiable.Text = "Disable Speech"; this.cmdDiable.Click += new System.EventHandler(this.cmdDiable_Click); // // txtHyp // this.txtHyp.Location = new System.Drawing.Point(106, 106); this.txtHyp.Name = "txtHyp"; this.txtHyp.Size = new System.Drawing.Size(168,20); this.txtHyp.TabIndex = 6; // // label1 // this.label1.Location = new System.Drawing.Point(18, 106); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(72, 16); this.label1.TabIndex = 4; this.label1.Text = "Hypothesis"; // 53

// label2 // this.label2.Location = new System.Drawing.Point(18, 146); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(72, 16); this.label2.TabIndex = 3; this.label2.Text = "Recognition"; // // txtReco // this.txtReco.Location = new System.Drawing.Point(106, 146); this.txtReco.Name = "txtReco"; this.txtReco.Size = new System.Drawing.Size(168, 20); this.txtReco.TabIndex = 5; // // label3 // this.label3.Location = new System.Drawing.Point(16, 184); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(248, 72); this.label3.TabIndex = 7; // // label4 // this.label4.Location = new System.Drawing.Point(24, 72); 54

this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(240, 23); this.label4.TabIndex = 8; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.Add(this.label4); this.Controls.Add(this.label3); this.Controls.Add(this.txtHyp); this.Controls.Add(this.label1); this.Controls.Add(this.label2); this.Controls.Add(this.txtReco); this.Controls.Add(this.cmdEnable); this.Controls.Add(this.cmdDiable); this.Menu = this.mainMenu1; this.Name = "Form1"; this.Text = "Speech Test"; this.ResumeLayout(false); this.PerformLayout(); } #endregion /// <summary> /// The main entry point for the application. /// </summary> [STAThread] 55

static void Main() { Application.Run(new Form1()); } private void cmdEnable_Click(object sender, System.EventArgs e) { label4.Text = "Initializing Speech Engine...."; // Get an insance of RecoContext. I am using the shared RecoContext. objRecoContext = new SpeechLib.SpSharedRecoContext(); // Assign a eventhandler for the Hypothesis Event. objRecoContext.Hypothesis += new _ISpeechRecoContextEvents_HypothesisEventHandler(Hypo_Event ); // Assign a eventhandler for the Recognition Event. objRecoContext.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(Reco_Even t); //Creating an instance of the grammer object. grammar = objRecoContext.CreateGrammar(0); label3.Text = "Speak Out one of the follwoing.\r\n1. Lightone On 2. Lightone Off 3. Fanone On 4. Fantwo Off\r\n5. Cut 6. Copy 7. Paste 8. Delete"; //Activate the Menu Commands. menuRule=grammar.Rules.Add("MenuCommands",SpeechRuleAttribu tes.SRATopLevel|SpeechRuleAttributes.SRADynamic,1); object PropValue = "";

56

menuRule.InitialState.AddWordTransition(null, "Lightone On", " ", SpeechGrammarWordType.SGLexical, "Lightone On", 1, ref PropValue, 1.0F); menuRule.InitialState.AddWordTransition(null, "Lightone Off", " ", SpeechGrammarWordType.SGLexical, "Lightone Off", 2, ref PropValue, 1.0F); menuRule.InitialState.AddWordTransition(null, "Fanone On", " ", SpeechGrammarWordType.SGLexical, "Fanone On", 3, ref PropValue, 1.0F); menuRule.InitialState.AddWordTransition(null, "Fantwo Off", " ", SpeechGrammarWordType.SGLexical, "Fantwo Off", 4, ref PropValue, 1.0F); menuRule.InitialState.AddWordTransition(null,"Cut"," ",SpeechGrammarWordType.SGLexical,"Cut",5, ref PropValue, 1.0F ); menuRule.InitialState.AddWordTransition(null,"Copy"," ",SpeechGrammarWordType.SGLexical,"Copy",6, ref PropValue, 1.0F ); menuRule.InitialState.AddWordTransition(null,"Paste"," ",SpeechGrammarWordType.SGLexical,"Paste",7, ref PropValue, 1.0F ); menuRule.InitialState.AddWordTransition(null,"Delete"," ",SpeechGrammarWordType.SGLexical,"Delete",8, ref PropValue, 1.0F ); grammar.Rules.Commit(); grammar.CmdSetRuleState("MenuCommands", SpeechRuleState.SGDSActive); label4.Text = "Speech Engine Ready for Input"; 57

} private void Reco_Event(int StreamNumber, object StreamPosition,SpeechRecognitionType RecognitionType,ISpeechRecoResult Result) { txtReco.Text = Result.PhraseInfo.GetText(0, -1, true); } private void Hypo_Event(int StreamNumber, object StreamPosition, ISpeechRecoResult Result) { txtHyp.Text = Result.PhraseInfo.GetText(0, -1, true); } private void cmdDiable_Click(object sender, System.EventArgs e) { label3.Text = ""; objRecoContext = null; label4.Text=""; } } }

58

CONCLUSION
The strategic conclusion of the project is an absolute automatic controlling of any electrical appliance just by recognizing the voice tag. We can able to turn off the total power supplied to any electrical appliances by just a voice tag. So that it can able to save the power of usage. The main advantage of this project is to decrease the burden on human beings by automatically controlling of any electrical appliance. And more over it can mostly benefit to physically disabled persons by the usage of voice based automation technology.

59

REFERENCES

60

You might also like