Вы находитесь на странице: 1из 71

CHAPTER-1 Company Profile

Advance Technology established in the year 1999, is an embedded design house. It provides outof-the-box solution from concept to reality. It is registered with Small Scale Industries with Chandigarh Administration. Arvind Dixit, the architect of the advance technology is a self made man and a man of vision. His foresight & 15 years of experience maintaining high quality standards, as a sure way of success and flourished rapidly. Advance Technology consists of a group of talented and experienced business professionals who are dedicated to maintaining a standard of excellence, while providing personalized services and the highest quality of products at the lowest price as possible as in the market place. The company is one of the innovations, dedication and diversification with 15 years of experience in the field of Embedded, VLSI, DSP and Wireless. The company has built a resource of base of high innovate professionals and state-of-art manufacturing in a very short time.

SOME EMBEDDED PRODUCTS OF COMPANY


Micro-controller Interfacing application Board

Features
Micro-controller Interfacing application Board C with ISP features89C51RD2 In- circuit Programming and serial communication through PC. 8-bit-8 channel ADC with I/Ps from multi-turns potentiometers. 8- bit single channel DAC EPROM with 12 C interface with capacity of 4K. RTC with battery back-up. Two 12V relays with isolated O/Ps. All interrupts available on header. 16X2 LCD display 8 I/Ps from DIPswitches. 8 O/Ps available on LED's Two multiplexed 7-segment displays

Windows based driver software for programming. ARM-7 Development Board

Features

ARM7TDMI-S Philips LPC22XX controller, 16 kB RAM / 256 kB Flash program memory. 128-bit wide interface/accelerator at 60 MHz operations. In-System/In-Application Programming (ISP/IAP) . Serial interfaces 2 serial ports, 8 channel 10-bit A/D converter . Two 32-bit timers/external event counters PWM unit (six outputs) and watchdog Low power RTC/ 32 kHz clock inout 60 Mhz maximum CPU clock, Port 2-channel AD sampling input through POT 2-channel PWM output, one is output to a buzzer 16 X 2 line LCD interface & 7 segment LED display interface 12C, CAN, SPI interface available on connector. Programmable project Board

Features

