Analysis
There is no single “right way” to plan and develop
software for every person and every project. This article
explains a way that works for me on small projects. There
are a lot of good books on software design methodologies
used by professionals, but a simplified process like this may
be a good starting point to organize your project’s
software without making it feel like work.
Most software design methods I have seen use an
iterative process, so instead of determining all of the needs
first and then moving on to implementation, they work in
stages, starting with the broadest part of each major
feature and testing that they all work together. Then, you
work out some details, test the results, and repeat until
finished.
A good first step in analysis is writing down what
features the project should have. My list was relatively
simple:
• Three rows by three columns of pushbutton
switches.
Based on these requirements, I determined that the
array of switches and the array of LEDs needed six
microcontroller pins each. After thinking a little more, I
realized I could treat it as a single array of three columns
by six rows, using only nine pins. It turns out this
assumption was partly wrong, but pretty close — as
explained in the next section.
With nine pins for switches and LEDs plus one pin to
signal when the user had won (for some visual indicator,
sound, or a solenoid to unlock a door like in the games
that inspired this project), I would need a microcontroller
with at least 10 pins.
More About Choosing a Microcontroller
As a hobbyist, I always choose microcontrollers that can be programmed in-circuit and use Flash memory, so they
don’t have to be removed and erased repeatedly during development. I also look for an internal oscillator for most
projects, to avoid using an external crystal or RC network.
There is one important item to point out in the PIC16F505. Section 4. 7 of its datasheet explains that when using
the CALL instruction or computing an address to jump to, the MCU cannot reach the second half of each memory
page, but the GOTO instruction can because it contains an extra bit in its address. In assembly language, you may
have to work around this by placing your functions and destinations of computed jumps at specific locations. If you
are using a C compiler or Basic, this should be taken care of for you.
Of course, the decision to use a specific part also may depend on having a particular microcontroller on-hand
which lets you start building and programming immediately!
SERVO 06.2010 49