So what is a “PIC”? Well, a PIC is a microcontroller sold by a company called Microchip. That’s the short answer, the longer answer is that “PICmicro”, usually shortened to “PIC” is the brand name for a family, in fact a series of families, of 8-bit RISC-based microcontrollers. RISC or “Reduced Instruction Set Computer” describes the philosophy of designing “a processor whose design is based on the rapid execution of a sequence of simple instructions rather than on the provision of a large variety of complex instructions”. A microcontoller is a relation of the microprocessor. Where as a microprocessor is designed to just perform mathematical and logic based calculations, usually relying on other chips to store the list of instructions to be run and to provide anything more than the most basic of input and output, a microcontroller can be thought of as a microprocessor which also packages these other functions and more all in the same chip. A microcontroller in some respects can be thought of as a mini one chip computer.
So what are PIC microcontrollers used for? They are used for a great number of things. Microcontrollers can be found inside your PC, controlling important functions such as temperature control. They are found at the heart of many electrical devices full-filling many varied tasks, many of which before the wide use of microcontrollers would have been done by complex purpose designed circuits. Many microcontrollers are re-programable, this feature allows systems to be developed that can be updated, allowing for bugs to be fixed or even extra features to be added, much as a computer can have its software updated.
Although PICs and microcontrollers in general have a greater array on input and output capabilities than microprocessors, these interfaces are not as complex as those found on a modern PC. They are not, as provided, capable of being plugged into a monitor and keyboard and they certainly don’t have a nice programming environment. There are a number of ways of writing a program for a microcontroller to run, the most basic of which is to write in the basic instructions that the microcontroller understands, though this is very cryptic and requires a good understanding of the workings of the microcontroller.
One step above that is to program in assembler. Assembler is very close to the machines natural code, though it is presented in a much more human readable form. Many people still write programs in assembler and a skilled microcontroller programmer can write code at least as efficiently as higher level methods. Indeed, in order to bug track errors encountered whilst coding in more abstract forms, it is often handy to be able to understand the assembler level output that the compilation process produces!
More abstract forms of programming microcontrollers do however exist. There are many projects and products that provide high level programming languages for microcontrollers, a number of these are based on existing computer programming languages such as C and Basic. These languages can greatly simplify the task of programming a microcontroller, sometimes libraries of common functions are provided which greatly speeds up development time and reduces the risk of major errors in the code and limits the re-inventing of the wheel. These higher abstract languages also greatly improve the programmers ability to quickly change the target of the code, be this between different models of a companies microcontrollers or even between microcontollers by different companies, based on entirely different instrution sets. This is something that would require a huge amount of effort when the application is written in assembler and many even require the code to be completely re-written.
Whether assembler or a higher language is used the work flow is vastly the same. The code is written on a computer. The code is compiled or assembled into a form readable by the microcontroller. As long as this process is successful a file is produced holding a representation of the commands which are to be transfered to the microcontroller for it to process, this file is commonly written using the Intel HEX format and given the extension “.hex”. These commands need to be transfered to the microcontroller. This is done with the aid of a “programmer”, a special set of circuitry that interfaces the microcontroller to one of the host computers general purpose ports. Using the relevant piece of software to drive this circuit, the commands can then be transfered to the microcontrollers non-volatile memory.
28 Jul 2007 #electronics