28128 Parallax Inc, 28128 Datasheet - Page 58

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
The next section is called the variable declarations section, and it begins with a comment
explaining that this is the declarations section. This program uses just the
variable at present. We'll add code that will make use of the other four variables
v2,
Following is a new type of declaration we haven't used before. Three constants are
defined using the
of the number
2
pin labels. The numbers were chosen based on BASIC Stamp I/O pin numbers.
Next there's the main routine section containing three
loop runs 3 different subroutines over and over again. The subroutines are named
ADC_Data, Calc_Volts,
So, how does a
GOSUB ADC_Data
finished. The program jumps to the
soon as it gets to the
after
GOSUB Calc_Volts
. The names for the pin identifications were chosen to correspond with the ADC0831's
and
GOSUB ADC_Data
' -----[ Declarations ]---------------------------------------
adcBits
v
r
v2
v3
' -----[ Initialization ]-------------------------------------
CS
CLK
DataOutput
' -----[ Main Routine ]---------------------------------------
DO
LOOP
v3.
Subroutine is a small program that does a specific task within a larger program.
GOSUB ADC_Data
GOSUB Calc_Volts
GOSUB Display
0
,
GOSUB
CLK
PIN
means go to the subroutine labeled
.
in place of the number
RETURN
directive. After we define these constants, we can use
. In this case, the next command is another
command work? As shown in the flow diagram in Figure 3-5,
VAR
VAR
VAR
VAR
VAR
PIN
PIN
PIN
and
command, the program jumps back to the command just
Display
Byte
Byte
Byte
Byte
Byte
0
1
2
ADC_Data
.
1
, and
label and starts executing commands. As
DataOutput
GOSUB
ADC_Data
commands. The
in place of the number
and come back when
GOSUB
CS
command,
adcBits
, v, R,
DO…LOOP
in place

Related parts for 28128