28128 Parallax Inc, 28128 Datasheet - Page 139

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
Usually, we know what voltage we want, so we can rearrange the equation to tell us what
duty we need:
Since we want our D/A output to be 3.25 volts:
The number 165.75 should be rounded to 166 so that we can set the duty to an integer
value.
The last quantity we need to determine for the
how many milliseconds the PWM output lasts, and it can be a number up to 65,535. The
typical method for choosing how many cycles to charge is:
Since we used a 1.0 µF capacitor and a 10 kΩ resistor,
For the components we are using, we need to set the
40.
Now we know that to generate a 3.25 volt output, our
Let's try it.
Program It
Modify the declarations section of Program 4.1 so that the variable n is defined as a word
instead of a nibble:
duty = 255 × (D/A Output ÷ 5)
duty = 255 × (3.25 ÷ 5) = 165.75
cycles = 4 × R × C, in milliseconds
cycles = 4 × 0.000001 × 10,000 = 0.04 = 40 × 10-3 = 40 ms
' -----[ Declarations ]--------------------------------------
adcBits
v
r
v2
v3
n
' -----[ Initialization ]------------------------------------
CS
PWM 8, 166, 40
VAR
VAR
VAR
VAR
VAR
VAR
PIN
Byte
Byte
Byte
Byte
Byte
Word
0
PWM
command is
Cycles
PWM
changed line
command needs to be:
value in the
Cycles
, which specifies
PWM
command to

Related parts for 28128