28128 Parallax Inc, 28128 Datasheet - Page 124

no-image

28128

Manufacturer Part Number
28128
Description
KIT BASIC ANALOG/DIGI PARTS ONLY
Manufacturer
Parallax Inc
Datasheet

Specifications of 28128

Accessory Type
ADC, DAC
Product
Microcontroller Accessories
For Use With/related Products
BASIC Stamp® 2 and Board of Education
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
Program It
Let's make a program that counts how many times the pulse train repeats itself. In effect,
we will make a program that determines the frequency of the pulse train. The BASIC
Stamp has a built in feature for counting frequency, and the PBASIC command is the
count command.
The BASIC Stamp increments the counter when the input voltage passes the 1.4 volt I/O
pin threshold twice. This makes programming and interpreting the frequency data easy
for periodic signals such as the pulse train, triangle wave and sine wave. Figure 6-7
shows why there are two threshold crossings per repetition of the waveform. When a
waveform repeats itself, it's called a cycle. With a 5 volt amplitude and a 0 volt DC
offset. Notice how the waveform crosses the threshold voltage twice per cycle.
Enter Program Listing 6.2 into the BASIC Stamp Editor and save it as P6_2R0.bs2.
' Basic Analog and Digital - PL6_2R0.bs2
' Frequency Meter
' {$STAMP BS2}
' {$PBASIC 2.5}
f
DO
LOOP
When you run the program, and adjust pot B to its maximum, the output should be
somewhere in the neighborhood of the frequency shown in Figure 6-8.
COUNT 0, 1000, f
DEBUG HOME, "Frequency:
1.4 Volts
5 Volts
0 Volts
VAR
Word
", DEC4 f, " Hz.", CR, CR
1 full cycle
Two crossings of the
threshold voltage
Figure 6-7
Full Cycle of
a Pulse Train

Related parts for 28128