28129 Parallax Inc, 28129 Datasheet - Page 84

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
This is the start of the digital to analog conversion (DAC) subroutine, so it's descriptively
labeled
above 0 on an output scale of 0 to 16. The value of
The BASIC Stamp I/O pins connected to the D/A converter are set to output. These
commands are normally found in the declarations section. If they were placed in the
declarations section, the program would run faster because these commands would only
be done once at the beginning of the program. Instead, they are executed each time the
subroutine is run. The reason they were placed in the subroutine is to make it easier to
present some new PBASIC techniques.
Next, the BASIC Stamp's parallel binary output is sent to the D/A converter. We are
using the same command for sending outputs that was used in Chapters #1 and #2, but
there is a new feature added. The variable
nibble value is being used. For example, the command
value of pin P7 equal to the value of bit 3 in the nibble variable
of
it's 1, which means the output value of P7 is set high. Also, when
P5 is set high, and P4 is set high.
That's all it takes for programming digital to analog conversion using a resistive ladder
network. The
following the
The first two lines in the
binary values of
n
to 11, the binary value of
DAC
DAC:
RETURN
n = 11
OUTPUT 7
OUTPUT 6
OUTPUT 5
OUTPUT 4
OUT7 = n.BIT3
OUT6 = n.BIT2
OUT5 = n.BIT1
OUT4 = n.BIT0
DEBUG HOME, CR, CR, "Decimal value to DAC:
DEBUG CR, CR, "Binary value to DAC:
. The value of
GOSUB DAC
RETURN
n
, the 4-bit binary value used D/A output value.
command sends the program back to the command immediately
command in the
n
Display
is set to 11. This means that the output should be n steps
n
is 1011. Bit 3 is the leftmost bit of the binary number, so
subroutine are modified to show the decimal and
'
'
'
'
'
'
'
'
'
'
main:
'
n
has an extension to indicate which bit in the
routine.
n
can be changed to specify voltage.
", BIN4 n
OUT7=n.BIT3
n
. Since we set the value
n = 11
", DEC2 n
sets the output
, P6 is set low,
'
'

Related parts for 28129