Basic Stamp overview

The Basic Stamp (shown wired for the X-10 TW523 in Figure 23) is a small microcontroller programmed with firmware to interpret the Basic programming language. The Basic Stamp 2 (BS2) module we used includes 32 bytes of RAM, of which 6 are used for I/O and 26 for variables, and 2KB of EEPROM, enough to hold around 500 instructions.

Parallax Basic Stamp
FIGURE 23: Parallax Basic Stamp

Performance of the Basic Stamps ranges from about 4K to 12K instructions per second, a range of about 3:1.We used the following program to make the performance measurements, commenting out different parts of the program and changing variable types for the different tests. The version in the listing is the one used for the GOSUB benchmark.

The Basic Stamp doesn’t have a built-in real-time clock, so we timed execution with a stopwatch, adjusting the loop count to require 20–30 seconds total except for the GOSUB, which required about twice as long.Times shown in the table for the assignments and GOSUB tests are after subtracting off the 22 seconds required for the FOR-NEXT loop using a word variable. Depending on the actual program you run, the table results are reasonably consistent with the performance Parallax states for the BS2, which is about 4K instructions per second. In comparison, the Javelin Stamp Java processor runs far faster, at about 1 µ per FOR loop iteration — over 700 times faster than the Basic Stamp.

The BS2 performance is acceptable for relatively slowly changing work, such as user interfaces, weather readings, or process control calculations, but won’t handle the faster demands of interfaces to A/D or D/A converters, or to many I/O devices. The TW523 is a good example — zero crossings occur a little more than 8 ms apart, leaving time for very few instructions, and fewer yet if you tried to organize your program with a modular structure involving loops

and subroutines. The need for an interpreter running on the small embedded microcontroller to execute the Basic Stamp language accounts for the relative slowness when compared to the processor’s 20 MHz clock. The Basic Stamp language compensates for the overhead of the interpreter by including several built-in commands to execute common embedded functions at much higher speed. Those built-in commands include ones to do A/D and D/A conversions, interface to serial communication ports and synchronous serial devices, generate DTMF tones used on telephone lines, and support raw interfaces to LCDs.