ADVENTURES IN PROPELLER PROGRAMMING
■ BY JON WILLIAMS
BASIC PROPELLER PROGRAMMING
We knew it had to happen, right? After all, Parallax and BASIC go together
like macaroni and cheese. On their own, the elements are great. When you
get them together, you create absolute magic!
I think it’s safe to say that more than a few Parallax customers were
disappointed when the Propeller arrived and couldn’t be programmed in
BASIC. Like me, many of these customers had invested years learning and
working with BASIC, and a good portion of that group had a lot of time
with embedded projects thanks to PBASIC. Now, I’m not being critical.
Spin is okay with me and I’m quite comfortable with it. That said, I’ve been
programming in one form of BASIC or another for almost 30 years, and that
kind-of makes BASIC a little bit hard to give up.
Well ... good news! The team that developed SX/B (headed by Terry “Bean” Hitt) has taken the lessons
learned from that product and created a BASIC language
compiler for the Propeller: PropBASIC. So, if you’ve been
holding off getting into the Propeller because you couldn’t
use BASIC, you have no more excuses.
WHAT IS PROPBASIC, ANYWAY?
Beyond the obvious, of course, PropBASIC is a single-pass compiler that generates Propeller assembly code so
that our programs run at the fastest speed possible. The
output is one or more Spin files that can be downloaded
to the Propeller. In version 1.0, the main program code is
limited to a single cog. Don’t let this bother you —
Propeller assembly is very powerful and processes that
take several assembly instructions in other micros are
handled with a single instruction in the Propeller. To top
that, we have seven additional cogs available and
PropBASIC lets us use them with tasks. In the future, it is
very likely that PropBASIC will adopt [Propeller whiz] Bill
■ FIGURE 1. LED circuit.
Henning’s LMM (large memory model) architecture,
allowing the compiled output to run from the Hub RAM,
breaking the 2K limit imposed by a cog.
For those that have used SX/B, PropBASIC will seem
very familiar and you should be able to migrate many of
your projects with just a few changes. If you’re coming
straight from the BASIC Stamp (or one of its many work-alikes), you’ll find PropBASIC similar to PBASIC, though
not directly compatible. Trust me, it’s not a problem; the
learning curve is very small. Many of us — myself included
— transitioned from the BASIC Stamp to the SX using
SX/B. The transition from PBASIC to PropBASIC will be
just as easy, and a lot of fun. Yes, you’ll have to get used
to a slightly new way of doing things, but once you do
you’ll wish you’d made the transition to a multi-core
Every PC programming book, no matter the language
it teaches, starts out with the now infamous “Hello,
World” program. Starting simple is smart as it allows us to
get the fundamentals in place before tackling the big stuff.
In the microcontroller world, we tend to blink an LED.
Trivial? Yes. Important? Yes! If we can’t blink an LED, then
we certainly can’t expect to control a multi-axis robot
using GPS input, now can we? Go ahead and connect an
LED circuit as shown in Figure 1. If you have a Propeller
demo board, that LED is in place.