5: BASIC Stamp Command Reference - COUNT
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 89
COUNT
BS1
BS2 BS2e BS2sx BS2p
COUNT
Pin, Period, Variable
Function
Count the number of cycles (0-1-0 or 1-0-1) on the specified pin during the
Period time frame and store that number 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.
•
Period
is a variable/constant/expression (1 – 65535) specifying the
time during which to count. The unit of time for Period is described
in Table 5.3.
•
Variable
is a variable (usually a word) in which the count will be
stored.
Quick Facts
BS2
BS2e
BS2sx
BS2p
Units in Period
1 ms
1 ms
400 µs
287 µs
Period range
1 ms to
65.535 s
1 ms to
65.535 s
400 µs to
26.214 s
287 µs to
18.809 s
Minimum pulse
width
4.16 µs
4.16 µs
1.66 µs
1.20 µs
Maximum
frequency
(square wave)
120,000 Hz
120,000 Hz
300,000 Hz
416,700 Hz
Explanation
The COUNT instruction makes the Pin an input, then for the specified
period of time, counts cycles on that pin and stores the total in a variable.
A cycle is a change in state from 1 to 0 to 1, or from 0 to 1 to 0.
According to Table 5.3, COUNT on the BS2 can respond to transitions
(pulse widths) as small as 4.16 microseconds (µs). A cycle consists of two
transitions (e.g., 0 to 1, then 1 to 0), so COUNT (on the BS2) can respond to
square waves with periods as short as 8.32 µs; up to 120 kilohertz (kHz) in
frequency. For non-square waves (those whose high time and low time are
unequal), the shorter of the high and low times must be at least 4.16 µs in
width (on the BS2). Refer to Table 5.3 for data on other BASIC Stamps.
2
e
2
sx
2
p
2
Table 5.3: COUNT Quick Facts.
NOTE: All timing values are
approximate.
Содержание BASIC Stamp 2e
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...