FIGURE 10. Programmer Parameters
Window.
power and ground connections to
operate. To create the demonstration
unit for the high school, we used one
of our breadboards from Beginner
Electronics.com. The breadboard
circuitry included the power
connections and the connections to
the 2x40 LCD per the schematic
shown in Figure 11. We had a large
box of brand new surplus 2x40 LCD’s
available, so we did the demo with
that LCD. (The same software will
work with any two line LCD.)
The software is shown in Listing
1. The first section that has all the
DEFINEs is required for the way we
wired up the LCD. This shows how the
PICBASIC Pro compiler handles the
setup in the background to make
the code easier to write. The final
example took 23 command lines, but
if we used a different PIC and used
the default DEFINE settings, then we
could remove the DEFINEs and the
program reduces down to 13 lines.
We are also writing to the LCD several
times within those 13 lines so this
is more efficient than other BS1
examples I saw.
The unique section of the code
required to use the PIC16F690 are the
special register setups shown below.
The sample programs may need these
same lines of code. These settings
make the pins digital instead of the
default analog mode. They also shut
off the internal comparator that is on
this part.
‘ Set A/D ports 0-7 as digital
ANSEL = 0
‘ Set A/D ports 8-10 as digital
ANSELH = 0
CM1CON0 = 0
CM2CON0 = 0
‘ Comparator 1 off
‘ Comparator 2 off
The rest of the program is fairly
simple to understand so I won’t go
through it all. The point is the code
was short and simple enough to fit
within the 31 command limit with
more space for a few more functions.
What Does All This
Cost?
• PICBASIC PRO compiler, sample
version (free)
• MicroCode Studio IDE (free)
• EZPIC JDM style serial port
programmer ($19.95 kit)
• WINPIC programmer software (free)
• PIC16F690 microcontroller (free
sample)
• 2x40 LCD module ($5.00 special at
BeginnerElectronics)
• Breadboard and wires ($12.95)
• 4.5V battery pack ($3.00)
Listing 1. PIC16F690 Driving
2x40 LCD Software.
70 SERVO 08.2008