You are on page 1of 31

SUMMER TRAINING REPORT 0n EMBEDDED SYSTEMS BASED ON PIC MICROCONTROLLER Submitted in partial fulfillment of the requirements for the

award of degree of Bachelor of Technology in Electronics and Communication Enginnering


Guide: Mr Naveen Kumar Submitted by: KAPIL 1508177 EC2

DEPARTMENT OF ELECTRONICS AND COMMUNICATION N.C COLLEGE OF ENGINEERING (permanently affiliated to KURUKSHETRA UNIVERSITY) ISRANA,PANIPAT

ACKNOWLEDGEMENT

I would like to articulate our profound gratitude and indebtedness to our project guide NAVEEN KUMAR; EMTECH FOUNDATION, who has always been a constant motivation and guiding factor throughout the project time in and out as well. It has been a great pleasure for us to get an opportunity to work under him and complete the project successfully. An undertaking of this nature could never have been attempted with our reference to andinspiration from the works of others whose details are mentioned in references section. I acknowledge my indebtedness to all of them. Last but not the least, my sincere thanks to all of my friends who have patiently extended all sorts of help for accomplishing this undertaking.

KAPIL (1508177) EC2

CONTENTS
Chapter 1 05
1.1 Introduction........ . 05 1.2 Objectives..... 05 1.3 Main Contributers......05 1.3.1 Robhatah Robotic Solution Pvt Ltd ....05 1.3.2 Jiyanjani Technologies Pvt Ltd08 1.3.3 Simpal technologies.....09 1.3.4 Aspirant Infotech Pvt Ltd.10 Chapter 2.......11 Training. . .......11 2.1 Abstract... ....11 2.2 Microchip PIC Microcontroller .. ...12 2.2.1 Introduction....12 2.2.2 Software Used....17 2.2.3 Interfacing..18 2.2.3.1 LED...18 2.2.3.2 Keypad Matrix....19 2.2.3.3 Liquid Crystal Display....20 2.1.3.4 Seven Segment Display..21

2.2.4 Timers/counters.21 2.2.5 ADC..22 2.2.6 USART.25 2.2.7 EEPROM Memory...26 3. PROJECT ..28 3.1 INTRODUCTION ..28 3.2 COMPONENTS USED...28 3.3 BLOCK DIAGRAM ...28 3.4 WORKING .29 3.4.1 LDR 29 3.4.2 ADC 30 3.5 APPLICATIONS .31

Chapter 1 :1.1 Introduction EMTECH Foundation is an ISO 9001:2001 certified Embedded Systems/ Microcontroller Training and Consultancy Company, powered by a passion to provide the best of services in the industry. Being In IT business for a couple of years, today Emtech is a leading solution provider for embedded system designs across the globe. 1.1 Obectives As Competitive scenarios, across the globe. Providing students a Technical Platform to become a industry ready professionals.We, Engineering the Engineers, Emtech Foundation Igniting minds. Our vision is to setup the best Robotic Design Center in India. We aim to ensure that our clients get the best of embedded solutions, with dedicated support from the talented and dedicated team of software professionals to the best of their needs. To meet the expectations of industry clients as well as students.

Fig 1.1 Microchip logo

Fig 1.2 Atmel logo

1.3 Main Contributers


1.3.1 ROBHATAH PVT LTD

It is a Private Limited in robotic technology consulting and consumer product manufacturing company founded in Singapore in the year 2004. Our technical team consists of the celebrated pioneers of international Robotic Research. Dr. Prahlad Vadakkepat, Director and chief mentor of Robhatah is also the general secretary of FIRA and holds prestigious positions in many Associations like IEEE, IETE etc. We provide robotics technology licenses, new concept and product development and consultancy services to our clients. Robhatahs two main capability groups, Corporate Consulting and Consumer Product Development, function strategically to exploit the synergies between them. The Consumer Product Development team develops innovative robotic solutions that address challenges in day-to-day life. This group focuses on delivering products that strongly appeal to customers by striking the right balance between product value and product cost. The Consulting team provides robotic research consultancy services to clients who have unique robotic needs, like health care providers, industries handling hazardous materials and the military.

