that we can install our 24-pin Stamp. Again, the enclosure
is designed well and intended for a grungy industrial environment, so there's no slop. On the back (opposite the I/O
connections label), you'll find three slots where you can use
a small screwdriver to release the locking tabs that hold the
case halves together. Go slowly, as the DIN rail lock is
spring-loaded and if you're not careful, it can go flying. (Ask
me how I know ...)
Once the case is open, you'll see two sockets: a wide
24-pin socket for the Stamp and a skinny DIP socket for
the optional MAX1270 ADC. Install the Stamp so that pin
1 is oriented toward the input connectors; do the same for
Before we put the Stamp PLC back together, we need
to configure the MAX1270 input channels. We have two
choices: voltage or 4-20 mA inputs. Adjacent to the right
side of the MAX1270, you'll see a line of eight header
posts; these are organized as two posts for each channel.
If we want to measure voltage (which is software configurable for various ranges), we leave the jumper out. If we
want a particular channel to measure a 4-20 mA current
signal, we need to add the jumper. Figure 1 shows the
inside of my Stamp PLC with a Javelin installed, the
MAX1270 installed, and channel four of the ADC inputs
configured for a 4-20 mA current signal.
Let's start with some hardware definitions. The BASIC
Clock PIN 0
Ld165 PIN 1
Di165 PIN 2
AdcCS PIN 3
AdcDo PIN 4
AdcDi PIN 5
Okay, these are easy. Now let's look at the same pin
definitions in the Javelin Stamp:
static final int CLOCK = CPU.pin0;
static final int LD_165 = CPU.pin1;
static final int DI_165 = CPU.pin2;
static final int ADC_CS = CPU.pin3;
static final int ADC_DO = CPU.pin4;
static final int ADC_DI = CPU.pin5;
What's In a Name?
Those of you that know me know that I am a bit of a
maniac when it comes to what I consider "proper" code
writing — a big part of that is using well-planned constant,
variable, and label names to make writing, reading, and
especially debugging my code a lot easier. Technically,
PBASIC has no formal standards for
naming and formatting, but many of
us have adopted standards used by
other flavors of BASIC (notably,
My experience is that Java is less
tolerant of free-form (sloppy) formatting, and there seems to be a standard that most Java programmers follow. The standard that I follow is articulated in the book, The Elements of
Java Style (ISBN: 0521777682). I
enjoyed this little book so much that I
used it as a model for a short document called The Elements of PBASIC
Style that demonstrates how we at
Parallax are now formatting our programs (this is an on-going process, so
older listings do not reflect this standard).
You can download the PBASIC
style document from the Parallax
Okay, before you run out the door screaming ... take a
deep breath, it's not so hard. What I can tell you is that setting up a program in the Javelin does require a bit more
effort. What you'll find, though, is that as the program
grows very large, things get easier to deal with in the
Javelin versus the BASIC Stamp, especially since the
Javelin allows us to have 32K of contiguous memory and
a bunch more variable space. When we get into reusable
class modules, it's a whole new world.
Let's press on. The keyword "static" is very important
as it allows us to define a constant, variable, or method (a
Java function or procedure) as part of a class instead of as
part of an object. What this lets us do is use that constant,
variable, or method without declaring an object. An example of this is the CPU class that declares many static values
The technology builder's source for kits, components, supplies, tools, books and education.
Robot Kits For All Skill Levels
ICs, Transistors, Project Kits
Motors, Frame Components
and Scratch Builder Supplies.
BEAM Kits and Components
Order by Internet, phone, fax or mail.
1405 Huntington Avenue, Suite 150
South San Francisco, CA 94080
Visit our showroom near SFO!
Most orders ship the day received! World-wide shipping. Convenient payment options.