BASIC Stamp computer
Colin Fahey
1. Introduction
2002.06
The BASIC Stamp is a computer that can be programmed using the BASIC (PBASIC) programming language, and the entire computer is about the size of a postage stamp.
BASIC Stamp computers are manufactured by Parallax, Inc.
Each BASIC Stamp computer is actually a tiny circuit board, with pins to allow the board to be plugged in to sockets like conventional microchips.
There is a family of BASIC Stamp computers: 1, 2, 2E, 2SX, 2P, ...; each differing in physical size and capabilities.

BASIC Stamp 1 (Notice the PIC16C56 microchip)

BASIC Stamp 2 (Notice the PIC16C57 microchip)
The core of each BASIC Stamp computer is a microcontroller: the PIC16C5x manufactured by Microchip Technology, Inc.
Here is a link to the data sheet for the PIC16C57C microcontroller, which is the core of the BASIC Stamp 2 circuit board.
Here's a link to a local copy of the PIC16C5X data sheet (which includes data for the PIC16C57C microcontroller):

The PIC16C57 microchip signals (as specified in the data sheet)

The PIC16C57 microchip instruction set (as specified in the data sheet)
Note that the PIC16C5X (e.g., X = 7C) instruction set is the native language of the microchip, and is not the BASIC (PBASIC) programming language.
I think the PBASIC compiler converts PBASIC code in to the microcontroller's native language.
Here are some specifications for the BASIC Stamp 2 circuit board computer:
================================================================
BASIC Stamp 2 - SPECIFICATIONS
================================================================
CORE: PIC16C57C (manufacturer: "Microchip Technology, Inc.")
-------------------------------------------------------------
RAM: 72 Bytes
EEPROM: 2048 Bytes
SPEED: 40 MHz (max)
I/O: 20 TTL Inputs/Outputs (configurable)
POWER: 5 VDC
BOARD / PBASIC INTERFACE:
-------------------------
POWER: 5 VDC
RAM: 32 Bytes (26 bytes user variables, 6 bytes I/O variables)
EEPROM: ~600 PBASIC instructions capacity
SPEED: ~4000 PBASIC instructions per second
SERIAL: 9600 baud typical (up to 100kbaud)
================================================================
Note that the PIC16C57C microchip contains the RAM, EEPROM, I/O lines, and serial I/O port implementation.
The BASIC Stamp 2 board provides very simple electrical support to the microcontroller. Although the PIC16C57C microchip works in terms of 33 native assembly language instructions, and can operate at a clock speed of 40 MHz, we only use PBASIC when we use the BASIC Stamp 2 software in conjunction with the board.
2. The "Board of Education" by Parallax, Inc.
Parallax, Inc. manufactures a product called the "Board of Education", which offers a convenient way to experiment with their BASIC Stamp 2 product.

The "Board of Education" by Parallax, Inc. (the BASIC Stamp 2 module is not shown in the socket)

The "Board of Education" by Parallax, Inc. (the BASIC Stamp 2 module is shown in the socket)
3. Testing the "Board of Education"
I purchased the BASIC Stamp 2 and the "Board of Education" together in a product called "BOE-BOT ROBOT FULL KIT", produced by Parallax, Inc.
This kit cost $199.99 at Fry's Electronics.
The kit contains: (1) BASIC Stamp 2 module; (2) "Board of Education" board; (3) RS-232 cable; (4) Software CD-ROM; (5) Simple robot parts (2 servo motors, LED, piezo speaker, robot chassis, robot wheels, transistors, resistors, capacitors); (6) BASIC Stamp programming book; (7) BOE-Robot construction book.
I purchased the kit because I have a fascination with embedded computers, and this kit had EVERYTHING needed to start playing around immediately.
I was not very interested in the "robot" aspect of the kit, and I don't think that the cost of the robot parts was a significant fraction of the overall price of the kit.
The robot parts can be used for the many experiments described in the BASIC Stamp programming book (with demonstration code on the CD-ROM).
The product is so easy to use that I was able to execute demonstration programs on BASIC Stamp 2 computer within 15 minutes of opening the box of the product.
The most difficult and time-consuming aspect of getting started was trying to install the software from the CD-ROM on to my PC, and then waiting for the files to copy!
I plugged in the RS-232 cable to a serial port (COM1) on my PC, and put 4 "AA" batteries in the battery pack, and plugged the BASIC Stamp 2 module in to the socket on the "Board of Education" board, started the PBASIC editor for Windows, opened a demonstration program file, and did Control-R to run...
A progress indicator indicated the progress of the transfer of code from the PC to the BASIC Stamp 2 module via RS-232 (COM1).
A moment later, the program was running!
Once a program is transferred, you can disconnect the RS-232 cable.
Because the program is stored in EEPROM (electrically erasable programmable memory), you can turn off the power to the board without losing the stored program.
When you turn the power on for the board, the program starts execution. You can restart the program with the reset button, too.
Here is a picture of my "Board of Education" board and BASIC Stamp 2 module, with power suppiled by four batteries.

The "Board of Education", with BASIC Stamp 2, with batteries.

The "Board of Education", with BASIC Stamp 2, with power.
Here is an entire PBASIC program to play the "Mary Had a Little Lamb" melody through a piezo speaker:
'========================================================================
'{$STAMP BS2} 'STAMP directive (specifies a BS2)
'------------------------------------------------------------------------
i VAR BYTE ' Counter for position in tune.
f VAR WORD ' Frequency of note for FREQOUT.
C CON 2092 ' C note
D CON 2348 ' D note
E CON 2636 ' E note
G CON 3136 ' G note
R CON 0 ' Silent pause (rest).
'------------------------------------------------------------------------
FOR i = 0 TO 28 ' Play the 29 notes of the LOOKUP table.
LOOKUP i,[E,D,C,D,E,E,E,R,D,D,D,R,E,G,G,R,E,D,C,D,E,E,E,E,D,D,E,D,C],f
FREQOUT 11,225,f,(f MIN 8) - 8
NEXT
STOP
'========================================================================
That program is quite simple!
Here is an audio recording of the BASIC Stamp 2 playing the "Mary Had a Little Lamb" melody through a piezo speaker, recorded by a microphone:
freqout_m8.wav
"Mary Had a Little Lamb" played by BASIC Stamp 2
72450 bytes
MD5: 48eb64680279abd341aa63ceabe44a03