C PROGRAMMING
for Microcontrollers Made Easy
New, no-cost online system cuts start-up time
from hours to minutes
by Sam Christy
Many aspiring roboticists take their transition to writing C code for microcon- A Different Approach
first steps in programming embed- trollers can be daunting. Not only do you
ded controllers with interpreted have to learn a new programming lan- Machine Science, Inc., of
languages, such as LOGO and Basic. guage, you also have to install a range Cambridge, MA, has developed a new
These languages are fine entry points for of new software tools: a text editor or on-line system that radically simplifies
beginners, but after a short time, their integrated development environment the process of developing C code for
limitations can become frustrating. To (IDE) for writing and editing your code, a microcontrollers. This unique, patented
tackle more sophisticated projects, C compiler that works with your chip, system enables users to write and com-sooner or later you will have to move up and a utility for downloading the pile code using an on-line interface,
to writing code for microcontrollers in C. compiled code to your embedded device. rather than a locally installed IDE. The
With C, your code will run faster Finding all of the necessary software compiler is installed on a server, and
and you will gain access to advanced tools and getting them to work together downloading is accomplished with a
chip features, like interrupts and univer- properly is a major challenge, even for Java applet, so there is no software for
sal asynchronous receiver/transmitter experienced developers. Most compilers the user to install or configure locally.
(UART) capabilities. C is also designed provide little or no user interface. They To access the system, users simply
to be portable, unlike Basic, whose work mysteriously in the background, log in to the Machine Science website
myriad varieties can be incompatible waiting for instructions and files from and write their code in a text window,
with one another. Moreover, since most the IDE. Within the IDE, command line which provides useful features such as
professional developers program options must be set, telling the compiler editing tools, line numbering, and
embedded controllers in C, there is a which chip is being used and what type color-coded C syntax highlighting
wealth of C code available on-line to help of output file is expected. Likewise, the (Figure 1). Users can then compile their get you started on your next project. downloading software has to be config- code and send the compiled hex file to ured with the correct oscillator settings, a microcontroller in real time, with a Bootstrapping the 0Old Way0or els1e the code1will not run2correctly.0single1mouse clic0k. Since all1of the soft1-
Even after the IDE, compiler, and ware is server-based, the system works
For the novice, making the downloader have been installed and on both PCs and Macintosh computers.
configured, there is the issue of library In addition to cutting set-up time,
and header files. At this stage, the there are other advantages to using an
novice programmer may have only raw on-line development environment for
C — about 30 recognized words — to microcontroller projects. Code files are
work with. Some C compilers come automatically stored on the server and
with built-in code libraries, but others can be accessed from any Internet con-do not. So if you are trying to get start- nected computer. This is particularly
ed inexpensively, there may be a fair handy if you want to work on the same
amount of legwork left to do in order project at the office and at home, or at
to establish basic coding functionality, different terminals in a high school or
like delay routines and text output. university computer lab. As a resource
All of this just to get to “Hello for users, Machine Science also pro-World,” or more likely, in the case of an vides a suite of code libraries, covering
embedded controller, a blinking LED! everything from pulse width modulation (PWM) to controls for liquid crystal
displays and other external devices.
54 SERVO 01.2008
FIGURE 1. Machine Science online
programming environment.
120100011110102110001