Sie sind auf Seite 1von 88

PROMOTING CAN 2.

0 FOR COLLEGE CAMPUS


A Mini - Project Report Submitted in partial fulfillment of the requirements for the award of the degree of

BACHELOR OF TECHNOLOGY
In

Electronics and Communication Engineering Submitted By Mr. Rohit.Y (07071A0471) Under the guidance of
Prof. V. KrishnaSree Associate Professor

Department Of Electronics and Communication Engineering

VNR Vignana Jyothi Institute of Engineering & Technology


(Recognized by AICTE & Affiliated to JNTUH) Accredited by NBA Bachupally, Hyderabad.

March, 2011.

VALLURIPALLI NAGESWARA RAO VIGNANA JYOTHI INSTITUTE OF ENGINEERING & TECHNOLOGY


(RECOGNIZED BY AICTE & AFFILIATED TO JNTUH) ACCREDITED BY NBA, BACHUPALLY, NIZAMPET (S.O.), HYDERABAD-500 090, A.P

CERTIFICATE
This is to certify that Mr. Rohit.Y (07071A0471) has successfully completed his mini project work at ECE Department of VNR VJIET; Hyderabad entitled PROMOTING CAN 2.0 FOR COLLEGE CAMPUS in partial fulfillments of the requirements for the award of B.Tech degree during the academic year 2009-2010. This work is carried out under my supervision and has not been submitted to any other University/Institute for award of any degree/diploma.

Prof. V.KrishnaSree Associate Professor Department of ECE VNR VJIET

Dr. P.Sri Hari Professor & Head Department of ECE VNR VJIET

20

External Examiner

DECLARATION

I hereby declare that the mini - project entitled PROMOTING CAN 2.0 FOR COLLEGE CAMPUS submitted in partial fulfillment of the requirements for award of the degree of Bachelor of Technology in Electronics and Communication Engineering at VNR Vignana Jyothi Institute of Engineering and Technology, affiliated to Jawaharlal Nehru Technological University, Hyderabad, is an authentic work and has not been submitted to any other University/Institute for award of any degree/diploma.

ROHIT.Y (07071A0471)
IV/IV B.Tech ECE VNR VJIET, HYDERABAD.

20

ACKNOWLEDGEMENT
Firstly, I would like to express my immense gratitude towards my institution VNR Vignana Jyothi Institute of Engineering & Technology, which created a great platform to attain profound technical skills in the field of Electronics and Communication, thereby fulfilling my most cherished goal. It gives me great pleasure and privilege to express my deep sense of gratitude and sincere thanks to our Principal, Dr.C.D.Naidu. I am very much thankful to our Head of Department, Dr.P.Sri Hari for extending his cooperation in doing this project. I extend my heartfelt thanks to our guide, Prof. V.KrishnaSree for her enthusiastic guidance throughout the course of our project. My appreciable obligation also goes to all the staff members of Electronics & Communication Engineering Department and to my fellow classmates who directly or indirectly helped me.

ROHIT.Y

20

ABSTRACT
Aim of this project is to implement class room attendance system with indoor counter and information announcement using CAN 2.0 Protocol. Controllerarea network (CAN or CAN-bus) is a vehicle bus standard designed to allow microcontrollers and devices to communicate with each other within a vehicle without a host computer. It was designed specifically for automotive applications but is now also used in other areas. Development of the CAN-bus started originally in 1983 at Robert Bosch GmbH. The intention of this project is implementation of hardware in a college campus using embedded CAN bus. The implemented system has the following characteristics, which distinguish it from existing approaches: (i) the class rooms interface with smart card attendance is automatically updated to HOD; (ii) a standard communication protocol (CAN) is used in the hardware implementation, providing reliability and error control; (iii) new class room nodes are easily inserted in the system; (iv) SMS/e-Mail alert to the parents about presents of their children in college. SYSTEM DESIGN: There are three nodes: 1. HOD room Node 1: it consists of CAN Controller to interface with Classrooms and then it will be interfaced with net to Mail facility. 2. CLASS room Node 2: it consists of CAN controller to interface with HOD room and smart card reader for attendance purpose. HARDWARE & SOFTWARE REQUIREMENTS:
Hardware components: PIC 16F877A, 2x16-LCD, MAX232, RS232, IR Sensors, CAN

Controller and Transceiver, Smart Card Reader

20

Software tools: Development tool MPLAB v7.42, Hardware Compiler - HI-Tech PICC,

Programmer - PIC Flash, Hardware Simulation tool - Proteus v6.9 Sp4. CONTENTS CHAPTER NO. PAGE NO.

1. 2. 3. 4.

OBJECTIVE OF THE STUDY METHODOLOGY OF THE STUDY INTRODUCTION TO CAN BLOCK DIAGRAM
4.1 SYSTEM DESIGN

7-8 9 - 18 19 - 21 22 23

4.2 BLOCK DIAGRAM DESCRIPTION 4.3 CIRCUIT DIAGRAM

24 - 26 27 - 29

5. 6. 7. 7.1 7.2 7.3

HARDWARE INFORMATION SOFTWARE INFORMATION RESULTS & CONCLUSION SYSTEM LEVEL TESTING APPLICATIONS CONCLUSION 67 - 69 70 70

30 - 51 52 - 65 66

8. 9.

BIBLIOGRAPHY APPENDIX-A

71 72 - 73

20

10.

COMPONENTS LIST 74 - 87

APPENDIX-B PROJECT CODING CHAPTER 1

OBJECTIVE OF THE STUDY

20

1.

OBJECTIVE OF THE STUDY

Aim of this project is to implement class room attendance system with indoor counter and information announcement using CAN 2.0 Protocol. Controllerarea network (CAN or CAN-bus) is a vehicle bus standard designed to allow microcontrollers and devices to communicate with each other within a vehicle without a host computer. It was designed specifically for automotive applications but is now also used in other areas. Development of the CAN-bus started originally in 1983 at Robert Bosch GmbH. The intention of this project is implementation of hardware in a college campus using embedded CAN bus. The implemented system has the following characteristics, which distinguish it from existing approaches: (i) the class rooms interface with smart card attendance is automatically updated to HOD; (ii) a standard communication protocol (CAN) is used in the hardware implementation, providing reliability and error control; (iii) new class room nodes are easily inserted in the system; (iv) SMS alert to the parents about presents of their children in college.

SYSTEM DESIGN: There are three nodes:

20

3. HOD room Node 1: it consists of CAN Controller to interface with Classrooms and then it will be interfaced with net to SMS facility.
4. CLASS room Node 2: it consists of CAN controller to interface with HOD room and

smart card reader for attendance purpose and also it is interfaced with Counter unit to intimate HOD about class room strength. 5. CLASS room Node 3: it is as same as Node 2.

CHAPTER 2

METHODOLOGY OF THE STUDY

20

2.

METHODOLOGY OF THE STUDY

RFID based attendance system is developed in embedded systems. The main purpose of this project is to PROMOTING CAN 2.0 FOR COLLEGE CAMPUS with the help of embedded platform tools.

2.1

EMBEDDED SYSTEMS: Embedded System is a combination of hardware and software used to achieve a single specific task. An

embedded system is a microcontroller-based, software driven, reliable, real-time control system, autonomous, or human or network interactive, operating on diverse physical variables and in diverse environments and sold into a competitive and cost conscious market. An embedded system is not a computer system that is used primarily for processing, not a software system on PC or UNIX, not a traditional business or scientific application. High-end embedded & lower end embedded systems. High-end embedded system - Generally 32, 64 Bit Controllers used with OS. Examples Personal Digital Assistant and Mobile phones etc .Lower end embedded systems - Generally 8,16 Bit Controllers used with an minimal operating systems and hardware layout designed for the specific purpose. Examples Small

20

controllers and devices in our everyday life like Washing Machine, Microwave Ovens, where they are embedded in.

SYSTEM DESIGN CALLS 2.2 THE EMBEDDED SYSTEM DESIGN CYCLE:

20

V Diagram In this place we need to discuss the role of simulation software, real-time systems and data acquisition in dynamic test applications. Traditional testing is referred to as static testing where functionality of components is tested by providing known inputs and measuring outputs. Today there is more pressure to get products to market faster and reduce design cycle times.

This has led to a need for dynamic testing where components are tested while in use with the entire system either real or simulated. Because of cost and safety concerns, simulating the rest of the system with real-time hardware is preferred to testing components in the actual real system. The diagram shown on this slide is the V Diagram that is often used to describe the development cycle. Originally developed to encapsulate the design process of software applications, many different versions of this diagram can be found to describe different product design cycles. Here we have shown one example of such a diagram representing the design cycle of embedded control applications common to automotive, aerospace and defense applications. In this diagram the general progression in time of the development stages is shown from left to right. Note however that this is often an iterative process and the actual development will not proceed linearly through these

20

