⇐
FIGURE 4.
Hardware Schematic.
31 COMMANDS! WHAT
CAN I DO WITH THAT?
PIC projects. You can later upgrade to
various professional programmers that
will work on a laptop or USB port.
SO WHAT DOES ALL
THIS COST?
This is where you might be
shocked. A 16F876A Microchip PIC
will cost around $10. The PicBasic Pro
compiler shown in Figure 2 comes in
a limited sample version that can be
downloaded for free from www.
melabs.com It is limited to 31 command lines, but that is more than
enough to get started. It is also limited to certain Microchip PICs:
16F627(A), 16F628(A), 16F84(A),
16F870, 16F871, 16F872, 16F873(A),
16F874(A), 16F876(A), and 16F877(A)
are all supported.
This gives you plenty
of PICs to work with.
The serial port
PIC programmer
shown in Figure 3 can
be obtained from my
website for $24.95.
The kit form will be
cheaper and hopefully available by the
time you read this at
elproducts.com
I also recommend the Microcode
Studio IDE software from
www.mecanique.co.uk/code-studio
It’s also a free download and was
designed to work with the PicBasic
Pro compiler. It makes writing
PicBasic code so much easier. You
also will need a few minor
components to make the PIC run,
such as the clock resonator
mentioned earlier and you will need
some type of 5V power source along
with a few resistors. This can all be
built on a standard breadboard.
Since I stated all this could be
done for less than $50 and we’ve
designated $10 for the PIC and $25 for
the programmer, you have $15 for
the breadboard, wiring, and other
components. Not bad right?
You may be wondering, what
good is all this if you only get 31 commands to work with? The PicBasic Pro
compiler is so efficient to write code
with, you really can do many simple
home projects with a single PIC chip
and less than 31 lines of code.
For example, I’ll build a simple LCD
controller out of a 16F876A PIC chip. It
will simply display the message “Hello
World” but can be expanded in the
future and still use the sample version
of the PicBasic Pro compiler because I’ll
do this with far less than 31 commands.
To do this, first download all the
free software and install the Microcode
Studio software and link it to the
PicBasic Pro compiler. You’ll have to
follow the MCStudio instructions, but
in most cases, it will find the PicBasic
Pro compiler automatically when you
install it. After these steps, you are
ready to program your first PIC.
The project schematic is shown in
Figure 4. All the connections are
straightforward. The PIC 16F876A has a
4 MHz resonator connected to the OSC1
and OSC2 pins. Two 20 pF capacitors
are connected to the OSC1 and OSC2
pins to ground. You can get a 4 MHz resonator with the capacitors built in from
companies like Digi-Key. The PIC also
needs a 1K resistor connected from 5V
to the MCLR pin. The MCLR pin is the
reset pin so you want this tied high.
Pulling this low will reset the PIC, so
adding a momentary push button from
MCLR to ground is an optional.
The LCD is a parallel version with
a Hitachi 44870 driver chip inside. This
is a common LCD available all over the
place for under $15 and usually less
than $10. Connect the LCD per the
schematic including the 1K pull-up
resistors to 5V. These help guarantee a
proper voltage level between the PIC
and the LCD. After this, the project is
ready to be programmed. The hardware is shown assembled in Figure 7.
SOFTWARE
The software is quite easy to
⇐ FIGURE 5. Microcode Studio
Window with Software.
76
January 2006