Академический Документы
Профессиональный Документы
Культура Документы
L A B
M A N U A L
Experiment
Equipment
Flight 8086 training board, Application board, PC with Flight86 software, download cable.
Tasks to be Performed
Simulation of a A/D conversion employing successive approximation method using D/A converter Use a D/A converter to perform the following:
1. Sine wave generation (using look up table) 2. Staircase waveform generation 3. Saw-tooth waveform generation
Read the DIL switches and output the digital values to the LEDs and DAC. The analog output of the DAC is to be represented by lighting up the bargraph.
47
C O E 3 0 5
L A B
M A N U A L
4.1 Background
In any computer controlled process it may be required to monitor analog values, i.e. the output of a voltmeter or strain gauge. In order to do this, the analog signal must be first converted into a digital value using an Analog-to-Digital Converter (A/D). On the other hand, Digital-to-Analog Converters (D/A) can be used to convert a digital output from the computer into an analog value. For instance, we could generate a series of tones by changing the digital output values in such a way that the analog signal is represented as a sine wave.
48
C O E 3 0 5
L A B
M A N U A L
Example 4.1: Write a program to simulate a simple A/D converter. Use the variable voltage source (UR6) as your analog source. The program should display one HEX digit (0-F) representing the digital value of the voltage input.
Set SW3 to VOLTS (Variable Voltage) Set SW4-2 to DAC (enable D/A converter) Set SW2-2, SW4-1, SW4-3, and SW4-4 OFF 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 COMSEG SEGMENT BYTE PUBLIC 'CODE' ASSUME CS:COMSEG, DS:COMSEG, ES:COMSEG, SS:COMSEG ORG 0100h Start: MOV AL, 99h ; initialize the 8255 PPI chip OUT 06h, AL ; A input, B output, C input MOV AL, 0 OUT 02h, AL ANAL: MOV BL, 0 SMALL: MOV AL, BL OUT 02h, AL NOP NOP NOP NOP NOP NOP IN AL, 00h AND AL, 08h JZ LARGE ; turn off all LEDs ; first digital value ; put in AL for output ; output value to D/A ; wait for D/A
; get input Port-B ; keep comparator bit (bit 3) ; ; ; ; if value is large (bit3= 0) then display the digital value else increment the digital value and tray again
; display the digital value as a HEX digit LARGE: MOV AL, BL CALL display_voltage JMP ANAL INCLUDE display_voltage.asm INCLUDE putc.asm COMSEG ENDS END start
49
C O E 3 0 5
L A B
M A N U A L
The previous code uses two functions, namely display_voltage and putc, to display the digital value corresponding to the input voltage. The first function converts the digital (binary) value of the input voltage into an ASCII character, and calls putc to display it on the screen. The two functions are given in two separate files display_voltage.asm and putc.asm, so that you can include these two files in your code using the INCLUDE directive.
50
C O E 3 0 5
L A B
M A N U A L
MOV AL, 0 ; turn off all LEDs OUT 02h, AL MOV SI, OFFSET Table ; 1st element in the table MOV BL, 36 ; number of elements in the table LODSB ; load AL from the table OUT 02h, AL; and output the value to D/A DEC BL JZ L2 JMP L1 DB 127 DB 149 DB 170 DB 191 DB 209 DB 224 DB 237 DB 246 DB 252 DB 254 DB 252 DB 246 DB 237 DB 224 DB 209 DB 191 DB 170 DB 149 DB 127 DB 105 DB 84 DB 64 DB 45 DB 30 DB 17 DB 8 DB 2 DB 0 DB 2 DB 8 DB 17 DB 30 DB 45 DB 64 DB 84 DB 105 COMSEG ENDS END start ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; count down table loop if not zero if zero then return to the start of the table 1.27V 1.49V 1.70V 1.91V 2.09V 2.24V 2.37V 2.46V 2.52V 2.54V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V 1.27V -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> sin(0) sin(10) sin(20) sin(30) sin(40) sin(50) sin(60) sin(70) sin(80) sin(90) sin(100) sin(110) sin(120) sin(130) sin(140) sin(150) sin(160) sin(170) sin(180) sin(190) sin(200) sin(210) sin(220) sin(230) sin(240) sin(250) sin(260) sin(270) sin(280) sin(290) sin(300) sin(310) sin(320) sin(330) sin(340) sin(350)
51
C O E 3 0 5
L A B
M A N U A L
This program reads the digital values form Table and output them to Port-A, then the D/A converter converts them to the corresponding analog voltages. Notice that the values in Table can generate only one cycle of the SIN wave. Therefore, the digital values in Table are output continuously to the D/A converter to generate a continuous SIN wave. Table 4.1: SIN Table
Degree 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 SIN(Degree) 0.000 0.174 0.342 0.500 0.643 0.766 0.866 0.940 0.985 1.000 0.985 0.940 0.866 0.766 0.643 0.500 0.342 0.174 0.000 -0.174 -0.342 -0.500 -0.643 -0.766 -0.866 -0.940 -0.985 -1.000 -0.985 -0.940 -0.866 -0.766 -0.643 -0.500 -0.342 -0.174 Assigned Voltage 1.27 1.49 1.70 1.91 2.09 2.24 2.37 2.46 2.52 2.54 2.52 2.46 2.37 2.24 2.09 1.91 1.70 1.49 1.27 1.05 0.84 0.64 0.45 0.30 0.17 0.08 0.02 0.00 0.02 0.08 0.17 0.30 0.45 0.63 0.84 1.05 Corresponding Digital Value 127 149 170 191 209 224 237 246 252 254 252 246 237 224 209 191 170 149 127 105 84 64 45 30 17 8 2 0 2 8 17 30 45 64 84 105
52
C O E 3 0 5
L A B
M A N U A L
Exercises
6.1.
Consider Example 4.1. Describe how you would minimize the number of digital values required to find the unknown voltage. How could you vary the frequency of the SIN wave generated in Example4.2? Use the D/A converter to perform the following: a. Staircase waveform generation b. Saw-tooth waveform generation
6.2.
6.3.
6.4.
The bar-graph (U10) is essentially a bank of 10 LEDs. It is driven by U11 (LM3914) which samples a voltage input signal, as the signal exceeds certain preset levels it will output a signal to light one of the LEDs on the bargraph. Hence, as the voltage increases, more LEDs will be turned on. a. Write a program to read the DIL switches and output the digital values to the LEDs and DAC. The analog output of the DAC is to be represented by lighting up the bar-graph. b. Plot a graph of switch digital value against the number of LEDs alight on the bar-graph.
53