Serial ADC for BS2.
Connect National's Semiconductors serial analog to
digital converter ADC0831 to Basic Stamp 2 and digitize your
analog data. The required program couldn't be simpler
(literally only 3 commands).
There are many implementations of analog to digital
converters. However none of them can be compared to simplicity
with this. We need only three available ports from Basic stamp
Also you will need a stabilized 9 Volt external
power supply (a 9Volt alkaline battery is the best choice).
There is now schematic. Just connect the components on
the BS2 board's breadboard like the following picture.
Attention: The 1MÙ
trimmer you see in the picture is actually not necessary.
We only use it for demonstration purposes (to generate the
analog voltage we want to convert). Instead of the trimmer
you can apply the analog voltage, you want to convert, directly
to pin 2 of the ADC0831 chip (referenced to the ground Vss).
The program is the definition of simplicity. We reed the
converted data (meaning the digitized analog voltage)
with only one SHIFTIN command. Before that we enable the
chip bys setting the appropriate port to low (in our case port
P2). After the SHIFTIN command we set P2 high again.
' Enable ADC0831
' Read the converted data
' Disable ADC0831
ADResult is the byte where the digitized voltage will be
I wrote a simple program to demonstrate this. Download the