Specifications

BASIC Stamp II
Page 308 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
sequence of bytes; or ignore a specified number of bytes. These
actions can be combined in any order in the inputData list.
Explanation
The BS2 can send and receive asynchronous serial data at speeds up to
50,000 bits per second. Serin, the serial-input instruction, can filter and
convert incoming data in powerful ways. With all this power inevita-
bly comes some complexity, which we’ll overcome by walking you
through the process of setting up Serin and understanding its options.
Physical/Electrical Interface
Since the STAMP2 host software runs on a PC, we’ll use its RS-232
COM ports as a basis for discussion of asynchronous serial communi-
cation. Asynchronous means “no clock.” Data can be sent using a single
wire, plus ground.
The other kind of serial, synchronous,
uses at least two wires, clock and data,
plus ground. The Shiftin and Shiftout
commands are used for a form of syn-
chronous serial communication.
RS-232 is the electrical specification for
the signals that PC COM ports use.
Unlike normal logic, in which a 1 is
represented by 5 volts and a 0 by 0
volts, RS-232 uses –12 volts for 1 and
+12 volts for 0.
Most circuits that receive RS-232 use
a line receiver. This component does
two things: (1) It converts the ±12 volts
of RS-232 to logic-compatible 0/5-volt
levels. (2) It inverts the relationship of
the voltage levels to corresponding
bits, so that volts = 1 and 0 volts = 0.
The BS2 has a line receiver on its SIN
pin (rpin = 16). See the BS2 hardware
Write custom software that uses the serial port with the
DTR line low. Under DOS, DTR is bit 0 of port $03FC or
$02FC (com 1 or 2, respectively). In QBASIC or
QuickBASIC, port locations are accessed using the INP
and OUT instructions. Here’s a QBASIC code fragment
that clears the DTR bit on com 1:
DTR
(DB9, pin 4)
0.1µF
(both)
Option 1: Custom Software
temp = INP(&H3FC)
OUT &H3FC,temp AND 254
However, even if this instruction is issued immediately after
the com port is OPENed, DTR goes high for almost 100ms
(more on a slow PC). This will cause the BS2 to reset,
unless the code runs
before
the BS2 is connected to the
com port.
Do not consider the software approach unless you are
an expert programmer able to go it alone, as there are
no canned examples available.
Insert the circuit below between the PC’s DTR output
and the BS2’s ATN input. The series capacitor blocks
DTR’s steady state (as set by a terminal program or
other software), but passes the attention/programming
pulse sent by the STAMP2 host software. The parallel
cap soaks up noise that might be coupled into the line.
Option 2: Capacitive Coupling of ATN
AT N
(BS2, pin 3)
The simplest solution is to break the ATN line and insert a
switch to let you conveniently connect and disconnect
DTR/ATN. When you want to program the BS2, close the
switch; when you want to communicate with some other
program, open the switch.
Option 3: Switch in ATN
DTR
(DB9, pin 4)
AT N
(BS2, pin 3)
close to program
Using the Carrier Board DB9 Connector
with PC Terminal Programs
Figure I-17