DESIGN OF AN INTELLIGENT ELECTRIC VEHICLE FOR BLIND

ABSTRACT:
As the technology increases we can solve many problems of the people.
There are lots of persons who cannot walk very easily due to blindness. For them
travelling with safety is a major problem. An intelligent electric vehicle is thus
required to solve their problem. The vehicle is made with a lot of technologies such
as Digital image processing for obstacle detection, edge detection and road
detection, Sonar, Infrared and Lidar based Obstacle avoidance, GPS and Map
based location guidance for vehicle, GSM based emergency servicing and semi
automatic control system for vehicle. We propose a design of completely
intelligent electric vehicle for blind which can be implemented successfully. The
vehicle is designed in such a way that it can climb footpaths. The vehicle is
designed to obey all traffic signals so that the design is apt for real world.

CHAPTER-1
INTRODUCTION:
In system the vehicle is designed with voice control along with automated
obstacle avoidance. Using voice commands the vehicle is navigated. The
microcontroller connected with the voice module kit recognizes the voice
command and controls the vehicle movement automatically. Also the vehicle is
attached with a web camera and a PC which is used to take images continuously
and if it encounters a traffic signal it analyses the signal and informs the
microcontroller about the traffic signal which in turn controls the vehicle
accordingly. Along with this the obstacle detecting system is established with
ultrasonic sensors.

CHAPTER-2
REQUIREMENTS
GENERAL
The requirements are to make the project using the some hardware’s and the
software’s. That all are listed below.
HARDWARE REQUIREMENT:




PIC Microcontroller
Ultrasonic sensor
Max232 & LCD
Relay
Robo model

SOFTWARE REQUIREMENT:
 MPLAB COMPILER
 EMBEDDED C

Block diagram:

Power
Supply

Traffic Light with
switch and battery

LCD Display

Recognition
Authenticati
on
Processing

Web
Camera

CIRCUIT DIAGRAM:

MAX
232
PIC16F877A
Microcontroller

Ultrasonic
Sensor
Driver
Circuit

Wheel
Chair

0K OHM 6MM SQ SMD" R1 Q1 BC547 1k .1uF 33 34 35 36 37 38 39 40 RL1 12V D4 DIODE 1 2 3 4 5 6 19 20 21 22 27 28 29 30 7 8 9 10 11 12 13 14 Q4 R4 LCD1 15 16 17 18 23 24 25 26 BC547 1k VSS VDD VEE 12v RL4 RS RW E 12V D2 DIODE D0 D1 D2 D3 D4 D5 D6 D7 Q3 R2 1k BC547 12v PIC16F877A LM016L RL2 D1 12V DIODE RV1 5.1uF 2 3 4 5 6 7 U1 1 3 C1+ C1- Y RXD FROM PC 11 12 10 9 T1IN R1OUT T2IN R2OUT T1OUT R1IN T2OUT R2IN TXD to PC VS+ VSC2+ 4 14 13 7 8 2 6 8 9 10 C1 0.12v RL3 12V D3 DIODE Q2 R3 B1 BC547 1k 12v 5V U2 13 14 C3 0.0K DESC="TRIMPOT 5.1uF 1 OSC1/CLKIN OSC2/CLKOUT RB0/INT RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD RA0/AN0 RA1/AN1 RA2/AN2/VREF-/CVREF RA3/AN3/VREF+ RA4/T0CKI/C1OUT RA5/AN4/SS/C2OUT RC0/T1OSO/T1CKI RE0/AN5/RD RC1/T1OSI/CCP2 RE1/AN6/WR RC2/CCP1 RE2/AN7/CS RC3/SCK/SCL RC4/SDI/SDA MCLR/Vpp/THV RC5/SDO RC6/TX/CK RC7/RX/DT C2- C2 5 RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RD4/PSP4 RD5/PSP5 RD6/PSP6 RD7/PSP7 MAX232 0.

CHAPTER-3

INTRODUCTION OF PIC16F877A:
The PIC16F877A CMOS FLASH-based 8-bit microcontroller is upward compatible with
the PIC16C5x, PIC12Cxxx and PIC16C7x devices. It features 200 ns instruction execution, 256
bytes of EEPROM data memory, self programming, an ICD, 2 Comparators, 8 channels of 10-bit
Analog-to-Digital (A/D) converter, 2 capture/compare/PWM functions, a synchronous serial port
that can be configured as either 3-wire SPI or 2-wire I2C bus, a USART, and a Parallel Slave
Port.

Microchip PIC16F877A Microcontroller Features:
High-Performance RISC CPU

Operating speed: 20 MHz, 200 ns instruction cycle

Operating voltage: 4.0-5.5V

Industrial temperature range (-40° to +85°C)

15 Interrupt Sources

35 single-word instructions

All single-cycle instructions except for program branches (two-cycle)

Special Microcontroller Features

Flash Memory: 14.3 Kbytes (8192 words)

Data SRAM: 368 bytes

Data EEPROM: 256 bytes

Self-reprogrammable under software control

In-Circuit Serial Programming via two pins (5V)

Watchdog Timer with on-chip RC oscillator

Programmable code protection

Power-saving Sleep mode

Selectable oscillator options

In-Circuit Debug via two pins

Peripheral Features

33 I/O pins; 5 I/O ports

Timer0: 8-bit timer/counter with 8-bit prescaler

Timer1: 16-bit timer/counter with prescaler
o Can be incremented during Sleep via external crystal/clock

Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler

Two Capture, Compare, PWM modules
o 16-bit Capture input; max resolution 12.5 ns
o 16-bit Compare; max resolution 200 ns
o 10-bit PWM

Synchronous Serial Port with two modes:
o SPI Master
o I2C Master and Slave

USART/SCI with 9-bit address detection

Parallel Slave Port (PSP)
o 8 bits wide with external RD, WR and CS controls

Brown-out detection circuitry for Brown-Out Reset

Analog Features

10-bit, 8-channel A/D Converter

Brown-Out Reset

Analog Comparator module
o 2 analog comparators
o Programmable on-chip voltage reference module
o Programmable input multiplexing from device inputs and internal VREF
o Comparator outputs are externally accessible

Pin diagram:

after we've burned it. one after the other.Memory of the PIC16F877 divided into 3 types of memories:  Program Memory . These two memories have separated data buses. The variables that we store in the Data Memory during the program are deleted after we turn of the micro. Program Counter executes commands stored in the program memory. . which contains a special registers like SFR (Special Faction Register) and GPR (General Purpose Register). As a reminder.  Data Memory – This is RAM memory type. which makes the access to each one of them very easy.A memory that contains the program(which we had written).

In contrast. . Data Memory does not save the information because it needs power in order to maintain the information stored in the chip. which store the information even after the power is turn off. This memory is used to store the program after we burn it to the microcontroller. PIC16F87XA Program Memory The PIC16F87XA devices have a 13-bit program counter capable of addressing an 8K word x 14 bit program memory space. Program Memory and Data EEPROM they are non-volatile memories. Each time we burn program into the micro. Each one of them has a different role.A memory that allows storing the variables as a result of burning the written program. These memories called Flash Or EEPROM. Program Memory and Data Memory two memories that are needed to build a program. Data EEPROM (Electrically Erasable Programmable Read-Only Memory) . and Data EEPROM is used to save data after the microcontroller is turn off. we erase an old program and write a new one. The PIC16F876A/877A devices have 8K words x 14 bits of Flash program memory that can be electrically erased and reprogrammed.

CALL has the address of the first instruction in the subroutine as its operand. The stack space is not part of either program or data space and the stack pointer is not readable or writable. this is a special block of RAM memory used only for this purpose. The CALL instruction is used to jump to a subroutine. RETLW or a RETFIE instruction execution. It is automatically incremented to the next instruction during the current instruction execution. In the PIC microcontrollers. . The PC is PUSHed onto the stack when a CALL instruction is executed.PIC16F876A/877A program memory map and stack Program Counter (PC) keeps track of the program execution by holding the address of the current instruction. or an interrupt causes a branch. The stack is POP’ed in the event of a RETURN. When the CALL instruction is executed. which must be terminated with the RETURN instruction. The PIC16F87XA family has an 8-level deep x 13-bit wide hardware stack. the destination address is copied to the PC.

