BASIC stamp manual v2.2
PULSIN – BASIC Stamp Command Reference
Page 344 • BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com
(greater than the Maximum Pulse Width shown in Table 5.83) PULSIN
"times out" and store 0 in Variable. This operation keeps your program
from locking-up should the desired pulse never occur.
Regardless of the size of Variable, PULSIN internally uses a 16-bit timer.
Unless the pulse widths are known to be short enough to fit in an 8-bit
result, it is recommended to use a word-sized variable. Not doing so may
result in strange and misleading results as the BASIC Stamp will only
store the lower 8-bits into a byte variable.
Figure 5.28: R/C Pulse Generator.
Demo Program (PULSIN.bs1)
' PULSIN.bs1
' This program uses PULSIN to measure a pulse generated by discharging a
' 0.1 uF capacitor through a 1k resistor. Pressing the switch generates
' the pulse, which should ideally be approximately 120 us (12 PULSIN units
' of 10 us) 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 command.
' {$STAMP BS1}
' {$PBASIC 1.0}
SYMBOL Pulse = 7 ' pulse input pin
SYMBOL time = W1 ' pulse width (10 uS units)
H
OW THE RESULT IS REPORTED.
1