Program your Microcontroller
Computers understand binary only. A microcontroller has an instruction set so that the user can instruct the microcontroller to do whatever he wants. These instructions can be telling the microcontroller to add two numbers, or to subtract etc. 16F84A has 35 instructions each 14bit machine code. These are binary code and read from the program memory of the microcontroller.
Early day’s the programmer used binary to program. Now we use assembly language or high level language. Assembly language is the same instruction set, but easy because you don’t have to remember machine codes. Instead you just have to type an instruction like “movwf” which will represent the binary instruction “00 0000 1fff ffff”. These “f” represents the 7bit file register address. More info will be on a later article. If you’re interested all the binary instructions are there in the microcontroller datasheet to see. When using assembly languages you are at the level of the CPU. You can reduce the chance of unused codes that wastes time and resources. You will use MPLAB IDE to program with assembly language. What MPLAB IDE does is converting your assembly language program to the corresponding binary code.
But programming with assembly for larger programs will be tiring. For larger programs you will need a high-end microcontroller and usually you program those with C.
Download MPLAB IDE to program the microcontroller using assembly language. Let’s say you have created the binary code using MPLAB IDE. Now you have to burn the program to the microcontroller. To burn the program to the microcontroller you need a microcontroller programmer which can connect your microcontroller to your PC via USB or RS232 or parallel Port. Many PIC programmers available to buy or you can build your own programmer!
Here’s a link for building your own programmer. But you will need a someone’s programmer to burn the firmware to the microcontroller used in the programmer.
I haven’t tested this one yet though.
Your program might not work correctly for the first time. You will have to see what went wrong and reprogram the chip few times. So you do the testing stages in breadboards. And for circuits which contain motors or any other stuff, I don’t test at the first time with the motor control circuits connected, instead I put LEDs to the corresponding pins. Your LEDs should not draw more than 40mA from the microcontroller pin. Use small resistors in series with the LEDs. Also whenever you are programming the microcontroller some pins to monitor whether they get high or low, you make the corresponding pin high by taking a wire from the positive power rail and connecting it to the pin. You can make the pin low by taking a wire from the negative power rail. Get a ZIF (Zero Insertion Force) socket to avoid breaking pins by having to insert and remove microcontroller from the breadboard rapidly. And do some simulation before burning the program to the microcontroller. How to do simulations in MPLAB IDE will be on a later article.