for example. This means that after the stack has been PUSHed eight times. the ninth push overwrites the value that was stored from the first push. The default bank is BANK0. micro PIC16F84 has only two banks. Interrupt Vector. The banks are located inside the RAM. Some of the memory is divided into the pages that are designed for write/burn the program into them. implemented as static RAM. Number of banks may vary depending on the microcontroller. where the special registers and the data located. . Data Memory is divided into the banks. it is working with the particular bank. The lower locations of each bank are reserved for the Special Function Registers.The stack operates as a circular buffer. PIC16F87XA Data Memory Organization The data memory is partitioned into multiple banks which contain the General Purpose Registers and the Special Function Registers. Attention! Program Memory is divided into the pages. our program will begin after the Interrupt Vector. The address 0004 is “reserved” for the “interrupt service routine” (ISR). Above the Special Function Registers are General Purpose Registers. While program is being executed. Each time the main program execution starts at address 0000 . The tenth push overwrites the second push (and so on). and if not we can start to write from the beginning of the Reset Vector. If we plan to use an interrupt. where the program is stored. and Reset Vector) is hardware registers. the remaining memory (Stack. Each bank extends up to 7Fh (128 bytes).Reset Vector.

There are special registers which can be accessed from any bank. but only a few most important ones:  STATUS register – changes/moves from/between the banks  PORT registers – assigns logic values (“0”/”1”) to the ports  TRIS registers . one should access it inside the program.To access a register that is located in another bank. PIC16F876A/877A register file map In order to start programming and build automated system. such as STATUS register. there is no need to study all the registers of the memory map.data direction register (input/output) .

3. the will use the definition of fundamental concepts. the program will work with banks 2. The following table demonstrates. which of the Banks the program is working with. the two methods will be studied in detail. the program will work with banks 0. and RP0) one can control the transition between the banks:  IRP . used for indirect addressing method.1. PIC STATUS register With the help of three left bits (IRP. When the IRP Equal to 1. this register is used to switch between the banks (Register Bank Select).You can learn about other registers at a later stage or as needed. Later on. used for direct addressing method. To distinguish between the two methods. RP1.  RP1:RP0: .Register Bank Select bit. based on the selection of the RP0 and RP1 bits: RP1:RP0 BANK 00 0 01 1 10 2 11 3 An example of using STATUS register and Register Bank Select bit: . but also has other capabilities. When the IRP Equal to 0. at this point.Register Bank Select bits. STATUS register In most cases.

Addwf 100. the maximum value is 256.1. in the third line. and thus. 5 . clrf TRISB . resulting in carry out. RP0. RP0. we switched back to Bank 0 by in changing/setting the 5th bit. 5 . Set PORTB as output 3. Movlw 200 2. 0 In this example. ADDLW. However. After PortB was set as output in the second line.SUBLW. bcf STATUS. Change to Bank 1 2. in the STATUS register to 1. The result is stored in W register and should be 300 (200+100). bsf STATUS. Change to Bank 0 In the first line.SUBWF instructions) (for borrow. in the STATUS register to 0. C: Carry/borrow bit (ADDWF. we are in changing/setting the 5th bit. we are assigning value of 200 to the W (working) register. Register W will contain the reminder: 44. DC: Digit carry/borrow bit (ADDWF. the polarity is reversed) 1 = A carry-out from the 4th low order bit of the result occurred 0 = No carry-out from the 4th low order bit of the result Z: Zero bit 1 = The result of an arithmetic or logic operation is zero 0 = The result of an arithmetic or logic operation is not zero .SUBWF instructions) 1 = A carry-out from the Most Significant bit of the result occurred 0 = No carry-out from the Most Significant bit of the result occurred An example of using STATUS register and Carry/borrow bit: 1. ADDLW. The C (bit 0) of the STATUS register becomes 1 (C = 1).SUBLW. Then. base on the table we are switching/selecting Bank 1. we are adding the value of 100 and the W register together.

. 2. sensor) or to send information to the external elements (e.The bits 3 and 4 are used with WDT . The corresponding data direction register is TRISB. PORTC is an 8-bit wide. bidirectional port. bidirectional port. Setting a TRISB bit (= 1) will make the corresponding PORTB pin an input. Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input. have 5 I/O ports located in the BANK 0.g. 4. Clearing a TRISB bit (= 0) will make the corresponding PORTB pin an output. Setting a TRISC bit (= 1) will make the corresponding PORTC pin an input.Watchdog Timer. PORTD is an 8-bit port with Schmitt Trigger input buffers. LCD). The corresponding data direction register is TRISC. PORTB is an 8-bit wide. while the 40/44-pin devices. like PIC16F877. Clearing a TRISC bit (= 0) will make the corresponding PORTC pin an output. The 28-pin devices have 3 I/O ports. 3.g. PD: Power-down bit 1 = After power-up or by the CLRWDT instruction 0 = By execution of the SLEEP instruction TO: Time-out bit 1 = After power-up. 1. Each pin is individually configurable as an input or output. PORTA is a 6-bit wide. bidirectional port. CLRWDT instruction or SLEEP instruction 0 = A WDT time-out occurred PORT register The role of the PORT register is to receive the information from an external source (e. Clearing a TRISA bit (= 0) will make the corresponding PORTA pin an output. The corresponding data direction register is TRISA.

5. We are allowed to use the names of the ports without considering their addresses. For example: # define SWITCH PORTA. Pin diagram of PIC16F877A We can control each port by using an assigned address of specific port. Usually we define the ports at the beginning of the program. RE1/WR/AN6 and RE2/CS/AN7) which are individually configurable as inputs or outputs. which received a value of bit number 0 of the PORTA. but there is much easier way to control the port. PORTE has three pins (RE0/RD/AN5. and then we use only the given names. . These pins have Schmitt Trigger input buffers. 0 We define a variable named SWITCH.

at this time. and then return to BANK0. If not set otherwise. we need to access TRIS register that is located inside BANK1. However. make the change. . to change port from an input to an output and vice versa. From the moment we moved to the BANK1. Here's a map of the locations: BANK0 BANK1 PORTA TRISA PORTB TRISB PORTC TRISC PORTD TRISD PORTE TRISE The default mode of each TRIS is input. Keep in mind: to change a specific port to an output.TRIS register The TRIS register is data direction register which defines if the specific bit or whole port will be an input or an output. the program will always work with BANK1. Each PORT has its own TRIS register. one should first move to the BANK1. the access to PORT registers is done inside BANK0. If you want to set a specific port as exit you must change the state of the TRIS to 0. to access registers inside BANK0. For example. The running program is working only with one bank at all time. The default state of the banks is BANK0. Part of the registers located inside BANK0. When we need to access a register that is not located inside BANK0. then as stated. the default bank is BANK0. we will have to return to the situation in which our program will work with BANK0. we are required to switch between the banks. and some are not.

The following figure shows the two addressing methods: Pin diagram of PIC16F877A To the left you can see the direct addressing method.Direct and Indirect addressing Direct Addressing: Using this method we are accessing the registers directly by detecting location inside Data Memory from Opcode and by selecting the bank using bits RP1 and RP0 of the STATUS register. INDF register is not an actual register (it is a virtual register that is not found in any bank). and there is FSR (File Select Register). Indirect Addressing: To implement indirect addressing. where the bank selection is made by RP bits and the referencing is made directly from memory Opcode by using the variable name. a File Select Register (FSR) and indirect register (INDF) are used. . Indirect addressing treated like a stack pointer. Don’t be confused! There is SFR (Special Function Register) . allowing much more efficient work with a number of variables. when using this method we choose bank using bit IRP of the STATUS register.special registers of RAM. In addition.

the content of the W passes to the TEMP variable. we will define the variable TEMP at the address 0X030. where the bank selection is made by IRP bit and accessing the variable by pointer FSR. Let’s explore the differences between the 2 methods: We want to assign number 5 to the variable TEMP located at address 0X030. Movlw 5 3. Movlw 0x030 3. Movwf INDF .To the right you can see the indirect addressing method. TEMP Equ 0x030 2. TEMP Equ 0x030 2. Example of direct addressing: 1. In the first row of each example. Movwf TEMP It's easy to understand. and in the line 3. Movwf FSR 4. Example of indirect addressing: 1. In the second line we put the number 5 into the working register W. that direct addressing method means working directly with the variables. Movlw 5 5.

with an address range from 00h to FFh. There are six SFRs used to read and write to this memory: 1. EEDATH 5. and from this moment FSR points to the address of the TEMP variable. EECON2 3. In the third line. In the fourth line. addresses from 80h to FFh are unimplemented. EECON1 2.In the second line. EEDATA 4. we move the contents of W register (which is 5) to the INDF. A few important points about Data EEPROM memory:  It lets you save data DURING programming  The data is saved during the “burning” process . EEADRH When interfacing to the data memory block. the value passes to the FSR register. These devices have 128 or 256 bytes of data EEPROM (depending on the device). PIC16F87XA Data EEPROM The data EEPROM and Flash program memory is readable and writable during normal operation (over the full VDD range). and in the fifth line. EEADR 6. the number 5 passes to the W register. In fact INDF performs the following: it takes the number 5 and puts it in the address indicated by FSR register. it is indirectly addressed through the Special Function Registers. we put a value into the W register. On devices with 128 bytes. EEDATA holds the 8-bit data for read/write and EEADR holds the address of the EEPROM location being accessed. Instead. This memory is not directly mapped in the register file space.

because there are functions (writing and reading) that are ready. Write to DATA EEPROM To write to an EEPROM data location. Then the user must follow a specific write sequence to initiate the write for each byte. WR . BSF STATUS.to write BSF STATUS.Write AAh BSF EECON1.Wait for write GOTO $-1 . MOVWF EECON2 . W .Enable writes BCF INTCON. the user must first write the address to the EEADR register and the data to the EEDATA register. RP0 .Data Memory MOVWF EEADR . You can read the data memory during the programming and use it  The use is made possible with the help of SFR At this point there is no need to learn how to use this memory with special registers.Write 55h MOVLW AAh .to complete BCF STATUS. RP0 .Bank 2 MOVF DATA_EE_ADDR.Point to DATA memory BSF EECON1. RP1 . MOVWF EECON2 . MOVLW 55h . WREN .Bank 3 BCF EECON1. RP0 .Address to write MOVF DATA_EE_DATA. W .Disable INTs. EEPGD . GIE . Bank 3 BTFSC EECON1.Set WR bit to begin write .Data Memory Value MOVWF EEDATA . BSF STATUS. WR .

RP0 . that process can be performed independently. Address to read BSF STATUS. The role of this electronic system is to display time in a very precise manner and change the display every second (for seconds).Disable writes Read DATA EEPROM To read a data memory location. the user must write the address to the EEADR register. . BSF STATUS. Bank 2 MOVF EEDATA. W . Simple example of this process is the digital wristwatch. RD . Data Memory MOVWF EEADR . RP0 . EEPGD . W . it can be read in the next instruction. PIC Timer0: Many times. therefore. WREN . Point to Data memory BSF EECON1. but it is better to use ready functions of Microchip. Bank 3 BCF EECON1. EEDATA will hold this value until another read or until it is written to by the user (during a write operation). clear the EEPGD control bit (EECON1<7>) and then set control bit RD (EECON1<0>). EE Read BCF STATUS. The data is available in the very next cycle in the EEDATA register. W = EEDATA Both of these functions are provided by the manufacturer.BSF INTCON. RP1 . RP0 .Enable INTs BCF EECON1. we plan and build systems that perform various processes that depend on time. BCF STATUS. Bank 2 MOVF DATA_EE_ADDR. There is a required sequence in order to write/read to/from the memory. every minute (for minutes) and so on. GIE .

To perform the steps we've listed. We will study each one separately. before the program could be continued. that was counting up to a specific value. So far we used “delay procedure” to implement some delay in the program. which needs to be very accurate in order to take necessary actions. In order for us to know how to work with these timers. using Timers we can build a very precise time delays which will be based on the system clock and allow us to achieve our desired time delay well-known in advance. we need to learn some things about each one of them. "Delay procedure" had two disadvantages:  we could not say exactly how long the Delay procedure was in progress  we could not perform any further steps while the program executes the "delay procedure" Now. PIC Timer0 The Timer0 module timer/counter has the following features:  8-bit timer/counter  Readable and writable  8-bit software programmable prescaler . the system must use a timer. The microcontroller PIC16F877 has 3 different timers:  PIC Timer0  PIC Timer1  PIC Timer2 We can use these timers for various important purposes. In this PIC timer module tutorial we will study the existing PIC timer modules. The clock is actually a core of any electronic system.

You can initialize the value of this register to what ever you want (not necessarily "0"). The TMR0 interrupt is generated when the TMR0 register overflows from FFh to 00h. This overflow sets bit TMR0IF (INTCON<2>). Prescaler . Internal (4 Mhz) or external clock select  Interrupt on overflow from FFh to 00h  Edge select (rising or falling) for external clock Let’s explain the features of PIC Timer0 we have listed above: Timer0 has a register called TMR0 Register.TMR0 Overflow Interrupt Flag bit. We can read the value of the register TMR0 and write into. We can reset its value at any given moment (write) or we can check if there is a certain numeric value that we need (read). TMR0IF .  1:2  1:4  1:8  1:16  1:32 . which is 8 bits of size. We can write the desired value into the register which will be increment as the program progresses.Frequency divider. Maximum value that can be assigned to this register is 255. Frequency varies depending on the Prescaler.

TOSE=0. PSA=0. // Prescaler is assigned to the Timer0 module 2. PS0=1. // which means divide by 256 5. PS1=1. 1:64  1:128  1:256 The structure of the OPTION_REG register We perform all the necessary settings with OPTION_REG Register. Initializing the OPTION_REG register The following is an example how we can initialize the OPTION_REG: 1. // Prescaler rate bits 3. // Internal instruction cycle clock Block diagram of the PIC Timer0 / WDT prescaler . TOCS=0. // are set to “111” 4. PS2=1. The size of the register is 8 bits. // rising edge 6.

the division is performed as follow: PIC TIMER0 formula for internal clock Fout – Output frequency after the division. (256 .PIC TIMER0 block diagram Calculating Count.A numeric value to be placed to obtain the desired output frequency . Tout – The Cycle Time after the division. Fout. . and TMR0 values If using INTERNAL crystal as clock. when using internal crystal as clock (and not external oscillator).TMR0) . Count .The division of the original clock (4 MHz) by 4.Fout. 4 .The number of times in the timer will count based on the register TMR0.

Second.An example of INTERNAL crystal as clock Suppose we want to create a delay of 0. let’s assume that the frequency division by the Prescaler will be 1:256. the division is performed as follow: PIC TIMER0 formula for external clock In this case there is no division by 4 of the original clock. Thus: . let’s assume that the frequency division by the Prescaler will be 1:256. What is the value of Count? Calculation: First. We use the external frequency as it is. Thus: Formula to calculate Cout using Timer0 If using EXTERNAL clock source (oscillator). let’s set TMR0=0. let’s set TMR0=0. when the external oscillator is 100kHz and Count=8? Calculation: First.5 second in our program using Timer0.Fout. Second. An example of EXTERNAL clock source (oscillator): What is the output frequency .

timer/counter. has the following features:  16-bit timer/counter consisting of two 8-bit registers (TMR1H and TMR1L)  readable and writable  8-bit software programmable prescaler  Internal (4 Mhz) or external clock select  Interrupt on overflow from FFFFh to 0000h Let’s explain the features of PIC Timer1 we have listed above: Timer1 has a register called TMR1 register. This interrupt can be enabled/disabled by setting/clearing .535 decimal). The TMR1 interrupt. if enabled. is generated on overflow which is latched in interrupt flag bit. which is 16 bits of size. TMR1IF (PIR1<0>).Formula to calculate Fout for Timer0 PIC Timer1: The Timer1 module. Actually. the TMR1 consists of two 8-bits registers:  TMR1H  TMR1L It increments from 0000h to the maximum value of 0xFFFFh (or 0 b1111 1111 1111 1111 or 65.

TMR1 interrupt enable bit. As we can see. You can initialize the value of this register to what ever you want (not necessarily "0"). so you can make four different division. This flag marks the end of ONE cycle count. the size of the register is 8 bits. The options are:  1:1  1:2  1:4  1:8 You can choose whether to use an internal system clock (crystal) or external oscillator that can be connected to a pin RC0. We can read the value of the register TMR1 and write into. The flag need to be reset in the software if you want to do another cycle count. We can reset its value at any given moment (write) or we can check if there is a certain numeric value that we need (read). TMR1IF – TMR1 overflow Interrupt Flag bit. The structure of the T1CON register We perform all the necessary settings with T1CON register. TMR1IE (PIE1<0>). We can use Prescaler for further division of the system clock. The size of the register is 2-bit only. Prescaler – Frequency divider. Let’s explore the relevant bits: .

Block diagram of the PIC Timer1 PIC TIMER1 block diagram Calculating Count. T1CKPS0=0. T1CKPS1=0. TMR1ON=1. // which means 1:1 (no division) Or you can set all the T1CON register at once as follows: T1CON=0b00000001. and Timer1 values If using INTERNAL crystal as clock. the division is performed as follow: PIC TIMER1 formula for internal clock . // Prescaler value set to “00” 4. // the timer is enable 2. Fout.Initializing the T1CON register The following is an example how we can initialize the T1CON register: 1. // internal clock source 3. TMR1CS=0.

Tout – The Cycle Time after the division.The division of the original clock (4 MHz) by 4. Second. Thus: Formula to calculate Cout for Timer1 PIC Timer2: . the division is performed as follow: PIC TIMER1 formula for external clock Simple example and calculation of how to use TIMER1: Suppose we want to create a delay of 2 second in the our program using Timer1. let’s set TMR1=0. If using EXTERNAL clock source (oscillator). let’s assume that the frequency division by the Prescaler will be 1:1. which means the TMR1 will count 65. 4 .Fout– The output frequency after the division.A numeric value to be placed to obtain the desired output frequency . What is the value of Count? Calculation: First.TMR1) . when using internal crystal as clock (and not external oscillator).536 times.Fout.The number of times in the timer will count based on the register TMR0. Count . (256 .

Each allows to make additional division of the frequency clock source.Timer2 is an 8-bit timer with a prescaler and a postscaler. TIMER2 Prescaler and Postscaler . PR2 is a readable and writable register and initialized to FFh upon Reset. Postscaler divides the frequency that comes out of the Comparator again for the last time. Prescaler divides the frequency clock source BEFORE the counting take place at the register TMR2. The TMR2 register is readable and writable and is cleared on any device Reset. • Prescaler and Postscaler . ie: using Timer2 we can determine the started count value. The Timer2 increments from 00h until it matches PR2 and then resets to 00h on the next increment cycle. thus the counting inside the TMR2 register is performed based on the divided frequency clock source by the Prescaler The match output of TMR2 goes through a 4-bit postscaler (which gives a 1:1 to 1:16 scaling inclusive) to generate a TMR2 interrupt (latched in flag bit.4 MHz crystal • Interrupt on overflow Let’s explain the features we have listed above: • Timer2 has 2 count registers: TMR2 and PR2. the final count value. and the count will be between these two values. Register TMR2 is used to store the “initial” count value (the value from which it begins to count). The size of each registers is 8-bit in which we can write numbers from 0 to 255. TMR2IF (PIR1<1>)). Register PR2 is used to store the “ending” count value (the maximum value we need/want to reach).The Timer2 module has the following features: • two 8-bit registers (TMR2 and PR2) • readable and writable • prescaler and a postscaler • connected only to an internal clock .

. • PR2 – The register in which the final or the maximum count value is written. Let’s explore the relevant bits: T2CKPS1:T2CKPS0: Timer2 Clock Prescale Select bits The input clock (FOSC/4) has a prescale option of 1:1. • TMR2 – The register in which the “initial” count value is written. We perform all the necessary settings with T2CON Register The structure of the T2CON register: As we can see. selected by control bits T2CKPS1:T2CKPS0 (T2CON<1:0>). the size of the register is 8 bits. 1:4 or 1:16.• TMR2IF . • Comparator – Compares the value of the register TMR2 and the maximum value of the register PR2.TMR2 to PR2 Match Interrupt Flag bit.

4. TMR2ON (T2CON<2>). to minimize power consumption. TOUTPS0=1. 0000 = 1:1 postscale 0001 = 1:2 postscale 0010 = 1:3 postscale 1111 = 1:16 postscale The following is an example how we can initialize the T2CON register: 1. TMR2ON=1. // Prescaler – 1:1 3. // the timer is enable 2. // Postscaler – 1:16 5. T2CKPS0=0. . T2CKPS1=0. TOUTPS0=1. 1 = Timer2 is on 0 = Timer2 is off TOUTPS3:TOUTPS0: Timer2 Output Postscale Select bits The match output of TMR2 goes through a 4-bit postscaler (which gives a 1:1 to 1:16 scaling inclusive selected by control bits TOUTPS3:TOUTPS0 (T2CON<6:3>).00 = Prescaler is 1 01 = Prescaler is 4 1x = Prescaler is 16 TMR2ON: Timer2 On bit Timer2 can be shut-off by clearing control bit.

Or you can set all the T2CON register at once as follows: T2CON=0b01111100.6. TOUTPS0=1. TIMER2 BLOCK DIAGRAM How to calculate the required values of the TIMER2: . TOUTPS0=1. 7.

Second. (PR2 – TMR2) . Tout – The Cycle Time after the division. Simple example and calculation of how to use TIMER2: Suppose we want to create a delay of 1 second in the our program using Timer2. let’s set TMR1=0 and PR2=255. What is the value of Count? Calculation: First.A numeric value to be placed to obtain the desired output frequency . let’s assume that the frequency division by the Prescaler will be 1:1 and Postscaler will be 1:16.fout.Fout – The output frequency after the division. when using internal crystal as clock (and not external oscillator).The number of times the counter will count. Thus: Introduction to Serial communication with PIC16F877 microcontroller In this tutorial we will study the communication component – USART (Universal Synchronous Asynchronous Receiver Transmitter) located within the PIC.The division of the original clock (4 MHz) by 4. Count . It is a . 4 .

let’s take a look at the following example: We have a multi-bit word. and we want to transmit it from one computer to the second computer. We will look at:  serial and parallel communications  synchronous and asynchronous communications  how to enable serial communication . and emphasize the difference between serial communication and parallel communication. which can be used as transmitter or as receiver. . We will start with the definition of media concepts.TXSTA and RCSTA registers  An example of 8-bit transmission  An example of 9-bit transmission  how to calculate the value being placed in the SPBRG register  USART Transmit and Receive block diagrams  Max323 Driver/Receiver  the implementation of the PIC serial communication (C program and a video) We will show how to set USART in order to allow communication between PIC to PIC or between PIC to a personal computer. There are two options to differentiate when speaking about transmission of information on the transmission lines:  serial communication  parallel communication In order to understand what serial communication is.universal communication component (Synchronous/Asynchronous).

Using the parallel communication: When using the parallel communication. the number of bits will be transmitted at once from one computer to the second computer. however. Transmitting the word 10011101 using parallel communication. .Using the serial communication: When using the serial communication we transmit the multi-bit word bit after bit (when at any given moment only one bit will pass). Transmitting the word 10011101 using serial communication.

In addition to the serial and parallel communications, there are 2 types of communication we
will explore:

Synchronous communication

Asynchronous communication

Synchronous communication
When using the synchronous communication – the information is transmitted from the
transmitter to the receiver:

in sequence

bit after bit

with fixed baud rate

and the clock frequency is transmitted along with the bits

That means that the transmitter and the receiver are synchronized between them by the same
clock frequency. The clock frequency can be transmitted along with the information, while it is
encoded in the information itself, or in many cases there is an additional wire for the clock.
This type of communication is faster compare to the asynchronous communication since it is
"constantly transmitting” the information, with no stops.
Asynchronous communication

When using the asynchronous communication - the transmitter and the receiver refraining
to transmit long sequences of bits because there isn't a full synchronization between the
transmitter, that sends the data, and the receiver, that receives the data.
In this case, the information is divided into frames, in the size of byte. Each one of the frame has:

“Start” bit marks the beginning of a new frame.

“Stop” bit marks the end of the frame.

Frames of information must not necessarily be transmitted at equal time space, since they are
independent of the clock.

Enabling Serial Communication
To communicate with external components such as computers or microcontrollers, the PIC
micro uses a component called USART - Universal Synchronous Asynchronous Receiver
Transmitter. This component can be configured as:

a Full-Duplex asynchronous system that can communicate with peripheral devices, such
as CRT terminals and personal computers

a Half-Duplex synchronous system that can communicate with peripheral devices, such
as A/D or D/A integrated circuits, serial EEPROMs, etc.

To enable the serial communication with PIC micro we must set different parameters within two
registers: (click the links for the explanation of each bit)
1. TXSTA - Transmit Status and Control Register

2. RCSTA - Receive Status and Control Register

An example of 8-bit transmission:
Let’s assume that we need to transmit the following information: 10110010. This
information will be stored inside TXREG register, which acts as a temporary buffer storage of
information prior to transmission. The bit TX9 will be zero (TX9=0) - which determines that the
transmission will be 8-bit transmission, so there is no need to address TX9D bit, which stores the
ninth bit of information.
The information before the transmission looks like this:

Transmitting 8 bit data
Now, let’s define the receiver side to receive 8 bit information. To do so, the register RX9
will be zero (RX9=0). The received information will be stored in the RSR register, which acts as
a temporary buffer storage.
The received information will look like this:

. This is important because the information of 8 bits may be transmitted immediately once being inside the TXREG register. lower 8-bit information. let’s define the receiver side to receive 9 bit information. we will store the low 8-bit in the register TXREG and the MSB in the TX9D bit. This information is in the size of 9-bit.enabling transmission of 9-bit data. The received. the register RX9 will be set (RX9=1). The information before the transmission will look like this: Transmitting 9 bit data Now. We will set the TX9 = 1 . It is important to note. will be stored in the RSR register. Thus. To do so. so there is not enough space to store all the information in the TXREG register . that first we need to store the 9th bit and only later other 8-bits. As a result the transmitted information will be incorrect.Receiving 8 bit data An example of 9-bit transmission: Suppose we want to transmit the following information: 110010110.

To do so. in asynchronous mode. The higher bit information (MSB) will be stored in RX9D. is made by the BRGH bit in TXSTA register:  1 = High speed  0 = Low speed .which acts as a temporary buffer storage. The baud rate is measured in units of bps (bit per second) or kbps (kilo bit per second). The size of SPBRG register is 8-bit. we need to “write” a hexadecimal number to the SPBRG register. As discussed previously. the baud rate of transmission of the information can be set to high speed or to low speed. The received information will look like this: Receiving 9 bit data Now let’s continue the explanation. The rate selection. This is done by setting the system clock to the value needed. Calculating the value being placed in the SPBRG register Let’s assume we want to transmit using the BAUD rate of 1200bps. The value written to the SPBRG register set the clock cycle to the value we want for the BAUD rate. Each transmission is transmitted in the particular rate (BAUD). as already seen.

in the case of a high baud rate and low baud rate. its describing the calculation needed for transmission in Low Speed: SPBRG = (4MHz / (64x1200)) -1 = 51. BRGH=0 BRGH=1 . to get the baud rate of 1. For example: We want to calculate the hex value that will be placed the register SPBRG.1. BRGH = 1 High Speed SPBRG = (Fosc / (64 x Baud rate)) .2kbps with low speed. The formula SPBRG = (Fosc / (64 x Baud rate)) . BRGH = 0 Low Speed The following outlines how the value which is placed in the SPBRG register is being computed. The following tables are the BAUD RATES FOR ASYNCHRONOUS MODE BRGH=0 and BRGH=1.1 was chosen since.1.For each baud rate we need to calculate the value being placed in the SPBRG differently: SPBRG = (Fosc / (16 x Baud rate)) .08 Because it is not possible to write a number with a decimal point to the register. we take only the whole part of the number and place inside the register SPBRG = 51.

USART transmit block diagram USART transmit block diagram .

At the same time. which is used as a temporary buffer before that information is transmitted. the TXREG register is empty and flag bit. the 9th bit is loaded into TX9D.Enabling SPBRG USART receive block diagram .TXREG. Of course. Once the TXREG register transfers the data to the TSR register.The information we want to transmit is loaded into the 8-bit register . TXIF is set. using 2 registers allows faster the transmission of the data. As mentioned earlier:  the register SPBRG sets the baud rate in the desired transmission  TXIE – allows interrupts when TXREG is empty and TXIF is set  TXEN . the information above is being loaded into the register TSR. If you want to transmit a 9-bit data.

Obviously. the CREN bit needs to be set. After receiving the data in the register RSR. the 9th bit goes into RX9D. that the information that was transmitted via pin RC6 in Port C. While the information that was received being transferred into RCREG. the information is loaded at the same time into the register RCREG. If there is a 9-bit transmission. using 2 registers allows faster receiving of the data. is received through the pin RC7 in Port C PIC interrupt In this tutorial we will study about the Polling and especially on the PIC Interrupt.USART receive block diagram The information is received in the register RSR. the new information has already been received into the register RSR. Of course. According to the USART TRANSMIT / RECEIVE BLOCK DIAGRAM. We will look at:  the different types of PIC interrupts  the existing PIC interrupts .

the microcontroller accesses at the exact time interval the external device. B) The second method is . The user is the one who determines the time intervals in which micro “contacts” the device. the settings of the required registers to work with PIC interrupts  the implementation of the external PIC interrupts (C program and a video) Computer systems include microcontroller. and only the micro is entitled to obtain access to the information it needs. which needs to wait and check whether the new information has arrived. An example of such a system is a digital thermometer. In fact we see that in the Polling method the external devices are not independent systems.Interrupt: . which includes timers. serial communication system. analog digital converter. and much more. located outside the micro itself which are communicating with micro through control lines. In the Polling method. Many times it is also external systems.Polling: Using this method. which is measure the temperature and at the end of the measurements transmitting the results to the PIC micro How does the processor know to get the required information from the external system? This operation can be performed in two ways:  using polling  using interrupts A) The first method is the simple one . the PIC microcontroller must "access by himself" the device and “ask” for the information it needs for processing. The main Drawback of this method when writing program is waste of time of microcontroller. and gets the required information. they depend on the microcontroller.