Programmable project Board The complete designer package must include hardware and software for Various projects experiments . On Board Bread Board :-01 no. 08 nos Digital inputs with SPDT toggle switch & LED indicator are provided on board 08 nos. digital outputs with LED indicator are provided on board. Function Generator. square, sine, triangular wave generator is provided on board . Seven segment Display :- 02 seven segment is provided On board power supply, with fully short circuit protected. Onboard 89C51 micro-controller with 4 ports open for interface along with pro adaptor. Facility for 20 pin ZIF Socket with Open I/Os On boards 16x2 Line LCD Display , on board Buzzer . On Board continuity tester with evaluation software of Digital & analog Simulatio (PCB Design , analog & digital simulations , Virtual Instruments, (digital multime generators ,oscilloscope ,probe , logic pulser etc) Libraries for semiconductor , digital &Liner ICs , Relays , Display devices, The trainer must be housed in attractive wooden box. With user manual etc. 4

And there are many products like : Universal Programmer Universal Embedded Development Package ARM9-based embedded Board NANO 51 Board Graphical LCD Display Interface Temperature Measurement board Traffic light study board Speed control using PWM For DC Motor Motion control of a CAR Model Fiber optic Transmitter Receiver Module Logic Controller Interface 96 I/O Line extender board Interface board NANO CPLD Trainer Kit Programmable Logic Control (PLC) Advance Digital Experimental System ADSP 2181 based DSP board

CHAPTER-2
5

Literature View 2.1 Definition of a Microcontroller


Microcontroller, as the name suggests, are small controllers. They are like single chip computers that are often embedded into other systems to function as processing/controlling unit. For example, the remote control you are using probably has microcontrollers inside that do decoding and other controlling functions. They are also used in automobiles, washing machines, microwave ovens, toys ... etc, where automation is needed. The key features of microcontrollers include: High Integration of Functionality Microcontrollers sometimes are called single-chip computers because they have on-chip memory and I/O circuitry and other circuitries that enable them to function as small standalone computers without other supporting circuitry. Field Programmability, Flexibility Microcontrollers often use EEPROM or EPROM as their storage device to allow field programmability so they are flexible to use. Once the program is tested to be correct then large quantities of microcontrollers can be programmed to be used in embedded systems. Easy to Use Assembly language is often used in microcontrollers and since they usually follow RISC architecture, the instruction set is small. The development package of microcontrollers often includes an assembler, a simulator, a programmer to "burn" the chip and a demonstration board. Some packages include a high level language compiler such as a C compiler and more sophisticated libraries. Most microcontrollers will also combine other devices such as:

A Timer module to allow the microcontroller to perform tasks for certain time periods.

A serial I/O port to allow data to flow between the microcontroller and other devices such as a PC or another microcontroller. An ADC to allow the microcontroller to accept analogue input data for processing.

Figure 2.1: Showing a typical microcontroller device and its different subunits

2.2 PIN CONFIGURATION

Vcc

P1 P0

R ESET R XD T XD IN T0 IN T1 T0 T1 RD WR X TA L 1 X TA L 2 GND P2 EA PSEN ALE

P3

figure 2.2 Pin configuration of Microcontroller We have 4 ports in 8051 micro controller. They are port0, port1, port2, port3 which can be accessed as i/o ports. The pins of the micro controller are explained below. Reset: It resets total 8051 micro controller.

RXD: TXD: INT0: INT1: T0: T1: RD: WR:

It receives data in serial communication. It transmits data in serial communication. External interrupt for timer 0. External interrupt for timer1 Timer0. Timer1. To read into external memory. To write into external memory.

XTAL1 & XTAL2: To connect the crystal oscillator. ALE: Address latch enable which is used to access the address locations from external memory. PSEN: Program store enable which is used for storing programming code into the external memory. EA: External Access: 64 KB of ROM is the limit for external memory.

Capacitor is storing charge permanently until we use it. Crystal Oscillator is used to generate a carrier signal with stable frequency. With the help of this oscillator we will deduce the execution speed in terms of bytes/ sec.It generates 12 clock pulses /machine cycle. Capacitors provide charge for crystal oscillator. If we are not connecting any external memory to micro controller, EA is connected to Vcc in case of 8051. 9

2.2.1 Interrupts An interrupt is a special feature which allows the 8051 to provide the illusion of "multitasking," although in reality the 8051 is only doing one thing at a time. . 2.2.2 Timers Timers are one of the categories of hardware time delays. Time delays are used to keep a system into halting System or sleepy mode. We have two timers-timer0, timer1.Hardware time delays are used to generate exact time delays.

2.3 Microcontrollers versus Microprocessors


Microcontroller differs from a microprocessor in many ways. First and the most important is its functionality. In order for a microprocessor to be used, other components such as memory, or components for receiving and sending data must be added to it. In short that means that microprocessor is the very heart of the computer. On the other hand, microcontroller is designed to be all of that in one. No other external components are needed for its application because all necessary peripherals are already built into it. Thus, we save the time and space needed to construct devices.

2.4 Central Processing Unit


Let add 3 more memory locations to a specific block that will have a built in capability to multiply, divide, subtract, and move its contents from one memory location onto another. The part we just added in is called "central processing unit" (CPU). Its memory locations are called registers.

10

Figure2.3: Simplified central processing unit with three registers Registers are therefore memory locations whose role is to help with performing various mathematical operations or any other operations with data wherever data can be found. Look at the current situation. We have two independent entities (memory and CPU) which are interconnected, and thus any exchange of data is hindered, as well as its functionality. If, for example, we wish to add the contents of two memory locations and return the result again back to memory, we would need a connection between memory and CPU. Simply stated, we must have some "way" through data goes from one block to another.

2.5 Bus
That "way" is called "bus". Physically, it represents a group of 8, 16, or more wires. There are two types of buses: address and data bus. The first one consists of as many lines as the amount of memory we wish to address and the other one is as wide as data, in our case 8 bits or the connection line. First one serves to transmit address from CPU memory, and the second to connect all blocks inside the microcontroller.

11

Figure2.4: Showing connection between memory and central unit using buses As far as functionality, the situation has improved, but a new problem has also appeared: we have a unit that's capable of working by itself, but which does not have any contact with the outside world, or with us! In order to remove this deficiency, let's add a block which contains several memory locations whose one end is connected to the data bus, and the other has connection with the output lines on the microcontroller which can be seen as pins on the electronic component.

2.6 Input-output unit


Those locations we've just added are called "ports". There are several types of ports: input, output or bidirectional ports. When working with ports, first of all it is necessary to choose which port we need to work with, and then to send data to, or take it from the port.

12

Figure2.5: Simplified input-output unit communicating with external world When working with it the port acts like a memory location. Something is simply being written into or read from it, and it could be noticed on the pins of the microcontroller. 2.7 INTERFACINGS WITH THE REAL WORLD DEVICES 2.7.1 INTERFACE (Computer Science) a program that controls a display for the user (usually on a computer monitor) and that allows the user to interact with the system part of a system exposed to a user. In general, the system can be any kind of system with which a user may interact at will, such as a mechanical system or a computer system. (Fluid, Electronic, Optic) One of the important issues in micro-fluidics is the interfacing of all the elements. How to align optical fibres? How to connect wires to the micro-device? How to introduce a sample into the fluid channel? These are some of the questions, which have to be solved. An interface is a set of commands or menus through which a user Communicates with a program. A command-driven interface is one in which you enter commands. A menudriven interface is one in which you select command choices from various menus displayed on the screen. Interfacing is a common term for a variety of materials used on the unseen or "wrong" side of fabrics in sewing. Interfacings can be used to stiffen or add body to fabric, such as the interfacing used in shirt collars; to strengthen a certain area of the fabric, for instance where

13

buttonholes will be sewn; or to keep fabrics, particularly knit fabrics, from stretching shape. Interfacings come in a variety of weights and stiffnesses to suit different purposes.

out of

2.7.2 USER INTERFACE The user interface is the aggregate of means by which people (the users) Interact with a particular machine, device, computer program or other complex tool (the system). The user interface provides means of: * Input, allowing the users to control the system* & Output, allowing the system to inform the users (also referred to as feedback). A good user interface makes it easy for users to do what they want to do. The junction between a user and a computer program. An interface is a set of commands or menus through which a user communicates with a program. A command-driven interface is one in which you enter commands. A menu-driven interface is one in which you select command choices from various menus displayed on the screen. The user interface is one of the most important parts of any program because it determines how easily you can make the program do what we want to. It is widely accepted that the user interface can make a critical difference in the perceived utility of a system regardless of the system's performance. In other words, the physical means of communication between a person and a software program or operating system. At its most basic, this is the exchange of communicates with the various database, system, and applications modules. 2.7.3 Efficiency of User Interface Design Many technological innovations rely upon User Interface Design to elevate their technical complexity to a usable product. Technology alone may not win user acceptance and subsequent marketability. The User Experience, or how the user experiences the end product, is the key to acceptance. And at is where User Interface Design enters the design the process. While product engineers focus on the technology, usability specialists focus on the user interface. For greatest efficiency and cost effectiveness, this working relationship should be maintained from the start of a project to its rollout. typed statements in English or a program-like set of commands. It is the method by which the human operator

14

When applied to computer software, User Interface Design is also known as HumanComputer Interaction or HCI. While people often think of Interface Design in terms of computers, it also refers to many products where the user interacts with controls or displays. Military aircraft, vehicles, airports, audio equipment, and computer peripherals, are a few products that extensively apply User Interface Design. Optimized User Interface Design requires a systematic approach to the design process. But, to ensure optimum performance, Usability testing is required. This empirical testing permits nave users to provide data about what does work as anticipated and what does not work. Only after the resulting repairs are made can a product be deemed to have a user optimized interface. The importance of good User Interface Design can be the difference between product acceptance and rejection in the marketplace. If end-users feel it is not easy to learn, not easy to use, or too cumbersome, an otherwise excellent product could fail. Good User Interface Design can make a product easy to understand and use, which results in greater user acceptance. 2.7.4 INTERFACING OF LCD WITH MICROCONTROLLER An intelligent LCD has two lines with 20 characters each line.The display contains two internal byte wide registers, one for commands and second for characters to be displayed. It also contains a user programmed RAM area that can be programmed to generate any desired character that can be formed using a dot matrix. To distinguish between these two data areas, the hex command byte 80 will be used to signify that the display RAM address 00h is chosen. From diagram Port 1 of microcontroller is used for 8 bit data display on the LCD. Data lines of the LCD Pin no.7 to pin no 14 are connected to the port 1 of the microcontroller. The control pin no.4 register select is connected to P3.5, pin no.5 of LCD for Read/write is connected to P3.6 and the enable pin (6) is connected to microcontroller

15

Fig. 2.6 LCD(LMB162A) interfaced with 8051 2.7.5 LCD pin description Pin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Symbol VSS VCC VEE RS R/W E PB0 PB1 DB2 DB3 DB4 DB5 DB6 DB7 I/O I I I/O I/O I/O I/O I/O I/O I/O I/O I/O Description Ground +5V power supply Power supply to control contrast RS=0 to select command register, RS=1 to select data register. R/W=0 for write, R/W=1 for read Enable The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus The 8 bit data bus Table 2.7.5 LCD pin description 16

Wap a progarm to use switch with LCD. #include<reg51.h> sbit rs=P2^0; sbit e=P2^1; sbit sw1=P1^0; sbit sw2=P1^1; sbit sw3=P1^2; sbit sw4=P1^3; void delay(); void cmd(); void dat(); unsigned char vik[]=" switch 1 is "; unsigned char jas[]=" switch 2 is "; unsigned char vik1[]=" switch 3 is "; unsigned char jas1[]=" switch 4 is "; unsigned char jass[]=" press switch "; unsigned char cmn[]=" pressed void main() { int i,j,k,l,m; P1=0x00; while(1) { P0=0x38; cmd(); delay(); P0=0x0e; cmd(); delay(); P0=0x06; cmd(); 17 ";

delay(); P0=0x01; cmd(); delay(); P0=0x80; cmd(); delay(); if(sw1==1) { for(i=0;i<=15;i++) { P0=vik[i]; dat(); delay(); } P0=0xc0; cmd(); delay(); for(j=0;j<=15;j++) { P0=cmn[j]; dat(); delay(); } } else if(sw2==1) { for(j=0;j<=15;j++) { P0=jas[j]; dat(); 18

delay(); } P0=0xc0; cmd(); delay(); for(j=0;j<=15;j++) { P0=cmn[j]; dat(); delay(); } } else if(sw3==1) { for(k=0;k<=15;k++) { P0=vik1[k]; dat(); delay(); } P0=0xc0; cmd(); delay(); for(j=0;j<=15;j++) { P0=cmn[j]; dat(); delay(); } } else if(sw4==1) 19

{ for(l=0;l<=15;l++) { P0=jas1[l]; dat(); delay(); } P0=0xc0; cmd(); delay(); for(j=0;j<=15;j++) { P0=cmn[j]; dat(); delay(); } } else { for(m=0;m<=15;m++) { P0=jass[m]; dat(); delay(); } } } } void cmd() { 20

rs=0; e=1; e=0; } void dat() { rs=1; e=1; e=0; } void delay() { int j; for(j=0;j<=30000;j++) { } } 2.8 STEPPER MOTOR A stepper motor is a widely used devicethat translates electrical pulses into mechanical movement. In applications such as disk drives, dot matrix printers, and robotics the stepper motor is used for positioning control. Every stepper motor has a permanent magnet rotor(also called the shaft) surrounded by a stator. The most common stepper motors have 4 stator windings that are paired with a centre-tapped common. This type of stepper motor is commonly referred to as four phased stepper motor. The centre tap allows a change of current directionin each of two coils when a winding is grounded, thereby resulting in a polarity changeof the stator. Notice that a conventional motor shaft runs freely, the stepper motor shaft moves in a fixed repeatable incrementwhich allows one to move it to a precise position. This repeatable fixed movement is possible as a result of basic magnetic theorywhere poles of the same polarity repel and opposite poles attract. The direction of rotation is directed by the stator poles. The stator poles are determined by the current sent through the wire coils. As the direction of the current is changed, the polarity is also changedcausing the

