Wednesday, December 28, 2011

Microcontroller (PIC 16F877)

Microcontroller (PIC 16F877)

2.1) Introduction:
A microcontroller is by definition a computer on a chip. It includes all the necessary parts in one IC. We just need to apply the power and clock signal to that device and it starts executing the program. A microcontroller generally has the main CPU core, ROM/ EEPROM/ FLASH RAM and some necessary functions all integrated into the chip.
Microcontrollers are typically used where processing power isn’t so important. More important are generally compact construction, small size, low power consumption and that those chip are cheap. There are countless numbers of small electronic devices, which are nowadays based on microcontroller .

2.2) Microcontroller Selecting :

When someone decides to use a microcontroller, the next step becomes is to decide which one to select. In this project Peripheral interface Controller (PIC) is used, but we should at least be aware that other options exist, like the Motorola 68HC, Atmel AVR, and the 8051 in all its varieties from various manufacturers .
Criteria that should be taken into account when choosing a microcontroller (family) are:
•    Availability.
•    Price.
•    Ease of use.
•    Quality and price of development tools.
•    Availability of application notes, reference designs.
•    Features of the chip (I/O pins, UART, A/D, D/A, counters, speed, code size, data size, etc.).

In the appendix


2.3) what is the PIC?
2.3.1) PIC was Developed for the Peripheral Controller :

PIC (Peripheral Interface Controller) or (Programmable Intelligent Computer) is the IC, which was developed to control the peripheral device, dispersing the function of the main CPU. When comparing to the human being, the brain is the main CPU and the PIC shares the part of which is equivalent to the autonomic nervous.








Figure (2.3.1): PIC Microcontroller chip.




2.3.2) PIC is the Small Computer :

    PIC has the calculation function and the memory like the CPU and is controlled by the software. However, the memory capacity isn’t big. It depends on the kind of PIC but the maximum operation clock frequency is about 20 MHz and the memory capacity to write the program is about 1K to 8K words. The clock frequency is related with the speed to read the program and to execute the instruction. Only at the clock frequency, the throughput can not be judged. It changes with the architecture in the processing part.
The WORD for the capacity of the program memory represents the one instruction. It often uses the BYTE to show the capacity of the memory. The 1 byte shows the 8 bits. The bit is the atomicity, which shows 1 or 0. The instruction of the PIC16F84A is composed of the 14 bits. It is 1 x 1,024 x 14 = 14,336 bits when converting the 1K words to the bit. It is 14,336/(8 x 1,024) = 1.75K bytes when converting this to the byte.


2.4) Types   PICs :

PICs started with the 16F84 and 16C84. These were the only affordable flash PICs and hence the hobbyist PICs. There are still find lots of designs in electronics magazines and on the Internet using these chips.
But recently Microchip has broadened its offering of flash chips with types that are much more attractive. For example 16F628, 16F877 and 18F452. The 16F628 are somewhat cheaper than the old 16F84, has twice the code size, much more RAM and UART. This is the chip for simple applications.
The 16F877 is around twice the price of the old 16F84, but has eight times the code size, much more RAM, much more I/O pins, a UART, A/D converter and a lot more.
The 18F452 is part of the new (16-bit core) series of PICs. It offers an instruction set that is much improved over the 14-bit (16F) PICs, improved peripherals, twice the code space and twice the speed compared to the 16F877, at a price that is only marginally higher. The price is of course an indication only. Both the absolute and relative prices will vary between sources. Table(2.1) compares some PICs that can be interesting.
The 12C509 is still popular for hacking pay-TV or game consoles, but its role as small and cheap PIC has been taken over by the 12F629. Note that a 16C509 can be programmed only once (OTP).
The 12F629 and 12F675 are very cheap 8-pin chips, suitable for projects that do not need the larger amount of code space, data space, I/O pins, peripherals, etc. which are present on the larger (and more expensive) chips. However, these chips are not recommended for a beginner because the code space and I/O pins of the larger chips make debugging much easier.
The 16C84 is the first re-programmable PIC. It was (and still is) featured in many designs on web pages and in magazines. The 16F84 and the 16F84A has long superseded the 16C84. Except for existing designs or to use existing documentation, these chips should be avoided: the 16F628 offers more memory for a lower price, in the same pin out.
The 16F628 can be considered the next-generation 16F84, because it is pin-compatible with those older chips. But note that it is not fully software compatible. The 16F628 also has a smaller cousin, the 16F627. The 16F627 do not seem to be an attractive chip because the price a little higher than for the 16F628.
With 8K code space and 34 I/O pins the 16F877 is the largest chip of the 16F87x family. The 16F876 comes in a smaller package with less (IO) pins. It is about the same price as a 16F877, so it is interesting only when the larger package of the 16F877 is a problem. The 16F873 and 16F874 have less resource and use a more cumbersome RAM address mapping to be compatible with older (non-flash) PICs .

