Wednesday 6 June 2012

Software for PIC16F877A

PIC 16F877A needs to be programmed in order to ask it what to do. Therefore, we have many languages that can be written to program the PIC. In the old days, people use assembly language and it was hard for other people to understand it. Then comes the C++ where it is easier to write and understand the sequence of the program. All of this languages can be written using MPLab v8.30 thought there are many more software out there that can deliver the job.

I have been using Microcode Studio v2.2.1.1 with a compiler of PICBasic Pro v2.46 since 2009 and it is much simpler and easy for people to understand without having any background programming or engineering. The language to be written are called Basic Language with an extension of .pbp at the end of file. If you are thinking where to buy to download the program, please click the link below:


Another thing is that i never installed the software on a Window 7 before cause i only use Window XP SP3.So if you are using Window XP, i can help with the installation.

There are a lot of example on the internet for Basic Language. I will be using Basic Language for PIC16F877A through out this blog. 

Tuesday 5 June 2012

Bootloader

Previously (around 8 hours after the previous post), we have discussed about the lifestyle of a hobbyist in microcontroller and the pin diagram of PIC 16F877A. Now to use a microcontroller, we must have a boot-loader. Boot-loader is used to download .hex file extension into the PIC or some people like to call it as burning procedure. 

In the old days, people like to download the program using MAX232 via RS232 cable. Yes...that brings back the old time of mine... But as life goes on, i am now using Cytron's bootloader which I will explain briefly. The boot-loader are as follows:

Bootloader: Cytron's UIC00B                                        ICSP Programmer Socket: UIC-S
                                     

The two hardwares above are to be used with the software called PICkit 2 v2.61. The software would look like this:

Ensure that the value at Vdd PICkit 2 is changed from 2.5 to 5.0 like below:

If there is a PIC in the ZIF socket, then the PICkit 2 will recognize it by displaying the device type as follows:
For the time being, I will not explain on how to use this software. We will discover it as we go on to the next post. If your are a first timer, then buying this boot-loader may help you in the next tutorial. However it can be easily bought via online order in Malaysia. If you already have a boot-loader, then this is just to add up to your knowledge.

Monday 4 June 2012

Pin Diagram 16F877A

Before doing any circuit on the 16F877A, we must understand and memorize the pin diagram of the 16F877A. Let's us review on the picture below,


Basically, this is a DIP (Dual in Line) package having 40 pins. The first impression on some students of mine are "what a lot of pins you have there...(while drooling)". Yes there are a lot of pins but let us simplify the pin diagram.

There are 7 main pins that need to be wired first. If there are any problems in the PIC system, I will check these 7 pins before looking to any interfaces on the PIC. The 7 pins are:
  • Pin 1   - MCLR (always give +5V. if momentarily give a 0V, it will reset)
  • Pin 11 & 32 - Vdd (give +5V)
  • Pin 12 & 31 - Vss  (give 0V)
  • Pin 13 & 14 - OSC1 & OSC2 (connect a resonator / crystal oscillator ranging from 4MHz to 20MHz)
  *reset refers to the program to jump back at the 1st line of the programming.
  *for Pin 1, if supplied with +5V at all time the PIC will be on standby but cannot reset. To do that, we must     
    add a push button and a resistor to supply with 0V. The circuit symbol are as follows:

  *crystal oscillator and resonator are like this:


Now we have stated that 7 pins needs to be connected to PIC16F877A, therefore 40 - 7 = 33pins. These 33 pins are bidirectional meaning that it can be an input or an output. 16F877A have 5 ports and each ports have different pins as described below:

Programming for the beginners

Before we start with the basics, i believe that those who are really interested in this discipline will have their lives at least 70% the same with the picture below. Mine is around 99.13%. I'll try my best to share the knowledge and experience to those who are in need (although you can just google it...).

I will explain I will not explain the theoretical aspects such as the function registers, memory allocation, architecture and the boring stuff that you can get anywhere in a class (or again...the google way). We will be mostly do some wiring, programming and stuffs that geeks do every minute of their lives.