Humanoid

manus

Genus

The MaNUS and GeNUS humanoid robots are capable of walking on roug h terrains an d to climb

Robot Soccer
Initiated and developed the complete robotic soccer system as a test bed for cooperative robotic research. The robot soccer teams developed has won two awards: 1. Second prize (2nd) in FIRA Robot World Cup Beijing 2001 2. Second prize in Singapore Robotic Games 2002.
.

Bipedal
Legged robots have distinct advantages over their wheeled counterparts when working in arbitrarily complex terrains they can generally cross obstacles more easily, and exhibit greater adaptability. These features are important in several applications Bipedal such as exploration, maintenance, intervention and service. These application domains are beyond the realm of traditional manufacturing robots.

Revobot
The Revobot educational kit Robhatah Robotic Solutions professionals and hobbyists their foray into the exciting artificial intelligence.
Revobot

is the one of its kind from intended to facilitate students, with a concrete platform for world of robotics and

Vacuum Cleaner

vacuum cleaner

A robotic vacuum cleaner is a compact mechanical device that does not require a human to run it. They are small, round, and move automatically to pick up dirt. Advances in microchip technology have created these lightweight, cordless vacuums that rely on infrared technology to help them avoid bumping into walls and to navigate around furniture. The round robotic vacuum is protected by a rubber bumper around its circumference. Some models come with a wallmounted storage bracket.

1.3.2 JIYANJANI TECHNOLOGIES PVT. LTD


Jiyanjani Technologies Pvt. Ltd., is well known name for providing PCB Design & Embedded Solutions to R & D division of organization in India. At Jiyanjani we have expertise in providing consulting & solution to various electronics companies. Under the brand of Jiyanjani now we have some other tie ups with world leading solution providers for various types of industries. At Jiyanjani our priority is to build a very strong, mutually-beneficial and long-lasting relationship with our customers. As a part of this philosophy, we provide unparalleled post-sales technical support to our customers till they dont need us.

We have diverse business offers, products and solutions. We are a major player in areas such as Embedded System Designing, PCB Designing & Manufacturing Services, Strategic Electronics, IT etc. with our team of experts located at New Delhi. We offer leading edge technology products and solutions in the advance technology areas.With a strong team of well-trained and experienced engineers, Product Support and Training Division of Jiyanjani Technologies provide pre-sales and post-sales support and training to the wide range of academic and research institutions and corporate clients.

1.3.3 SIMPAL TECHNOLOGIES


Simpaltechnologies is the Authorized Alliance Partner of
Renesas Singapore Region

Embedded projects

1.3.4 ASPIRANT INFOTECH PVT. LTD


Aspirant is a privately held company.Aspirant solely focuses on customers challenges and provide solutions to ensure that our customers are secured enough to handle the external attack or internal sabotage and have maximum productivity. Aspirant with its focus and niche in IT 9

Security arena (for IT Infrastructure & Networks) strives to provide solutions for Privileged Password Management, Remote Vendor Management, Single Sign-On solutions, Internet Access management, Patch and Compliance Management, Eliminate Administrator Rights, Least Privilege Access, Appliance based eMail solutions and IT Helpdesk solutions. Manufacturing, Telecommunications, Banking, Insurance, Finance, Healthcare and Public utilities are our key-sectors. Client-Server, Web Enabling, Network Consultation etc are among the many services we offer. Products:

Aspirant vision

Privileged Password Management: Internet Access Management: Privilege Manager: Security & Compliance: Web Filtering Network Access Control Email Solution Patch & Compliance Mgt Single Sign on Internet Security Appliance

10

CHAPTER 2 MY TRAINING
2.1 ABSTRACT
At Emtech Foundation, I learnt the design and development process in an embedded systems project. My area of study was basics of the EMBEDDED SYSTEM which can be used to give prototype of one of the big working model or can design simple small working model. I studied and worked on Microchips PIC16F877A microcontroller. o Interfacing o Programming o Debugging o Simulation I studied the basic about the PIC I learnt the Design and Development process in the embedded systems. I worked on hardware testing that included: o Path testing o Testing for short circuit o Components testing These were tought to us by the help of MUTIMETER only I studied the PCB designing process. o Design circuit using ORCAD o Pasting the circuit on Copper o Etching process o Drilling o Use of abrasives for cleaning

