AL-Hussein Bin Talal University College of Engineering Department of Computer Engineering Computer Interfacing and Peripherals Lab Student Name:

Dr. Fadi Abu-Amara Eng. Huda Saqallah Student Number:

Lab 5: Analog-to-Digital Converter (ADC) 1. Objectives The objective of this lab is to show how the analog-to-digital converter (ADC, A/D, or A-to-D) chip can be used to convert an analog input signal to a digital data. The analog signal is usually received from a sensor device such as microphone, temperature sensor, etc. In this lab, the ADC0809 chip will be used. 2. Introduction The ADC is an electronic device that converts an input analog voltage or current (a continuous quantity) to a digital number proportional to the magnitude of the current or voltage (a discretetime digital representation) at that time instant. The analog-to-digital conversion process is done in two steps: sampling and quantization. Sampling is the process of converting an analog signal into a discrete-time signal (a set of values). Quantization is the process of mapping a large set of input values (possible amplitudes of the signal) to a smaller set (some sort of rounding). The most important characteristics of ADC devices are: - Resolution: the overall voltage measurement range divided by the number of discrete voltage intervals: For example: o A 6-bit ADC with full scale measurement range of 0-5V has the resolution:  Resolution = (5-0)/2^6 = 78.13mV. -

Quantization error (QE): it is the difference between the original signal amplitude and the digitized signal amplitude. QE is due to the finite resolution of the digital representation of an analog signal. This error causes an imperfect reconstruction of the original signal.

-

Sampling rate: the rate at which new digital values are sampled from the analog signal.

3. Procedure In this section different exercises will be performed such as: variable resistor, phototransistor, Thermistor, and sound recording. 3.1. Variable Resistor The following figure shows the block diagram of the circuit that will be used in this experiment. The input analog voltage is applied to the pin IN0 of the ADC. By changing value of the variable resistor VR2, different input analog voltages can be obtained. This input analog voltage is converted to 8-bit digital code and sent to the 8086 microprocessor. Then, it is sent through the 8255 chip for display on LEDs. Also, it is sent through the serial port RS-232 for display on the PC monitor. The eighth switch is used to enable the ADC0809.

Figure 1: Functional circuit description of the variable resistor experiment. The following program is used to program the previous circuit to perform the analog-to-digital conversion process. ADC0 CNT3 BPORT3 CODE

START:

J1:

EQU 3FC8H EQU 3FD6H EQU 3FD2H SEGMENT ASSUME CS:CODE, DS:CODE ORG 0 MOV SP,4000H MOV AX,CS MOV DS,AX MOV DX,CNT3 MOV AL,91H OUT DX,AL MOV DX,OFFSET MSG MOV AH,9 INT 21H MOV AX,0 MOV DX,ADC0 OUT DX,AL MOV CX,20H LOOP $ IN AL,DX MOV DX,BPORT3 OUT DX,AL MOV DX,OFFSET DATA1 MOV AH,9 INT 21H MOV DH,2 INT 10H MOV DX,OFFSET DATA2 MOV AH,9 INT 21H CALL CONVERT MOV CX,0 LOOP $ Page 2 of 5

JMP J1 CONVERT: MOV AH,0 MOV BL,51 DIV BL MOV DL,AL OR DL,30H MOV AL,AH MOV AH,2 INT 21H MOV DL,'.' MOV AH,2 INT 21H MOV BL,10 MUL BL MOV BL,51 DIV BL MOV DL,AL OR DL,30H MOV AL,AH MOV AH,2 INT 21H MOV BL,10 MUL BL MOV BL,51 DIV BL MOV DL,AL OR DL,30H MOV AL,AH MOV AH,2 INT 21H MOV DL,' ' INT 21H MOV DL,'V' INT 21H RET MSG DB 0DH,0AH,9,9,' ===A\D TEST===' DB 0DH,0AH,0AH,9,9,9,'$' DATA1: DB 0DH,9,9,'INPUT VALUE : $' DATA2: DB 'H, INPUT VOLTAGE : $' CODE ENDS END START For this experiment, do the following: - Explain the previous code in your report. - Modify the previous code to reduce the output levels of the ADC from 256 levels into 128 levels. - Find how much time does the ADC takes for the conversion process.

Page 3 of 5

3.2. Phototransistor The following figure shows the block diagram of the circuit that will be used in this experiment. The phototransistor is used in the reverse-bias at the collector-base junction with open base. The junction photocurrent increases with the increase of incident photo light. This means that the current flowing through the phototransistor is proportional to the light passed through the base of the device, resulting in lower voltage drop at the collector.

Figure 2: Functional circuit description of the phototransistor experiment. When the previous program is executed, the analog input voltage from the phototransistor sensing circuit is converted to binary code and displayed on the LEDs and in hexadecimal format on the PC monitor. 3.3. Thermistor The following figure shows the block diagram of the circuit that will be used in this experiment. The Thermistor is a type of resistor whose resistance varies significantly with temperature. Thermistors are widely used as temperature sensors. They are characterized by their small size, fast time-constant, and wide range of available base resistance. The output of the Thermistor is connected to an amplification circuit because the current flowing through Thermistor must be kept very low to assure near-zero power dissipation and near-zero heating.

Figure 3: Functional circuit description of exercise 6-3 When the previous program is executed, the input analog voltage from the Thermistor sensing circuit is converted to binary code and displayed on the LEDs and in hexadecimal format on the PC monitor.

Page 4 of 5

Exercises 1.

Write a program that lights lamp according to the value of sensed temperature. Hint: no need to connect to an actual lamp, just display the intensity value of the light.

2. Make a comparison between the previous three methods of generating the analog input voltage in terms of: conversion speed, implementation cost, and ease-of-use. 3. Measure the voltage gain of the amplifier used in the circuit of Figure 3. 4. Explain the structure, pin diagram, and the operation of ADC0809.

Page 5 of 5