5: BASIC Stamp Command Reference – PULSIN
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 241
PULSIN
BS1 BS2 BS2e BS2sx BS2p
PULSIN
Pin, State, Variable
Function
Measure the width of a pulse on Pin described by State and store the result
in Variable.
•
Pin
is a variable/constant/expression (0 – 15) that specifies the I/O
pin to use. This pin will be set to input mode.
•
State
is a variable/constant/expression (0 – 1) that specifies whether
the pulse to be measured is low (0) or high (1). A low pulse begins
with a 1-to-0 transition and a high pulse begins with a 0-to-1
transition.
•
Variable
is
a variable (usually a word) in which the measured pulse
duration will be stored. The unit of time for Variable is described in
Table 5.62.
Quick Facts
BS1
BS2
BS2e
BS2sx
BS2p
Units in Variable
10 µs
2 µs
2 µs
0.8 µs
0.75 µs
Maximum pulse
width
655.35 ms
131.07 ms
131.07 ms
52.428 ms
49.125 ms
Explanation
PULSIN is like a fast stopwatch that is triggered by a change in state (0 or
1) on the specified pin. The entire width of the specified pulse (high or
low) is measured, in units shown in Table 5.62, and stored in Variable.
Many analog properties (voltage, resistance, capacitance, frequency, duty
cycle) can be measured in terms of pulse durations. This makes PULSIN a
valuable form of analog-to-digital conversion.
PULSIN will wait, for the desired pulse, for up to the maximum pulse
width it can measure, shown in Table 5.62.
If it sees the desired pulse, it
measures the time until the end of the pulse and stores the result in
Variable. If it never sees the start of the pulse, or the pulse is too long
(greater than the Maximum Pulse Width shown in Table 5.62) PULSIN
1
2
e
2
sx
2
p
2
1
NOTE: Expressions are not
allowed as arguments on the BS1.
The range of the Pin argument on
the BS1 is 0 – 7.
Table 5.62: PULSIN Quick Facts.
S
PECIFICS OF
PULSIN'
S OPERATION
.
Summary of Contents for BASIC Stamp 2e
Page 1: ...BASIC Stamp Programming Manual Version 2 0c...
Page 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...