You are on page 1of 23

Summer Training Report

on

PIC16F877A
Submitted By: Tanveer Singh 11102003 Paramdeep Singh 11102016

COMPANY PROFILE
Jetking is an organization came into establishment in1947. Jetking is Indias No. 1 Computer Hardware and Networking Institute. Jetking evolved in tune with the changing face of technology. During its 55 years in the field of electronic technology, Jetking has successfully trained thousands of students, preparing them for high paying careers.

Mr. Suresh G. Bharwani is the Chairman and Managing Director of Jetking Infotrain Ltd. Indias leading Computer Hardware and Networking Institute. With the vision to promote and the conviction to deliver the widespread propagation of computer hardware and networking education across the nation, Mr. Bharwani was the first to set up a training institute offering innovative courses in computer hardware in 1990.

MICROCONTROLLERS AND MICROPROCESSORS


A microcontroller differs from a microprocessor in many ways. The first and most important difference is its functionality. In order that the microprocessor may be used, other components such as memory must be added to it. Even though the microprocessors are considered to be powerful computing machines, their weak point is that they are not adjusted to communicating to peripheral equipment. With development in computer technology, newer versions of processing units are coming into existence. Each new unit has some advantages over the previous one which results in replacement of older units. Microprocessors were used in a significantly large number of applications but they were soon replaced in certain fields by the microcontroller.

MICROCONTROLLER ARCHITECTURES
1. Von-Neumann Architecture: It has only one bus which is used for both data transfers and instruction fetches, and therefore data transfers and instruction fetches must be scheduled - they cannot be performed at the same time. 2. Harvard Architecture: It has physically separate signals and storage for code and data memory. It is possible to access program memory and data memory simultaneously.

PIC16F877A MICROCONTROLLER
The PIC16F877 is a microcontroller product from Microchip. It features all the components which modern microcontrollers normally have. For its low price, wide range of application, high quality and easy availability, it is the ideal solution in applications such as the control of different processes in industry, machine control devices, measurement of different values etc.

Features: High-Performance RISC CPU Peripheral Features Analog Features Special Microcontroller Features CMOS Technology

PIC16F877A MICROCONTROLLER
Advantages: Small instruction set RISC architecture Easy entry level, in circuit programming plus in circuit debugging PIC Kit units Inexpensive microcontrollers Wide range of interfaces

PIC16F877A MICROCONTROLLER
Architecture:

PIC16F877A MICROCONTROLLER
Pin Description:

PIC16F877A MICROCONTROLLER
Central Processing Unit (CPU):

PIC16F877A MICROCONTROLLER
MEMORY The PIC16F877A microcontroller has three types of memory - ROM, RAM and EEPROM. All of them will be separately discussed since each has specific functions, features and organization. ROM MEMORY ROM memory is used to permanently save the program being executed. This is why it is often called program memory. The PIC16F877A device has 8K words x 14 bits of Flash program memory. Accessing a location above the physically implemented address will cause a wraparound. Since this ROM is made with Flash technology, its contents can be changed by providing a special programming voltage (13V). This is performed by means of a special program on the PC and a programmer.

EEPROM MEMORY Similar to program memory, the contents of EEPROM are permanently saved, even if the power goes off. However, unlike ROM, the contents of EEPROM can be changed during operation of the microcontroller. This is why this memory is perfect for permanently saving results created and used during the operation.

PIC16F877A MICROCONTROLLER
REGISTERS (I) GENERAL PURPOSE REGISTERS (GPRs) General Purpose Registers are used for storing temporary data and results created during operation. (II) SPECIAL FUNCTION REGISTERS (SFRs) Special-Function Registers are also RAM memory locations, but unlike general-purpose registers, their purpose is predetermined during manufacturing process and cannot be changed. STACK A part of the RAM is used for the stack. It consists of eight 13-bit registers. Before the microcontroller starts to execute a subroutine (CALL instruction) or when an interrupt occurs, the address of first next instruction being currently executed is pushed onto the stack, i.e. onto one of its registers.

PIC16F877A MICROCONTROLLER
BASIC CONNECTIONS Power Supply Reset Signal Crystal Oscillator

PIC16F877A MICROCONTROLLER
INTERFACING The following figure shows the internal components of a PIC16F877A and various types of peripherals which can be connected to it.

PROJECT OVERVIEW
The project created using the PIC 16F877A is a Binary Decimal Coded (BCD) Clock which is a variation of a Binary Clock. A binary clock is a clock which displays traditional sexagesimal(base 60) time in a binary format. It displays the hours, minutes, and seconds as binary numbers. Binary Coded Decimal clocks use six columns of LEDs to represent zeros and ones. Each column represents a single decimal digit, a format known as binary-coded decimal (BCD). The bottom row in each column represents 1 (or 20), with each row above representing higher powers of two, up to 23 (or 8).

PROJECT OVERVIEW
PROJECT PREREQUISITES The successful completion of the project required sufficient knowledge regarding the following tools that were implemented in its creation. 1. Binary Coded Decimal (BCD) 2. Embedded C

PROJECT REQUIREMENTS 1. Hardware Requirements 2. Software Requirements 3. Electronic Components

