Observations from Scotland. Allan Copland GM1SXX 24 October 2007
The Cart before the Horse.
What exactly is a PIC?
It dawned on me after posting my recent article on PIC microcontrollers that I had just jumped in with both feet and not introduced readers to the devices called PICs although of course it's likely that many readers will already have seen or heard of these devices. A clear case of 'Putting the cart before the horse!' This OBS is a very short introduction to PIC Micro-controllers.
Whether you are aware of it or not, most of you will certainly have a few of these devices 'embedded' in domestic appliances.
The PIC (Peripheral Interface Controller) was originally designed by General Instruments. Although named a Peripheral Interface Controller, it was actually a completely self-contained microprocessor plus memory and peripheral devices fabricated on a single IC die. The PIC is a RISC computer (Reduced Instruction Set Computer) having only about 35 instructions for the small PICs and around 70 for the large powerful devices.. What's more, unlike most conventional computers, the PIC keeps its program and data in separate memory space making it faster to load and execute instructions. Clock speeds of 4-20Mhz are common and some PIC devices are rated for 40Mhz clocks. GI sold their semiconductor arm to Arizona Microchip, and the rest as they say is history. Microchip have shipped 6 billion, yes 6,000,000,000 of these microprocessors. They are in exceedingly widespread use in all manner of things from your computer mouse or smart-card to Earth Satellites. You can read a little more about the history of the PIC at http://www.jpixton.dircon.co.uk/pic/history.html
Putting what is essentially a fast simple-to-use computer chip along with memory and I/O ports into a single DEVICE allows designers to do what was impossible previously... to build an intelligent self-contained circuit for any purpose they could devise. The PIC family has continued to expand since Arizona Microchip took over the business and their product range is now very extensive. Even the larger, more capable PIC's might not have enough port pins for some applications so those clever folks at Microchip produce port expander IC's to cater for larger applications. The port expander is very useful in mechatronics applications.
PICs were designed from the outset to be self-contained and easy to use. Microchip provides excellent support for all their devices on their main website. Welcome to Planet Microchip... http://www.microchip.com
The two best things about the PIC (IMHO) are these.
1) Circuit design is very simple indeed.
and
2) If you already know a high-level computer language, there's a good chance there's a compiler for it. This means a shallower learning curve. You can if you wish, write programs in Assembler for the PIC. Thanks to the reduced instruction set, PIC Assembler is quite straightforward to learn. The alternative is to program in a high level language and compile it to code suitable for the PIC. There's a free C compiler on the Microchip website
Google is your friend... http://www.google.co.uk/search?hl=en&q=free+PIC+compilers&meta=
Having used two different PIC compilers , and heard of many more, I've settled with one from Mikroelektronika for the reason that it's excellent and powerful and doesn't use a hardware lock (AKA Dongle).
With a suitable compiler to write code with, and a means to 'program' them, a PIC programmer, you can effectively treat the PIC as an 'intelligent component', and just 'embed' it into your circuit . This makes them very useful indeed to the radio amateur. Need a beacon keyer? Even a small simple PIC can do that easily. Control a DDS? point your rotator? a cheap portable ASCII terminal to drive a TNC? All of these things and more are possible with a cheap and cheerful PIC.
To get a PIC to function, you have to
1) program it.
2) provide 5V DC power
3 provide some sort of clock.
and
4) provide a reset circuit.
Programming. You can program the PIC in Microchip Assembler or a high-level language such as C, Pascal or BASIC using a suitable compiler. A compiler takes the code that you write and turns it into the binary code that the PIC actually uses. The compiled code ends up as a HEX file (just a convenient way to package binary code). There are a number of commercially produced compilers for the PIC as well as some free offerings. See my 'Ten Quid Computer' article for more on this). Once you have compiled your code into a HEX file, you need a means of transferring the HEX into the PIC chip. This is accomplished by means of a PIC Programmer. These can be found at low cost in places such as Ebay. yet again, please consult the 'Ten Quid Computer' article for more information.
At it's most basic, the clock can be a cheap ceramic resonator across the oscillator pins with a small value (27pf typical) capacitor from each of the pins to ground . You can even use an R/C oscillator if accurate timing is not required. Oscillator frequencies of 4 & 20Mhz are commonly used. The clock is used to time the processes within the PIC. In general terns, the PIC executes instruction in a single 'cycle' of the clock, typically 200 nanoseconds. That's 0.000000200 of a second per instruction. A nanosecond is one billionth of a second or 0.000000001seconds. If your applications needs to keep accurate time of communicate with other devices, it's usual to use a 4 or 20Mhz quartz crystal as the timing element.
The reset circuit consists of an RC network across the5V power supply line. The resistor connects to the 5V line and the capacitor in series is connected to ground. The junction between then is then connected to the MCLR pin. 10K and 1uf works fine. The reset circuit's purpose is to create a start-up time delay while the processor gets stabilised.
PICs are not the only kids on the block. ATMEL also make single-chip computers and these are reputed to be even faster than the PIC although of course you need appropriate ATMEL compilers and programmers for these chips. Other chip manufacturers have brought out their 'own brand' devices but it's probably safe to say that for the moment at least, The PIC and ATMEL chips rule the roost.
Why did I choose the PIC and not the ATMEL devices? Easy, I heard of the PIC first!
73 Al.
GM1SXX