The 16F870 and 16F871 have even less resource but use the same RAM addressing as the 16F877. Note that the 16F877 and 16F876 both have a UART (for asynchronous serial communication) and an MSSP (for SPI and I2C), while the smaller chips have only a UART. The 16F872 are a 16F870 but with an MSSP instead of a UART.
The 18F chips are new family of PICs, with an instruction set that is much improved over the 16F chips, with more peripherals, and more code and data space. Yet the price of the 18F chips is only marginally higher than the comparable 16F87x chips.
Microchip part number has some prefix such as:
•    The prefix 12 is for chips with 8 pins
•    The prefix 16 is for 12-bit and 14-bit core chips with more than 8 pins
•    The prefix 18 is for 16-bit core chips.
•    Next the letter C is for EPROM (OTP or windowed) chips, except for the 16C84 that has EEPROM, which is (for a user) almost the same as flash.
•    The letter F is for flash chips
•    Windowed EPROM chips have a JW suffix.

For some of the chips mentioned in the table, Microchip has released improved versions, identified by appending A to the type. Such A chips are in most aspects identical to their non-A predecessors (but it does not harm to check the data sheets), except that the programming algorithm often changes. We note: The 16F84A uses the same programming algorithm as the 16F84, but the A chip can run at up to 20 MHz, the non-A only up to 10 MHz.

2.5) Select a Language :

There are different programming languages can be used to programming the PIC such as CSS C and JAL, but the question is which language to use?. Criteria that can be taken into account when choosing a language are:
•    Which languages does user know.
•    Price of the tool.
•    Quality of the tool.
•    Ease of writing (a high level language is definitely easier to write in than assembler) .
•    Effective use of the microcontroller's resources.
•    Quality of the tool documentation.
•    Support for the tool (vendor, mailing list, newsgroups).
•    Availability of useful libraries.





 2.6 ) Programming of PICs :

We will need a computer to run software, such as Circuit Wizard, allowing you to program a PIC microcontroller circuit. A fairly cheap, low specification computer should run the software with ease. The computer will need a serial port or USB port . This is used to connect the computer to the microcontroller circuit.
Software such as, Genie Design Studio It can be used to program microcontroller circuits. It allows the programmer to simulate the program, before downloading it to a PIC microcontroller IC (Integrated Circuit).
Simulating the program on screen, allows the programmer to correct faults and to change the program.
The software is quite easy to learn, as it is flow chart based. Each ‘box’ of a flow chart has a purpose and replaces numerous lines of text programming code. This means that a program can be written quite quickly, with fewer mistakes, as shown in the figure (2.6.1 ) .











               ( 2.6.1 )  : Screen program of Genie Design Studio

USB lead  connects the computer to the programmable circuit, allowing the transfer of the program to the PIC microcontroller IC.
When the program has been simulated and works, it is downloaded to the PIC microcontroller circuit. The USB lead can be disconnected and the microcontroller circuit can be used independently.
This way we have completed the process of programming PIC used in the project by using the program and the method the above-mentioned .


2.7) Microcontroller (PIC16F877) Core Features :

•    High-performance RISC CPU.
•    Only 35 single word instructions to learn.
•    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.
•    Interrupt capability (up to 14 sources).
•    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.
•    Power saving SLEEP mode.
•    Wide operating voltage range: 2.0V to 5.5V.
•    High sink / source current : 25 mA .












Figure (2.7.1) : PIC 16f877 pin configuration.

No comments:

Post a Comment