You are on page 1of 18

# TABLE OF CONTENT CHAPTER NO. ABSTRACT LIST OF TABLES LIST OF FIGURES 1. 2. INTRODUCTION THE PROJECT DESIGN 2.

1 SCHEMATIC DESIGN 2.2 THEORETICAL ANALYSIS 2.1 PIC PROGRAMMING 2.11 FLOWCHART 2.12 C CODE 3. DISCUSSION & CONCLUSION 1 TITLE PAGE NO.

ABSTRACT

## LIST OF TABLES TABLE 1: CRYSTAL INFORMATION TABLE ................................................. 10

LIST OF FIGURES FIGURE .1 ANALOG & DIGITAL SIGNALS .................................................... 5 0 FIGURE .2 EXAMPLE OF 18 PIN PIC ............................................................. 7 0 FIGURE .1 SCHEMATIC DESIGN ................................................................... 8 0 FIGURE .2LED ........................................................................................... 9 0 FIGURE .3CRYSTAL CIRCUIT .................................................................... 10 0 FIGURE .4 BREADBOARD CONNECTION .................................................... 11 0 FIGURE .5 PROGRAM FLOWCHART ............................................................ 13 0 FIGURE .6 CONNECTING THE PIC TO THE PROGRAMMER .......................... 15 0 FIGURE .7 BURNING THE HEX FILE.......................................................... 15 0 FIGURE .8 PROGRAMMING SUCCESSFUL .................................................. 16 0 FIGURE .9 CONNECTING THE CIRCUIT ...................................................... 17 0

INTRODUCTION In contrast to analog signal, a digital signal exists only at specific levels or states and changes its level in discrete steps. An analog signal and digital signal are illustrated in the following figure

## Figure0.1 Analog & Digital Signals

Most analog signals have only two states: high and low. A system using two states signals allows the application of Boolean logic, and binary number representations, which form the foundation of the digital devices. Digital devices are categorized according to their function as combinational logic or sequential logic devices. The difference between two categories is based on the signal timing, for sequential logic devices the timing or sequencing history, of the input signals plays a role in determining the output, but for combinational logic devices the output depend only on the instantaneous values of inputs.

Integrated circuits (IC) are consisting of combinational logic circuits or sequential logic circuits, and they are considered as hardware since they are hardwired to a circuit board. Microprocessors are considered a very-large-scale-integration (VLSI) chip that contains many digital circuits and performs arithmetic, logic, communication, and control functions, moreover they are programmable logic devices reads binary data from a storage device called memory, and then when this device been connected to I/O devices its called microcomputer. When this microcomputer is placed in a single chip its called microcontroller, which can be defined as single chip microcomputer, consist of central processing unit (CPU), memory, timers and counters, analog to digital converters (ADC), digital to analog converters (DAC), serial ports, interrupt logic, oscillator circuitry and many more functional blocks on chip. Microcontrollers are used in wide array applications including home appliances, entertainment equipment, telecommunication equipment, automobiles, trucks, airplanes, toys, and offices equipment. The focus here is on the PIC (Peripheral interface controller) microcontroller, which is manufactured by Microchip Technology, due to

its low cost, abundant information resources, wide availability in market, and easy to use. The PIC microcontroller architecture is based on a modified Harvard RISC (Reduced Instruction Set Computer) instruction set with dual-bus architecture, providing fast and flexible design with an easy migration path from only 6 pins to 80 pins, and from 384 bytes to 128 Kbytes of program memory. Although there are massive numbers of PIC models, the family can be divided into three main groups, which are: 12-bit instruction word (e.g; 12C5XX, 16C5X). 14-bit instruction word (e.g; 16F8X, 16F87X). 16-bit instruction word (e.g; 17C7XX, 18C2XX). This mini project is a scrolling LED project using one of the most popular PIC microcontrollers; its the PIC16F84, which is a low-cost 8-bit Microcontroller, supports 13 I/O digital lines simple architecture, less amount of instructions.

## Figure0.2 Example of 18 pin PIC

THE PROJECT DESIGN Schematic design: The circuit was designed and simulated in Protues 7.2 SP2.

## Figure0.1 Schematic Design

The schematic consists of the microcontroller PIC16F877 connected to 8 LEDs to function the flashing, a reset push button, a crystal with 20MHz frequency and a power source that supplies +5V. 8 LEDs are connected to all port B, and between each LED and the PIC there is a 330 resistor and those resisters were selected based on the nearest manufactured resistor to the calculated results in the theoretical part. Concerning LEDs color, 4 of them are red light (2.2V) and the other 4 are white light (2V).

