1998, 2001EME Systems, Berkeley CA
Systems Home Page>
BASIC Stamp Support
BASIC Stamp micro-controller has generated
enthusiasm in the electronics industry, where it has twice been
nominated EDN Product of the Year.
The family of BASIC Stamps is growing. It started with the BS2
original with the green mask seen at the right in the bottom
row in the
middle. Each new addition to the family adds new
and capabilities for either speed or low power operations.
- BS2 original 2k program memory, PIC microcontroller.
- BS2sx, 2.5 times the speed, 16k program memory, 64 byte
scratchpad RAM, SX28 microcontroller.
- BS2e, same speed as BS2 original, but with the additional memory
- BS2p, more speed than the BS2sx, 128 byte scratchpad, support for
I2C, and 1-wire
available in both -24 and -40 pin versions based on turbo SX48
- BS2pe, like '2p. but low power consumption, 16kbytes extra
memory, optimized for data logging.
- BS2px, like '2p, but more speed, added configuration and
The BASIC Stamp is popular among
professional engineers, educators and hobbyists alike. In this
you will find links to notes I have written about the Stamps. I add
to and change the material from time to time as I find new ways to do
things. I enjoy hearing if you find these pages helpful or, please,
if you find bugs I've missed.
the left, OWL2pe data
logger. This is based on the OEM BASIC
Stamp 2pe-40 chip, which is the 48 pin chip toward the upper left in
the photo. In addition to the functionality of the Stamp 2pe, the data
logger also includes a real time clock,
battery backed RAM, a 12-bit, 11 channel analog to digital converter,
1/2 megabyte of flash memory for data logging, power supplies and
protection for the inputs and outputs.
My own collection of links
to other stamp
Stamp SX WebRing site owned by Thomas
Previous Site | Next
Sites | Join
interface to the BASIC Stamp, and OWL2pe data logger
Some environmental sensors require
an Analog to Digital convertor, while other sensors connect directly to
the BASIC Stamp II
input pins. Both types are represented here. I have endeavored to use
a minimum of external hardware, to make best use of the BASIC Stamp
capabilities and to optimize the software routines.
The purpose of these document is to provide information about how
to connect different kinds of sensors to the OWL2pe data logger, or to
the BASIC Stamp generally. Some kinds of sensors such as the LM34
temperature sensor are analog and need to be connected to an analog
to digital converter input, such as the TLC2543 found on the OWL2pe.
Other kinds of sensors attach directly to the versitile Stamp io
pins, to measure time intervals, frequencies, counts, etc.. Examples of
this type of sensor are the rain gage, the anemometer or the digital
barometer. This document shows how to transform and display the data
in the proper units and most economically store it in memory, and
give hints about other issues that arise in appication of the
These techniques have both
software components. I have endevoured to develop techniques that use
a minimum of external hardware (such as in the case of the rain
gage), and software routines that run efficiently and minimize the
required code space. In the BS2 I was always running near the full
program capacity of the BS2 and had to prune and prune to minimize
the code. Some of the program requirements might seem a bit unusual,
but in the context of scientific research, you can run into some pretty
odd setups, odd timing and odd data processing.
- Analog to digital converter
- Humidity, with temperature too
- Wind, speed and direction (Examples use the DAVIS Instruments
- Light level, using the LI-COR scientific sensors, Pyranometer,
Quantum PAR, and Photometer.
- Rain, tipping bucket rain gage or event counter
- Soil moisture using tensiometer or Watermark or gypsum blocks
- Electrode type sensors
- Conductivity sensors
- Water level sensors
Stamp integer math and related topics
Some of the BASIC Stamp math operators are familiar, but others
may seem strange at first. Even simple addition, subtraction and
multiplication must be done with care, to avoid overflowing the 16
bit integer word, and simple division can easily lead to bogus
results. People expect answers as if from a push-button calculator.
Forget it! The BASIC Stamp calls for "work-arounds" and "insight". I
enjoy this kind of puzzle, and I hope you will too. At least the
results. It is a recipe book, and a tutorial on how to know if the
recipe will work in a given situation. Here the application notes are
broken into several HTML documents loosely organized by topic.
- Topics on
multiplying a variable times a constant fraction, sensor calibration.
- */ and ** operators for multiplying a
variable times a fraction
- how it works
- a cookbook example, how to compute
- example using the RCtime command to
determine and unknown capacitance
- example of Fahrenheit to Celsius
- example, computation of a well-tempered
- Topics in division,
where a variable is in the denominator
- long division, where both numerator and
denominator can be variables
- Example: precision calibration of a
- reciprocal of a variable and fast
inline division to improve accuracy
- Functions: the
square root, arccos & arctan, logarithm, and interpolation.
- arcCos and arcTan and trig functions
- interpolation of the square root
- logarithm by interpolation in a table
- logarithm by calculation
- tables and interpolation
- thermistor readout using interpolation
- Calculation and
display: Negatives, Decimals, Time and Date, IF-THEN-LET.
- BS2 integer math and negative numbers
- display of data with decimal point
- Bar Graph on LCD display, high
- Julian date and time
- IF-THEN LET constructs
calculations and digital filtering.
- statistics: mean, min, max, and S.D.
- max, min, median, mode: filtering
- Double precision
- addition, subtraction, negation
- multiplication double and up to
- division, where the denominator is a
compile time constant.
- division of a double precision
number by 10,100,1000, 60 and arbitrary.
- division, 32 bit numerator and 8 bit
- division, 32 bit numerator and 16 bit
- Multibyte long
division algorithm for microcontrollers
- interpretation of fixed point fractions
- CORDIC math primer
- What is a COordinate Rotation DIgital
Computer, and what does it have to do with the Stamp?
- The Givens transform
- Sine, Cosine, and Arctangent
BASIC Stamp miscellany, tricks
Command Central. Here you will find technical notes that describe
the operation of Stamp commands in more detail than is to be found in
the Parallax manuals. How to avoid pitfalls and bugs. Details of how
the commands really work. Application articles. Weird stuff.
- PBASIC 2.5
command syntax reference
- equivalent command sequences in old
- example programs
- for understanding and optimization
- RCtime command
- inside look at how the command works
- error sources
- monitoring photo-current and current
- monitoring battery voltage and current
- Many switches, one pin, revisited
- Measuring small voltages with RCtime
- PWM command
- nitty gritty details of how it works
and its timing.
- RS232 Serial
commands, SERIN and SEROUT
- how to use flow control, master-slave
scenarios, timing data, a bug, how to use a modem with the Stamp.
- Stamp Power supply,
- table of power supply currents.
- The SLEEP bug and the BS2 (BS2e and
BS2sx and BS2P exempt)
- working with SLEEP, NAP END
- brownouts, differences between the
- brownouts, effect on battery life and
integrity of variables
- The BASIC Stamp 2pe,
special considerations for low power consumption and data logging
- lThe sleep-wake cycle
- 32k byte memory for logging using
STORE, READ, WRITE
- Finite State Machines
- some examples of state machine logic
- encoders, games, keypad scanner, inside
look at the button command.
- BS2sx and BS2e
- Differences in speed, power consumption
- Electrical characteristics, operating
- Tricks to working in the multibank
- Strategies for allocation of "local"
and "global" variables
- crossbank "subroutine" calls
- example, double precision math library
- example, data logger
- example, OWL2e data logger
- Stamp timing and
speed of execution (BS2, BS2e and BS2sX)
- Table of times for many BS2 and BS2sx
- How fast will a BS2 (or SX or e)
program take to run?
- Some optimal timing loops
- BASIC Stamp bugs and
- the SLEEP bug, brownout bug, other
things that can go bump in the night.
- Stamp Cloning
- One BS2 can program another, and
another, and another...
- logic behind the Stache
- Interface to the
ATMEL dataflash (AT45D0xx) megabyte memory chips
- Up to 8 megabytes of flash memory, SPI
interface, plus lots of RAM too.
- IrDA infrared
communication interface using the MAX3100 UART
- IrDA infrared protocol is used by Palm
and WinCE computers for shortrange wireless.
- The MAX3100 is a UART that provides
buffering for input data, as well as IrDA drive.
- HP200LX palmtop to
program and offload the BS2
- A step by step procedure we use to
offload data from our OWL2 data loggers
- Set up the HP200LX to run STAMP2.EXE to
program the stamp in the field (or STAMP2SX.EXE or STAMP2e.EXE)
Earth Measurements, now
retitled and revised "Applied Sensors", Parallax stamps-in-class
I am proud to have written this curriculum for the Parallax
"Stamps-in-Class" program. This series is meant for advanced high
school students or college students in science or engineering, who
want exposure to how microcontrollers can be used in environmental
sciences. The Stamps-in-Class
web site describes this and other curricula, all free for
download. The following files in PDF format are available from this
Measurements full download (pdf)
- Chapter 1
- Audio transducer, and a digital
- Lesson 1 shows how to use a piezo
transducer for audio feedback, and then moves on to use the debug
command to display readings from a DS1620 temperature transducer. The
serial communication between the BASIC Stamp and the temperature
transducer is explained in detail.
- Chapter 2
- User interface, and a "talking
- This lesson adds a pushbutton and
teaches how to program it to respond to a single click, double click or
long click, and how to store data in eeprom. The pushbutton, sound
transducer and the temperature sensor are combined to make a "talking
thermometer" using Morse code.
- Chapter 3
- Temperature probe for
microenvironments, and calibration
- Lesson 3 adds another temperature
sensor to the mix, this one a small AD590 sensor constructed and
waterproofed on a long cable so that it can be extended out to probe
microenvironments. The BASIC Stamp reads the temperature using the
RCtime command. The sensor is calibrated using an ice bath and checked
against the DS1620 digital sensor.
- Chapter 4
- Light sensor, and data logging
- This lesson explains a photodiode as a
linear light detector, and uses it to explore the huge range of light
in the environment. Again, the text deals with principles and math of
calibration. The data is logged into memory, and means are provided to
record several data points and to play them back later.
- Chapter 5
- The liquid environment, water
conductance and level.
- Lesson 5 deals with the liquid
environment, namely, how to measure conductivity and water depth. An
LMC555 timer circuit is justified to provide AC excitation to the
electrodes. The program uses the count command and presents the data
using ascii graphics on the debug screen.
- Chapter 6
- Measurement and control, a water pump
and data logger.
- This final lesson adds an element of
control to the system. A pump controlled by the BASIC Stamp fills a
cup, and feedback from the conductance sensor is used to set a level
under computer control. The final project monitors two temperatures,
light level, and water level and controls the water level by turning
the pump on and off.