the processors can send to each other interrupts as a way to communicate.Interrupt is the signal sent to the micro to mark the event that requires immediate attention. which causes to the keyboard to send interrupt to the microcontroller to read the information of the pressed key. In fact. the PIC microcontroller does not "see" the request for the interrupt and will not . division by 0 will causes an interrupt. An example: Procedure . jumps to the place in memory that reserved for a procedure – executes the procedure and only then returns back to the program and continues to execute. the method of interrupt defines the option to transfer the information generated by internal or external systems inside the micro by them self! Once the system has finished the task imposed on it. go to make an interrupt and then to return to continue to execute the program. Hardware interrupts -these are sent to microcontroller by hardware devices as a third-party. For example. Common example is pressing on the key on the keyboard. Interrupt is “requesting" the processor to stop to perform the current program and to “make time” to execute a special code.when there is a procedure call.  In the multi-processor system. There are two types of PIC interrupts: Software interrupts .come from a program that runs by the processor and “request” the processor to stop running the program.(masking) by Interrupt Enable bit (IE). the processor stops the execution of the program. some of them can be blocked . the processor will be notified that it can access and receive the information and use it.  The processor can send interrupts to itself as a result of executing the program. The “request” for the microcontroller to “free itself” to execute the interrupt could come from several sources:  External hardware devices. to report an error in the code. When the interrupt is “blocked”.