21

reverse motion of the rotor.The stepper motor discussed here has a total of 6 leads.As the sequense of power is applied to each stator winding the rotor will rotate.

Fig. 2.8 STEPPER MOTOR Wap a program to use switch with steeper motor and control its speed. #include<reg51.h> sbit sw1=P2^0; sbit sw2=P2^1; sbit sw3=P2^2; sbit sw4=P2^3; void delay(unsigned int x); void main() { while(1) { if(sw1==1) { P0=0x01; delay(30000); P0=0x02; delay(30000); P0=0x04; delay(30000); P0=0x08; delay(30000); 22

} else if(sw2==1) { P0=0x01; delay(10000); P0=0x02; delay(10000); P0=0x04; delay(10000); P0=0x08; delay(10000); } else if(sw3==1) { P0=0x01; delay(3000); P0=0x02; delay(3000); P0=0x04; delay(3000); P0=0x08; delay(3000); } else if(sw4==1) { P0=0x08; delay(30000); P0=0x04; delay(30000); P0=0x02; delay(30000); 23

P0=0x01; delay(30000); } else { P0=0x00; } } } void delay(unsigned int x) { int i; for(i=0;i<=x;i++) { } } 2.9 ISOLATOR CARD Whenever there is a need of connecting some high load device(i.e. working on high values of voltages and current, like D.C motor) with the microcontroller, we cant connect it directly, because it may the harm the sensitive controller through back currents. So, for those applications, we need to form some kind of isolation between the two devices and for that purpose we have an isolator card. An isolator card consists of an Optocoupler, shown below. 2.10 OPTOCOUPLER It consists of a IR led and a photo transistor as shown. The I.R Led would emit infra red light whenever it is forward biased. The photo transistor is a a npn type and it works only whe a light of certain frequency falls on it. The property that, an IR Led can make a photo transistor work but a photo transistor cant make an IR Led work, is used to form isolation

24

Fig. 2.9 Optocoupler 2.10.1 DESCRIPTION The general purpose optocouplers consist of a gallium arsenide infrared emitting diode driving a silicon phototransistor in a 6-pin dual in-line package. 2.10.2 FEATURES Also available in white package by specifying -M suffix, eg. 4N25-M UL recognized (File # E90700) VDE recognized (File # 94766) - Add option V for white package (e.g., 4N25V-M) - Add option 300 for black package (e.g., 4N25.300) 2.10.3 APPLICATIONS Power supply regulators Digital logic inputs Microprocessor inputs 2.11 RELAY (Electrical Switch) A relay is an electrically operated switch. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so relays have two switch positions and they are double throw (changeover) switches.

25

Relays allow one circuit to switch a second circuit which can be completely separate from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. There is no electrical connection inside the relay between the two circuits, the link is magnetic and mechanical. The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can be as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips) cannot provide this current and a transistor is usually used to amplify the small IC current to the larger value required for the relay coil. The maximum output current for the popular 555 timer IC is 200mA so these devices can supply relay coils directly without amplification.

Fig. 2.10 Relay 2.11.1 Internal Structure of a RELAY

Fig2.11.1 The relay's switch connections are usually labelled COM, NC and NO: COM = Common, always connect to this, it is the moving part of the switch. NC = Normally Closed, COM is connected to this when the relay coil is off. NO = Normally Open, COM is connected to this when the relay coil is on. Relays can switch AC and DC, transistors can only switch DC. 26

Advantages of relays:

Relays can switch high voltages, transistors cannot. Relays are a better choice for switching large currents (> 5A). Relays can switch many contacts at once. Relays are bulkier than transistors for switching small currents. Relays cannot switch rapidly (except reed relays), transistors can switch many times per second. Relays use more power due to the current flowing through their coil. Relays require more current than many ICs can provide, so a low power transistor may be needed to switch the current for the relay's coil. Wap a program to use relay and buzzer in a serial manner #include<reg51.h> sbit bzr=P0^4; sbit rly1=P0^5; sbit rly2=P0^6; sbit sw1=P1^0; void delay(); void main() { int i; P0=0x00; P1=0x00; while(1) { if(sw1==1) { P2=0x01; delay(); { rly1=1; delay(); 27

Disadvantages of relays:

