Specifications

BASIC Stamp II
Page 290 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
stopped by 0-to-1
triggered by 1-to-0
measured in 2µs units
and stored in variable
PULSIN pin,0,variable
stopped by 1-to-0
triggered by 0-to-1
measured in 2µs units
and stored in variable
PULSIN pin,1,variable
Figure I-8
Figure I-8 shows how the state bit controls triggering of Pulsin.
I/O pin
100k
0.1µF
1k
+5V
Figure I-9
Demo Program
This program uses Pulsin to measure a pulse generated by discharg-
ing a 0.1µF capacitor through a 1k resistor as shown in figure I-9. Press-
ing the switch generates the pulse, which should ideally be approxi-
mately 120µs (60 Pulsin units of 2µs) long. Variations in component
values may produce results that are up to 10 units off from this value.
For more information on calculating resistor-capacitor timing, see the
RCtime instruction.
time var word
again:
PULSIN 7,1,time ' Measure positive pulse.
if time = 0 then again ' If 0, try again.
debug cls,dec ? time ' Otherwise, display result.
goto again ' Do it again.