For example: The processor is in the middle of a calculation. There are some interrupts that can not be “masked”/”blocked” . The interrupts on the left side of the figure below are low priority and all of them together can be “blocked” by enabling bit interrupt PEIE = 0. and if the GIE = 0 we are blocking all of the interrupts. We will “unblock” the interrupt only after the processor finished the calculation. such as the drop of voltage.GIE. In fact the blocked interrupt will not be executed until it will be unblocked. we will “block” the "write to the memory" interrupt. thus preventing him to write into the memory as long as it is in the middle of the action. They are used to report on critical hardware issues. When the GIE = 1 we are enabling the interrupts. when xxIF is an interrupt flag and xxIE is an Interrupt Enable bit. From the diagram below you can see all the sources of the interrupts.Non Mask able Interrupts. and we do not want to write into memory until the micro did not finish the calculation. Interrupt flag shows the result of an interrupt and interrupt enable bit is used to enable or to “block” the interrupt. In this situation we are interested in immediate response from the processor without the ability to ignore them. In this situation. We can also determine whether to allow the system shown in figure below to treat or block all of the interrupts. . Let’s explore the existing interrupts within the PIC16F877 microcontroller: The microcontroller has 14 interrupt sources.NMI .execute it. This is done by using the global interrupt enable bit .