SIMULATION AND TESTING


Before physically implementing the BCD clock circuit, it is created and run in a simulation using Proteus 7 ISIS. LEDs for representing hours are connected to PORT B, the LEDs for representing minutes are connected to PORT D and the LEDs for representing seconds are connected to PORT C. The button for incrementing hours is connected to pin RB6 and the button for incrementing minutes is connected to pin RB7. A clock of frequency 20 MHz is connected to the pins CLKIN and CLKOUT. Fig.18 shows the simulation in action

CIRCUIT IMPLEMENTATION
Once the circuit has been thoroughly tested in the simulation, it is implemented on the PCB by soldering the various components together. The front face of the completed circuit is shown below:

WORKING
Initially the PORTS B, D and C representing hours, minutes and seconds respectively are set to 0x00 i.e. all the pins are set to low. On connecting the battery, the PIC16F877A powers on. When the program enters the while loop the PORTS B, D and C are assigned values based on the values arrays arr_l and arr_h determined by the variables hh, mm and ss. Since the variables have been initialized to zero therefore initially all PORT outputs will be assigned the zeroth elements of arrays arr_l (corresponding to the lower 4-bits of a PORT) and arr_h (corresponding to the upper 4-bits of a PORT). Since the zeroth element of both arrays is 0x00 therefore no LEDs will light up. The time read will be 00:00:00. On encountering the delay function delay_l() the microcontroller pauses for a short time and then moves on to the ms_inc() function. The ms_inc() function increments the value of the variable ms by one. It then checks the conditions for second increment, minute increment and hour increment. If any of the conditions is satisfied the corresponding variable is incremented.

WORKING
After exiting the ms_inc() function the program checks two if-conditions which determine whether any of the increment buttons are pressed. If suppose the RB7 pin i.e. mm_inc is high it means that the minute increment button is pressed since it is being directly connected to the +5V supply. In this case the mm variable is incremented by one. The program checks if the mm variable has reached 60. If this condition is found to be true then the variable is assigned zero. After this there is a short delay delay_s() to prevent overlapping of button presses. The hour increment is checked in a similar manner but with a value check of 24. After this the next iteration of the while-loop starts and the entire process repeats. Now after a sufficient number of iterations have passed, the ss variable will be incremented by one meaning that one second has passed. When this happens, PORT C will be assigned the value of the first element of the array arr_l. This corresponds to 0x01 i.e. a BCD value of one. Thus the pin RC0 will be set high and the leftmost LED of the lowermost row will light up indicating that one second has passed. The time read will be 00:00:01. Fig. 23 shows this state of the BCD Clock.

WORKING
Similarly, after ten seconds have passed, ss will be equal to 10. In this case PORT C will be assigned the value of first element of array arr_h plus zeroth element of array arr_l. Therefore the value assigned will be 0x10 + 0x00 = 0x10 whicjh corresponds to BCD value of ten. In a similar manner values will be assigned to PORTS B and D for hours and minutes respectively. Since the array arr_h only contains BCD values from 0 to 5 (i.e. 0x00 to 0x50) therefore the upper rows of both minute and second sections will be restricted to showing values up to 5 only. In the case of the hour section this limit is further decreased to 2. In program will keep on functioning in this manner till the power supply is disconnected. Fig. 24 shows the BCD clock at time 11:10:17.

PROJECT APPLICATIONS
Owing to its use of binary format the BCD clock is not suited for widespread use the way a normal clock might be. However its small number of components and low cost are quite advantageous and thus it manages to find application in certain niche areas: o Binary Learning Tool The BCD clock is an easy and practical way of introducing the binary number system to beginners. Since the binary digits can visibly be seen incrementing and can be easily referenced with a real clock, it provides a convenient tool for familiarizing oneself with the binary number system and more specifically the Binary Coded Decimal system. The project can also be extended to implement other codes such as Gray Code. o Novelty Clock Binary clocks are sought after by programming and electronics enthusiasts who want an offbeat style of time keeping. As of 2008, the most common binary clocks sold are designed by Anelace Inc.

SHORTCOMINGS & SCOPE FOR IMPROVEMENT


Though PIC16F877A is very efficient microcontroller for some specific operations but still it has some limitations: Maximum clock frequency that the PIC16F877A can be run at is 20MHz. For applications requiring more precision higher clock frequencies are required which are not supported by the PIC16F877A. The PIC16F877a model of the PIC microcontroller series has no internal oscillator therefore an external crystal oscillator or other clock source is necessary for its operation. Since the time interval for this project is based on software delays, therefore in the long run inaccuracies will appear in the time keeping. The functionality of the project can be further extended at the expense of a few more components and higher cost: Instead of using software based delays, a periodic external interrupt of period 1Hz can be used for mare accurate timekeeping. A buzzer and some more buttons can be added to implement an alarm clock system.

REFERENCES
Study material provided by teachers at Jetking, Chandigarh. Websites http://en.wikipedia.org/wiki/PIC_microcontroller http://www.microchip.com http://www.microchip.com/forums http://books.google.co.in/

You might also like