11

2.2 MICROCHIPS PIC MICROCONTROLLER 2.2.1 Introduction

Microchip Technology (NASDAQ: MCHP) is an American manufacturer of microcontroller, memory and analog semiconductors. The company was founded in 1987 when General Instrument spun off its microelectronics division as a wholly owned subsidiary. Its products include microcontrollers (PICmicro, dsPIC / PIC24, PIC32), Serial EEPROM devices, SerialSRAM devices, KEELOQ devices, radio frequency (RF) devices, thermal, power and battery management analog devices, as well as linear, interface and mixed signal devices. Some of the interface devices include USB, ZigBee/MiWi, Controller Area Network, and Ethernet. In April 2009, Microchip Technology announced the nanoWatt XLP Microcontrollers (With Worlds Lowest Sleep Current). Corporate headquarters is located Arizona andGresham, Oregon. at Chandler, Arizona with wafer fabs in Tempe,

PIC controller

PIC is a family of Harvard architecture microcontrollers made by Microchip Technology, derived from the PIC1640[1] originally developed by General Instrument's Microelectronics Division. The name PIC initially referred to "Programmable Interface Controller". PICs are popular with both industrial developers and hobbyists alike due to their low cost, wide availability, large user base, extensive collection of application notes, availability of low cost or free development tools, and serial programming (and re-programming with flash memory) capability.

12

FEATURES OF THE PIC MICROCONTROLLER :--Harvard Architecture Instruction Pipelining Large Register File Single Cycle Instructions Single Word Instructions Long Word Instructions Reduced Instruction Set Orthogonal Instruction Set

Baseline Core devices These devices feature a 12-bit wide code memory, a 32-byte register file, and a tiny two level deep call stack. They are represented by the PIC10 series, as well as by some PIC12 and PIC16 devices. Baseline devices are available in 6-pin to 40-pin packages. Generally the first 7 to 9 bytes of the register file are special-purpose registers, and the remaining bytes are general purpose RAM. If banked RAM is implemented, the bank number is selected by the high 3 bits of the FSR. This affects register numbers 1631; registers 015 are global and not affected by the bank select bits. Mid-Range core devices These devices feature a 14-bit wide code memory, and an improved 8 level deep call stack. The instruction set differs very little from the baseline devices, but the increased opcode width allows 128 registers and 2048 words of code to be directly addressed. The mid-range core is available in the majority of devices labeled PIC12 and PIC16. The first 32 bytes of the register space are allocated to special-purpose registers; the remaining 96 bytes are used for general-purpose RAM. If banked RAM is used, the high 16 registers (0x700x7F) are global, as are a few of the most important special-purpose registers, including the STATUS register which holds the RAM bank select bits. (The other global registers are FSR

13

and INDF, the low 8 bits of the program counter PCL, the PC high preload register PCLATH, and the master interrupt control register INTCON.) PIC18 High End core devices Microchip introduced the PIC18 architecture in 2000. Unlike the 17 series, it has proven to be very popular, with a large number of device variants presently in manufacture. In contrast to earlier devices, which were more often than not programmed in assembly, C has become the predominant development language .

PIC24 and dsPIC 16-bit microcontrollers In 2001, Microchip introduced the dsPIC series of chips,[7] which entered mass production in late 2004. They are Microchip's first inherently 16-bit microcontrollers. PIC24 devices are designed as general purpose microcontrollers. dsPIC devices include digital signal processingcapabilities in addition. PIC32 32-bit microcontrollers In November 2007 Microchip introduced the new PIC32MX family of 32-bit microcontrollers. The initial device line-up is based on the industry standard MIPS32 M4K Core. The device can be programmed using the Microchip MPLAB C Compiler for PIC32 MCUs, a variant of the GCC compiler. The first 18 models currently in production (PIC32MX3xx and PIC32MX4xx) are pin to pin compatible and share the same peripherals set with the PIC24FxxGA0xx family of (16-bit) devices allowing the use of common libraries, software and hardware tools. The PIC32 architecture brings a number of new features to Microchip portfolio, including:

