BASIC Stamp
Support
Index
(c)
1998,
2001EME Systems, Berkeley CA
U.S.A.
<to EME
Systems Home Page>
<updated 1/8/08>
The Parallax
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
features
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
microcontroller.
- BS2pe, like '2p. but low power consumption, 16kbytes extra
memory, optimized for data logging.
- BS2px, like '2p, but more speed, added configuration and
comparator commands.
The BASIC Stamp is popular among
professional engineers, educators and hobbyists alike. In
this
index
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.
To
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
sites
Sensor
interface to the BASIC Stamp, and OWL2pe data logger
|
<top>
<next>
|
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
sensors.
These techniques have both
hardware and
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
- Temperature
- Humidity, with temperature too
- Wind, speed and direction (Examples use the DAVIS Instruments
77xx)
- 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
- Miscellaneous
BASIC
Stamp
integer math and related topics
|
<top>
<next>
|
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
Y=X*1.2207
- example using the RCtime command to
determine and unknown capacitance
- example of Fahrenheit to Celsius
conversion
- example, computation of a
well-tempered
musical scale
- 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
light sensor
- 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
resolution
- Julian date and time
- IF-THEN LET constructs
- Statistical
calculations and digital filtering.
- smoothing
- statistics: mean, min, max, and S.D.
- max, min, median, mode: filtering
- Double precision
calculations
- addition, subtraction, negation
- multiplication double and up to
quadruple precision
- 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
denominator
- division, 32 bit numerator and 16
bit
denominator
- theory
- Multibyte long
division algorithm for microcontrollers
- algorithm
- theory
- interpretation of fixed point
fractions
- CORDIC math
primer
(in progress)
- 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
and explorations
|
<top>
<next>
|
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
PBASIC
- example programs
- for understanding and optimization
- RCtime command
- inside look at how the command works
- error sources
- monitoring photo-current and current
output sensors
- 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
stamps
- 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
application notes
- Differences in speed, power
consumption
and compatibility
- Electrical characteristics,
operating
and sleep
- Tricks to working in the multibank
programming environment
- 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
commands
- How fast will a BS2 (or SX or e)
program take to run?
- Some optimal timing loops
- BASIC Stamp bugs
and
gotchas
- 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
curriculum
|
<top>
|
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
web site.
Earth
Measurements
full download (pdf)
- Chapter 1
- Audio transducer, and a digital
temperature sensor
- 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
thermometer"
- 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.
.<top>
<home>
< mailto:info@emesystems.com>