steps. The goal of rapid development is to make this cycle as efficient as possible by minimizing the iterations required for a design. If the x-axis of the diagram is thought of as time, the goal is to narrow the V as much as possible and thereby reduce development time. The y-axis of this diagram can be thought of as the level at which the system components are considered. Early on in the development, the requirements of the overall system must be considered. As the system is divided into sub-systems and components, the process becomes very low-level down to the point of loading code onto individual processors. Afterwards components are integrated and tested together until such time that the entire system can enter final production testing. Therefore the top of the diagram represents the high-level system view and the bottom of the diagram represents a very low-level view. Notes: V diagram describes lots of applicationsderived from software development. Reason for shape, every phase of design requires a complimentary test phase. High-level to low-level view

of application.

This is a simplified version. Loop back/ Iterative process, X-axis is time (sum up). Characteristics of Embedded System: An embedded system is any computer system hidden inside a product other than a computer There will encounter a number of difficulties when writing embedded system software in addition

2.3

to those we encounter when we write applications

Throughput Our system may need to handle a lot of data in a short period of time.

20

ResponseOur system may need to react to events quickly TestabilitySetting up equipment to test embedded software can be difficult DebugabilityWithout a screen or a keyboard, finding out what the software is doing

wrong (other than not working) is a troublesome problem

Reliability embedded systems must be able to handle any situation without human

intervention

Memory space Memory is limited on embedded systems, and you must make the

software and the data fit into whatever memory exists

Program installation you will need special tools to get your software into embedded

systems

Power consumption Portable systems must run on battery power, and the software in

these systems must conserve power

Processor hogs computing that requires large amounts of CPU time can complicate the

response problem

Cost Reducing the cost of the hardware is a concern in many embedded system projects;

software often operates on hardware that is barely adequate for the job. Embedded systems have a microprocessor/ microcontroller and a memory. Some have a serial port

or a network connection. They usually do not have keyboards, screens or disk drives.

Applications: 20

1. Military and aerospace embedded software applications. 2 . Commun ication Appli cati ons. 3 . In du stri al au tomati on and process control sof tware.

2.4

DETAILS ABOUT MICROCONTROLLER: The micro-controller is a chip, which has a computer processor with all its support function,

memory (both program storage and RAM), and I/O built in to the device. These built in functions minimize the need for external circuits and devices to design in the final applications. Most microcontrollers do not require a substantial amount of time to learn how to efficiently program them, although many of then which have quirks which you will have to understand before you attempt to develop your first application. Along with micro-controllers getting faster, smaller and more power efficient they are also getting more and more features. Often, the first version of micro-controller will just have memory and digital I/O, but as the device family matures, more and more pat numbers with varying features will be available. PIC 16F877A: Microcontroller Core Features: High-performance RISC CPU. 20

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. Pin out compatible to the PIC16C73B/74B/76/77 Interrupt capability (up to 14 sources) Eight level deep hardware stack Direct, indirect and relative addressing modes. Power-on Reset (POR). Power-up Timer (PWRT) and Oscillator Start-up Timer (OST). Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation. Programmable code-protection. Power saving SLEEP mode. Selectable oscillator options. Low-power, high-speed CMOS FLASH/EEPROM technology. Fully static design. In-Circuit Serial Programming (ICSP) . Single 5V In-Circuit Serial Programming capability. In-Circuit Debugging via two pins. Processor read/write access to program memory. Wide operating voltage range: 2.0V to 5.5V. 20

High Sink/Source Current: 25 mA. Commercial and Industrial temperature ranges. Low-power consumption. - < 2 mA typical @ 5V, 4 MHz - 20 typical @ 3V, 32 kHz A - < 1 A typical standby current

2.5

PIN DIAGRAM OF PIC 16F874A/877A:

20

PERIPHERAL FEATURES: Timer0: 8-bit timer/counter with 8-bit prescaler Timer1: 16-bit timer/counter with prescaler, can be incremented during sleep via external crystal/clock

20

Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler Two Capture, Compare, PWM modules - Capture is 16-bit, max. Resolution is 12.5 ns - Compare is 16-bit, max. Resolution is 200 ns - PWM max. Resolution is 10-bit 10-bit multi-channel Analog-to-Digital converter Synchronous Serial Port (SSP) with SPI (Master Mode) and I2C (Master/Slave) Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-bit address detection Parallel Slave Port (PSP) 8-bits wide, with external RD, WR and CS controls (40/44-pin only) Brown-out detection circuitry for Brown-out Reset (BOR)

CMOS TECHNOLOGY: Low-power, high-speed Flash/EEPROM technology. Fully static design. Wide operating voltage range (2.0V to 5.5V). Commercial and Industrial temperature ranges. Low-power consumption.

CHAPTER 3

20

INTRODUCTION TO CAN

3. CAN (Controller Area Network)


The CAN protocol is an ISO standard (ISO 11898) for serial data communication. The protocol was developed aiming at automotive applications developed by Robert Bosch (an industry

20

of automation). Today CAN has gained widespread use and is used in industrial automation as well as in automotives and mobile machines. The CAN bus The CAN bus is a broadcast type of bus. This means that all nodes can "hear" all transmissions. There is no way to send a message to just a specific node; all nodes will invariably pick up all traffic. The CAN hardware, however, provides local filtering so that each node may react only on the interesting messages. Maximum Bus Speed The maximum speed of a CAN bus, according to the standard, is 1 Mbit/second. Some CAN controllers will nevertheless handle higher speeds than 1Mbit/s and may be considered for special applications. Maximum Cable Length At a speed of 1 Mbit/s, a maximum cable length of about 40 meters (130 ft.) can be used. Other maximum cable lengths are (these values are approximate)

100 meters (330 ft) at 500 Kbit/s 200 meters (650 ft) at 250 Kbit/s 500 meters (1600 ft) at 125 Kbit/s 6 kilometers (20000 ft) at 10 Kbit/s

20

The CAN messages CAN uses short messages - the maximum utility load is 94 bits. There is no explicit address in the messages; instead, the messages can be said to be contents-addressed, that is, their contents implicitly determines their address. Message Types There are four different message types (or "frames") on a CAN bus:

the Data Frame, the Remote Frame, the Error Frame, and the Overload Frame.

The Data Frame Summary: "Hello everyone, here's some data labeled X, hope you like it!" The Remote Frame Summary: "Hello everyone, can somebody please produce the data labeled X?" The Error Frame Summary: (everyone, aloud) "OH DEAR, LET'S TRY AGAIN" The Overload Frame Summary: "I'm a very busy little 82526; could you please wait for a moment?"

CHAPTER 4

20

BLOCK DIAGRAM

4.1

SYSTEM DESIGN:

20

HOD Room Node 1


Power supply unit

PC with net interface

MAX 232

PIC Microcontroller

CAN Controller Node 1

RS232 LCD

Class Room Node 2


Power supply unit

CAN Bus

Speaker unit

PIC Microcontroller

CAN Controller Node 2

IR Object Counter unit

Class Room Node 3


Power supply unit

CAN Bus

PIC
Smart Card Reader

Microcontrolle r

CAN Controller Node 3

Student ID

LCD & Keypad

4.2

DESCRIPTION OF THE BLOCK DIAGRAM:

20

The major components of this project are PIC Microcontrollers, RFID Tag Reader and RS 232 protocol cable to communicate with PC. Power supply: The Entire Project needs power for its operation. However, from the study of this project it comes to know that we supposed to design 5v and 12v dc power supply. So by utilizing the following power supply components, required power has been gained. (230/12v (1A and 500mA) Step down transformers, Bridge rectifier to converter ac to dc, booster capacitor and +5v (7805) and +12v (7812) regulator to maintain constant 5v & 12 supply for the controller circuit and Smart Card Reader). PIC Microcontroller: The major heart of this project is PIC16F877A microcontroller, the reasons why we selected this in our project?, it has more features like 16bit timer, 10-bit ADC, USART, SPI, I2C, 256 bytes of EEPROM memory, and 8kbytes of flash program memory, then at last its speed of program execution is about to 1 microsecond or 10 MIPS (10 Million Instructions per second), etc. However, compare to other microcontroller it is fast and very ease to program in C language because of huge support can gain from the manufacturer (Microchip Corporation)for programming. The special IDE offered by the manufacture, it is named as MPLAB IDE for it code generation purpose. Then one more thing is several cheapest programming tools to dump the coding in to the controller are available, for example: ProPIC, PIC Flash, ProMATE, and ProUniversal. RS232 (USART): The PIC microcontroller is connected to PC through RS232 protocol, for this inbuilt USART module is utilized. A serial port sends and receives data one bit at a time over one wire. While it takes eight times as long as to transfer each byte of data this way, only a few wires are required. In fact, two-way (full duplex) communications is possible with only three separate wires- one to send, one to receive, and a common signal ground wire.

20

