Teach-In 2008 Using PIC Microcontrollers Part One – Introduction to PIC Microcontrollers and the Development Interface Board for this series JOHN BECKER
T
EACH-IN 2008 takes a slightly different format to previous Teach-Ins. Whereas the earlier ones have concentrated on telling you about components and how to use them in general, Teach-In 2008 takes a specific component, a PIC microcontroller, the PIC16F628, and examines it in detail, providing you with information on how to use PICs in your own projects. The series has been inspired by the number of readers, many of them new to reading EPE, who have been noting the emphasis we place on PICs and who wish to know more about how to use them. In the past, we have published PIC Tutorials in various forms, and the last one, EPE PIC Tutorial V2, is still valid. That concentrated on a command-bycommand examination and explanation of various aspects of PIC programming, principally in relation to the PIC16F84. The text, hardware and softare for it are on our PIC Resources CD-ROM, periodically advertised in our pages.
Constructional examples This Teach-In 2008 gives constructional examples in each part of the series, explaining how to program and use a PIC16F628 in a variety of circuit types, using ‘breadboarded’ circuits you can quickly and easily put together yourself. They could also be assembled on stripboard, for a more permanent construction, although guidance on stripboard assembly is not given.
Prototype of the dual-purpose PIC programming and development interface board used in the Teach-In 2008 series
can be readily used to write programs for other PICs from the increasing number of types available. Most of the commands used are similar between types, although the method in which they are used can vary between PIC families.
PIC16F628
Getting started
The PIC16F628 was chosen because it is a good compromise between the various PIC types available and simplicity of use. There are many PICs in the current range which are totally unsuited to learning about PICs in general, requiring too many concepts to be grasped by the newcomer to PICs. The PIC16F628 is one of the 16F family but without a lot of the ‘frills’ now found in many PIC families. There are other 16Fs that could have been chosen, but this one is widely available from many suppliers. For this series, the PIC16F627 could also be used without changes, the only difference is that it has a somewhat smaller memory capacity. Once you understand the basics of programming a PIC16F628, your knowledge
In this first part of the series we tell you about the general nature of a PIC microcontroller, and present a simple PIC programming circuit which is assembled on a small printed circuit board (PCB). Its controlling software is the author’s renowned Toolkit TK3 assembler/programmer. This provides the essential aspects required for writing and assembling PIC software, and programming the PIC with the results via a PC’s parallel printer port. There are many text notes built into the TK3 program that give information on how use it. The board is also used as the Master Control PCB for the Teach In 2008 demonstration programs. It will also be of future use when writing your own software.
20
It is recognised that many modern PCs do not have a parallel printer port, and use a USB serial bus. For those readers who cannot use the programming aspects of the Master Control PCB to program their PICs, it is recommended that a simple PIC Programmer such as the PICkit2 programmer be used, as reviewed by Mike Hibbett in the July ’07 issue. PICkit2 can be used to actually program your PIC, and then the PIC can be transferred to the Master Control PCB for use in the demo program examples presented in this series. The Master Control PCB is described later, along with its assembly. Details of obtaining the PICkit2 hardware and software are also given later. If you already have the PCB designed to go with the TK3 software when it was originally published, then you may use that instead of the Master Control PCB. The same applies to the TK3 board available pre-built from Magenta Electronics. The TK3 boards have facilities for programming a variety of PIC sizes.
Everyday Practical Electronics, November 2007