27220 Parallax Inc, 27220 Datasheet - Page 118

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
The BASIC Stamp’s PULSIN function is designed to measure the width of an
incoming pulse. By using PULSIN to measure the high and low portions of an
incoming signal, its period and frequency can be calculated. The result of PULSIN
(on the BS2) is expressed in units of two microseconds. First the PULSIN values
are converted to µs by the following formula:
Scale refers to the units of the PULSIN command. Thus, the formula for calculating
frequency becomes:
This creates a problem for BASIC Stamp math though, as values are limited to 16
bits (maximum value is 65,535). To fix the formula, we can divide 1,000,000 by 16
(62,500) and rewrite the formula like this:
This formula works with any BS2 module – after the raw measurements from
PULSIN have been converted to microseconds. This is the purpose of the Scale
constant in the program: it converts the raw input from PULSIN to microseconds for
the generalized frequency calculations.
Run the program and adjust the 10 kΩ potentiometer. Notice that the Debug
Terminal window is updated without delay and that there is no waiting as when
using COUNT to determine frequency. This method of measuring a frequency works
better at higher frequencies (above 100 Hz).
period = (pLow + pHigh) */ Scale
Frequency = 1,000,000 / period (µs)
Frequency = 62,500 / period (µs) * 16

Related parts for 27220