Cable Length: The MAX-232 standard imposes a cable length limit of 50 feet. You can usually ignore this standard, since a cable can be as long as 10000 feet at baud rates up to 19200 if you use a high quality, well shielded cable. The external environment has a large effect on lengths for unshielded cables. MAX232 (Voltage Converter): Since the RS232 is not compatible with todays microprocessors and micro controller, we need line driver to convert the RS232 signals to TTL voltage levels that will be acceptable to the 8051s TXD and RXD pins. One example of such a converter is MAX 232 from maxim corp. The MAX 232 converts from RS232 voltage levels to TTL voltage levels, and vice versa. One advantage of MAX232 chip is that it uses a +5V power source, which is the same as the source voltage for the PIC 16f877A micro controller. In other words, with a single +5v power supply we can power both the PIC and MAX 232, with no need of for the dual power supplies that are common in many older systems. The MAX 232 requires four capacitors ranging from 1 to 22 microfarad. The most widely used value for this capacitor is 22microfarad. Smart card (student ID): A smart card, chip card, or integrated circuit card (ICC), is any pocket-sized card with embedded integrated circuits which can process data. This implies that it can receive input which is processed by way of the ICC applications and delivered as an output. There are two broad categories of ICCs. Memory cards contain only non-volatile memory storage components, and perhaps some specific security logic. Microprocessor cards contain volatile memory and microprocessor components. The card is made of plastic, generally PVC, but sometimes ABS. The card may embed a hologram to avoid counterfeiting. Using smartcards also is a form of strong security authentication for single sign-on within large companies and organizations

20

Benefits of Smart Card


Smart cards can be used for identification, authentication, and data storage.

Smart cards provide a means of effecting business transactions in a flexible, secure, standard way with minimal human intervention. READER/WRITER:

Smart card reader/writer

Contact smart card readers are used as a communications medium between the smart card and a host, e.g. a microcontroller, a computer, a point of sale terminal, or a mobile telephone. Discipline: In the HOD room he/she can see the students attendance using smart card reader and present counts using IR object counter on the LCD screen, mean while using speaker system circulars he can forward to the class rooms, finally the HOD room system which can be connect to PC for sending SMS alert to the parents about presents of their son/daughter.
PHYSICAL DESIGN:

The process of developing the hardware and Microcontroller program is referred to as physical design. We have to design the process by identifying reports and the other outputs the system will produce. Coding the program for CAN inside of microcontroller is performed in this step. Proper software specification is also done in this step.

20

4.3

CIRCUIT DIAGRAM:

HOD Room Node 1

20

Class Room Node 2

20

Class Room Node 3

20

CHAPTER 5

HARDWARE INFORMATION

5.1

MICROCONTROLLER:
20

INTRODUCTION TO MICROCONTROLLER: A computer-on-a-chip is a variation of a microprocessor which combines the processor core (CPU), some memory, and I/O (input/output) lines, all on one chip. The computer-on-a-chip is called the microcomputer whose proper meaning is a computer using a (number of) microprocessor(s) as its CPUs, while the concept of the microcomputer is known to be a microcontroller. A microcontroller can be viewed as a set of digital logic circuits integrated on a single silicon chip. This chip is used for only specific applications. Most microcontrollers do not require a substantial amount of time to learn how to efficiently program them, although many of them, which have quirks, which you will have to understand before you, attempt to develop your first application. Along with microcontrollers getting faster, smaller and more power efficient they are also getting more and more features. Often, the first version of microcontroller will just have memory and digital I/O, but as the device family matures, more and more pat numbers with varying features will be available. In this project we used PIC 16f877A microcontroller. For most applications, we will be able to find a device within the family that meets our specifications with a minimum of external devices, or an external but which will make attaching external devices easier, both in terms of wiring and programming. For many microcontrollers, programmers can built very cheaply, or even built in to the final application circuit eliminating the need for a separate circuit. Also simplifying this requirement is the availability of micro-controllers wit SRAM and EEPROM for control store, which will allow program development without having to remove the micro controller fro the application circuit.

PIC MICRO CONTROLLER - CORE FEATURES: High-performance RISC CPU.

20

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 (RAM) Up to 256 x 8 bytes of EEPROM data memory. Memory

Pin out compatible to the PIC16C73B/74B/76/77 Interrupt capability (up to 14 sources) Eight level deep hardware stack Direct, indirect and relative addressing modes. Power-on Reset (POR). Power-up Timer (PWRT) and Oscillator Start-up Timer (OST). Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation. Programmable code-protection. Power saving SLEEP mode. Selectable oscillator options. Low-power, high-speed CMOS FLASH/EEPROM technology. Fully static design. In-Circuit Serial Programming (ICSP) . Single 5V In-Circuit Serial Programming capability. In-Circuit Debugging via two pins. Processor read/write access to program memory. Wide operating voltage range: 2.0V to 5.5V. High Sink/Source Current: 25 mA. Commercial and Industrial temperature ranges.

20

Low-power consumption. In this project we used PIC 16f877A microcontroller. PIC means Peripheral Interface Controller.

The PIC family having different series. The series are 12- Series, 14- Series, 16- Series, 18- Series, and 24- Series. We used 16 Series PIC microcontrollers. ADVANTAGES OF USING A MICROCONTROLLER OVER MICROPROCESSOR: A designer will use a Microcontroller to Gather input from various sensors Process this input into a set of actions Use the output mechanisms on the Microcontroller to do something useful RAM and ROM are inbuilt in the MC. Cheap compared to MP. Multi machine control is possible simultaneously.

Examples: 8051 (ATMEL), PIC (Microchip), Motorola (Motorola), ARM Processor.

APPLICATIONS: Cell phones. Computers. Robots. Interfacing to two pcs.

20

5.2

PIN DIAGRAM - PIC 16 F874A/877A:

20

5.3

FUNCTIONAL BLOCK DIAGRAM OF PIC 16F877A:

20

PIN DESCRIPTION: OSC1/CLKI: 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). OSC2/CLKO: Oscillator crystal or clock output. Oscillator crystal output. Connects to The 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. MCLR/VPP: Master Clear (input) or programming voltage (output). Master Clear (Reset) input. This pin is an active low Reset to the device. Programming voltage input. RA0/AN0. RA1/AN1. RA2/AN2/VREF-/CVREF. VREFCVREF. RA3/AN3/VREF+. VREF+. RA4/T0CKI/C1OUT. T0CKI. C1OUT. RA5/AN4/SS/C2OUT/SS/C2OUT.

20

I/O PORTS: Some pins for these I/O ports are multiplexed with an alternate function for the peripheral features on the device. In general, when a peripheral is enabled, that pin may not be used as a general purpose I/O pin. PORTA AND TRISA REGISTER: 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 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. The TRISA register controls the direction of the port pins even when they are being used as analog inputs. The user must ensure the bits in the TRISA register are maintained set when using them as analog inputs.

20

Note: On a Power-on Reset, these pins are configured as analog inputs and read as 0. The comparators are in the off (digital). PORT B AND 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 Debugger and Low-Voltage Programming function: RB3/PGM, RB6/PGC and RB7/PGD. Four of the PORTB pins, RB7:RB4, have an interruption- change feature. Only pins configured as inputs can cause this interrupt to occur (i.e., any RB7:RB4 pin configured as an output is excluded from the interruption- change comparison). The input pins (of RB7:RB4) are compared with the old value latched on the last read of PORTB. The mismatch outputs of RB7:RB4 are ORed together to generate the RB port change interrupt with flag bit RBIF (INTCON<0>). This interrupt can wake the device from Sleep. The user, in the Interrupt Service Routine, can clear the interrupt in the following manner: a) Any read or write of PORTB. This will end the mismatch condition. b) Clear flag bit RBIF. A mismatch condition will continue to set flag bit RBIF. Reading PORTB will end the mismatch condition and allow flag bit RBIF to be cleared. The interrupt-on-change feature is

20

recommended for wake-up on key depression operation and operations where PORTB is only used for the interrupt-on-change feature. Polling of PORTB is not recommended while using the interrupt-on- change feature. This interrupt-on-mismatch feature, together with software configurable pull-ups on these four pins, allow easy interface to a keypad and make it possible for wake-up on key depression. PORTC AND 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 SMBus 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. 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

20

(Parallel Slave Port) by setting control bit, PSP MODE (TRISE<4>). In this mode, the input buffers are TTL. 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.

MEMORY ORGANIZATION: There are three memory blocks in each of the PIC16F87XA devices. The program memory and data memory have separate buses so that concurrent access can occur and is detailed in this section. The EEPROM data memory block is detailed in.

PROGRAM MEMORY ORGANIZATION: The PIC16F87XA devices have a 13-bit program counter capable of addressing an 8K word x 14 bit program memory space. The PIC16F876A/877A devices have 8K words x 14 bits of

20