The program will play a sound from a buzzer that is located on the EduPIC development board. PIE2) – This register contains the interrupt enabling bits of the low-priority interrupts.How to set the required registers to work with interrupts? The settings of the interrupts are done by using 3 interrupt control registers:  INTCON – This register contains the status of the high-priority interrupts (see diagram above) and general definitions.  PIR (PIR1. Writing a C language program to implement external interrupt Let’s write an example program. we will “create an external interrupt” using our program itself. where we will explore the way we need to define the external interrupt connected to PORTB pin RB0. by incrementing the . every time there is an external interrupt that is generated through RB0 pin. To make our live trouble-free we will not connect any external device to the PORTB0. PIR2) – This register contains the interrupt flags of the low-priority interrupts. Instead.  PIE (PIE1.

The interrupt function is called by the hardware itself and operates by following steps:  After the interrupt function is loaded into the memory. the last bit (LSB) will vary each cycle of the program from "0" to "1" and vice versa. So far functions were called from the main program or other functions. This function is a special function.value of PORTB by 1. any change in the last bit (which is actually a change to the pin RB0) from "0" to "1" will cause the INTF flag to be set. . from "0" to "1". In this section of code. we will increase the value of PORTB by 1 (PORTB + + ).  When the interrupt has occurred. When we are increasing the value by 1. when there is a logic change in the pin RB0. the operating system stops the execution of the main function and “free itself” to perform the interrupt function. the external interrupt flag will be set INTF = 1. As explained above. the function waits for a moment for the interrupt to occur. The change in the value in the last bit of PortB is described in the example below: 00000000 a change from 0 to 1 00000001 00000010 a change from 0 to 1 00000011 00000100 a change from 0 to 1 00000101 00000110 a change from 0 to 1 00000111 In order for us to work with the interrupts. we need to learn another function: interrupt function. Thus.

For example: Suppose that the voltage that supplied to the A/D converter varies from 0 to 5 volt. the operating system continues to run the main function from the place it stopped before the interrupt has occurred. and the A/D converter converts the input voltage to a binary number of two-bits. 8.A/D. After the execution of the interrupt function. we can ONLY display 4 different options: 00 01 10 11 That is. The more bits the binary number has. the higher the resolution of the . or more precisely four levels. 4. With two bits. 10-bit. These binary numbers can be in different length . You can see the 4 levels in the following illustration: . we can show the changes from 0 to 5 volt with 4 numbers.2. PIC Analog to Digital Converter: The role of the ANALOG-TO-DIGITAL CONVERTER (A/D) is to convert analog voltage values to digital values. Let’s explore the principle of operation of the A/D converter: The ANALOG-TO-DIGITAL CONVERTER converts analog voltage to binary numbers.

the A/D converter converts the input voltage to a binary number of three-bits.BLUE line describes the changes in the input voltage of the ANALOG-TO-DIGITAL CONVERTER (A/D) of the microcontroller. we can show the changes from 0 to 5 volt with 8 numbers. suppose that the voltage that supplied to the A/D converter is still varies from 0 to 5 volt. or more precisely 8 levels.e. We can see that the red signal far from being ideal. however. With three bits we can get 8 different options: 000 001 010 011 100 101 110 111 That is. You can see the eight levels in the following illustration: . not close enough to the original analog input voltage values. i. Thus. Now. RED line represents the digital levels at the output of the ANALOG-TO-DIGITAL CONVERTER (A/D) of the microcontroller. we can say that A/D with the binary number of two-bits has a low resolution and there is a large gap between the real value of the analog input voltage and the values represented by the A/D.

we can say that current A/D converter has a high-resolution compare to previous case. If you are planning to build accurate and fast systems. The gap between the analog signal and the digital signal smaller compared to the previous graph. The conversion time of the low resolution A/D takes less time than the conversion time of the high resolution A/D. . Therefore we can say that the ANALOG TO DIGITAL CONVERTER (A/D) of the microcontroller with a larger amount of bits has a higher resolution and better accuracy when converting from analog signal to digital signal. it takes a certain time.Now we can see that the RED line represents the original signal “better” than the previous RED line. Since the converter converts the signals. There is another fact to mention about the resolution of the A/D converter. you have to take into account this fact. When you are planning special systems. Based on the "good" results that we received. but if you select an analog to digital converter (A/D) with high-speed response – you will loose the resolution of the system. you have to consider carefully which convert to choose: if you select an analog to digital converter (A/D) with high resolution – system will not be as “fast.

For example: Voltage levels [V] Binary representation 0-0.51-3. the converter can divide the analog input voltage between 0v and 5v to 2^ 10 levels.621v to 1.62 000 0.75 101 3.871-2.25v have a binary representation of 001 so on.251-1. which are 1024 levels. For example. the analog voltage values from 0v to 0.12 100 3.How to convert analog values to digital values: If we decide to work with an analog to digital converter (A/D) with three-bit length. we obtain eight different binary numbers which represent different voltage levels.371-5. How do we know what is the binary value/representation of the analog input voltage? We can use the triangle method to calculate/find the binary representation of an analog input voltage. lets calculate/find the binary value representation on the analog input voltage of 3.25 001 1.87 010 1.37 110 4.65 volt: .621-1.5 011 2. We can say that the resolution of this component is very high.62v have a binary representation of 000. the analog voltage values from 0. The Analog to Digital Converter (ADC) module located within the PIC microcontroller has a resolution of ten-bit length.121-3. Therefore.751-4.00 111 In this example.

Each bit has an important role in the definition of the component.A/D Control Register 1. Here's a breakdown of the bits role: After we define the appropriate pins in the specific PORT to be analog inputs.Using similar way we can find a binary representation for any desired level of the analog input voltage.65v will be represented by decimal number 748 or by binary number 1011101100. determines the configuration of the PORTA and PORTE and how the result of conversion of A/D will be store  ADRESH . These registers are:  ADCON0 .A/D Result Low Register The size of this register is one byte (8 bits).The analog input voltage of 3.A/D Result High Register  ADRESL . The A/D module has four 8 bit registers. we can sample the analog input voltage using one of the following channels: .A/D Control Register 0. determines the behavior of the A/D  ADCON1 .

GO/DONE: A/D Conversion Status bit If ADON = 1: 1 = A/D conversion in progress (setting this bit starts the A/D conversion) 0 = A/D conversion not in progress (this bit is automatically cleared by hardware when the A/D conversion is complete) ADON: A/D On bit 1 = A/D converter module is operating 0 = A/D converter module is shut-off and consumes no operating current The size of this register is one byte (8 bits). Each bit has an important role in the definition of the component. 0 = Left justified.You can sample from PORTA each of the pins RA0 and RA5 except pin RA4 (used for other purposes) as well as of PORTE. Here's a breakdown of the bits role: ADFM: A/D Result Format Select bit 1 = Right justified. As we said.e. 6 Least Significant bits of ADRESL are read as ‘0’. i. Therefore. the result of the conversion can not be stored in one register of eight bits. the A/D converter has a resolution of ten bits. the result is stored in two registers: . 6 Most Significant bits of ADRESH are read as ‘0’..

ADRESL and ADRESH. so that we have 16 (2*8) bits all together. We can decide an analog (A) or digital (D) mode. Left Justified X X X X X X X X X X ADRESH 0 0 0 0 0 0 ADRESL Alignment to the right – the eight LSB bits are stored in ADRESL."0". In this case six highest bits appear as . and two MSB bits are stored in the ADRESH. the remaining six bits appear as . . Right Justified 0 0 0 0 0 0 X X X X ADRESH X X X X X X ADRESL PCFG3:PCFG0: A/D Port Configuration Control bits: With these bits we can control the pins of PORTA or PORTE. In this case. We can store the result of the conversion which is 10 bits long using the two registers ADRESL and ADRESH in the following 2 ways:  alignment to the left  alignment to the right Alignment to the left – the eight MSB bits are stored in the ADRESH. The size of each register is 8 bits long. and the two LSB bits are stored in ADRESL."0".

we have to set up channel through which the analog information will be received using TRIS command.If we want to work with the PORTA and PORTE as analog ports. . When the conversion ends. we have to set the GO/DONE =1. then we select the option PCFG3: PCFG0 = 011x. the result will be loaded into 2 registers ADRESH: ADRESL. after the specified desired behavior of the A/D converter unit and before we start the conversion operation. Status bit GO/DONE (the register ADCON0) will be set to zero and the ADIF flag is set. If we want to work with ports as digital. To begin making the conversion. In general. This is done by using the command ADGO = 1. then we select the option PCFG3: PCFG0 = 0000.

Analog to Digital BLOCK DIAGRAM To summarize. Configure the A/D module: o Configure analog pins/voltage reference and digital I/O (ADCON1) o Select A/D input channel (ADCON0) . the following steps should be followed for doing an A/D Conversion: 1.

Configure A/D interrupt (if desired): o Clear ADIF bit o Set ADIE bit o Set PEIE bit o Set GIE bit 3. clear bit ADIF if required. Read A/D result register pair (ADRESH:ADRESL). by either: o Polling for the GO/DONE bit to be cleared(with interrupts enabled). For the next conversion. 4. Wait the required acquisition time. go to step 1 or step 2. Start conversion: o Set GO/DONE bit (ADCON0) 5.o Select A/D conversion clock (ADCON0) o Turn on A/D module (ADCON0) 2. 7. as required. CHAPTER-5 INTRODUCTION ABOUT SOFTWARE: . OR o Waiting for the A/D interrupt 6. Wait for A/D conversion to complete.

use the MON51. Simulation helps you understand hardware configurations and avoids time wasted on setup problems.  When you are ready to begin testing your software application with target hardware. CAN. When starting a new project. A/D Converter. Interrupts. with simulation. simply select the microcontroller you use from the Device Database and the µVision IDE sets all compiler. D/A Converter. SPI. or FlashMON51 Target Monitors. MONADI. Additionally.  Numerous example programs are included to help you get started with the most popular embedded 8051 devices. UART. . and memory options for you. MON390. I/O Ports. and PWM Modules) of your 8051 device. you can write and test applications before target hardware is available. or the ULINK USB-JTAG Adapter to download and test program code on your target system. assembler. the ISD51 In-System Debugger.  The Keil µVision Debugger accurately simulates on-chip peripherals (I²C. linker.

with a single microcontroller chip. Embedded systems control many devices in common use today. or the systems controlling nuclear power plants. to very high with multiple units. benefiting from economies of scale. factory controllers. design engineers can optimize it to reduce the size and cost of the product and increase the reliability and performance. a general-purpose computer. is designed to be flexible and to meet a wide range of end-user needs. It was built from transistor logic and had a hard disk for main memory. peripherals and networks mounted inside a large chassis or enclosure . Physically. such as a personal computer (PC). to large stationary installations like traffic lights. Embedded systems contain processing cores that are being dedicated to handle a particular task. Since the embedded system is dedicated to specific tasks. embedded systems range from portable devices such as digital watches and MP3 players. Complexity varies from low. Some embedded systems are mass-produced.CHAPTER-6 INTRODUCTION TO EMBEDDED SYSTEMS An Embedded System is a computer system designed to do one or a few dedicated and/or specific functions often with real-time computing constraints. It is embedded as part of a complete device often including hardware and mechanical parts. By contrast.

 Respond to external events .  Embedded system allowing the system hardware to reduce costs.  Performs a specific task.  Program is stored in non-volatile memory and it can be executed on power.Embedded systems are not always standalone devices.  High performance  Reliability  Low power consumption .  Processing power and memory Limitations.The characteristics of embedded system are:  In-build intelligence  Immediate control of hardware.

. Assembler & Cross Assembler.  They may even be battery operated.CLASSIFICATION OF EMBEDDED SYSTEM SMALL SCALE EMBEDDED SYSTEM  Single 8-bit or 16-bit micro controller. MEDIUM SCALE EMBEDDED SYSTEM  Both hardware and software complexity.  The need to limit power dissipation when system is running continuously.  Programming tools.  Little hardware and software complexity.  Editor.  Usually “C” is used for developing these system.

I²C.g RS-232.g.) or network (e. etc. Ethernet) connection. Source code Engineering Tool and Integrated Development Environment (IDE). USB.  Some systems provide user interface remotely with the help of a serial (e. Single or few 16 or 32 bit micro controllers or digital signal processors (DSP) risk reduced instruction set computers (RISC). SOPHISTICATED EMBEDDED SYSTEM  Enormous hardware and software complexity  Which may need scalable processor or configurable processor and programming logic arrays?  Constrained by the processing speed available in their hardware units. Programming tools: RTOS. .

media player. navigation equipment’s and medical instruments. A compiler or retarget able compiler might have to be developed for this. machine control. Programming tools  For these systems may not be readily available at reasonable cost or may not be available at all. networking equipment. set-top boxes and other consumer electronics devices. These languages are used in mobile phones. POWER SUPPLY UNIT A power supply unit (PSU) converts mains AC to low-voltage regulated DC power for the internal components of a computer. . industrial automation. Modern personal computers universally use a switched-mode power supply. personal digital assistants. Some power supplies have a manual selector for input voltage. while others automatically adapt to the supply voltage.

Several direct-current voltages are required. While an ATX power supply is connected to the mains supply. it always provides a 5 V standby (5VSB) voltage so that the standby functions on the computer and certain peripherals are powered. which includes form factor and voltage tolerances. They also provide a signal to the motherboard to indicate when the DC voltages are in spec. A power supply rail or voltage rail refers to a single voltage provided by a power supply unit (PSU). encounter it in the context of personal computer power supplies.Most modern desktop personal computer power supplies conform to the ATX specification. especially computer enthusiasts. many people. so that the computer is able to safely power up and boot. The desktop computer power supply changes alternating current from a wall socket to low-voltage direct current to operate the processor and peripheral devices. . ATX power supplies are turned on and off by a signal from the motherboard. and they must be regulated with some accuracy to provide stable operation of the computer. Although the term is generally used in electronic engineering.

The switched-mode supply is much lighter and less costly. up to 99%. than an equivalent linear power supply. Active PFC is more complex and can achieve higher PF. undervoltage protection. When the computer is powered down but the power supply is still on. overcurrent protection. . overpower (overload) protection. Recent power supplies have a standby voltage available.First-generation microcomputer and home computer power supply units used a heavy step-down transformer and a linear power supply. Computer power supplies may have short circuit protection. Modern computers use switched-mode power supplies (SMPS) with a ferrite-cored high frequency transformer. Power supplies may have passive or active power factor correction (PFC). overvoltage protection. and is more efficient. to allow most of the computer system to be powered off. Passive PFC is a simple way of increasing the power factor by putting a coil in series with the primary filter capacitors. and over temperature protection. it can be started remotely via Wake-on-LAN and Wakeon-ring or locally via Keyboard Power ON (KBPO) if the motherboard supports it.

laser printers. They are limited to text only. etc. Ground 2. with 8 customizable characters. and 20x4 among others. portable television. industrial test equipment. Contrast adjustment 4. These screens come in common configurations of 8x1 characters. Backlights can be LED. 16x2. These screens are often found in copiers. The largest such configuration is 40x4 characters. but these are rare and are actually two separate 20x4 screens seamlessly joined together. fluorescent. VCC (+5V) 3. it will have 16 pins. networking equipment such as routers and storage devices. fax machines. Character LCDs can come with or without backlights. or electroluminescent. The pinouts are as follows: 1. These are not the kind of screens one would find in a cell phone. Character LCDs use a standard 14-pin interface. etc. If the screen has a backlight. Register Select (R/S) .MODULE 2: LCD LCD LCD Introduction An HD44780 Character LCD is an industry standard liquid crystal display (LCD) display device designed for interfacing with embedded electronics.

Bit 3 11.Bit 4 12. In 4 bit mode. Clock (Enable) 7. whereas LCDs supporting more than 80 characters make use of 2 HD44780 controllers. pins 7 through 10 are unused and the entire byte is sent to the screen using pins 11 through 14 by sending a nybble at a time. Apart from displaying some simple static characters you can create animated text scripts and a lot more! .Bit 6 14. Bit 1 9.5. 2 Line or 4 Line LCDs which have only one controller and support at most 80 characters.Bit 5 13.Bit 7 Character LCDs can operate in 4-bit or 8-bit mode. Bit 0 8. Bit 2 10. Read/Write (R/W) 6. The most commonly used LCDs found in the market today are 1 Line.

refer to the datasheet for exact details). (We may also have 16 pins in 2 controllers. but you will have to wait a little as these things mentioned below will help you to create your own magical codes… Most LCDs with 1 controller has 14 Pins and 16 Pins (two extra pins are for backlight LED connections).Let’s start playing with them. Pin description is shown in the table below. .

(Only one command that is “Get LCD status” is read commands all others are write command) It is a control line. Read/Write (RW): 1. 2. We will discuss here 8 bit mode first (that is data transfer through all the 8 data pins). the information on the data bus is being written to the LCD. When RW is high (1).This may not match with the exact pin configuration for your LCD. 4 bit mode will be discussed later on. the information is being written on LCD. the program is effectively querying (or . When RW is low (0). for reading from LCD. check application circuit in datasheet for exact configuration.) RW=1.) RW= 0.