The highest execution speed 80 MIPS (90+ Dhrystone MIPS @80 MHz) The largest FLASH memory: 512 kByte One instruction per clock cycle execution The first cached processor Allows execution from RAM Full Speed Host/Dual Role and OTG USB capabilities Full JTAG and 2 wire programming and debugging Real-time trace

Variants 14

Within a series, there are still many device variants depending on what hardware resources the chip features.

General purpose I/O pins. Internal clock oscillators. 8/16/32 Bit Timers. Internal EEPROM Memory. Synchronous/Asynchronous Serial Interface USART. MSSP Peripheral for IC and SPI Communications. Capture/Compare and PWM modules. Analog-to-digital converters (up to ~1.0 MHz). USB, Ethernet, CAN interfacing support. External memory interface. Integrated analog RF front ends (PIC16F639, and rfPIC). KEELOQ Rolling code encryption peripheral (encode/decode)

Microchip Programmers

Microchip PICSTART Plus programmer

There are many programmers/debuggers available directly from Microchip. Current Microchip Programmers (as of 1/2010)[15] PICKit 3 (USB interface) PICStart Plus (RS232 serial interface) : intelligent. MPLAB ICD 3 (USB 2.0 interface) MPLAB PM3 (RS232 serial and USB interface) MPLAB REAL ICE (USB 2.0 interface) : ICSP programming only Legacy Microchip Programmers PICKit 2 (USB interface) 15

MPLAB ICD2 (RS232 serial and USB 1.0 interface) : ICSP programming only PICKit 1 (USB interface) PRO MATE II (RS232 serial interface) : intelligent.

In-Circuit Debugging Later model PICs feature an ICD (in-circuit debugging) interface, built into the CPU core. ICD debuggers (MPLAB ICD2 and other third party) can communicate with this interface using three lines. This cheap and simple debugging system comes at a price however, namely limited breakpoint count (1 on older pics 3 on newer PICs), loss of some IO (with the exception of some surface mount 44-pin PICs which have dedicated lines for debugging) and loss of some features of the chip. For small PICs, where the loss of IO caused by this method would be unacceptable, special headers are made which are fitted with PICs that have extra pins specifically for debugging. In-Circuit Emulators Microchip offers three full in circuit emulators: the MPLAB ICE2000 (parallel interface, a USB converter is available); the newer MPLAB ICE4000 (USB 2.0 connection); and most recently, the REAL ICE. All of these ICE tools can be used with the MPLAB IDE for full source-level debugging of code running on the target. The ICE2000 requires emulator modules, and the test hardware must provide a socket which can take either an emulator module, or a production device. The REAL ICE connects directly to production devices which support in-circuit emulation through the PGC/PGD programming interface, or through a high speed connection which uses two more pins.

2.2.2 SOFTWARE USED


MPLAB IDE is a software program that runs on a PC to develop applications for Microchip microcontrollers. It is called an Integrated Development Environment, or IDE, because it

16

provides a single integrated Environment to develop code for embedded microcontrollers. Experienced embedded systems designers may want to skip ahead Section1.7Components of MPLAB IDE. Here in this environment we can develop our program in the EDITOR , can see the o/p as and When required to check out whether the program is going right as required or not and to do this We make use of the SIMULATOR tolls provided to us by IDE eg. LCD,LED,KEYPAD etc.

MPLAB IDE 7.40

MPLAB IDE

2.2.3 INTERFACING

17

2.2.3.1 LED Now the most basic way to detect the o/p is 1 or 0 is that the connect the LED Here we can connect 8 leds to see the output , we can specify the pin to the each LED . As in this example we have connected the LED s to the PORT D (all eight pins) This is very useful feature of the simulator IDE .

.
led intrfacing