Flash program memory, while PIC16F873A/874A devices have 4K words x 14 bits. Accessing a location above the physically implemented address will cause a wraparound. The Reset vector is at 0000h and the interrupt vector is at 0004h. The data memory is partitioned into multiple banks which contain the General Purpose Registers and the Special Function Registers. Bits RP1 (Status<6>) and RP0 (Status<5>) are the bank select bits. Each bank extends up to 7Fh (128 bytes). The lower locations of each bank are reserved for the Special Function Registers. Above the Special Function Registers are General Purpose Registers, implemented as static RAM. All implemented banks contain Special Function Registers. Some frequently used Special Function Registers from one bank may be mirrored in another bank for code reduction and quicker access.

TIMER0 MODULE: The Timer0 module timer/counter has the following features: 8-bit timer/counter Readable and writable 8-bit software programmable prescaler Internal or external clock select Interrupt on overflow from FFh to 00h Edge select for external clock

20

Timer mode is selected by clearing bit T0CS (OPTION_REG<5>). In Timer mode, the Timer0 module will increment every instruction cycle (without prescaler). If the TMR0 register is written, the increment is inhibited for the following two instruction cycles. The user can work around this by writing an adjusted value to the TMR0 register. TIMER0 INTERRUPT: The TMR0 interrupt is generated when the TMR0 register overflows from FFh to 00h. This overflow sets bit TMR0IF (INTCON<2>). The interrupt can be masked by clearing bit TMR0IE (INTCON<5>). Bit TMR0IF must be cleared in software by the Timer0 module Interrupt Service Routine before re-enabling this interrupt. The TMR0 interrupt cannot awaken the processor from Sleep since the timer is shut-off during Sleep. TIMER1 MODULE: The Timer1 module is a 16-bit timer/counter consisting of two 8-bit registers (TMR1H and TMR1L) which are readable and writable. The TMR1 register pair (TMR1H:TMR1L) increments from 0000h to FFFFh and rolls over to 0000h. The TMR1 interrupt, if enabled, is generated on overflow which is latched in interrupt flag bit, TMR1IF (PIR1<0>). This interrupt can be enabled/disabled by setting or clearing TMR1 interrupt enable bit, TMR1IE (PIE1<0>). Timer1 can operate in one of two modes: As a Timer As a Counter The operating mode is determined by the clock select bit, TMR1CS (T1CON<1>).

20

In Timer mode, Timer1 increments every instruction cycle. In Counter mode, it increments on every rising edge of the external clock input. Timer1 can be enabled/disabled by setting/clearing control bit, TMR1ON (T1CON<0>).Timer1 also has an internal Reset input. This Reset can be generated by either of the two CCP modules. Shows the Timer1 Control register. When the Timer1 oscillator is enabled (T1OSCEN is set), the RC1/T1OSI/CCP2 and RC0/T1OSO/T1CKI pins become inputs. That is, the TRISC<1:0> value is ignored and these pins read as 0. TIMER2 MODULE: Timer2 is an 8-bit timer with a prescaler and a postscaler. It can be used as the PWM time base for the PWM mode of the CCP module(s). The TMR2 register is readable and writable and is cleared on any device Reset. The input clock (FOSC/4) has a prescaler option of 1:1, 1:4 or 1:16, selected by control bits T2CKPS1:T2CKPS0 (T2CON<1:0>). The Timer2 module has an 8-bit period register, PR2. A Timer2 increment from 00h until it matches PR2 and then resets to 00h on the next increment cycle. PR2 is a readable and writable register. The PR2 register is initialized to FFh upon Reset. 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, TMR2IF (PIR1<1>)). Timer2 can be shut-off by clearing control bit, TMR2ON (T2CON<2>), to minimize power consumption. IN-CIRCUIT DEBUGGER: PIC16F87XA devices have a Watchdog Timer which can be shut-off only through configuration bits. It runs off its own RC oscillator for added reliability. There are two timers that offer necessary delays on power-up. One is the Oscillator Start-up Timer (OST), intended to keep

20

the chip in Reset until the crystal oscillator is stable. The other is the Power-up Timer (PWRT), which provides a fixed delay of 72 ms (nominal) on power-up only. It is designed to keep the part In Reset while the power supply stabilizes. With these two timers on-chip, most applications need no external Reset circuitry. Sleep mode is designed to offer a very low current power-down mode. The user can wake-up from Sleep through external Reset, Watchdog Timer wake-up or through an interrupt. Several oscillator options are also made available to allow the part to fit the application. The RC oscillator option saves system cost while the LP crystal option saves power. A set of configuration bits is used to select various options. 5.4 POWER SUPPLY UNIT

POWER SUPPLY UNIT COSISTS OF FOLLOWING UNITS: 1) Step down transformer 2) Rectifier unit 3) Input filter 4) Regulator unit 5) Output filter

20

STEP DOWN TRANSFORMER: The Step down Transformer is used to step down the main supply voltage from 230V AC to lower value. This 230 AC voltage cannot be used directly, thus it is stepped down. The Transformer consists of primary and secondary coils. To reduce or step down the voltage, the transformer is designed to contain less number of turns in its secondary core. The output from the secondary coil is also AC waveform. Thus the conversion from AC to DC is essential. This conversion is achieved by using the Rectifier Circuit/Unit.

RECTIFIER UNIT: The Rectifier circuit is used to convert the AC voltage into its corresponding DC voltage. There are Half-Wave, Full-Wave and bridge Rectifiers available for this specific function. The most important and simple device used in Rectifier circuit is the diode. The simple function of the diode is to conduct when forward biased and not to conduct in reverse bias. The Forward Bias is achieved by connecting the diodes positive with positive of the battery and negative with batterys negative. The efficient circuit used is the Full wave Bridge rectifier circuit. The output voltage of the rectifier is in rippled form, the ripples from the obtained DC voltage are removed using other circuits available. The circuit used for removing the ripples is called Filter circuit.

INPUT FILTER: Capacitors are used as filter. The ripples from the DC voltage are removed and pure DC voltage is obtained. And also these capacitors are used to reduce the harmonics of the input voltage. The primary action performed by capacitor is charging and discharging. It charges in

20

positive half cycle of the AC voltage and it will discharge in negative half cycle. So it allows only AC voltage and does not allow the DC voltage. This filter is fixed before the regulator. Thus the output is free from ripples.

5.5

REGULATOR UNIT:

7805 REGULATOR Regulator regulates the output voltage to be always constant. The output voltage is maintained irrespective of the fluctuations in the input AC voltage. As and then the AC voltage changes, the DC voltage also changes. Thus to avoid this Regulators are used. Also when the internal resistance of the power supply is greater than 30 ohms, the output gets affected. Thus this can be successfully reduced here. The regulators are mainly classified for low voltage and for high voltage. Further they can also be classified as: 1) Positive regulator Input pin Ground pin Output pin

It regulates the positive voltage. 2) Negative regulator

20

Ground pin Input pin Output pin

It regulates the negative voltage. OUTPUT FILTER: The Filter circuit is often fixed after the Regulator circuit. Capacitor is most often used as filter. The principle of the capacitor is to charge and discharge. It charges during the positive half cycle of the AC voltage and discharges during the negative half cycle. So it allows only AC voltage and does not allow the DC voltage. This filter is fixed after the Regulator circuit to filter any of the possibly found ripples in the output received finally. Here we used 0.1F capacitor. The output at this stage is 5V and is given to the Microcontroller.

5.6

CAN CONTROLLER:

Description:

20

Microchip Technologys MCP2515 is a stand-alone Controller Area Network (CAN) controller that implements the CAN specification, version 2.0B. It is capable of transmitting and receiving both standard and extended data and remote frames. The MCP2515 has two acceptance masks and six acceptance filters that are used to filter out unwanted messages, thereby reducing the host MCUs overhead. The MCP2515 interfaces with microcontrollers (MCUs) via an industry standard Serial Peripheral Interface (SPI). Features: Implements CAN V2.0B at 1 Mb/s: - 0 8 byte length in the data field
Three transmit buffers with prioritization and abort Features

Interrupt output pin with selectable enables DEVICE OVERVIEW: The MCP2515 is a stand-alone CAN controller developed to simplify applications that require interfacing with a CAN bus. A simple block diagram of the MCP2515 is shown in Figure below. The device consists of three main blocks: 1. The CAN module, which includes the CAN protocol engine, masks, filters, transmit and receive buffers. 2. The control logic and registers that are used to configure the device and its operation. 3. The SPI protocol block.

20