{For LCDs like 1x16. A high to low pulse (of minimum length 450ns) before sending any command/data to LCD. so whatever you write after 16 chars is written in DDRAM but is not visible to the user. allows the user to send command such as clear display. 1. the data register. Enable (En) pin: is used to tell the LCD that we are sending it data. cursor at home. only 16 characters are visible. Only one instruction ("Get LCD status") is a read command. 2.} . The Instruction command code register. allow user to send data to be displayed at LCD. All others are write commands--so RW will be low for majority of the time.reading from) the LCD. The area in display data RAM (DDRAM) that is not used for display can be used as general data RAM. etc.) RS= 0. Its extended capacity is 80 X 8 bits. The RS pin is used for their selection. So whatever you send on the DDRAM is actually displayed on the LCD.) RS=1. or 80 characters. Registers: There are two very important registers in the LCD. How many characters can we send to LCD? Display data RAM (DDRAM) stores display data represented in 8-bit character codes.

This may not be very appropriate as the delay is not very accurate. character generator ROM. (You can also add your own characters in the list!!) How much time should there be in two consecutive Commands/Instructions?  The first method is to create a delay between two consecutive commands or instructions. This flag is internally set by LCD & can be monitored by µC for exact amount of delay. is used to convert ASCII values send by µC into 5 x 8 dot or 5 x 10 dot character patterns from 8-bit character. .  BUSY FLAG (BF): The MSB of the LCD data bus (D7) act as busy flag. (Check the datasheet for exact time of execution of an instruction).(DDRAM address for 2 line LCD) How does the ASCII value change to characters? The answer is CGROM i. When BF = 1 means LCD is busy and will not accept next command or data and BF = 0 means LCD is ready for the next command or data to process.e.

