28129 Parallax Inc, 28129 Datasheet - Page 139

TEXT BASIC ANALOG & DIGITAL

28129

Manufacturer Part Number
28129
Description
TEXT BASIC ANALOG & DIGITAL
Manufacturer
Parallax Inc
Type
Programmingr
Datasheet

Specifications of 28129

Style
Book
Title
Basic Analog and Digital
Contents
Basic Analog and Digital Text
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
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 28129