27220 Parallax Inc, 27220 Datasheet - Page 112

BOOK STAMPWORKS

27220

Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet

Specifications of 27220

Accessory Type
Booklet
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
StampWorks
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Not applicable / Not applicable
Program: SW21-EX16-Freq_Measure.BS2
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[ Program Description ]---------------------------------------------
'
' This program counts the number of events in one second and calculates
' frequency from it. Since frequency in Hertz is cycles per second, the
' number of cycles counted is the input frequency.
' -----[ I/O Definitions ]-------------------------------------------------
FreqIn
' -----[ Constants ]-------------------------------------------------------
OneSec
' -----[ Variables ]-------------------------------------------------------
cycles
' -----[ Program Code ]----------------------------------------------------
Main:
Behind the Scenes
In the previous experiment, several lines of code were used to count pulses on an
input pin. That method works when counting to a specific number. Other programs
will want to count the number of pulses that arrive during a specified time period.
The BASIC Stamp’s COUNT function is designed for this purpose.
The frequency of an oscillating signal is defined as the number of cycles per second
and is expressed in Hertz. The BASIC Stamp’s COUNT function monitors the specified
DO
LOOP
COUNT FreqIn, OneSec, cycles
DEBUG HOME,
"Frequency: ", DEC cycles, " Hz"
PIN
CON
VAR
15
1000
Word
' frequency input pin
' capture window = 1 sec
' counted cycles
' count for 1 second
' display

Related parts for 27220