typically 220V rms. 2) Select the command or instruction register. This resulting dc voltage usually has some ripple or ac voltage variation. POWER SUPPLY Block Diagram The ac voltage. STEPS TO PROGRAM: 1) Initialize the LCD. . 3) Set RW low (to write). A diode rectifier then provides a full-wave rectified voltage that is initially filtered by a simple capacitor filter to produce a dc voltage. 5) Check if the LCD is busy. 6) Move to instruction or command function. is connected to a transformer. the conditions RS = 0 and R/W = 1 must be met. 7) Repeat steps 4-7.To read Busy Flag. 4) Send a high to low pulse on Enable pin. which steps that ac voltage down to the level of the desired dc output.

A regulator circuit removes the ripples and also remains the same dc value even if the input dc voltage varies. TRANSFORMER RECTIFIER FILTER IC REGULATOR Fig 5. This voltage regulation is usually obtained using one of the popular voltage regulator IC units. or the load connected to the output dc voltage changes.3 Block Diagram of Power supply CHAPTER-7 WORKING PRINCIPLE Transformer LOAD .

The potential transformer will step down the power supply voltage (0-230V) to (06V) level. Then the secondary of the potential transformer will be connected to the precision rectifier. Waveforms (1) and (2) can be observed across D1 and D3. and back to point A. through the secondary of the transformer back to point B. and the output is taken from the remaining two corners. up through RL. Bridge rectifier When four diodes are connected as shown in figure. The advantages of using precision rectifier are it will give peak voltage output as DC. D4 and D2 are reverse biased and will block current flow. Let us assume that the transformer is working properly and there is a positive potential. up through RL. At this time D3 and D1 are forward biased and will allow current flow to pass through them. The path for current flow is from point B through D1. through D3. which is constructed with the help of op–amp. The input to the circuit is applied to the diagonally opposite corners of the network. Waveforms (3) and (4) can be observed across D2 and D4. through D2. The negative potential at point B will forward bias D1 and reverse D2. Current flow will now be from point A through D4. forward biasing D2 and D4 and reverse biasing D1 and D3. at point A and a negative potential at point B. the positive potential at point A will forward bias D3 and reverse bias D4. the circuit is called as bridge rectifier. One-half cycle later the polarity across the secondary of the transformer reverse. through the secondary of T1. The current flow through RL is . This path is indicated by the broken arrows. this path is indicated by the solid arrows. rest of the circuits will give only RMS output.

control device. the peak voltage from the center tap to either X or Y is 500 volts. Since current flows through the load (RL) during both half cycles of the applied voltage. With both circuits using the same transformer. In flowing through RL this current develops a voltage corresponding to that shown waveform (5). the bridge rectifier circuit produces a higher output voltage than the conventional full-wave rectifier circuit. or an adjustably set voltage. the peak output voltage across the load resistor is nearly 1000 volts. Therefore. The peak voltage developed between points X and y is 1000 volts in both circuits. In the conventional full-wave circuit shown—in view A. IC units provide regulation of either a fixed positive voltage. which is 1000 volts. One advantage of a bridge rectifier over a conventional full-wave rectifier is that with a given transformer the bridge rectifier produces a voltage output that is nearly twice that of the conventional full-wave circuit. assume that the same transformer is used in both circuits. comparator amplifier. a fixed negative voltage. and overload protection all in a single IC. as result of the small voltage drop across the diode. This may be shown by assigning values to some of the components shown in views A and B. the maximum voltage that can be rectified at any instant is 500 volts. the maximum voltage that can be rectified is the full secondary voltage. IC voltage regulators Voltage regulators comprise a class of widely used ICs.always in the same direction. Since only one diode can conduct at any instant. The regulators can be selected for operation with load currents from hundreds of milli amperes to tens of amperes. . this bridge rectifier is a fullwave rectifier. Regulator IC units contain the circuitry for reference source. The maximum voltage that appears across the load resistor is nearly-but never exceeds-500 v0lts. corresponding to power ratings from milli watts to tens of watts. In the bridge rectifier shown in view B.

Vo. The series 78 regulators provide fixed positive regulated voltages from 5 to 24 volts. op-amp. LCD --------. relay circuits ---------.Fig 2. Vi.  For ICs.12 volts . a regulated dc output voltage.6 Circuit Diagram Of Power Supply A fixed three-terminal voltage regulator has an unregulated dc input voltage. with the third terminal connected to ground. the series 79 regulators provide fixed negative regulated voltages from 5 to 24 volts. applied to one input terminal. Similarly. microcontroller. from a second terminal.5 volts  For alarm circuit.

sonar. fullness of a tank. This technology can be used for measuring: wind speed and direction (anemometer).Module 2: Ultrasonic Sensor: Ultrasonic sensor: Ultrasonic sensors (also known as tranceivers when they both send and receive) work on a principle similar to radar or sonar which evaluate attributes of a target by interpreting the echoes from radio or sound waves respectively. For measuring speed or direction a device uses multiple detectors and calculates the speed from the relative distances to particulates in the air or water. burglar alarms. Ultrasonic sensors generate high frequency sound waves and evaluate the echo which is received back by the sensor. and non-destructive testing. Sensors calculate the time interval between sending the signal and receiving the echo to determine the distance to an object. the sensor measures the distance to the surface of the fluid. . medical ultrasonography. and speed through air or water. Further applications include: humidifiers. To measure the amount of liquid in a tank.

While technically a dog whistle is an ultrasonic transducer that converts mechanical energy in the form of air pressure into ultrasonic sound waves. or sound waves above the normal range of human hearing. Transducers Sound field of a non focusing 4MHz ultrasonic transducer with a near field length of N=67mm in water. the ultrasound frequency and the sound . can be determined by the active transducer area and shape.Systems typically use a transducer which generates sound waves in the ultrasonic range. The plot shows the sound pressure at a logarithmic db-scale. The location at which a transducer focuses the sound. by turning electrical energy into sound. Piezoelectric crystals have the property of changing size when a voltage is applied. then upon receiving the echo turn the sound waves into electrical energy which can be measured and displayed. For example foam on the surface of a fluid in a tank could distort a reading. Sound pressure field of the same ultrasonic transducer (4MHz.000 hertz. N=67mm) with the transducer surface having a spherical curvature with the curvature radius R=30mm An ultrasonic transducer is a device that converts energy into ultrasound. above 20. the term is more apt to be used to refer to piezoelectric transducers that convert electrical energy into sound. The technology is limited by the shapes of surfaces and the density or consistency of the material. thus applying an alternating current (AC) across them causes them to oscillate at very high frequencies. thus producing very high frequency sound waves.

Sensors with an on or off digital output are available for detecting the presence of objects.velocity of the propagation medium. Detectors Since piezoelectric crystal generate a voltage when force is applied to them. Clinicians who perform ultrasound-guided procedures often use a probe positioning system to hold the ultrasonic transducer. Some systems use separate transmitter and receiver components while others combine both in a single piezoelectric transceiver.The example shows the sound fields of an unfocused and a focusing ultrasonic transducer in water. The transducer may be passed over the surface of the body or inserted into an body opening such as the rectum or vagina. the same crystal can be used as an ultrasonic detector. Use in industry Ultrasonic sensors are used to detect the presence of targets and to measure the distance to targets in many automated factories and process plants. Alternative methods for creating and detecting ultrasound include magnetostriction and capacitive actuation. An ultrasonic transducer is affixed to a stainless steel pan which . and sensors with an analog output which varies proportionally to the sensor to target separation distance are commercially available. Use in medicine Medical ultrasonic transducers (probes) come in a variety of different shapes and sizes for use in making pictures of different parts of the body. Other types of transducers are used in commercially available ultrasonic cleaning devices.

Time for recording is 8-20 seconds .is filled with a solvent (frequently water or isopropanol) and a square wave is applied to it. data retention up to 100 years and typical 100. imparting vibrational energy on the liquid. providing zero-power message storage.000 erase/record cycles can be reached. With the embedded Flash memory employed. Recordings are stored into on-chip non-volatile memory. ISD1820 voice recording and playback module 1. Introduction This module board is based on ISD18B20. which is a single-chip single-message record/playback device.

