In The Trenches
important. It allows the student to concentrate on the program logic instead
of the technical details of converting
the Basic code into machine language.
That’s a major reason why Basic is
easy and fast to learn.
You can also see that Basic is a
program that must always be present in
the computer. This means that some
fraction of the computer’s memory
must be allocated for it. Obviously, this
reduces the available resources for your
program. This may not be an important
consideration for a large computer, but
for uCs, the Basic Interpreter can take
up most of the available memory.
Note that there are Basic “
compilers” available that take a Basic program and convert the whole thing into
machine language, which is then
loaded and run alone. This speeds up
the execution and eliminates the need
to allocate memory space for the
interpreter. However, it doesn’t fix one
last problem. This last problem is that
Basic has no real structure. This is
very useful for the student because
there is no need to understand or
specify (initially at least) data types,
word sizes, memory allocation, and so
on. Again, all the student has to focus
on is the logic of the program. But
complex software needs structure.
I view Basic as the equivalent to
white “proto-boards.” It’s very easy to
get a simple circuit up and running.
It’s easy to change. But no one would
consider mass-producing a product
with a proto-board inside. Note that I
do use Basic and think it’s great for
the purpose for which it was designed.
But it’s important to remember that it
was designed as a learning tool — not
for creating commercial software.
Since I’ve been programming all
sorts of computers since the IBM
1130, my experience may be helpful. I
generally use the bottom-up approach
because I’m usually the only one working it. I always do the output routines
first so that I can later use them to display whatever I want to look at. Often,
this is faster than invoking a simulator
and creating input files for testing. This
is especially true with analog inputs.
If I am using analog inputs, I write
those input routines next. I use the
output routine to verify that the analog
code is operating properly. I always
keep this output routine in the
program for possible future use. It
comes in handy if a change causes
problems. Often, I include it in the self-
test routines. If not, I convert the code
to comments so it doesn’t use any
resources but is there when I need it.
I then proceed to work through the
program, routine by routine. Generally,
I’ll develop related routines in
sequence. For example, if I have to
manipulate an analog input, I’ll do that
right after I’ve done the input routine.
It’s convenient. One thing I do that
bothers some people is to add the
comment “TESTED AND WORKING”
to every module that has been verified.
This way I never have to wonder, several weeks later, if I really tested it.
Additionally, it’s nice to see those milestones achieved. It’s a good idea to
keep a library of routines you develop.
It obviously saves a lot of time and
effort to re-use code rather than reinvent it. For example, there will always
be applications where you drive seven-segment LEDs for uCs. Therefore, you
will need a binary-to-seven-segment
LED conversion routine. If you make it
fairly general to begin with, you’ll be
able to easily use it repeatedly.
The Standard for checking
Good enough to be the
choice of Panasonic,
Pioneer, NBC, ABC, Ford,
JVC, NASA and thousands
of independent service
Locate shorted or leaky
components or conditions
to the exact spot in-circuit
Still cutting up the pcb,
and unsoldering every
part trying to guess at
where the short is?
NUTS & VOLTS
Your DVM shows the same shorted reading all
along the pcb trace. LeakSeeker 82B has the
resolution to find the defective component.
And with a 60 day trial period, satisfaction Touch pads along the trace, and LeakSeeker
guaranteed or money-back policy, the only beeps highest in pitch at the defect’s pad. Now
thing you can lose is all the time you’re you can locate a shorted part only a quarter of
currently spending on trying to repair all an inch away from a good part. Short can be
those dogs you’ve given up on. from 0 to 150 ohms
CapAnalyzer 88A LeakSeeker 82B
Available at your distributor, or call 561-487-6103
Electronic Design Specialists www.eds-inc.com
Inexpensive enough to pay for itself in just
one day’s repairs. At $199, it’s affordable.
I rarely use routines written by
someone else, even those supplied by
the manufacturer. The reason I write
my own routines is because I hate
being dependent upon someone
else’s expertise, or lack thereof. Most
likely, the subroutines provided by the
manufacturer work properly. But
what if they don’t? You will find a disclaimer in every applications note
saying that the code is not guaranteed to work. Additionally, there are
often many ways to approach a given
problem. How can you be sure that
the approach someone else used is
the best approach for you?
I call this creeping mediocrity
because there seems to be a growing
tendency to depend upon someone
else’s expertise, rather than on your
own. This is partly because systems
are becoming increasingly complicated and partly because there is greater
pressure to get to market in the shortest possible time. There is also the mistaken notion that whoever wrote the