Lab 2 – Basic Stamp II – Building a Digital Multimeter

Assigned: Feb 28th 2002 Due: March. 20th 2002


The physical world remains fundamentally analog while the computer is primarily a digital device. Hence, conversion between analog and digital domains, appropriately termed Analog to Digital Conversion (ADC) and Digital to Analog Conversion (DAC), is essential to permit operation by computers on the physical world, and this second project focuses primarily on such conversions. For example, sensors typically output an analog signal (voltage or resistance) proportional to the quantity being measured; and actuator outputs are designed to be proportional to analog control signals (voltage/current), which must be provided by the computer. (In subsequent labs we will look at the actual sensors that transduce physical quantities into electrical signals, and the actuator technology that transduce the electrical signals to take actions on the physical world). To motivate and understand this process, we will be implementing the following “products” that will be of use to us in subsequent labs:


A)      A Digital Ohmmeter (which you can implement using the BS2 RCTIME command) to measure resistance;

B)      A Digital Voltmeter (for which you will use an ADC chip, the ADC0831) to measure voltages; and

C)      An R-2R ladder based Digital-to-Analog Converter (R2RDAC).




At the end of this exercise you will become familiar with:

1.       Digital measurement of analog voltages and resistances and digital control of analog voltage output.

2.       Interfacing an analog-to-digital converter (which uses a synchronous serial input/output interface).

3.       Performing basic floating-point operations using only integer arithmetic.

4.       Creation and control of a basic Digital to Analog Converter using either an R-2R ladder.

5.       Calibration techniques for resistances, A/D and D/A converters.


Implementation Details:


The following steps are to be implemented using the Stamp Works kit:

A.      Digital Ohmmeter

Construct a simple digital Ohmmeter (using the circuit shown in Figure 1) to measure the value of the unknown resistance “R” and display the value on your LCD display. The Ohmmeter mode is activated by pressing Button D1 and is deactivated when any of the other buttons are pressed. Pressing Button D1 again (at any time in the process) initiates a fresh measurement and updates the value of the measured resistance on the LCD display. Refer to the use of the RCTIME command from your Stamp Manual for further details.


Obviously, your ohmmeter will work well for a given range of resistances. For your report, determine that range of operation and then by selecting a series of known resistances within that range and measuring the values read in by your created Ohmmeter. Use a linear fit of the data to obtain the calibration constants for your ohmmeter so as to improve its accuracy. Your Ohmmeter must be capable of reading any arbitrary resistance (between 1K to 10K) during the demonstration. (DEMO 1)


 Figure 1: RC Circuit for the Digital Ohmmeter


B.      Digital Voltmeter

1.       Construct a voltage divider on your breadboard using the supplied potentiometer and the +5V supply and ground as shown in Figure 2.

 Figure 2: Voltage Divider using a Potentiometer

2.       Interface the 8 bits, serial A/D converter (ADC0831) to the Basic Stamp (see application note in Stamp manual [Pages 353-60] and the discussions on SHIFTIN and SHIFTOUT [Pages 330-35, 439-42]) and measure the variable voltage provided by the Voltage divider created in Step 1.

      ADC0831 Specs:


This looks like (and is) a reasonably trivial step but will take you the longest time to finish. So please plan on spending time reading the relevant Stamp literature and the ADC0831 literature.


3.       Pressing Button D2 sets the system into the Digital Voltmeter mode. Convert the obtained binary values from the ADC into a floating point voltage level (between 0 and 5) and display both on the LCD screen -- Binary value on line 1 and the converted voltage value (to three decimal places) on line 2 of your display. (DEMO 2)


4.       For your report, verify the measured voltages displayed on the LCD screen using the desktop Digital Volt Meter (DVM). Create a calibration table and chart for the A/D converter (in increments of 0.5V) with the following entries:






 A/D value

LCD Display Reading














   Table 1: Calibration Table for the ADC (Sample)                Figure 3: Calibration Chart for the ADC (Sample)               

What can you say about the linearity of this ADC? Please also note down other important characteristics of this ADC in your report.                                                                                                                                   


C.      Digitally Controlled Voltage Source using an R-2R Ladder Network (R2RDAC)

1.       Create an R-2R ladder network DAC (as discussed in class) and interface its output to a LED and the ADC as shown in the Figure 4 below.

Figure 4: R-2R ladder without Voltage Follower    


2.       Note: Figure 4 depicts the implementation of a 4-bit R-2R ladder network where by outputting a series of LOWs (0) and HIGHs (1) on the output pins P4-P7 one can create the appropriate output voltage levels (Resolution = 4 bits). The LED serves as a load on the DAC circuitry while the ADC (set up in the previous stage) serves to measure the output voltage levels.  In your system, you will need to create the R-2R ladder by using resistors that are available in your Stamp Works kit. Set up the system so that pressing Button D3 increments the output of the DAC while Button D4 decrements the output of the DAC. Create a table and note down the values of the output voltage from this DAC for the range of 8-bit digital output values (from $00 to $FF in increments of 16). 


3.       Augment the setup in Step 1 by adding the voltage follower circuit as shown in Figure 4 using one of the channels of the LM358 shown in Figure 5. Now create a similar calibration table to correlate the output digital levels to the actual values measured by the ADC. (DEMO 3)

LM358 Specs: On the National Semiconductor Web Site


Figure 5: R-2R ladder with Voltage Follower            




Provide a self-standing document, which could be used as an “Application Note” which describes and explains your system and would enable someone else to replicate your work. Document your system with a circuit diagram, list of components, and parts cost estimate. Include a listing of your program with thorough comments:

·         Please follow the guidelines provided at

·         For sample reports see and


Additionally, please make sure you include a brief discussion of the following:

·         The principle, circuitry and operation of the Ohmmeter mode that uses the RCTIME command. How accurate are these results compared with the DVM measured values? Identify the possible sources for the error in measurement of resistance between the desktop DVM and your newly created multimeter!

·         The implementation and operation and limitations of the voltmeter.  What is the maximum sampling rate for the ADC?  How accurate is the voltage and resistance measurement? Other comments?

·        The implementation and operation of the DAC, and resolution/accuracy/other features of the system.


Each group should send in a weekly e-mail to the TA, Mr. Chin-Pei Tang ( briefly outlining their progress for the week and outlining a schedule for proposed completion of the rest of your lab assignment by the group (these will be due on the Thursday of each week).