28128 Parallax Inc, 28128 Datasheet - Page 65

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
So, now we know to multiply by 5 and divide by 255 for a 5 volt scale with 256 levels.
We can calculate the voltage from Figure 3-6 where the ADC0831’s output is 10100101
= 165. The measured voltage is:
To calculate and display this voltage using the BASIC Stamp, we’ll add some code to
both the
expressed in PBASIC code. Here is an example of some code that could reasonably be
expected to work.
This PBASIC calculation looks like it will give us the output we want, but it won’t. It’s
instructive to try it this way and see what happens. Modify the
subroutines in Program Listing 3.1 as follows:
We calculated that 165 would lead to a measured voltage of 3.24 volts. The 003 volts
shown in Figure 3-7 is only accurate to the nearest volt! What happened?
v = 5 * adcBits / 255
Calc_Volts:
RETURN
Display:
RETURN
Voltage
Calc_Volts
v = 5 * adcBits / 255
DEBUG HOME
DEBUG "8-bit binary value:
DEBUG CR, CR, "Decimal value:
DEBUG CR, CR, "DVM Reading:
=
5
×
255
165
and
=
Display
3.24
Volts
subroutines. First, the voltage equation needs to be
rounded
", BIN8 adcBits
to
", DEC3 v, " Volts"
two
", DEC3 adcBits
decimal
places
Calc_Volts
.
'
'
and
new line
new line
Display

Related parts for 28128