rly2=1; delay(); bzr=1; delay(); bzr=0; } for(i=0;i<=6;i++) { P2=P2<<1; delay(); } } else { bzr=0; rly1=0; rly2=0; } } } void delay() { int j; for(j=0;j<=30000;j++) { } }

28

2.12 KEIL SOFTWARE 2.12.1 Introduction Keil Software to provide you with software development tools for 8051 based microcontrollers. With the Keil tools, you can generate embedded applications for virtually every 8051 derivative. The supported microcontrollers are listed in the Vision Device Database. The Keil Software 8051 development tools are designed for the professional software developer, but any level of programmer can use them to get the most out of the 8051 microcontroller architecture. 2.12.2 Software development cycle When you use the Keil Vision, the project development cycle is roughly the same as it is for any other software development project. 1. Create a project, select the target chip from the device database, and configure the tool settings. 2. Create source files in C or assembly. 3. Build your application with the project manager. 4. Correct errors in source files. 5. Test the linked application. 2.12.3 Keil Components The Keil Software 8051 development tools listed below are programs you use to compile your C code, assemble your assembly source files, link and locate object modules and libraries, create HEX files, and debug your target program. 2.12.4 How to use KEIL 1. Open the KEIL. The following window will pop up.

29

1. Go to the project & click on new project

2. Save the project by giving it a name.

30

3. When you click on the save button, following window opens.

4. Select I.C.

31

5. Now open a new file and save it as shown below:

32

6. Write your program code and again save it.

7. Right click on source group and then click on add files to group source group 1 33

8. Add the source file

9. Go to target 1 and click on options for target 1

34

10. Set crystal frequency and check create hex file.

35

11. Now debug (Click on the pointed option).

12. Now build target 36

(Click on the pointed option).

12. Now debug (Click on the pointed option).

14. Finally burn the program in the microcontroller. 2.13 Elements of C Language The Structure of a program 37

Keywords Operators Data Types and Type Casting Functions Declaring a function Calling a function String handling in C Conditional expressions Flow control statements 1 The structure of a program All C programs consists of at least -A main module (a source file) -The main function The compiler automatically adds startup code to initialize the underlying processor. The linker adds library code as used within the source code as needed.

2 Keywords The following keywords are reserved and may not be used otherwise. 2 char double enum float int long short signed struct union unsigned void typedef variable type declarations. const auto extern register static volatile variable type modifiers. for do while continue break loops. if else switch case default break conditional execution. goto return program flow control. sizeof type information. Operators C defines a lot of operators. Relational operators Arithmetic operators Boolean operators Pointer operators 38

