Our resident expert on all things
robotic is merely an email away.
Tap into the sum of allhumanknowledge and get your questions answered here!
From software algorithms to material selection, Mr. Roboto strives to meet you
where you are — and what more would you expect from a complex service droid?
It is a new year. Part of me shudders (another year gone by) and part of me rejoices (what will be new this year?). Nothing seems to come
to a person without some kind of conflict! For
me, new stuff in robotics is ALWAYS interesting,
but it also comes with a conflict: What about the
stuff that I am already used to, know, love, and
am good with?
This month’s column started out much like
that little internal question I pondered above. In
our robot group’s discussions a little while ago,
that very question came up (YahooGroup:
FrontRangeRobotics). The group as a whole was
discussing how nice the Arduino environment is
for the newcomer to embedded programming
and amateur robotics. A regular poster (Oric_Dan
to those who see his posts all over the ‘net) asked
if the Arduino could handle software serial ports
in multiple numbers. He wanted to know if it
could possibly be a step up from that pioneer in
the embedded hobbyist world: the Parallax BASIC
Stamp. Well, no one knew. A lot of us have used
a BASIC Stamp as a central clearing house for our
digital I/O from serial inputs over the years, but
it’s been limited in how much it could buffer.
There just wasn’t that much RAM in the device.
So, I did some investigating, and here are the
Q. Can the Arduino open and use several serial ports at the same time so that many different devices can be
communicated with from a single microcontroller?
A. Good question! I’ve been a fan of the Arduino environment for about a year now. It runs on just about every OS there is out
there, it is open source, has inexpensive hardware,
and it is easy to use. What’s not to like?
Well, for one thing, the standard Arduino
library can only deal with the hardware UART
for serial communications. The Arduino has an
expansion library called SoftwareSerial which
adds a single software serial port; but it’s only
one port and it has some limitations. Fortunately,
the Arduino has an incredible open source
support network, and a group of folks developed
the NewSoftSerial library that helps us out.
NewSoftSerial (NSS) can add any number of
software serial ports to your Arduino project —
subject to your memory availability, obviously.
There are some caveats, however. I quote from
the NewSoftSerial developer’s site: “NewSoftSerial
is written on the principle that you can have as
many devices connected as resource constraints
allow, as long as you only use one of them at a
Hmm, what does that mean, “… use one of
them at a time ...” One way of looking at it is that
only one block of code can be used at a time so,
of course, only one NSS can be used at a time,
right? Wrong. Or rather, it depends. I did some
experiments to see what would and would not
work. I started out small, so let’s first see how to
add the expansion library to the Arduino
Install the Arduino
Get the latest version for Arduino which is
version 0017 from http://arduino.cc/en/Main/
Software select the one that matches your OS. I
am a Macintosh user, so for me I get a .dmg file
and just drag the Arduio.app file to a folder
SERVO 01.2010 15