Theoretical analysis: Resistor calculations of the LEDs: In any circuit resistor is needed to limit electrical current that flows through LED. LED's resistors calculations: The output voltage from the PIC is Vs = 5V The voltage drop in the red LED is Vd = 1.8V The voltage drop in the white LED is Vd = 2.2V R= For the white LEDs: R= = 280
Figure 0.2LED

## For the red LEDs: R= = 320

If the exact value resistor cant be found on the market, it needed to round it up to be safe. It is always better to supply less current to the component than it is to let the component pull more than it needs, and the long pin of the LED is the anode and the short one is the cathode.

The crystal and capacitors of the clock: This project use high speed clock, it uses 20MHz crystal and 18pF capacitors. This is connected to the pins 13 and 14 in the PIC16F877.

## Figure 0.3Crystal Circuit

10

The breadboard: A breadboard is used to make up temporary circuits for testing or to try out an idea. No soldering is required so it is easy to change connections and replace components. Parts will not be damaged so they will be available to re-use afterwards. Connections on Breadboard Breadboards have many tiny sockets (called 'holes') arranged on a 0.1" grid. The leads of most components can be pushed straight into the holes. ICs are inserted across the central gap with their notch or dot to the left. Wire links can be made with single-core plastic-coated wire of 0.6mm diameter (the standard size). Stranded wire is not suitable because it will crumple when pushed into a hole and it may damage the board if strands break off. The diagram shows how the breadboard holes are connected :

11

The top and bottom rows are linked horizontally all the way across as shown by the red and black lines on the diagram. The power supply is connected to these rows, + at the top and 0V (zero volts) at the bottom. The other holes are linked vertically in blocks of 5 with no link across the centre as shown by the blue lines on the diagram. Notices how there are separate blocks of connections to each pin of ICs.

12

PIC Programming: High level language was used to design the flashing function of the LEDs, started with the flow chart the program was designed as follow:
START

DELAY (500mS)

DELAY (500mS)

13

## The program itself was written in C language as follow:

#include <pic.h> #include "Delay.h" __CONFIG (0x3F32); #define #define #define #define #define #define #define #define r1 r2 r3 r4 l1 l2 l3 l4 RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 *\\ assign port RB7 to r1 *\\ assign port RB6 to r2 *\\ assign port RB5 to r3 *\\ assign port RB4 to r4 *\\ assign port RB3 to l1 *\\ assign port RB2 to l2 *\\ assign port RB1 to l3 *\\ assign port RB0 to l4

void main () { PORTB=0x00; TRISB=0X00; while(1) { r1='1'; r2='1'; r3='1'; r4='1'; DelayMs(500); r1='0'; r2='0'; r3='0'; r4='0'; l1='1'; l2='1'; l3='1'; l4='1'; DelayMs(500); l1='0'; l2='0'; l3='0'; l4='0'; } return; }

## *\\on all left side leds

*\\ delay for 0.5sec *\\ off all left side leds

Compiling the C file and burning the HEX file to the PIC:

14

15

16

## Figure 0.9 Connecting the Circuit

The circuit was designed as shown in Figure 0.9. The programming codes were written and compiled in the MPLAB software, and then the programming codes were converted to machine code (Hex file). The Hex file was uploaded to the PIC in Proteus software to simulate the circuit and check it. Then the USB ICSP PIC PROGRAMMER V2010 was connected to the computer through USB, Figure 0.6. By using PICkit2 Programmer software the PIC was identified (PIC16F877A), Figure 0.7 the Hex file was imported and the program was written to the PIC, and then verified, Figure 0.8, finally the PIC took place in the breadboard Figure 0.9.

17

DISCUSSION: Some problems during the developing of the circuit have been solved to accomplish the desired results. The PIC16F84A: After the program was written for the PIC16F84A, it was burned to the PIC and tested in the circuit it wasnt working as it is supposed to be. After the troubleshooting a major damage was discovered in the PIC16F84A and it had to be replaced with another PIC which is PIC16F877. Programming the PIC16F877: Replacing the PIC means modifying the program to be compatible with the new hardware, during the modification a DELAY command conflict was noticed and it was solved through the Microchip website.

CONCLUSION In this mini project, the basics of the microcontroller were applied in such a way the helps improving the ability of designing these small projects using the microcontroller, interface it with other electronic components and program it using the high level language or the assembly language.

18