Assignment Operators 4 Constants Decimal, octal, hexadecimal character and string constants are supported. 16 decimal integer (starts with non-zero digit). 075 octal integer (starts with zero digit). 0xFABB hexadecimal values (starts with 0x). 61.0 floating point number (decimal point). 61e1 floating point number (exponential part). 'a' the character a. '\r' the control character carriage return. '\n' the control character line feed. "abc" a string of characters the string is stored as an array of characters a NULL character is added automatically so the string occupies four bytes in memory. 5 Data Types The following basic data types are defined to be used for program variables and function arguments. Data Type Size Range of values. signed char 1 Byte -128 to +127 unsigned char 1 Byte 0 to 255 (i.e. a BYTE) signed int 2 Byte -32768 to +32767 unsigned int 2 Byte 0 to 65535 (i.e. a WORD) signed long 4 Byte -2147483648 to +2147483647 unsigned long 4 Byte 0 to 4294967295 (i.e. DWORD) float 4 Byte 1,176E-38 to 3,40E+38 double 8 Byte 1,7E-308 to 1,7E+308 pointer 1, 2 or 3 Bytes, as address of objects(depending of memory type

6 Functions Function declaration A function is declared by its type and name followed by an argument list enclosed in parentheses ( ). 39

The parentheses are mandatory even if the function has no arguments in this case the argument list is empty. The statements of the function are enclosed in braces { } following the declaration. The function uses the return keyword to return a result value to the caller.

Example of a function with no parameters returning an integer result. int FunctionName( ) { return 5; } 37 Calling a function A function is called by naming it, followed by a parenthesized list of arguments. A function may return a result value which can be assigned to other variables.

Examples FunctionName( ); Result = FunctionName( ); 38 The void Keyword The void keyword is used to explicitly state no value it is used in several declarations. Functions (parameters) int FunctionName(void) means that the function does not have any parameters. Functions (return value) void FunctionName(int Param) means that the function does not return a result. Pointers void* pNothing means that the pointer does not point to a specific data type or the data type is not known at this point. 7 Strings

40

C does not provide a fundamental string data type. Strings are represented as arrays of characters with a terminating zero character (also called ASCIIZ strings). To manipulate strings, the user has to use library functions. strlen returns the length of a string(the number of characters). strcpy copy one string into an other. strcat concatenate two strings strcmp compare two strings strchr

Attention ! There is no compiler or runtime check for enough space in a character array, string functions may accidentally overwrite the data following the array. Dont forget to count the tailing zero character. 8 Conditional Execution / Expressions The C language provides alternate ways to write conditional statements. Conditional execution using the if and else statements. Conditional expressions with the ternary operator ? : Conditional execution using switch and case. if (a > b) // checks the expression a > b else z = b; // statement executed if expression is false. 9 Conditional Expressions The conditional expression, written with the ternary operator ? :, provides an alternate way to write the following and similar constructions. (expression1) ? expression2 : expression3 First a condition expression1 is evaluated. Depending of the result one of two other expressions is evaluated and that is the value. If condition expression1 is true (non-zero) expression2 is evaluated and if condition expression1 is false (zero) expression3 is evaluated. z = (a > b) ? a : b; // z = max(a, b) 41

z = a; // statement executed if expression is true.

Using the switch, case and break statements, an expression can be be tested to match a number of constant integer values the default case catches all other values. switch(d) { case 1: printf("Mon"); // executed for d is one break; case 2: printf("Tue"); // executed for d is two break; default: // executed if d does not match // one of the case values printf("<invalid>"); } 10 Flow Control Statements Flow control statements are Loop statements for do while break continue goto return

Jump statements

11 The Compiler Preprocessor The compiler preprocesses the source code to provide some facilities this is conceptually a separate first step of compilation. #include is used to include the contents of another source file #include reg51.h; // include register definition header file at this place in 42

// the source code. #include <reg51.h>; // same, but look in include file directory instead of //current directory. #define replaces a token by an arbitrary sequence of characters (also called a macro).

2.14 THE COMPILE PROCESS


You type in your program as C source code, compile it (or try to run it from your programming IDE, which will typically compile and build automatically) to turn it into object code, and then build the program using a linker program to create an executable program that contains instructions written in machine code, which can be understood and run on the computer that you are working on. To compile a C program that you have typed in using C++ Builder, do one of the following:-

Fig. 2.14 The Compiler Process Click on the Project menu and choose the Compile menu item. Hold down the Ctrl key and press F9 (this actually Makes the program). button to Compile and run the currently selected program.

Click on the

43

CHAPTER 3

Introduction to PIC Microcontroller (PIC16F877A) 3.1 Introduction to PIC16F877A Microcontroller


Microcontroller PIC16F877A is one of the PIC Micro Family microcontroller which is popular at this moment, start from beginner until all professionals. Because very easy using PIC16F877A and use FLASH memory technology so that can be write-erase until thousand times. The superiority this Risc Microcontroller compared to with other microcontroller 8-bit especially at a speed of and his code compression. PIC16F877A have 40 pin by 33 path of I/O. PIC16F877A perfectly fits many uses, from automotive industries and controlling home appliances to industrial instruments, remote sensors, electrical door locks and safety devices. It is also ideal for smart cards as well as for battery supplied devices because of its low consumption. EEPROM memory makes it easier to apply microcontrollers to devices where permanent storage of various parameters is needed (codes for transmitters, motor speed, receiver frequencies, etc.). Low cost, low consumption, easy handling and flexibility make PIC16F877A applicable even in areas where microcontrollers had not previously been considered (example: timer functions, interface replacement in larger systems, coprocessor applications, etc.).In System Programmability of this chip (along with using only two pins in data transfer) makes possible the flexibility of a product, after assembling and testing have been completed. This capability can be used to create assemblyline production, to store calibration data available only after final testing, or it can be used to improve programs on finished products. High-Performance RISC CPU. Only 35 single-word instructions to learn All single-cycle instructions except for program branches, which are two-cycle Operating speed: DC 20 MHz clock input DC 200 ns instruction cycle Up to 8K x 14 words of Flash Program Memory, Up to 368 x 8 bytes of Data Memory (RAM), Up to 256 x 8 bytes of EEPROM Data Memory Pinout compatible to other 28-pin or 40/44-pin PIC16CXXX and PIC16FXXX microcontrollers

44

PIN Description of PIC16F877A

U2
13 14 2 3 4 5 6 7 8 9 10 1 OSC1/CLKIN OSC2/CLKOUT RB0/INT RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD 33 34 35 36 37 38 39 40 15 16 17 18 23 24 25 26 19 20 21 22 27 28 29 30

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 RD0/PSP0 RD1/PSP1 RD2/PSP2 RD3/PSP3 RD4/PSP4 RD5/PSP5 RD6/PSP6 RD7/PSP7 PIC16F877A

45

Pin Name OSC1/CLKI OSC1 CLKI

PDIP Pin# 13

I/O/P Type I I

Description Oscillator crystal or external clock input. Oscillator crystal input or external clock source input. ST buffer when configured in RC mode; otherwise CMOS. External clock source input. Always associated with pin function OSC1 (see OSC1/CLKI, OSC2/CLKO pins). Oscillator crystal or clock output. Oscillator crystal output. Connects to crystal or resonator in Crystal Oscillator mode. In RC mode, OSC2 pin outputs CLKO, which has 1/4 the frequency of OSC1 and denotes the instruction cycle rate Master Clear (input) or programming voltage (output). Master Clear (Reset) input. This pin is an active low Reset to the device. Programming voltage input. PORTA is a bidirectional I/O port. Digital I/O. Analog input 0. Digital I/O.

OSC2/CLKO OSC2 CLKO

14 O O

MCLR/VPP MCLR VPP RA0/AN0 RA0 AN0 RA1/AN1 RA1 AN1 RA2/AN2/VREF/CVREF RA2 AN2 VREFCVREF

1 I P 2 I/O I 3 I/O I

Analog input 1.

Digital I/O. 4 Analog input 2. I/O I O Digital I/O. 46 A/D reference voltage (Low) input. Comparator VREF output.

Analog input 3. 5 RA3/AN3/VREF+ I/O RA3 AN3 VREF+ 6 RA4/T0CKI/C1OUT I/O RA4 I T0CKI O C1OUT 7 RA5/AN4/SS/C2OUT I/O RA5 I AN4 I SS O C2OUT RB0/INT RB0 INT RB1 RB2 RB3/PGM RB3 34 35 36 I/O Low-voltage ICSP programming enable pin. 33 I/O I I/O Digital I/O. I/O Digital I/O. PORTB is a bidirectional I/O port. PORTB can be software programmed for internal weak pull-up on all Inputs Digital I/O. External interrupt Digital I/O. Analog input 4. SPI slave select input. Comparator 2 output. Digital I/O. Comparator 1 output. I O Timer0 external clock input. Digital I/O Open-drain when configured as output. A/D reference voltage (High) input.

47

PGM RB4 RB5 RB6/PGC RB6 PGC RB7/PGD RB7 PGD RC0/T1OSO/T1CKI RC0 T1OSO T1CKI RC1/T1OSI/CCP2 16 RC1 T1OSI CCP2 RC2/CCP1 RC2 CCP1 RC3/SCK/SCL RC3 18 17 15 40 37 38 39

I I/O I/O

Digital I/O. Digital I/O.

Digital I/O. In-circuit debugger and ICSP programming clock. I/O I Digital I/O. In-circuit debugger and ICSP programming data I/O I/O

I/O O I

Digital I/O. Timer1 oscillator output. Timer1 external clock input. Digital I/O.

I/O Timer1 oscillator input. I I/O Capture2 input, Compare2 output, PWM2 output.

I/O I/O

Digital I/O. Capture1 input, Compare1 output, PWM1 output. Digital I/O.

I/O

48

SCK SCL RC4/SDI/SDA RC4 SDI SDA RC5/SDO RC5 SDO RC6/TX/CK RC6 TX CK RC7/RX/DT RC7 RX DT 26 25 24 23

I/O I/O

Synchronous serial clock input/output for SPI mode. Synchronous serial clock input/output for I2C mode.

I/O I I/O Digital I/O. SPI data in. I2C data I/O. I/O O Digital I/O. SPI data out. I/O O I/O Digital I/O. USART asynchronous transmit. USART1 synchronous clock. I/O I I/O Digital I/O. USART asynchronous receive. USART synchronous data. PORTD is a bidirectional I/O port or Parallel Slave Port when interfacing to a microprocessor bus. I/O Digital I/O. I/O Parallel Slave Port data. 49

RD0/PSP0 RD0 PSP0

19

RD1/PSP1 RD1 PSP1 RD2/PSP2 RD2 PSP2 RD3/PSP3 RD3 PSP3 RD4/PSP4 RD4 PSP4 RD5/PSP5 RD5 PSP5 RD6/PSP6 RD6

20 I/O Digital I/O. I/O Parallel Slave Port data. 21 I/O Digital I/O. I/O Parallel Slave Port data. 22 I/O Digital I/O. I/O Parallel Slave Port data. 27 I/O Digital I/O. I/O Parallel Slave Port data. 28 I/O Digital I/O. I/O Parallel Slave Port data. 29 I/O Digital I/O. I/O Parallel Slave Port data. 30 I/O Digital I/O. I/O Parallel Slave Port data.

PSP6 RD7/PSP7 RD7 PSP7 Pin Name PDIP Pin#

I/O/P Type

Description

50

PORTE is a bidirectional I/O port. RE0/RD/AN5 RE0 RD AN5 RE1/WR/AN6 RE1 WR AN6 RE2/CS/AN7 RE2 CS AN7 10 I/O I I Digital I/O. Chip select control for Parallel Slave Port. Analog input 7. 9 I/O I I Digital I/O. Write control for Parallel Slave Port. Analog input 6. 8 I/O I I Digital I/O. Read control for Parallel Slave Port. Analog input 5.

VSS VDD NC

12,31 11,32 -

P P -

Ground reference for logic and I/O pins. Positive supply for logic and I/O pins. These pins are not internally connected. These pins should be left unconnected.

PORTA and Associated Register with it


PORTA is a 6-bit wide, bidirectional port. The corresponding data direction register is TRISA. Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input (i.e., put the corresponding output driver in a High- Impedance mode). Clearing a TRISA bit (= 0) will make the corresponding PORTA pin an output (i.e., put the contents of the output latch on the selected pin). Reading the PORTA register reads the status of the pins, whereas writing to it will write to the port latch. All write operations are read-modify-write operations. Therefore, a write to a port implies that the port pins are read, the value is modified and then written to the port data latch. Pin RA4 is multiplexed with the Timer0 module clock input to become the RA4/T0CKI pin. The RA4/T0CKI pin is a Schmitt Trigger input and an open-drain output. All other PORTA pins have 51

TTL input levels and full CMOS output drivers. Other PORTA pins are multiplexed with analog inputs and the analog VREF input for both the A/D converters and the comparators. The operation of each pin is selected by clearing/setting the appropriate control bits in the ADCON1 and/or CMCON registers.

Registers
Address 05h 85h Name Bit7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 RA0

PORTA TRISA

RA5 RA4 RA3 RA2 RA1 PORTA Data Direction Register

PORTB and the TRISB Register


PORTB is an 8-bit wide, bidirectional port. The corresponding data direction register is TRISB. Setting a TRISB bit (= 1) will make the corresponding PORTB pin an input (i.e., put the corresponding output driver in a High-Impedance mode). Clearing a TRISB bit (= 0) will make the corresponding PORTB pin an output (i.e., put the contents of the output latch on the selected pin). Three pins of PORTB are multiplexed with the In-Circuit ebugger and Low-Voltage Programming function: RB3/PGM, RB6/PGC and RB7/PGD. Each of the PORTB pins has a weak internal pullup. A single control bit can turn on all the pull-ups. This is performed by clearing bit RBPU OPTION_REG<7>). The weak pull-up is automatically turned off when the port pin is configured as an output. The pull-ups are disabled on a Power-on Reset. Address 06h, 106H 86h, 186H 81h, 181h Name PORTB TRISB OPTION_RE G Bit7 RB7 RBPU Bit 6 RB6 Bit 5 RB5 Bit 4 Bit 3 RB4 RB3 Bit 2 Bit 1 RB2 RB1 Bit 0 RB0

PORTA Data Direction Register T0SE PS0 PSA PS2

INTEDG T0CS PS1

OPTION_REG RBPU bit 7 bit 6 bit 5 bit 4 INTEDG T0CS T0SE PSA PS2 PS1 PS0

RBPU INTEDG T0CS: TMR0 Clock Source Select bit 1 = Transition on T0CKI pin 0 = Internal instruction cycle clock (CLKO) T0SE: TMR0 Source Edge Select bit 1 = Increment on high-to-low transition on T0CKI pin 52

0 = Increment on low-to-high transition on T0CKI pin bit 3 PSA: Prescaler Assignment bit 1 = Prescaler is assigned to the WDT 0 = Prescaler is assigned to the Timer0 module bit 2-0 PS2:PS0: Prescaler Rate Select bits Bit Value TMR0 Rate WDT Rate 000 001 010 011 1:16 100 101 110 111 1:2 1:4 1:8 1:8 1:32 1:64 1:128 1:256 1:16 1:32 1:64 1:128 1:1 1:2 1:4

PORTC and the TRISC Register


PORTC is an 8-bit wide, bidirectional port. The corresponding data direction register is TRISC. Setting a TRISC bit (= 1) will make the corresponding PORTC pin an input (i.e., put the corresponding output driver in a High-Impedance mode). Clearing a TRISC bit (= 0) will make the corresponding PORTC pin an output (i.e., put the contents of the output latch on the selected pin). PORTC is multiplexed with several peripheral functions (Table 4-5). PORTC pins have Schmitt Trigger input buffers. When the I2C module is enabled, the PORTC<4:3> pins can be configured with normal I2C levels, or with SM Bus levels, by using the CKE bit (SSPSTAT<6>). When enabling peripheral functions, care should be taken in defining TRIS bits for each PORTC pin. Some peripherals override the TRIS bit to make a pin an output, while other peripherals override the TRIS bit to make a pin an input. Since the TRIS bit override is in effect while the peripheral is enabled, read-modify write instructions (BSF, BCF, XORWF) with TRISC as the destination, should be avoided. The user should refer to the corresponding peripheral section for the correct TRIS bit settings. Address 07h 87H Name Bit7 Bit Bit 5 Bit Bit 3 Bit Bit 1 6 4 2 RC6 RC5 RC4 RC3 RC2 RC1 PORTA Data Direction Register Bit 0 RC0

PORTC RC7 TRISAC

PORTD and TRISD Registers


PORTD is an 8-bit port with Schmitt Trigger input buffers. Each pin is individually configurable as an input or output. PORTD can be configured as an 8-bit wide microprocessor port (Parallel Slave Port) by setting control bit, PSPMODE (TRISE<4>). In this mode, the input buffers are TTL. Address Name Bit7 Bit 6 Bit 5 53 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0

08h 88H 89h

PORTD RD7 TRISD TRISE IBF

RD6 RD5 RD4 RD3 RD2 RD1 RD0 PORTA Data Direction Register OBF IBOV PSPMODE PORTE Data Direction Bits

PORTE and TRISE Register


PORTE has three pins (RE0/RD/AN5, RE1/WR/AN6 and RE2/CS/AN7) which are individually configurable as inputs or outputs. These pins have Schmitt Trigger input buffers. The PORTE pins become the I/O control inputs for the microprocessor port when bit PSPMODE (TRISE<4>) is set. In this mode, the user must make certain that the TRISE<2:0> bits are set and that the pins are configured as digital inputs. Also, ensure that ADCON1 is configured for digital I/O. In this mode, the input buffers are TTL. Register 4-1 shows the TRISE register which also controls the Parallel Slave Port operation. PORTE pins are multiplexed with analog inputs. When selected for analog input, these pins will read as 0s. TRISE controls the direction of the RE pins, even when they are being used as analog inputs. The user must make sure to keep the pins configured as inputs when using them as analog inputs. Address 09h 89H 9FH Name Bit7 Bit 6 Bit Bit 3 Bit 2 Bit 1 Bit 0 4 ----RE2 RE1 RE0 PORTA Data Direction Register ADCS2 PCFG3 PCFG2 PCFG1 PCFG0 Bit 5

PORTE -TRISE ADCON1 ADFM

54

CHAPTER 4

4.1 IMPLEMENTATION OF PROJECT


RFID BASED SECURITY SYSTEM

Fig 4.1 appearance of attandance system My training project is RFID based Attendance cum Security System. This idea came to my mind when I saw our lecturers taking the attendance of 40 of students little hardly. We thought we can integrate the RFID based Security System with attendance system as well. That what our final year project is doing. 55

4.2 BLOCK DIAGRAM OF THE PROJECT:

Door Lock

PIC Tx Rx
PORT 2

DATA PIN

RFID TAG

Fig 4.2 RFID based Attendance system

4.3 History of RFID: In a very interesting article, the San Jose Mercury News tells us about Charles Walton, the man behind the radio frequency identification technology (RFID). Since his first patent about it in 1973, Walton, now 83 years old, collected about $3 million from royalties coming from his patents. Unfortunately for him, his latest patent about RFID expired in the mid-1990s. So he will not make any money from the billions of RFID tags that will appear in the years to come. But he continues to invent and his latest patent about a proximity card with incorporated PIN code protection was granted in June 2004. 56

4.4 What is RFID. RFID is short for Radio Frequency Identification. Generally a RFID system consists of 2 parts. A Reader, and one or more Transponders, also known as Tags. RFID systems evolved from barcode labels as a means to automatically identify and track products and people. You will be generally familiar with RFID systems as seen in:

Access Control. RFID Readers placed at entrances that require a person to pass their proximity card (RF tag) to be "read' before the access can be made.

Contact less Payment Systems. RFID tags used to carry payment information. RFIDs are particular suited to electronic Toll collection systems. Tags attached to vehicles, or carried by people transmit payment information to a fixed reader attached to a Toll station. Payments are then routinely deducted from a users account, or information is changed directly on the RFID tag.

Product Tracking and Inventory Control. RFID systems are commonly used to track and record the movement of ordinary items such as library books, clothes, factory pallets, electrical goods and numerous items.

4.5 How do RFIDs work. Shown below is a typical RFID system. In every RFID system the transponder Tags contain information. This information can be as little as a single binary bit , or be a large array of bits representing such things as an identity code, personal medical information, or literally any type of information that can be stored in digital binary format.

57

Shown is a RFID transceiver that communicates with a passive Tag. Passive tags have no power source of their own and instead derive power from the incident electromagnetic field. Commonly the heart of each tag is a microchip. When the Tag enters the generated RF field it is able to draw enough power from the field to access its internal memory and transmit its stored information.When the transponder Tag draws power in this way the resultant interaction of the RF fields causes the voltage at the transceiver antenna to drop in value. This effect is utilized by the Tag to communicate its information to the reader. The Tag is able to control the amount of power drawn from the field and by doing so it can modulate the voltage sensed at the Transceiver according to the bit pattern it wishes to transmit. 4.6 COMPONENTS OF RFID A basic RFID system consist of three components:

An antenna or coil A transceiver (with decoder) A transponder (RF tag) electronically programmed with unique information

These are described below:

58

4.6.1

ANTENNA

The antenna emits radio signals to activate the tag and read and write data to it. Antennas are the conduits between the tag and the transceiver, which controls the system's data acquisition and communication. Antennas are available in a variety of shapes and sizes; they can be built into a door frame to receive tag data from persons or things passing through the door, or mounted on an interstate tollbooth to monitor traffic passing by on a freeway. The electromagnetic field produced by an antenna can be constantly present when multiple tags are expected continually. If constant interrogation is not required, a sensor device can activate the field. Often the antenna is packaged with the transceiver and decoder to become a reader (a.k.a. interrogator), which can be configured either as a handheld or a fixed-mount device. The reader emits radio waves in ranges of anywhere from one inch to 100 feet or more, depending upon its power output and the radio frequency used. When an RFID tag passes through the electromagnetic zone, it detects the reader's activation signal. The reader decodes the data encoded in the tag's integrated circuit (silicon chip) and the data is passed to the host computer for processing.

4.6.2TAGS (Transponders)

59

An RFID tag is comprised of a microchip containing identifying information and an antenna that transmits this data wirelessly to a reader. At its most basic, the chip will contain a serialized identifier, or license plate number, that uniquely identifies that item, similar to the way many bar codes are used today. A key difference, however is that RFID tags have a higher data capacity than their bar code counterparts. This increases the options for the type of information that can be encoded on the tag, including the manufacturer, batch or lot number, weight, ownership, destination and history (such as the temperature range to which an item has been exposed). In fact, an unlimited list of other types of information can be stored on RFID tags, depending on application needs. An RFID tag can be placed on individual items, cases or pallets for identification purposes, as well as on fixed assets such as trailers, containers, totes, etc. Tags come in a variety of types, with a variety of capabilities. Key variables include: "Read-only" versus "read-write" There are three options in terms of how data can be encoded on tags: (1) Read-only tags contain data such as a serialized tracking number, which is pre-written onto them by the tag manufacturer or distributor. These are generally the least expensive tags because they cannot have any additional information included as they move throughout the supply chain. Any updates to that information would have to be maintained in the application software that tracks SKU movement and activity. (2) "Write once" tags enable a user to write data to the tag one time in production or distribution processes. Again, this may include a serial number, but perhaps other data such as a lot or batch number. (3) Full "read-write" tags allow new data to be written to the tag as neededand even written over the original data. Examples for the latter capability might include the time and date of ownership transfer or updating the repair history of a fixed asset. While these are the most costly of the three tag types and are not practical for tracking inexpensive items, future standards for electronic product codes (EPC) appear to be headed in this direction.

60

RFID TAGS
4.6.3Data capacity The amount of data storage on a tag can vary, ranging from 16 bits on the low end to as much as several thousand bits on the high end. Of course, the greater the storage capacity, the higher the price per tag.

4.6.4Form factor

The tag and antenna structure can come in a variety of physical form factors and can either be selfcontained or embedded as part of a traditional label structure (i.e., the tag is inside what looks like a regular bar code labelthis is termed a 'Smart Label') companies must choose the appropriate form factors for the tag very carefully and should expect to use multiple form factors to suit the tagging needs of different physical products and units of measure. For example, a pallet may have an RFID tag fitted only to an area of protected placement on the pallet itself. On the other hand, cartons on the pallet have RFID tags inside bar code labels that also provide operators humanreadable information and a back-up should the tag fail or pass through non RFID-capable supply chain links.

4.6.5Passive versus active

61

Passive tags have no battery and "broadcast" their data only when energized by a reader. That means they must be actively polled to send information. "Active" tags are capable of broadcasting their data using their own battery power. In general, this means that the read ranges are much greater for active tags than they are for passive tagsperhaps a read range of 100 feet or more, versus 15 feet or less for most passive tags. The extra capability and read ranges of active tags, however, come with a cost; they are several times more expensive than passive tags. Today, active tags are much more likely to be used for high-value items or fixed assets such as trailers, where the cost is minimal compared to item value, and very long read ranges are required. Most traditional supply chain applications, such as the RFID-based tracking and compliance programs emerging in the consumer goods retail chain, will use the less expensive passive tags.

4.6.7Frequencies Like all wireless communications, there are a variety of frequencies or spectra through which RFID tags can communicate with readers. Again, there are trade-offs among cost, performance and application requirements. For instance, low-frequency tags are cheaper than ultra high-frequency (UHF) tags, use less power and are better able to penetrate non-metallic substances. They are ideal for scanning objects with high water content, such as fruit, at close range. UHF frequencies typically offer better range and can transfer data faster. But they use more power and are less likely to pass through some materials. UHF tags are typically best suited for use with or near wood, paper, cardboard or clothing products. Compared to low-frequency tags, UHF tags might be better for scanning boxes of goods as they pass through a bay door into a warehouse. While the tag requirements for compliance mandates may be narrowly defined, it is likely that a variety of tag types will be required to solve specific operational issues. You will want to work with a company that is very knowledgeable in tag and reader technology to appropriately identify the right mix of RFID technology for your environment and applications. 4.6.7EPC Tags EPC refers to "electronic product code," an emerging specification for RFID tags, readers and business applications first developed at the Auto-ID Center at the Massachusetts Institute of Technology. This organization has provided significant intellectual leadership toward the use and 62

application of RFID technology. EPC represents a specific approach to item identification, including an emerging standard for the tags themselves, including both the data content of the tag and open wireless communication protocols. In a sense, the EPC movement is combining the data standards embodied in certain bar code specifications, such as the UPC or UCC-128 bar code standards, with the wireless data communication standards that have been developed by ANSI and other groups.

4.6.8 RF Transceiver: The RF transceiver is the source of the RF energy used to activate and power the passive RFID tags. The RF transceiver may be enclosed in the same cabinet as the reader or it may be a separate piece of equipment. When provided as a separate piece of equipment, the transceiver is commonly referred to as an RF module. The RF transceiver controls and modulates the radio frequencies that the antenna transmits and receives. The transceiver filters and amplifies the backscatter signal from a passive RFID tag. 4.7 Typical Applications for RFID

Automatic Vehicle identification Inventory Management Work-in-Process Container/ Yard Management Document/ Jewellery tracking Patient Monitoring

4.8 Common Problems with RFID Some common problems with RFID are reader collision and tag collision. Reader collision occurs when the signals from two or more readers overlap. The tag is unable to respond to simultaneous queries. Systems must be carefully set up to avoid this problem. Tag collision occurs when many tags are present in a small area; but since the read time is very fast, it is easier for vendors to develop systems that ensure that tags respond one at a time. See Problems with RFID for more details.

63

4.9Microcontroller (PIC16F877A) About Microcontroller (PIC16F877A) The PIC16F877A is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes of downloadable Flash programmable and erasable read only memory and 2K bytes of EEPROM. The device is manufactured using Microchips high-density non volatile memory technology and is compatible with the industry-standard PIC instruction set and pin out. The on-chip downloadable Flash allows the program memory to be reprogrammed in-system through an SPI serial interface or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with downloadable Flash on a monolithic chip, the PIC16F877A is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications.

The PIC16F877A provides the following standard features: 8K bytes of downloadable Flash, 2K bytes of EEPROM, 256 bytes of RAM, 32 I/O lines, programmable watchdog timer, two data pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the P89C51RD2 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next interrupt or hardware reset. The downloadable Flash can be changed a single byte at a time and is accessible through the SPI serial interface. Holding RESET active forces the SPI bus into a serial programming interfaces and allows the program memory to be written to or read from unless Lock Bit 2 has been activated.

PROGRAM OF PROJECT
//using 8mhz crystal 64

sbit rs at RB0_bit; sbit e at RB2_bit; sbit rly at RE0_bit; sbit buz at RE1_bit; unsigned char arr3[]=" ENTER CARD "; unsigned char arr1[]=" CORRECT unsigned char arr2[]=" IN-CORRECT void dat() { rs=1; e=1; e=0; } void cmd() { rs=0; e=1; e=0; } 65 "; ";

void delay() { int s; for(s=0;s<=30000;s++); }

void lcd() { portd=0x38; cmd(); delay(); portd=0x01; cmd(); delay(); portd=0x06; cmd(); delay(); portd=0x0e; cmd(); 66

delay(); portd=0x80; cmd(); delay(); } void main() { int i; unsigned char arr[20]; trisb=0x00; portb=0x00; trisd=0x00; portd=0x00; trise=0x00; porte=0x00; lcd(); for(i=0;i<=15;i++) { portd=arr3[i]; 67

dat(); delay(); } INTCON.GIE=1; //INTCON.PEIE=1; RCSTA=0x90; TXSTA.BRGH=1; SPBRG=50; TXSTA.SYNC=0; RCSTA.SPEN=1; PIE1.RCIE=1; RCSTA.CREN=1; while(1) { for(i=0;i<=11;i++) { while(PIR1.RCIF==0); arr[i]=RCREG; //portd=arr[i]; 68

PIR1.RCIF==1; } if(arr[11]=='E') { portd=0x01; cmd(); delay(); portd=0x80; cmd(); delay(); for(i=0;i<=15;i++) { portd=arr1[i]; dat(); delay(); } rly=1; } else 69

{ portd=0x01; cmd(); delay(); portd=0x80; cmd(); delay(); for(i=0;i<=15;i++) { portd=arr2[i]; dat(); delay(); } buz=1; } } }

70

4.10 LEARNING OUTCOMES:

Understanding the hardware detail of a PIC16F877A Microcontroller Microcontroller programming RFID Technology RFID based Attendance cum Security System

5. References
THE 8051 MICROCONTROLLER AND EMBEDDED SYSTEM by Muhammad Ali Mazidi , Janice Gillispie Mazidi, Rolin D. Mckinlay. The 8051 MICROCONTROLLER by K. J. Ayala. "Advanced Microprocessors and Microcontrollers" by B.P. Singh & Renu Singh. "Let Us C" by Yashwant Kanitkar. "Data Structure through C" by Yashwant Kanitkar.

NET LINKS: 1. www.8051projects.net


2. www.atmel.com 3. www.electronicsforyou.com 4. www.encyclopedia.com 5. www.wikipedia.com

71

Вам также может понравиться