PIC16F877A Microcontroller : Basics

MICROCONTROLLER

A highly integrated chip that contains all the components comprising a controller. Typically  this  includes  a CPU, RAM,  some  form  of ROM, I/O ports,  and  timers. Unlike a general-purpose computer, which also includes all of these components, a microcontroller is designed for a very specific task — to control a particular system. As a result, the parts can be simplified and reduced, which cuts down on production      costs.      Microcontrollers      are      sometimes      called embedded microcontrollers, which just means that they are part of an embedded system — that is, one part of a larger device or system. An embedded system can simply be understood as a collection of components that is made to perform a specific task.

INTERFACING WITH MICROCONTROLLER:

In a microcontroller, various hardware components can be interfaced, which are thereby controlled by the controller. The embedded system can be considered as a microcontroller acting like a brain and various components like other parts in the body, doing their own work in the system. You can program a microcontroller as per your need and all that needs to be done is to process all data within. A circuit that connects various components with the controller is called a Printed Circuit Board (PCB).

MICROCHIP PIC16F877A

 

0

This  powerful  yet  easy-to-program  CMOS  FLASH-based  8-bit  microcontroller packs  Microchip’s  powerful  PIC  architecture  into  an  40-pin  package  and  is upwards compatible with the PIC16C5X, PIC12CXXX and PIC16C7X devices. The PIC16F877A features 256 bytes of EEPROM data memory, self-programming, an ICD, 2 Comparators, 8 channels of  10-bit Analog-to-Digital (A/D) converter, 2 capture/compare/PWM functions, the synchronous serial port can be configured as either 3-wire Serial Peripheral Interface (SPI) or the 2-wire Inter-Integrated Circuit (I²C) bus and a Universal Asynchronous Receiver Transmitter (USART). All of these features make it ideal for more advanced level A/D applications in automotive, industrial, appliances and consumer application.

 

PIN DIAGRAM

1

 

2

 

An oscillator needs to be connected to the microcontroller for timing reference and synchronous operation. The oscillator provides master clock for the microcontroller.

3

Fig. -CONNECTION OF OSCILLAOTR AND MASTER CLEAR PIN

 

HARDWARE COMPONENTS USED IN THE CIRCUIT

VOLTAGE REGULATORS

4

A voltage regulator is designed to automatically maintain a constant voltage level. Electronic  voltage  regulators  are  found  in  devices  such  as  computer  power supplies where they stabilize the DC voltages used by the processor and  other elements.

 

5

Measures of regulator quality

 

The output voltage can only be held roughly constant; the regulation is specified by two measurements:

load regulation is the change in output voltage for a given change in load current (for example: “typically 15mV, maximum 100mV for load currents between 5mA and 1.4A, at some specified temperature and input voltage”).

line regulation or input regulation is the degree to which output voltage changes with input (supply) voltage changes – as a ratio of output to input change (for example “typically 13mV/V”), or the output voltage change over the entire specified input voltage range (for example “plus or minus 2% for input voltages between 90V and 260V, 50-60Hz”).

The voltage regulator has three terminals. It has an unregulated dc input voltage, applied to its input terminal (first), a regulated output voltage from third terminal and the second is grounded.

Series 78 regulators provide fixed regulated voltages from 5v-24v. 7805 gives 5v as regulated output. 7812 gives 12v as regulated output and so on.

Series 79 regulators provide negative voltage regulation . 7905 gives -5v as regulated output. 7912 gives -12v as regulated output and so on.

LED

6

 

A light-emitting diode (LED) is a semiconductor light source. LEDs are used as indicator lamps in many devices and are increasingly used for other lighting.

 

When a light-emitting diode is forward-biased (switched on), electrons are able to recombine with electron holes within the device, releasing energy in the form of

 

  1. photons. This effect  is  called  electroluminescence and  the  color  of  the  light (corresponding to the energy of the photon) is determined by the energy gap of the semiconductor. LEDs are often small in area (less than 1 mm2), and integrated optical components may be used to shape its radiation pattern. LEDs present many advantages over incandescent light sources including lower energy consumption, longer  lifetime, improved physical robustness, smaller size, and faster switching. LEDs powerful enough for room lighting are relatively expensive and   require   more   precise   current   and   heat   management   than   compact fluorescent lamp sources of comparable output.

 

INTERFACING OF LED WITH MICROCONTROLLER :

7

To  save  the  microcontroller from  burning  due  to  any  electric  fluctuations, a resistor is placed between microcontroller and led (general value=330 ohms). The microcontroller is used as a source for the current through the led.

 

 

7 SEGMENT DISPLAY

 

 

8

This  device  is  highly  common  but  still  very  useful.  It  comprises  of  7    LEDs connected in a matrix and used to display numbers.

Table of display

9

Software for Microcontroller Programming

 

The Integrated Development Environment (IDE)

The core set of development tools operate under the IDE umbrella, called MPLAB. This gives a consistent look and feel to all the development tools so that minimal learning of the new tool interface is required. The MPLAB IDE integrates all the following aspects of development:

 

  • Source code editing
  • Project management
  • Machine code generation (from assembly or “C”)
  • Device simulation
  • Device emulation
  • Device programming

 

This comprehensive tool suite allows the  complete development of  a  project without leaving the MPLAB environment.

 

MPLAB

The MPLAB IDE Software brings an ease of  software development previously unseen  in  the  8-bit  microcontroller  market.  MPLAB  is  a  Windows  based application that contains:

  • a full featured editor
  • Three operating modes

– editor

– emulator

– simulator

  • A project manager
  • Extensive on-line help

MPLAB allows you to:

  • Edit your source files. (ASM and C files)
  • One touch assemble (or compile) and download to PIC16/17 tools
  • Debug using:

– source files

– absolute listing file

– program memory

 

PROGRAMS

LED BLINKING USING for LOOP:

 

#include<htc.h>

main()

{

int i; TRISB=0x00; while(1)

{

PORTB=0xFF; for(i=0;i<10;i++);

PORTB=0x00; for(i=0;i<10;i++);

}

}

LED BLINKING USING DELAY FUNCTION:

#include<htc.h>

#define _XTAL_FREQ 4000000 main(){

TRISB=0;

while(1) { PORTB=0xFF;

delay_us(100); PORTB=0x00;

delay_us(100);

}

}

 

SEVEN SEGMENT DISPLAY:

#include<htc.h>

main ()

{

int i;

int codes[]={0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0X07,0X7F,0X6F};

TRISB=0X00;

PORTB=0X00;

while(1){

for(i=0;i<10;i++){

PORTB= codes[i];}}}

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s