2001EME Systems, Berkeley CA
Systems Home Page>
BASIC Stamp micro-controller has
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
original with the green mask seen at the right in the
row in the
middle. Each new addition to the family adds
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
- BS2p, more speed than the BS2sx, 128 byte scratchpad, support
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
you will find links to notes I have written about the Stamps. I
to and change the material from time to time as I find new ways
things. I enjoy hearing if you find these pages helpful or,
if you find bugs I've missed.
the left, OWL2pe data
logger. This is based on the OEM
Stamp 2pe-40 chip, which is the 48 pin chip toward the upper
the photo. In addition to the functionality of the Stamp 2pe,
logger also includes a real time clock,
battery backed RAM, a 12-bit, 11 channel analog to digital
1/2 megabyte of flash memory for data logging, power supplies
protection for the inputs and outputs.
My own collection of
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
an Analog to Digital convertor, while other sensors connect
the BASIC Stamp II
input pins. Both types are represented here. I have endeavored
a minimum of external hardware, to make best use of the BASIC
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,
the BASIC Stamp generally. Some kinds of sensors such as the LM34
temperature sensor are analog and need to be connected to an
to digital converter input, such as the TLC2543 found on the
Other kinds of sensors attach directly to the versitile Stamp io
pins, to measure time intervals, frequencies, counts, etc..
this type of sensor are the rain gage, the anemometer or the
barometer. This document shows how to transform and display the
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
a minimum of external hardware (such as in the case of the rain
gage), and software routines that run efficiently and minimize
required code space. In the BS2 I was always running near the
program capacity of the BS2 and had to prune and prune to
the code. Some of the program requirements might seem a bit
but in the context of scientific research, you can run into some
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
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
Forget it! The BASIC Stamp calls for "work-arounds" and "insight".
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
broken into several HTML documents loosely organized by topic.
- Topics on
multiplying a variable times a constant fraction, sensor
- */ and ** operators for multiplying
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
- Topics in
where a variable is in the denominator
- long division, where both numerator
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
- arcCos and arcTan and trig functions
- interpolation of the square root
- logarithm by interpolation in a
- logarithm by calculation
- tables and interpolation
- thermistor readout using
- Calculation and
display: Negatives, Decimals, Time and Date, IF-THEN-LET.
- BS2 integer math and negative
- 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
- Multibyte long
division algorithm for microcontrollers
- interpretation of fixed point
- CORDIC math
- What is a COordinate Rotation
Computer, and what does it have to do with the Stamp?
- The Givens transform
- Sine, Cosine, and Arctangent
BASIC Stamp miscellany,
Command Central. Here you will find technical notes that describe
the operation of Stamp commands in more detail than is to be found
the Parallax manuals. How to avoid pitfalls and bugs. Details of
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
- 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,
scenarios, timing data, a bug, how to use a modem with the
- Stamp Power
- 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
integrity of variables
- The BASIC Stamp 2pe,
special considerations for low power consumption and data
- lThe sleep-wake cycle
- 32k byte memory for logging using
STORE, READ, WRITE
- Finite State
- some examples of state machine logic
- encoders, games, keypad scanner,
look at the button command.
- BS2sx and BS2e
- Differences in speed, power
- Electrical characteristics,
- Tricks to working in the multibank
- Strategies for allocation of "local"
and "global" variables
- crossbank "subroutine" calls
- example, double precision math
- example, data logger
- example, OWL2e data logger
- Stamp timing and
speed of execution (BS2, BS2e and BS2sX)
- Table of times for many BS2 and
- How fast will a BS2 (or SX or e)
program take to run?
- Some optimal timing loops
- BASIC Stamp bugs
- 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,
interface, plus lots of RAM too.
- IrDA infrared
communication interface using the MAX3100 UART
- IrDA infrared protocol is used by
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
program the stamp in the field (or STAMP2SX.EXE or
Earth Measurements, now
retitled and revised "Applied Sensors", Parallax
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
site describes this and other curricula, all free for
download. The following files in PDF format are available from
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
command to display readings from a DS1620 temperature
serial communication between the BASIC Stamp and the
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
transducer and the temperature sensor are combined to make
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
waterproofed on a long cable so that it can be extended
out to probe
microenvironments. The BASIC Stamp reads the temperature
RCtime command. The sensor is calibrated using an ice bath
against the DS1620 digital sensor.
- Chapter 4
- Light sensor, and data logging
- This lesson explains a photodiode as
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
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
LMC555 timer circuit is justified to provide AC excitation
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
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
light level, and water level and controls the water level
the pump on and off.