Basic Analog and Digital
Student Guide
VERSION 1.4
WARRANTY
Parallax, Inc. warrants its products against defects in materials and workmanship for a period of 90 days. If you
discover a defect, Parallax will, at its option, repair, replace, or refund the purchase price. Simply call for a Return
Merchandise Authorization (RMA) number, write the number on the outside of the box and send it back to Parallax.
Please include your name, telephone number, shipping address, and a description of the problem. We will return your
product, or its replacement, using the same shipping method used to ship the product to Parallax.
14-DAY MONEY BACK GUARANTEE
If, within 14 days of having received your product, you find that it does not suit your needs, you may return it for a
full refund. Parallax, Inc. will refund the purchase price of the product, excluding shipping / handling costs. This does
not apply if the product has been altered or damaged.
COPYRIGHTS AND TRADEMARKS
This documentation is copyright 1999-2008 by Parallax Inc. By downloading or obtaining a printed copy of this
documentation or software you agree that it is to be used exclusively with Parallax products. Any other uses are not
permitted and may represent a violation of Parallax copyrights, legally punishable according to Federal copyright or
intellectual property laws. Any duplication of this documentation for commercial uses is expressly prohibited by
Parallax Inc. Duplication for educational use is permitted, subject to the following Conditions of Duplication: the
text, or any portion thereof, may not be duplicated for commercial use; it may be duplicated only for educational
purposes when used solely in conjunction with Parallax products, and the user may recover from the student only the
cost of duplication.
This text is available in printed format from Parallax Inc. Because we print the text in volume, the consumer price is
often less than typical retail duplication charges.
BASIC Stamp, Stamps in Class, Board of Education, Boe-Bot, SumoBot, Toddler, and SX-Key are registered
trademarks of Parallax, Inc. HomeWork Board, Propeller, Parallax, and the Parallax logo are trademarks of Parallax
Inc. If you decide to use trademarks of Parallax Inc. on your web page or in printed material, you must state that
"(trademark) is a (registered) trademark of Parallax Inc.”, “upon the first appearance of the trademark name in each
printed document or web page. Other brand and product names are trademarks or registered trademarks of their
respective holders.
ISBN 10: 1-928982-04-2
ISBN 13: 9-781928-982456
1.4.0-08.05.13-SCP
DISCLAIMER OF LIABILITY
Parallax, Inc. is not responsible for special, incidental, or consequential damages resulting from any breach of
warranty, or under any legal theory, including lost profits, downtime, goodwill, damage to or replacement of
equipment or property, and any costs or recovering, reprogramming, or reproducing any data stored in or used with
Parallax products. Parallax is also not responsible for any personal damage, including that to life and health, resulting
from use of any of our products. You take full responsibility for your BASIC Stamp application, no matter how life-
threatening it may be.
INTERNET DISCUSSION LISTS
We maintain active web-based discussion forums for people interested in Parallax products. These lists are accessible
from www.parallax.com via the Support
→
Discussion Forums menu. These are the forums that we operate from our
web site:
Propeller Chip – This forum is for users of the multiprocessing Parallax Propeller chip.
BASIC Stamp – This forum is widely utilized by engineers, hobbyists and students who share their
BASIC Stamp projects and ask questions.
SX Microcontrollers and SX-Key – Discussion of programming the SX microcontroller with Parallax
assembly language SX – Key
®
tools and 3rd party BASIC and C compilers.
Stamps in Class
®
– Created for educators and students, subscribers discuss the use of the Stamps in Class
series in their courses. Students, educators and hobbyists are welcome to participate.
Javelin Stamp – Discussion of application and design using the Javelin Stamp, a Parallax module that is
programmed using a subset of Sun Microsystems’ Java
®
programming language.
Robotics – Designed exclusively for Parallax robots, this forum is intended to be an open dialogue for
robotics enthusiasts. Topics include assembly, source code, expansion, and manual updates. The Boe-
Bot
™
, Toddler
™
, SumoBot
®
, HexCrawler and QuadCrawler robots are discussed here.
HYDRA – A place for enthusiasts of the Propeller-based HYDRA game development system.
Parallax Educators – A private forum exclusively for educators and those who contribute to the
development of Stamps in Class. Parallax created this forum for educators to provide feed back and to
obtain, develop, and share teaching materials.
ERRATA
While great effort is made to assure the accuracy of our texts, errors may still exist. If you find an error, please let us
know by sending an email to editor@parallax.com. We continually strive to improve all of our educational materials
and documentation, and frequently revise our texts. Occasionally, an Errata sheet with a list of known errors and
corrections for a given text will be posted to our web site, www.parallax.com. Please check the individual product
page’s free downloads for an errata file.
Table of Contents ·
Page i
Table of Contents
Preface.........................................................................................................................v
Audience and Teacher’s Guide ...................................................................................... v
Conditions of Duplication ............................................................................................... vi
Foreign Translations ...................................................................................................... vi
Special Contributors ...................................................................................................... vi
Chapter #1: Analog Voltage and Binary States .......................................................1
Introduction to Analog and Digital...................................................................................1
Parts Required ...........................................................................................................2
Building the Analog and Digital Comparator ..............................................................7
Programming the Project ...........................................................................................9
What have I learned? ...............................................................................................15
Questions .................................................................................................................16
Challenge! ................................................................................................................16
Why did I learn it? ....................................................................................................17
How can I apply this? ...............................................................................................17
Chapter #2: Introduction to Bit Crunching ............................................................19
Basic Comunication ......................................................................................................19
Parts Required .........................................................................................................19
Building the Circuit ...................................................................................................20
Programming the Project .........................................................................................22
Parallel and Serial Transmission..............................................................................30
Reprogramming to Receive Serial Data...................................................................31
What have I learned? ...............................................................................................37
Questions .................................................................................................................38
Challenge! ................................................................................................................38
Why did I learn it? ....................................................................................................39
How can I apply this? ...............................................................................................39
Chapter #3: Basic Analog to Digital Conversion...................................................41
Build Your Own Digital DC Voltmeter ...........................................................................41
Parts Required .........................................................................................................42
The Potentiometer - A Source of Variable Voltage ..................................................42
The ADC0831 Integrated Circuit - An 8-bit Analog to Digital Converter ..................43
Build It ......................................................................................................................45
Program It ................................................................................................................45
Binary to Decimal Conversion Revisited ..................................................................52
Calculate Voltage .....................................................................................................54
Resolution ................................................................................................................61
Calibration ................................................................................................................62