CAN Module The CAN module handles all functions for receiving and transmitting messages on the CAN bus. Messages are transmitted by first loading the appropriate message buffer and control registers. Transmission is initiated by using control register bits via the SPI interface or by using the transmit enable pins. Status and errors can be checked by reading the appropriate registers. Any message detected on the CAN bus is checked for errors and then matched against the user defined filters to see if it should be moved into one of the two receive buffers. Control Logic The control logic block controls the setup and operation of the MCP2515 by interfacing to the other blocks in order to pass information and control. Interrupt pins are provided to allow greater system flexibility. There is one multi-purpose interrupt pin (as well as specific interrupt pins) for each of the receive registers that can be used to indicate a valid message has been received and loaded into one of the receive buffers. Use of the specific interrupt pins is optional. The general purpose interrupts 20

pin, as well as status registers (accessed via the SPI interface), can also be used to determine when a valid message has been received. Additionally, there are three pins available to initiate immediate transmission of a message that has been loaded into one of the three transmit registers. Use of these pins is optional, as initiating message transmissions can also be accomplished by utilizing control registers, accessed via the SPI interface. SPI Protocol Block The MCU interfaces to the device via the SPI interface. Writing to, and reading from, all registers is accomplished using standard SPI read and write commands, in addition to specialized SPI commands. 5.7 EXAMPLE SYSTEM IMPLEMENTATION

5.8

HIGH-SPEED CAN TRANSCEIVER

20

DEVICE OVERVIEW The MCP2551 is a high-speed CAN, fault-tolerant device that serves as the interface between a CAN protocol controller and the physical bus. The MCP2551 provides differential transmit and receive capability for the CAN protocol controller and is fully compatible with the ISO-11898 standard, including 24V requirements. It will operate at speeds of up to 1 Mb/s. Typically, each node in a CAN system must have a device to convert the digital signals generated by a CAN controller to signals suitable for transmission over the bus cabling (differential output). It also provides a buffer between the CAN controller and the high-voltage spikes that can be generated on the CAN bus by outside sources (EMI, ESD, electrical transients, etc.). Transmitter Function The CAN bus has two states: Dominant and Recessive. A dominant state occurs when the differential voltage between CANH and CANL is greater than a defined voltage (e.g.,1.2V). A recessive state occurs when the differential voltage is less than a defined voltage (typically 0V). The dominant and recessive states correspond to the low and high state of the TXD input pin, respectively. However, a dominant state initiated by another CAN node will override a recessive state on the CAN bus.

MAXIMUM NUMBER OF NODES 20

The MCP2551 CAN outputs will drive a minimum load of 45, allowing a maximum of 112 nodes to be connected (given a minimum differential input resistance of 20 k and a nominal termination resistor value of 120).

Receiver Function The RXD output pin reflects the differential bus voltage between CANH and CANL. The low and high states of the RXD output pin correspond to the dominant and recessive states of the CAN bus, respectively.

CHAPTER 6

SOFTWARE INFORMATION
20

6.1
6.2

SOFTWARE TOOLS:
HI-Tech PIC C Compiler MPLAB Protel Propic INTRODUCTION TO EMBEDDED C: Ex: Hitec c, Keil c HI-TECH Software makes industrial-strength software development tools and C compilers

that help software developers write compact, efficient embedded processor code. For over two decades HI-TECH Software has delivered the industry's most reliable embedded software development tools and compilers for writing efficient and compact code to run on the most popular embedded processors. Used by tens of thousands of customers including General Motors, Whirlpool, Qualcomm, John Deere and many others, HI-TECH's reliable

20

development tools and C compilers, combined with world-class support have helped serious embedded software programmers to create hundreds of breakthrough new solutions. Whichever embedded processor family you are targeting with your software, whether it is the ARM, PICC or 8051 series, HI-TECH tools and C compilers can help you write better code and bring it to market faster. HI-TECH PICC is a high-performance C compiler for the Microchip PIC micro 10/12/14/16/17 series of microcontrollers. HI-TECH PICC is an industrial-strength ANSI C compiler - not a subset implementation like some other PIC compilers. The PICC compiler implements full ISO/ANSI C, with the exception of recursion. All data types are supported including 24 and 32 bit IEEE standard floating point. HI-TECH PICC makes full use of specific PIC features and using an intelligent optimizer, can generate high-quality code easily rivaling hand-written assembler. Automatic handling of page and bank selection frees the programmer from the trivial details of assembler code.

6.3

EMBEDDED C COMPILER ANSI C - full featured and portable Reliable - mature, field-proven technology Multiple C optimization levels An optimizing assembler Full linker, with overlaying of local variables to minimize RAM usage Comprehensive C library with all source code provided 20

Includes support for 24-bit and 32-bit IEEE floating point and 32-bit long data types Mixed C and assembler programming Unlimited number of source files Listings showing generated assembler Compatible - integrates into the MPLAB development tools IDE, MPLAB ICD and most 3rd-party

6.4

Runs on multiple platforms: Windows, Linux, UNIX, Mac OS X, Solaris MPLAB INTEGRATION

MPLAB Integrated Development Environment (IDE) is a free, integrated toolset for the development of embedded applications employing Microchip's PIC micro and dsPIC microcontrollers. MPLAB IDE runs as a 32-bit application on MS Windows, is easy to use and includes a host of free software components for fast application development and super-charged debugging. MPLAB IDE also serves as a single, unified graphical user interface for additional Microchip and third party software and hardware development tools. Moving between tools is a snap, and upgrading from the free simulator to MPLAB ICD 2 or the MPLAB ICE emulator is done in a flash because MPLAB IDE has the same user interface for all tools. Choose MPLAB C18, the highly optimized compiler for the PIC18 series microcontrollers, or try the newest Microchip's language tools compiler, MPLAB C30, targeted at the high performance PIC24 and dsPIC digital signal controllers. Or, use one of the many products from third party language tools vendors. They integrate into MPLAB IDE to function transparently from the MPLAB project manager, editor and compiler.

20

6.5

EMBEDDED DEVELOPMENT ENVIRONMENT This environment allows you to manage all of your PIC projects. You can compile,

assemble and link your embedded application with a single step. Optionally, the compiler may be run directly from the command line, allowing you to compile, assemble and link using one command. This enables the compiler to be integrated into third party development environments, such as Microchip's MPLAB IDE.

6.6

EMBEDDED SYSTEM TOOLS

ASSEMBLER An assembler is a computer program for translating assembly language essentially, a mnemonic representation of machine language into object code. A cross assembler (see cross compiler) produces code for one type of processor, but runs on another. The computational step where an assembler is run is known as assembly time. Translating assembly instruction mnemonics into opcodes, assemblers provide the ability to use symbolic names for memory locations (saving tedious calculations and manually updating addresses when a program is slightly modified), and macro facilities for performing textual substitution typically used to encode common short sequences of instructions to run inline instead of in a subroutine. Assemblers are far simpler to write than compilers for high-level languages.

ASSEMBLY LANGUAGE HAS SEVERAL BENEFITS Speed: Assembly language programs are generally the fastest programs around. 20

Space: Assembly language programs are often the smallest. Capability: You can do things in assembly which are difficult or impossible in High level languages. Knowledge: Your knowledge of assembly language will help you write better programs, even when using High level languages. An example of an assembler we use in our project is RAD 51. SIMULATOR Simulator is a machine that simulates an environment for the purpose of training or research. We use a UMPS simulator for this purpose in our project.

COMPILER A compiler is a program that reads a program in one language, the source language and translates into an equivalent program in another language, the target language. The translation process should also report the presence of errors in the source program. Target Source Program Compiler Program

Error Messages

20

There are two parts of compilation. The analysis part breaks up the source program into constant piece and creates an intermediate representation of the source program. The synthesis part constructs the desired target program from the intermediate representation.

6.7

COUSINS OF THE COMPILER ARE: 1. Preprocessor. 2. Assembler. 3. Loader and Link-editor.

A naive approach to that front end might run the phases serially. 1. Lexical analyzer takes the source program as an input and produces a long string of

tokens. 2. Syntax Analyzer takes an out of lexical analyzer and produces a large tree.

Semantic analyzer takes the output of syntax analyzer and produces another tree. Similarly, intermediate code generator takes a tree as an input produced by semantic analyzer and produces intermediate code. PHASES OF COMPILER: The compiler has a number of phases plus symbol table manager and an error handler. Input Source Program Lexical

20

Analyzer Syntax Analyzer Symbol Semantic Table Analyzer Manager Intermediate Code Generator Code Optimizer Code Generator Out Target Handler Error

Program 6.8 FABRICATION DETAILS The fabrication of one demonstration unit is carried out in the following sequence. Finalizing the total circuit diagram, listing out the components and sources of procurement. Procuring the components, testing the components and screening the components. 20

Making layout, repairing the interconnection diagram as per the circuit diagram. Assembling the components as per the component layout and circuit diagram and soldering components.

Integrating the total unit, inter-wiring the unit and final testing the unit.