2.2.3.2 KEYPAD MATRIX Keys are used to transfer the logic from one side of it to another. Its an 4x4 matrix of keys providing us a total of 16 keys with the use of only 8 pins. We get the maximum hardware utilization out of it. We can have 16 functions out of our 16 keys, can have more by multiplexing it. Here one thing has to be kept in mind that scan lines should be the o/p lines And the return lines should be the i/p lines.This I have used in my project to allow the user to enter the password so this tool helped me a lot in debugging and to confirm that my program is right So it was indespensible for me

18

Keypad matrix

2.2.3.2 LIQUID CRYSTAL DISPLAY This is the most looked after feature as it make the o/p or display very attractive , As it is one of the best GUI (graphic user interface) . A liquid crystal display (LCD) is a flat panel display, electronic visual display, video display that uses the light modulating properties of liquid crystals (LCs). LCs do not emit light directly . They are used in a wide range of applications, including computer monitors, television, instrument panels, aircraft cockpit displays, signage, etc. They are common in consumer devices such as video players, gaming devices, clocks, watches, calculators, and telephones. LCDs have displaced cathode ray tube (CRT) displays in most applications. They are usually more compact, lightweight, portable, less expensive, more reliable, and easier on the eyes.

19

LCD

In it we can select by our choice which pin of PIC to connect as the enable pin And which to connect as the RS pin (to select the DATA or COMMAND ) 2.1.3.5 SEVEN SEGMENT DISPLAY

Seven segment display - This is the cheap GUI and it is easy to handle used in the AC s in our college 20

2.2.4 TIMERS /COUNTERS PIC 16 had three timers: Timer0 Timer1 Timer2 I used them to create a delay of 1ms, 1s and also made them act as a counter for externally generated pulse. 2.2.5 ADC Most important specification of ADCs is the resolution. This specifies how accurately the ADC measures the analog input signals. Common ADCs are 8 bit, 10 bit and 12 bit. For example if the reference voltage(explained latter) of ADC is 0 to 5v then a 8 bit ADC will break it in 256 divisions so it can measure it accurately up to 5/256 v= 19mV approx. While the 10 bit ADC will break the range in 5/1024 = 4.8mV approx. So you can see that the 8 bit ADC can't tell the difference between 1mV and 18mV. The ADC in PIC16 are 10 bit. Other specification include (but not limited to) the sampling rate, that means how fast the ADC can take readings. Microchip claims that pic18f4520's ADC can go as high as 100K samples per second. ADC Terminology Reference Voltage: The reference voltage specifies the minimum and maximum voltage range of analog input. In PIC 18 there are two reference voltage, one is the Vref- and one is Vref+. The Vref- specifies the minimum input voltage of analog input while the Vref+ specifies the maximum. For example if the input signal Vref- is applied to analog input channel then the result of conversion will be 0 and if voltage equal to Vref+ is applied to the input channel the result will be 1023 (max value for 10bit ADC).

Fig2.9: ADC Reference Voltage. The Vref+ and Vref- pins are available in PIN5 and PIN4 of the PIC16F877A chip. So you can connect the reference voltage here. For a simple design the Vref- is GND and Vref+ is Vcc. As this is such a common configuration that the ADC can be set up to use these reference internally. 21

Therefore you do not need to connect these on the external Vref pins, so you can use them for other purpose.

FORMULA FOR THE DIGITAL OUTPUT IS :Digital o/p = {( Vin - Vref- ) / (Vref+ - Vref-)}x1023

ADC Channels: The ADC module is connected to several channels via a multiplexer. The multiplexer can connect the input of the ADC to any of the available channels. This allows you to connect many analog signals to the MCU (say 3 temperature sensors). In PIC18F877A there are 8 analog input channels, they are named AN0, AN1 etc. You can have a look at the pin configuration on the previous page . Acquisition Time: When an specific channel is selected the voltage from that input channel is stored in an internal holding capacitor. It takes some time for the capacitor to get fully charged and become equal to the applied voltage. This time is called acquisition time. Once acquisition time is over the input channel is disconnected from the source and the conversion begin. The acquisition times depends on several factor like the source impedance, Vdd of the system and temperature. You can refer to the page 227 and 228 in the datasheet for details on its calculation. A safe value is 2.45uS, so the delay of this much time should atleast be given. ADC Clock: ADC Requires a clock source to do its conversion, this is called ADC Clock. The time period of the ADC Clock is called TAD. It is also the time required to generate 1 bit of conversion. The ADC requires 11 TAD to do a 10 bit conversion. It can be derived from the CPU clock (called TOSC) by dividing it by a suitable division factor. There are Seven possible option. 2 x TOSC 4 x TOSC 8 x TOSC 16 x TOSC 32 x TOSC 64 x TOSC Internal RC For Correct A/D Conversion, the A/D conversion clock (TAD) must be as short as possible but greater than the minimum TAD . See table 26-25 in PIC16F877A datasheet it is 0.7uS for PIC16FXXXX device .We are running at 4MHz.

