e031068.pdf

(273 KB) Pobierz
MICRO CONTROLLER
The Javelin Stamp
Parallax goes Java
By Harry Baggen
Parallax Inc. from the USA are known the world over for their BASIC
Stamps, a series of microcontroller modules that can be programmed in
BASIC. The youngest member of the family not only offers more memory
than its predecessors, it also talks a different language: Java!
sional users, but also to hobbyists
and educational institutions.
Over the past 15 years, the Stamp
1 matured and customers got ever
better products, with more I/O lines,
more memory capacity and higher
clock speeds: the BASIC Stamp 2,
2e, 2sx and 2p24/2p40. They all have
one thing in common: programming
is achieved using the PBASIC lan-
guage designed by Parallax.
The arrival, last summer, of the
Javelin Stamp indicates that Parallax
have had the wherewithal to change
to Java, a programming language
that should be known to everyone
who’s ever been on the Internet. The
Java language offers the user more
possibilities than PBASIC, while
many programmers have already
acquired some knowledge of it, hav-
ing written applets for websites.
Features
Just as its predecessors, the Javelin
Stamp consists of a miniature PCB
with the footprint of a 24-way DIP
case (see introductory photograph).
It is pin compatible with the BASIC
Stamp and may be plugged onto any
BASIC Stamp board having a 24-pin
socket.
In addition to the Javelin Stamp
module proper, Parallax also supply
a dedicated starter kit ( Figure 1 ),
which consists of a Javelin module,
Rocklin (CA) based Parallax Inc. has
acquired name and fame with their Stamp
microcontroller modules (The Editor remem-
bers when they were a garden-shed com-
pany). The basic idea they had was simple
and effective: launch a microcontroller prod-
uct that’s easy to program and apply, allow-
ing relatively inexperienced users to
quickly develop an application without
deep knowledge of the dreaded phenome-
non called assembly code. The idea evolved
into a product called Basic Stamp,
a small module containing a PIC
running a BASIC interpreter, some
memory, a voltage regulator and a
resonator to furnish the microcon-
troller clock signal. A we write this
the Parallax company have been in
business for 15 years, shipping,
directly and via their distributor
network, impressive numbers of
BASIC Stamps, not only to profes-
68
Elektor Electronics
1/2003
993438755.009.png 993438755.010.png
 
MICRO CONTROLLER
a prototyping board, a manual, an
RS232 cable, a zero-modem adapter,
a CD-ROM and a set of components
for various worked out examples dis-
cussed in the manual.
The microcontroller used is an
SX48C from Ubicom. It gives you, the
user, 32 kBytes RAM, 32 kBytes
EEPROM, 16 I/O lines and 2 RS232
ports. The miniature, on-board
switch-mode power supply accepts
a wide input voltage range while it
is capable of supplying appreciable
current. Components are found at
both sides of the double-sided board.
The Javelin architecture is differ-
ent from that used for the BASIC
Stamp we have come to appreciate
so much. Although the program is
stored in EEPROM, the actual exe-
cutable code is fetched from a super-
fast SRAM (static RAM). The
firmware is designed such that
besides the main program a number
of tasks may be performed in the
background.
Figure 1. The starter kit contains everything to get started straight away.
A Java dialect
The Javelin Stamp employs a subset
of Java 1.2 as developed by Sun Sys-
tems. It contains firmware exten-
sions (known as Virtual Peripherals,
VPs) that emulate hardware like
UARTs, timers, A/D and D/A con-
verters, and so on. Using these VPs,
interfacing the Stamp to peripheral
equipment is straightforward.
Although the VPs cause the devel-
opment of a Javelin Stamp program
to deviate from that of a Java pro-
gram for the PC, all it takes is a little
getting used to, practicing and
experimenting — just the kind of
thing many of our readers will have
no objection to.
The following VPs are available:
UART, PWM, 32-bit timer, pulse
counter, pulsewidth measurement,
pulse generation, 1-bit DAC, sigma-
delta DAC, ADC with RC timer and
SPI master.
BASIC programmers will need to
‘think differently’, though, because
programming in Java is a totally dif-
ferent kettle of fish not vaguely
resembling BASIC. Fortunately, the
extensive manual supplied with the
Javelin Stamp supplies a fair num-
ber of example programs to make
the migration to Java as painless as
possible.
The two programs in Listing 1
illustrate some of the differences
between practical Java Stamp and
BASIC Stamp programming. Both
programs cause an LED to flash as
long as a certain key is pressed.
Most of you will recognize program
A as intended for the BASIC Stamp — ‘ B
shows the Java Stamp equivalent.
PC software
At the PC side, the user has available an inte-
grated Design Environment (IDE) containing
Figure 2. The development platform for the javelin Stamp contains an extensive editor and
debugger.
1/2003
Elektor Electronics
69
993438755.011.png 993438755.001.png 993438755.002.png 993438755.003.png 993438755.004.png
MICRO CONTROLLER
Listing 1
A. LED flasher with pushbutton control, BASIC Stamp version
output 0 ‘ make P0 an output
out0=1 ‘ make P0 “high”
Input 2
recheck: ‘ a label
if in2=0 then blink ‘ check to see if P2 is a “0”, if it is
‘ then go and blink the LED
goto recheck ‘ if P2 was a “1”, then go back
‘ and check again
blink: ‘ a label
low 0 ‘ turn on the LED
pause 200 ‘ wait .2 seconds
high 0 ‘ turn off the LED
pause 200 ‘ wait .2 seconds
goto recheck ‘ loop back & do it again
B. LED flasher with pushbutton control, Javelin Stamp version
import stamp.core.*;
public class ButtonLED {
static boolean P0 = true;
public static void main() {
while(true) {
if (CPU.readPin(CPU.pins[1]) == false) { // If button pressed
P0 = !P0; // Negate P0
CPU.writePin(CPU.pins[0],P0); // LED [On]
CPU.delay(1000);
} // end if
else {
CPU.writePin(CPU.pins[0],true); // LED [Off]
} // end else
} // end while
} // end main
} // end class declaration
an extensive editor, debugger and a Message
window ( Figure 2 ). The debugger is marked
by the following features:
– multiple breakpoint allowed
– stack backtrace
– variables and objects checking
– single-step, run, stop, reset
– inbuilt bi-directional serial
Message Terminal
Javelin Stamp. The whereabouts of
this information is also unchanged
— you’ll find it all on the Parallax
website. All documentation and PC
software is always available in the
latest versions. The website also
hosts an extensive Java library as
well as a page with applications.
This page is sure to grow in content
as an increasing number of pro-
grammers get their teeth in the
Javelin Stamp. A separate forum is
available on the website for users to
exchange ideas and practicalities.
(020355-1)
Parallax distributor for the UK
Milford Instruments Ltd., Leeds.
Tel. (+44) (0)1977 683665,
fax (+44) (0)1977 681465.
Email: sales@milinst.com
Website: www.milinst.com
Online help is available, giving access to
extensive documentation on the library
classes and some weblinks to Parallax.
Websites:
www.parallaxinc.com
www.javelinstamp.com
Support
Just as with the BASIC Stamp series, a vast
resource of information is available on the
70
Elektor Electronics
1/2003
993438755.005.png 993438755.006.png 993438755.007.png 993438755.008.png
 
Zgłoś jeśli naruszono regulamin