DESIGN OF EMBEDDED SYSTEM Like every other system development design cycle embedded system too have a design cycle. The flow of the system will be like as given below. For any design cycle these will be the implementation steps. From the initial state of the project to the final fabrication the design considerations will be taken like the software consideration and the hardware components, sensor, input and output. The electronics usually uses either a microprocessor or a microcontroller. Some large or old systems use general-purpose mainframe computers or minicomputers. USER INTERFACES User interfaces for embedded systems vary widely, and thus deserve some special comment. User interface is the ultimate aim for an embedded module as to the user to check the output with complete convenience. One standard interface, widely used in embedded systems, uses two buttons (the absolute minimum) to control a menu system (just to be clear, one button should be "next menu entry" the other button should be "select this menu entry"). Another basic trick is to minimize and simplify the type of output. Designs sometimes use a status light for each interface plug, or failure condition, to tell what failed. A cheap variation is to have two light bars with a printed matrix of errors that they select- the user can glue on the labels for the language that he speaks. For example, most small computer printers use lights labeled with

20

stick-on labels that can be printed in any language. In some markets, these are delivered with several sets of labels, so customers can pick the most comfortable language. In many organizations, one person approves the user interface. Often this is a customer, the major distributor or someone directly responsible for selling the system. 6.9 PLATFORM There are many different CPU architectures used in embedded designs such as ARM, MIPS, Coldfire/68k, PowerPC, X86, PIC, 8051, Atmel AVR, H8, SH, V850, FR-V, M32R etc. This in contrast to the desktop computer market, which as of this writing (2003) is limited to just a few competing architectures, mainly the Intel/AMD x86, and the Apple/Motorola/IBM PowerPC, used in the Apple Macintosh. With the growing acceptance of Java in this field, there is a tendency to even further eliminate the dependency on specific CPU/hardware (and OS) requirements. Standard PC/104 is a typical base for small, low-volume embedded and ruggedized system design. These often use DOS, Linux or an embedded real-time operating system such as QNX or Inferno. A common configuration for very-high-volume embedded systems is the system on a chip, an application-specific integrated circuit, for which the CPU was purchased as intellectual property to add to the IC's design. A related common scheme is to use a field-programmable gate array, and program it with all the logic, including the CPU. Most modern FPGAs are designed for this purpose. TOOLS

20

Like typical computer programmers, embedded system designers use compilers, assemblers, and debuggers to develop embedded system software. However, they also use a few tools that are unfamiliar to most programmers. Software tools can come from several sources:

Software companies that specialize in the embedded market. Ported from the GNU software development tools. Sometimes, development tools for a personal computer can be used if the embedded

processor is a close relative to a common PC processor. Embedded system designers also use a few software tools rarely used by typical computer programmers. One common tool is an "in-circuit emulator" (ICE) or, in more modern designs, an embedded debugger. This debugging tool is the fundamental trick used to develop embedded code. It replaces or plugs into the microprocessor, and provides facilities to quickly load and debug experimental code in the system. A small pod usually provides the special electronics to plug into the system. Often a personal computer with special software attaches to the pod to provide the debugging interface. Another common tool is a utility program (often home-grown) to add a checksum or CRC to a program, so it can check its program data before executing it. An embedded programmer that develops software for digital signal processing often has a math workbench such as MathCAD or Mathematica to simulate the mathematics.

20

Less common are utility programs to turn data files into code, so one can include any kind of data in a program. A few projects use Synchronous programming languages for extra reliability or digital signal processing.

6.10

DEBUGGING Debugging is usually performed with an in-circuit emulator, or some type of debugger that

can interrupt the microcontroller's internal microcode. The microcode interrupt lets the debugger operate in hardware in which only the CPU works. The CPU-based debugger can be used to test and debug the electronics of the computer from the viewpoint of the CPU. This feature was pioneered on the PDP-11. As the complexity of embedded systems grows, higher level tools and operating systems are migrating into machinery where it makes sense. For example, cell phones, personal digital assistants and other consumer computers often need significant software that is purchased or provided by a person other than the manufacturer of the electronics. In these systems, an open programming environment such as Linux, OSGi or Embedded Java is required so that the thirdparty software provider can sell to a large market.

6.11

OPERATING SYSTEM Embedded systems often have no operating system, or a specialized embedded operating

system (often a real-time operating system), or the programmer is assigned to port one of these to the new system.

20

BUILT- IN SELF- TEST Most embedded systems have some degree or amount of built-in self-test. There are several basic types. 1. Testing the computer. 2. Test of peripherals. 3. Tests of power. 4. Communication tests. 5. Cabling tests. 6. Rigging tests. 7. Consumables test. 8. Operational test. 9. Safety test.

START UP All embedded systems have start-up code. Usually it disables interrupts, sets up the electronics, tests the computer (RAM, CPU and software), and then starts the application code.

20

Many embedded systems recover from short-term power failures by restarting (without recent selftests). Restart times under a tenth of a second are common.

Many designers have found a few Leds useful to indicate errors (they help troubleshooting). A common scheme is to have the electronics turn on all of the led(s) at reset (thereby proving that power is applied and the Leds themselves work), whereupon the software changes the led pattern as the power-on self test executes. After that, the software may blink the led(s) or set up light patterns during normal operation to indicate program execution progress or errors. This serves to reassure most technicians/engineers and some users. An interesting exception is that on electric power meters and other items on the street, blinking lights are known to attract attention and vandalism.

CHAPTER 7

20

RESULTS & CONCLUSION

7.1

SYSTEM TESTING AND IMPLEMENTATION

7.1.1 SYSTEM TESTING

20

System testing is a critical aspect of Software Quality Assurance and represents the ultimate review of specification, design and coding. Testing is a process of executing a program with the intent of finding an error. A good test is one that has a probability of finding an as yet undiscovered error. The purpose of testing is to identify and correct bugs in the developed system. Nothing is complete without testing. Testing is the vital to the success of the system. In the code testing the logic of the developed system is tested. For this every module of the program is executed to find an error. To perform specification test, the examination of the specifications stating what the program should do and how it should perform under various conditions. Unit testing focuses first on the modules in the proposed system to locate errors. This enables to detect errors in the coding and logic that are contained within that module alone. Those resulting from the interaction between modules are initially avoided. In unit testing step each module has to be checked separately. System testing does not test the software as a whole, but rather than integration of each module in the system. The primary concern is the compatibility of individual modules. One has to find areas where modules have been designed with different specifications of data lengths, type and data element name. Testing and validation are the most important steps after the implementation of the developed system. The system testing is performed to ensure that there are no errors in the implemented system. The software must be executed several times in order to find out the errors in the different modules of the system. Validation refers to the process of using the new software for the developed system in a live environment i.e., new software inside the organization, in order to find out the errors. The validation phase reveals the failures and the bugs in the developed system. It will be come to know about the practical difficulties the system faces when operated in the true environment. By testing the code of the implemented software, the logic of the program can be examined. A specification test is conducted to check whether the specifications stating the program are performing under

20

various conditions. Apart from these tests, there are some special tests conducted which are given below: Peak Load Tests: This determines whether the new system will handle the volume of activities when the system is at the peak of its processing demand. The test has revealed that the new software for the agency is capable of handling the demands at the peak time. Storage Testing: This determines the capacity of the new system to store transaction data on a disk or on other files. The proposed software has the required storage space available, because of the use of a number of hard disks. Performance Time Testing: This test determines the length of the time used by the system to process transaction data. In this phase the software developed Testing is exercising the software to uncover errors and ensure the system meets defined requirements. Testing may be done at 4 levels Unit Level Module Level Integration & System Regression UNIT TESTING A Unit corresponds to a screen /form in the package. Unit testing focuses on verification of the corresponding class or Screen. This testing includes testing of control paths, interfaces, local data structures, logical decisions, boundary conditions, and error handling. Unit testing may use Test Drivers, which are control programs to co-ordinate test case inputs and outputs, and Test stubs, which replace low-level modules. A stub is a dummy subprogram.

7.1.1.1

7.1.1.2

MODULE LEVEL TESTING Module Testing is done using the AT commands on terminal software.

20

7.1.1.3

INTEGRATION & SYSTEM TESTING Integration testing is used to verify the combining of the software module and hardware

modules.

Integration testing addresses the issues associated with the dual problems of

verification and program construction. System testing is used to verify, whether the developed system meets the requirements.

7.1.1.4 REGRESSION TESTING Each modification in hardware impacts unmodified areas, which results serious injuries to that hardware. So the process of re-testing for rectification of errors due to modification is known as regression testing. Installation and Delivery: Installation and Delivery is the process of delivering the developed and tested hardware and software to the customer. Refer the support procedures. Acceptance and Project Closure: Acceptance is the part of the project by which the customer accepts the product. This will be done as per the Project Closure, once the customer accepts the product, closure of the project is started. This includes metrics collection, PCD, etc. ADVANTAGES:
1. 2. 3. 4.

Easy to install, light weight. Low cost and low power consumption by the equipment. Fast response to identify the users information from the database. CAN bus we extend up to maximum 6km depends up on the data rate.