22

CONTROL REGISTERS :ADCON0 :-

ADCON1:-

OUTPUT

REGISTERS :-

23

ADC BLOCK DIAGRAM :(from datasheet)

2.2.6 USART- ASYNCHRONOUS TRANSMISSION The Universal Synchronous Asynchronous ReceiverTransmitter (USART) module is one of the two serial I/O modules. (USART is also known as a Serial Communications Interface or SCI.) The USART can be configured as a full-duplex asynchronous system that can communicate with peripheral devices, such as CRT terminals and personal computers. It can also be configured as a half-duplex synchronous system that can communicate with peripheral devices, such as A/D orD/A integrated circuits, serial EEPROMs and so on. The USART module implements additional features, by this we can take in data i.e digital from various serial devices so can interface them with the PIC These are - RFID - GPS Etc.

24

usart
. 2.2.7 EEPROM MEMORY EEPROM (also written E2PROM and pronounced "e-e-prom," "double-e prom" or simply "esquared") stands for Electrically Erasable Programmable Read-Only Memory and is a type of non-volatile memoryused in computers and other electronic devices to store small amounts of data that must be saved when power is removed, e.g., calibration tables or device configuration. When larger amounts of static data are to be stored (such as in USB flash drives) a specific type of EEPROM such as flash memory is more economical than traditional EEPROM devices. EEPROMs are realized as arrays of floating-gate transistors. EEPROM is user-modifiable read-only memory (ROM) that can be erased and reprogrammed (written to) repeatedly through the application of higher than normal electrical voltage generated externally or internally in the case of modern EEPROMs. Unlike EPROM chips, EEPROMs do not need to be removed from the computer to be modified. However, an EEPROM chip has to be erased and reprogrammed in its entirety, not selectively. It also has a limited life - that is, the number of times it can be reprogrammed is limited to tens or hundreds of thousands of times. In an EEPROM that is frequently reprogrammed while the computer is in use, the life of the EEPROM can be an important design consideration. 25

Eeprom memory editor

26

3. PROJECT NAME :- COLOR SENSOR 3.1 :- INTRODUCTION System: way of organizing a task. Embedded : 1. put into a machinery 2. specific purpose 3. controller-based

3.2 COMPONENTS USED :1. Harvard architecture of PIC16F877A 2. 8 bit microcontroller 3. 10 bit ADC 4. 8K ROM 5. 368 Bytes RAM 6. 5 I/O ports ETC. 3.3 BLOCK DIAGRAM :-

LDR UNITS ADC PIC16F877A

DISPLAY UNITS

3.4 WORKING 27

LDR senses the light intensity reflected Sent signal to ADC Compare with pre known value So correspondingly glow that color LED

WORKING OF THE INDIVIDUAL COMPONENTS :3.4.1 LDR(LIGHT DEPENDENT RESISTOR)

CdS Absorbs light & gain energy to jump from valence band to conduction band This generates free e- & thereby, current increases & resistance decreases when li -ght falls.

28

29

FUNCTION OF ADC: SAR ADC 0808 INBUILT 8 Inputs Controlled By 3-Channels 2 SFG: ADCON 0&1 Pcfg decided from datasheet V(D) = [V(in) / V(dd)]*1023

FIGURE:

30

APPLICATIONS: 1. FOOD INDUSTRY 2. IN DIFFENTIATING PACKAGING OF WAFERS. 3. IN SMART CARD READERS 4. AT ENTRY GATE FOR SECURITY

31