this board can drive 8 Ohm 0. this board can drive 8 Ohm 0. which is a single-chip single-message record/playback device.5V 2. Time for recording is 8-20 seconds Features: 1.000 erase/record cycles can be reached. All the pins of ISD1820 are extended out with an connector. which can powered and controlled by microprocessor directly ISD1820 voice recording and playback module This module board is based on ISD18B20. With the embedded Flash memory employed. data retention up to 100 years and typical 100.5V 2.providing zero-power message storage. Power input: DC 2.4-5.5W speaker directly. Board dimension: 54mm x 38mm 5. Microphone is on board 4. Recordings are stored into on-chip non-volatile memory.Features: 1. With internal audio amplifier.5W speaker directly. Power input: DC 2. With internal audio amplifier.4-5. 3. .

Each driver converts TLL/CMOS input levels into EIA-232 levels. MAX 232: Max 232: The MAX232 is a dual driver/receiver that includes a capacitive voltage generator to supply RS 232 voltage levels from a single 5v supply. The R2OUT pin is connected to . which can powered and controlled by microprocessor directly. In this circuit the microcontroller transmitter pin is connected in the MAX232 T2IN pin which converts input 5v TTL/CMOS level to RS232 level.3. Board dimension: 54mm x 38mm 5. Microphone is on board 4. All the pins of ISD1820 are extended out with an connector. The P3_0 (RX) and P3_1 (TX) pin of controller is connected to the max 232 driver and the TX and RX pin of max 232 is connected to the GSM modem or PC. In PC the transmitting data is given to R2IN of MAX232 through transmitting pin of 9 pin D type connector which converts the RS232 level to 5v TTL/CMOS level. Each receiver converts RS-232 to 5v TTL/CMOS levels. Then T2OUT pin is connected to reviver pin of 9 pin D type serial connector which is directly connected to PC.

receiver pin of the microcontroller. CIRCUIT: . Likewise the data is transmitted and received between the microcontroller and PC or other device vice versa.

The collector-current rating of a single Darlington pair is 500mA. FEATURES: * 500mA rated collector current (Single output) * High-voltage outputs: 50V * Inputs compatible with various types of logic.7kW series base resistor for each Darlington pair for operation directly with TTL or 5V CMOS devices.Module 8: Motor Driver: DRIVER CIRCUIT: The ULN2003 is a monolithic high voltage and high current Darlington transistor arrays. lamp drivers. Applications include relay drivers. and logic buffers. The darlington pairs may be paralleled for higher current capability. hammer drivers. The ULN2003 has a 2. line drivers. display drivers (LED gas discharge). It consists of seven NPN darlington pairs that features high-voltage outputs with common-cathode clamp diode for switching inductive loads. * Relay driver application .

All devices are pinned with outputs opposite inputs to facilitate ease of circuit board layout. Prefix ‘ULN’ devices are rated for operation over the temperature range of -20C to +85C. prefix ‘ULQ’ devices are rated for operation to -40 ºC. These Darlington arrays are furnished in 18-pin dual in-line plastic packages (suffix ‘A’) or 18lead small-outline plastic packages (suffix ‘LW’). Embedded C BASICS .The ULN2003 series input resistors selected for operation directly with 5 V TTL or CMOS. The outputs are capable of sinking 500mA and will withstand at least 50 V in the OFF state. The ULx2823A/LW and ULx2824A/LW will withstand 95 V in the OFF state. The ULN 2003 is the standard Darlington arrays. The ULN2003 have series input resistors for operation directly from 6 V to 15 VCMOS or PMOS logic outputs. Outputs may be paralleled for higher load current capability. These devices will handle numerous interface needs particularly those beyond the capabilities of standard logic buffers.

This C course is based on many years experience of teaching C. We focus on the needs of day-to-day users of the language with the emphasis being on practical use and delivery of reliable software. PDAs and similar applications. Those wanting in-depth training specifically on RTLinux or Linux kernel internals should contact us to discuss their requirements. The modules include an introduction to the development of Linux device drivers. mobile device.This Embedded C is extensive and contains many advanced concepts. extensive industrial programming experience and also participation in the ANSI X3J11 and BSI standards bodies that produced the standard for C. this set of modules is geared more towards providing the groundwork for approaching those domains rather than as in-depth training on a specific approach. The Embedded C basics contains essential information for anyone developing embedded systems such as microcontrollers. For teams without experience of C and high-end real time operating sytems it would typically require eight to ten days of intensive training to give full coverage to the topics included here. The course covers all of the important features of the C language as well as a good grounding in the principles and practices of real-time systems development including the POSIX threads (pthreads) specification. The design of the modules is intended to provide an excellent working knowledge of the C language and its application to serious real time or embedded systems. real-time and embedded systems concepts through to the design and implementation of real time embedded or standalone systems based on real-time operating systems and their device drivers. Predominantly intended to be taught to development teams at customer sites it is not expected that any one course would cover the full range of modules in a typical five day period. MATLAB CODING: . Real time Linux (RTLinux) is used as an example of such a system. real-time control systems. The range of modules covers a full introduction to C.

'BaudRate'. imtool close all.j)>70 && ir(i. 'rgb') vid.j)>50 && gray(i.:. start(vid) s = serial('COM1'). gray=rgb2gray(imge). set(vid. [r c d]=size(imge). set(s. clear. % Close all figure windows except those created by imtool. 'YUY2_640x480'). set(vid.j)<180 && ig(i.9600). 'ReturnedColorspace'. for i=1:r for j=1:c if gray(i. while(vid. ir=imge(:.clc.1). 1.j)>20 . close all.FramesAcquired<=50) imge = getsnapshot(vid).1). delete(s). ig=imge(:. % Delete all variables. end fclose(s). 'FramesPerTrigger'. clear s. fopen(s).:.2). if red==1 fprintf(s. vid = videoinput('winvideo'.FrameGrabInterval =5. % Clear command window.j)<100 && ir(i. Inf).

static bit m2 @ ((unsigned) & PORTC*8+1). . clear all. else temp(i. PIC CODING: #include<pic.h> #include"lcd. static bit m4 @ ((unsigned) & PORTC*8+3). sbit trig=P3^5.1. static bit m3 @ ((unsigned) & PORTC*8+2)._nop_()._nop_(). flushdata(vid). _nop_().h" unsigned char temp. end end end subplot(1._nop_().j)=0.1).temp(i. imshow(temp). void send_pulse(void) //to generate 10 microseconds delay { TH0=0x00.h" #include "uart._nop_().TL0=0x00. trig=1. title('') end stop(vid). sfr16 DPTR =0x82.j)=255. static bit m1 @ ((unsigned) & PORTC*8+0).

PORTB=0x00. SPBRG=25. } unsigned int get_range(void) { unsigned int range._nop_(). TRISD=0x00. PORTD=0x00. RCIE=1. if(DPTR<35000)//actually you need to use 38000 but the sensor may not work at higher levels range=DPTR/59._nop_(). . RCSTA=0X90.// seconds DPH=TH0. __CONFIG(HS & WDTDIS & BOREN & UNPROTECT & LVPDIS). TRISC=0X80._nop_(). else range=0. while(!INT0). send_pulse(). TH0=0xFF. // indicates that there is no obstacle in front of the sensor return range. SPEN=1.TL0=0xFF._nop_().// in sake of these lines you can generate a delay of 40 Milli seconds=40000 micro while (INT0). TRISB=0x00. TXEN=1. void main(){ TXSTA=0X20.DPL=TL0. BRGH=1._nop_(). trig=0.

16).16). LCD_command(0x01). LCD_dis(" MOVING FORWARD ". LCD_command(0x06). m1=0. m3=0. m2=0. while(1){ while(RCIF==0). m1=1. }else if(temp == 'B'){ . m2=0. }else if(temp == 'R'){ LCD_command(0xC0). if(temp == 'F'){ LCD_command(0xC0). m4=0. LCD_dis(" MOVING LEFT ". m4=1. LCD_dis(" MOVING RIGHT ".16). m3=1.16). }else if(temp == 'L'){ LCD_command(0xC0). m1=1. m4=0. LCD_command(0x0c).LCD_command(0x38). temp=RCREG. m3=1. LCD_command(0x80). m2=1. LCD_dis(" FLUX ROBOT ".

m2=0.LCD_command(0xC0). }else if (temp == 'S'){ LCD_command(0xC0). LCD_dis(" ROBOT STOPPED ". m3=0. m3=0. Then easy understand and any obstacles find . m1=0. } } } CHAPTER-8 CONCLUTION: There are several ways to help blind people . m4=1.16).16). m2=1. LCD_dis(" MOVING REVERSE ". m4=0.by using this technology we will make them forgot their defect. m1=0.

in IEEE expert. 1994. REFEENCES: 1. Magnus Snorrason. Sensor detects that image identification it our recommended of process to be used the blind people. Mobile Robot Navigation: The CMU System. Monterey. Vision based obstacle detection and path planning for planetary rovers . A. Jeff Norris and Paul Backes. 44-54. Stenz and M Hebert. Our sensor detect that any information of particular period understand and that search location to transfer the information of blind people safely in our control. Y. Abstract | Full Text: PDF (5499KB) 3. Vol. 1987. pp. Winter. Goto and A. 2. A Complete Navigation System for Goal Acquisition in Unknown Environments.then clearly say to identify the particular path. It use of blind people to locate that place very kindly move that around the out of side ownly. Stenz. presented at ARPA image Understanding Workshop. CA.

Horn and A. O. pp. The 33rd Annual conference of the IEEE industrial Electronics society (IECON). Taipei. 20-8-2001 . 5-8-2007. Bourhis. G. Pruski An autonomous vehicle for people with Motor Disabilities.4. Taiman Development of Autonomous Robotic wheelchair controller using Embedded system. IEEE Robotics & automation magazine Vo1.8. 5. .