DISADVANTAGES:
1.

We should put the CAN bus (cable) to the n number of class rooms.

7.2

APPLICATIONS:

20

The entire project idea is to develop a multipurpose CAN bus network The system can be used at industries for the same purpose as College campus Networked Healthcare applications - citizen health ID cards, physician ID cards

verification Networked Payment applications ex: milk dispenser units

7.3

CONCLUSION:

The current application developed is in accordance with the request that has been provided by the organization. On regarding the future enhancement, the application can further expanded in accordance with changing scenario. Since the change in testing and user needs arises frequently in certain short intervals of time, the application can be further upgraded to meet the requirements that may arise in the far or near future. With regarding to the needs that arises, more and more features can be included by adding it as separate modules and integrate it with the existing system. The Embedded concept, whose main advantage is modularity, which helps us in adding the future needs as add-on modules to work with the main system which can be done effortlessly instead of rewriting or modifying the entire application. So the scope of future enhancement is absolutely clear with the concept that is incorporated in the today that was made used to build the application.

CHAPTER 8

20

BIBLIOGRAPHY
BIBLIOGRAPHY:

Customizing and programming your PIC microcontroller- Myke Predcko C programming for embedded systems- Kirk Zurell Teach yourself electronics and electricity- Stan Giblisco

CHAPTER 9

20

APPENDIX-A

APPENDIX-A

20

COMPONENTS USED
1. Step Down Transformer 2. Diodes 3. Capacitors 4. Regulators 5. Light Emitting Diodes 6. Smartcard modem 7. PIC microcontroller

:( 230 /12V) 3 No. :( 1N4007) 12 No. : 1000F 3 No., 22pF- 6 Nos. : 7805 3 No., 7812 2No. : LED`s 6Nos. : 1 No. : 16f877A 3 Nos. : MCP2515 3 Nos. : MCP2551 3 Nos. : 20MHz 6Nos. : 10 K- 1 Nos., 1 K 1Nos., : 1No. : Male connector with cable

8. CAN Controller 9. CAN transreceiver


10. Crystal Oscillator 11. Resistors

12. MAX232
13. RS232

CHAPTER 10

20

APPENDIX-B

APPENDIX-B /********* PROMOTING CAN 2.0 FOR COLLEGE CAMPUS Coding *******/

CODING: HOD room node 1

20

#include<pic.h> #include"SPI.c" #include"MCP2515.c" #include"LCD_16x2.c" //----------------------------------------------------------// Function prototypes //----------------------------------------------------------void InitPICmicro(void); void Delay_ms(unsigned char num_ms); void RTS(char TxDLC, char TxBFByt, char Txdata, char RTS_BF); void smart_cmd(const char * s); void SM_Verif_Att(); write_eeprom(unsigned char add, unsigned int data); void ReadEEPROM_Attendance(char regcount); void dispname(unsigned char ID); //------------------------------------------------------------------// Globals //------------------------------------------------------------------unsigned char gRXFlag = 0,gSampleFlag = 0,CAN_Dat_Rx,CAN_Dat_Rx1,CAN_Dat_Rx2,sec,min,mill_count,spkout,cnt; #define BUT1 RB4 #define BUT2 RB5 //----------------------------------------------------------// ISR //----------------------------------------------------------void interrupt ISR(void) { if(INTF){ gRXFlag = 1; INTF = 0; } if(SSPIF){ // Clear interrupt flag SSPIF = 0; } if(TMR1IF){ mill_count++; if(mill_count>=25) { mill_count=0; // sec++; // if(sec>59){ sec=0; min++; // if(min>2){ if(! gSampleFlag)gSampleFlag = 1; } // } } TMR1IF = 0; } } //-----------------------------------------------------------

20

// main() //----------------------------------------------------------void main(void) { unsigned int CAN_Dat=0,systx;//,cancnt=0; InitPICmicro(); can_init(); lcd_clear(); GIE = 1; do {

/***************** Major programe *******************/ lcd_move(0,0); lcd_puts("HOD_R CAN N1 "); lcd_move(1,0); lcd_putn(CAN_Dat_Rx1); lcd_move(1,6); lcd_putn(CAN_Dat_Rx2); if(BUT1) { while(BUT1); CAN_Dat='+'; } if(BUT2) { while(BUT2); CAN_Dat='-'; } if(systx==1){ TXREG=2+0x30; while(!TRMT);systx=0;} if(systx==2){ TXREG=1+0x30; while(!TRMT);systx=0;} /******************* CAN Loops *******************/ if(gRXFlag) { can_peek_message(); CAN_Dat_Rx = can_rx_byte();INTF=0; if(CAN_Dat_Rx == 'a') { DelayMs(100); can_peek_message(); systx=CAN_Dat_Rx1=can_rx_byte(); } if(CAN_Dat_Rx == 'b') { DelayMs(100); can_peek_message(); CAN_Dat_Rx2=can_rx_byte(); } gRXFlag = 0; }

20

if(CAN_Dat) { RTS(TXB0DLC, TXB0D0, CAN_Dat, CAN_RTS_TXB0); CAN_Dat=0; } }while(1); } //----------------------------------------------------------// InitPIC() //----------------------------------------------------------void InitPICmicro() { //Configure I/O ADCON1 = 0x06; TRISB = 0x21; TRISC7 = 1; TRISC6 = 0; spi_init(); spi_disable_devices(); lcd_init(); SPBRG=129; BRGH=1; RCSTA=0X90; TXSTA=0X24; RCIF=0; TMR1L=0X17; TMR1H=0XFC; T1CON=0X01; TMR1IF=0; //Interrupts INTEDG = 0; INTE = 1; TMR1IE = 1; PEIE = 1; DelayMs(10); // INT on falling edge. // Enable INT pin // Timer 1 // Enable unmasked peripheral INTs //Pins are digital

} //---------------------------------------------------------------------------// RTS(buffer) // buffer = CAN_RTS_TXBn; where 'n' = 0, 1, 2 //TXB0DLC, TXB0D0, CANData, CAN_RTS_TXB0 //---------------------------------------------------------------------------void RTS(char TxDLC, char TxBFByt, char Txdata, char RTS_BF) { can_init_buffer(); can_load_byte(TxBFByt, Txdata); can_tx_buffer(TxDLC,RTS_BF); return; }

20

/******************* END OF CODING ****************************/

CODING: Class room node 2


#include<pic.h> #include"SPI.c" #include"MCP2515.c" #include"LCD_16x2.c" //----------------------------------------------------------// Function prototypes //----------------------------------------------------------void InitPICmicro(void); void Delay_ms(unsigned char num_ms); void RTS(char TxDLC, char TxBFByt, char Txdata, char RTS_BF); void smart_cmd(const char * s); void SM_Verif_Att(); write_eeprom(unsigned char add, unsigned int data); void ReadEEPROM_Attendance(char regcount); void dispname(unsigned char ID); //------------------------------------------------------------------// Globals //------------------------------------------------------------------unsigned char Rec_ctl[12]; bank2 unsigned char gRXFlag = 0,gSampleFlag = 0,stdcount,sec,min,mill_count,check; bank3 unsigned char ArrstfID[5],RX1,arc,smart_stat,smart_ID,stfID,stfIDeeadd,spkout; #define keyok RB7 //----------------------------------------------------------// ISR //----------------------------------------------------------unsigned interrupt isr(void) { if(INTF){ gRXFlag = 1; INTF = 0; } if(SSPIF){ // Clear interrupt flag SSPIF = 0; } if(RCIF==1){ RCIF=0; RX1=RCREG; if(arc<=12) { Rec_ctl[arc]=RX1;

20

} if(TMR1IF){ }

arc++; if(arc==13) { arc=0; }

mill_count++; if(mill_count>=25) { mill_count=0; sec++; if(sec>59){ sec=0; min++; if(min>1){min=0; if(! gSampleFlag)gSampleFlag = 1; } } } TMR1IF = 0; } } //----------------------------------------------------------// main() //----------------------------------------------------------void main(void) { unsigned int CAN_Dat=0; InitPICmicro(); can_init(); GIE=1; arc=0; smart_cmd("#0206!"); DelayMs(250); lcd_clear(); { do /***************** Major programe *******************/ lcd_putn(smart_stat); lcd_move(0,0); lcd_puts("CLASS_R1 CAN N2 "); lcd_move(1,0); lcd_puts("Press Menu Key "); if(keyok) { while(keyok); DelayMs(25); SM_Verif_Att(); lcd_clear(); } if(spkout=='+') {

20

RB2=1; DelayMs(250); RB2=spkout=0;

/******************CAN Loops*********************/ if(gRXFlag) { can_peek_message(); spkout = can_rx_byte(); gRXFlag = 0; } if(stdcount) { RTS(TXB0DLC, TXB0D0, 'a', CAN_RTS_TXB0); DelayMs(100); CAN_Dat = stfID; RTS(TXB0DLC, TXB0D0, CAN_Dat, CAN_RTS_TXB0); stdcount=gSampleFlag = 0; } }while(1); } //----------------------------------------------------------// InitPIC() //----------------------------------------------------------void InitPICmicro() { //Configure I/O TRISB = 0xF1; TRISC7 = 1; TRISC6 = 0; ADCON1 = 0x06; //Pins are digital spi_init(); spi_disable_devices(); lcd_init(); keyok=0; SPBRG=129; BRGH=1; RCSTA=0X90; TXSTA=0X24; RCIF=0; TMR1L=0X17; TMR1H=0XFC; T1CON=0X01; TMR1IF=0; //Interrupts INTEDG = 0; INTE = 1; TMR1IE = 1; RCIE=1; PEIE = 1; // INT on falling edge. // Enable INT pin // Timer 1 // Enable unmasked peripheral INTs

20

DelayMs(10); } //---------------------------------------------------------------------------// Delay_ms() // Tcy = 1 us // Tcy X 1000 = 1 ms // FFFFh - 3E8h (1000d) = FC17h // For(){} loop is in 1 ms increments //---------------------------------------------------------------------------/*void Delay_ms(unsigned char num_ms) { unsigned char n; TMR1H = 0xFC; TMR1L = 0x17; TMR1ON = 1; //Start timer for(n = 0; n < num_ms; n++) { while(!TMR1IF); //Wait for timer flag TMR1IF = 0; //Clear flag TMR1H = 0xFC; TMR1L = 0x17; } } TMR1ON = 0; //Stop timer

*/ //---------------------------------------------------------------------------// RTS(buffer) // buffer = CAN_RTS_TXBn; where 'n' = 0, 1, 2 //TXB0DLC, TXB0D0, CANData, CAN_RTS_TXB0 //---------------------------------------------------------------------------void RTS(char TxDLC, char TxBFByt, char Txdata, char RTS_BF) { can_init_buffer(); can_load_byte(TxBFByt, Txdata); can_tx_buffer(TxDLC,RTS_BF); return; } /***************************************************************************/ void smart_cmd(const char * s) { while(*s) { TXREG=*s++; while(!TRMT); } }

20

write_eeprom(unsigned char add, unsigned int data) { EEADR=add; EEDATA=data; EEPGD = 0; WREN=1; GIE=0; EECON2=0X55; EECON2=0XAA; WR=1; while(WR); GIE=1; WREN=0; } void ReadEEPROM_Attendance(char regcount) { char i; for(i=0;i<=regcount;i++) { EEADR = i; EEPGD = 0; RD=1; ArrstfID[i]=EEDATA; } } void SM_Verif_Att() { lcd_clear(); lcd_move(0,0); lcd_puts("Insert Smrt Card"); DelayMs(250); DelayMs(250); DelayMs(250); DelayMs(250); DelayMs(250); DelayMs(250); DelayMs(250); arc=0; smart_cmd("#0206!"); DelayMs(250); arc=0; smart_cmd("#01!"); DelayMs(250); smart_stat = ((Rec_ctl[1]-0x30)*10)+(Rec_ctl[2]-0x30); lcd_move(1,14); lcd_putn(smart_stat); DelayMs(250); if(smart_stat==80)

20

Rec_ctl[1]=Rec_ctl[2]=0; lcd_move(0,0); lcd_puts("Smrt Card Presnt "); DelayMs(250); arc=0; smart_cmd("#0206!"); DelayMs(250); arc=0; smart_cmd("#10002001!"); DelayMs(250); smart_ID=(Rec_ctl[10]-0x30); lcd_move(1,14); lcd_putn(smart_ID); DelayMs(250); if(smart_ID == 1 || 2) { stfID=smart_ID; } else stfID=99; if(smart_ID==stfID) { if(stfID==1)stfIDeeadd=0; if(stfID==2)stfIDeeadd=1;

write_eeprom(stfIDeeadd,stfID); RB3=1; lcd_move(0,0); lcd_puts("Atnce Scfuly Ent"); dispname(stfID); DelayMs(250); DelayMs(250); RB3=0; DelayMs(250); DelayMs(250); stdcount++;

} else {

RB3=1; lcd_clear(); lcd_move(0,0); lcd_puts("SmID&Class MisMat"); DelayMs(250); DelayMs(250); DelayMs(250); DelayMs(250); DelayMs(250);

20

DelayMs(250); RB3=0; } else { }

Rec_ctl[1]=Rec_ctl[2]=0; lcd_move(0,0); lcd_puts("Smrt Card Absent"); lcd_move(1,0); lcd_puts("Insert Smrt Card"); DelayMs(250); DelayMs(250); } } void dispname(unsigned char ID) { lcd_move(0,0); if(ID==1) { lcd_move(0,0); lcd_puts(" GRIET "); lcd_move(1,0); lcd_puts("Dsg:LECT,Dpt:ECE"); DelayMs(250); } if(ID==2) { lcd_move(0,0); lcd_puts("Mr.BALRAJ "); lcd_move(1,0); lcd_puts("Dsg:STUD,Dpt:ECE"); DelayMs(250); } }

/***************** END OF CODING *****************************/

CODING: Class room node3


#include<pic.h> #include"SPI.c" #include"MCP2515.c" #include"LCD_16x2.c" //----------------------------------------------------------// Function prototypes //----------------------------------------------------------void InitPICmicro(void);

20

void Delay_ms(unsigned char num_ms); void RTS(char TxDLC, char TxBFByt, char Txdata, char RTS_BF); void smart_cmd(const char * s); void SM_Verif_Att(); write_eeprom(unsigned char add, unsigned int data); void ReadEEPROM_Attendance(char regcount); void dispname(unsigned char ID); //------------------------------------------------------------------// Globals //------------------------------------------------------------------unsigned char gRXFlag = 0,gSampleFlag = 0,sec,min,mill_count,spkout,cnt; #define IR1 RB7 #define IR2 RB6 //----------------------------------------------------------// ISR //----------------------------------------------------------void interrupt ISR(void) { if(INTF){ gRXFlag = 1; INTF = 0; } if(SSPIF){ // Clear interrupt flag SSPIF = 0; } if(TMR1IF){ mill_count++; if(mill_count>=25) { mill_count=0; sec++; if(sec>59){ sec=0; min++; if(min>1){min=0; if(! gSampleFlag)gSampleFlag = 1; } } } TMR1IF = 0; } } //----------------------------------------------------------// main() //----------------------------------------------------------void main(void) { unsigned int CAN_Dat=0; InitPICmicro(); DelayMs(2); //Wait for MCP2515 to come out of reset can_init(); lcd_clear(); GIE = 1;

20

do { /***************** Major programe *******************/ lcd_move(0,0); lcd_puts("CLASS_R2 CAN N3 "); lcd_move(1,0); lcd_puts("COUNT:"); lcd_putn(cnt); if(spkout=='-') { RB2=1; DelayMs(250); RB2=spkout=0; } if(IR1) { cnt++; DelayMs(250); DelayMs(250); // DelayMs(250); } if(cnt>=1) { if(IR2) { cnt--; DelayMs(250); DelayMs(250); } if(cnt>99 || cnt<=0) { cnt=0; } /******************* CAN Loops *******************/ if(gRXFlag) { can_peek_message(); spkout = can_rx_byte(); gRXFlag = 0; } if(cnt!=CAN_Dat) { RTS(TXB0DLC, TXB0D0, 'b', CAN_RTS_TXB0); DelayMs(100); CAN_Dat=cnt; RTS(TXB0DLC, TXB0D0, CAN_Dat, CAN_RTS_TXB0); gSampleFlag=0; } }while(1); } //----------------------------------------------------------// InitPIC() //----------------------------------------------------------void InitPICmicro()

20

//Configure I/O ADCON1 = 0x06; TRISB = 0xC1; spi_init(); spi_disable_devices(); lcd_init(); TMR1L=0X17; TMR1H=0XFC; T1CON=0X01; TMR1IF=0; //Interrupts INTEDG = 0; INTE = 1; TMR1IE = 1; PEIE = 1; DelayMs(10); // INT on falling edge. // Enable INT pin // Timer 1 // Enable unmasked peripheral INTs //Pins are digital

} //---------------------------------------------------------------------------// RTS(buffer) // buffer = CAN_RTS_TXBn; where 'n' = 0, 1, 2 //TXB0DLC, TXB0D0, CANData, CAN_RTS_TXB0 //---------------------------------------------------------------------------void RTS(char TxDLC, char TxBFByt, char Txdata, char RTS_BF) { can_init_buffer (); can_load_byte (TxBFByt, Txdata); can_tx_buffer (TxDLC,RTS_BF); return; }

/**************************** END OF CODING ********************************/

20

Das könnte Ihnen auch gefallen