


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



1
2
1000
This is a simple resistive network for a D/A converterPort 1, Port 0 are digital inputs ==> 00 (minimum), 01,10, 11 (maximum)You need to design the resistive network to generateproper outputs.For ECE5430 students, a four-bit D/A with an Op-amp isrecommended.
1000 ohms
3
ATMEGA
PB1 PB0 ADC0(PA0)
VTG
RXDTXD
To Computer Serial Port
AREF
STK
357 833 1000
R
R3^ R
VA
STK500 reads the analog value from VA using ADC channel 0
4
Equations for D/A Outputs:
-^
0.0 VS = (R1 || R2 || R3 ) * (0 Volts)
0.3 VS = (R1 || R3 ) * (5 volts) / ((R1 || R3 ) +R2 )
0.7 VS = (R1 || R2 ) * (5 volts) / ((R1 || R2 ) +R3 )
1.0 VS = R1 * (5 volts) / ((R2 || R3 ) + R1 )
Given: VS = 4 Volts, R1 = 1000
-^
Find R2 and R3 by solving 2 equations with 2 variablesusing the equations for B’01 and B’11.
Here we choose R1 = 1000 ohms.You can choose any proper value you want for R1.If R1 is too small, it may require large currents resulting inoverheat problem.
5
Theoretical vs Actual DAC
5.04.5 4.03.53.0 2.52.01.5 1.00.5 0.
0
1
2
3
4
Binary Output
DAC Output (V)
Theoretical DACActual DAC
6
5.000V
5.000V
0V
0V
R2 833
1.200V 0V
R5 833
R11k 2.800V
R3 357
V 5Vdc
R9 357
0V^0
0
V 5Vdc
0
R12 357
0
0V R71k
R6 357 R11 833
0 0
R8 833
R41k 4.000V 0
0
V 5Vdc
R101k
7
In-Lab Tasks
-^
Construct Circuit 4-1 with appropriate values ofresistance. Do NOT connect Circuit 4-1 to the AVR mcu.
-^
Given your computed values of R2 and R3, verify thevoltage of VA for the four possible port values.
-^
Connect Circuit to the AVR mcu.
-^
Write software for the AVR mcu that sets analogvoltages at VA. Have the software loop through thevoltages from 0.0VS, 0.30VS, xVS, , .. ,1.0VS and stepback down to 0.0VS. Include a delay between eachvalue. Use the C-routine delay_ms() in <delay.h> togenerate the delay.
-^
Verify and document the resulting voltages of VA.
8
Initialize peripherals in ATMEGA
μP:
•Port x : Output to LED’s • Port x : DAC output on pins 0 & 1 • Port D : UART on pins 0 & 1 • UART : 9600 baud, 8-N-
Display opening marqueeStart counter at 0
Start
Port x = counter (to DAC)Port x = ~ counter (to LED’s)Increment counter so it runs: 1, 2, 3, 4, 1, 2 …Delay 2.5 seconds for voltage measurement
Sample of Software flowchart
13
-^
while (1)
-^
{
-^
// Loop from b00, b01, b10, b11.
-^
for( i = 0; i < 4; i++ )
-^
{
-^
// Change to the next D to A step.
-^
PORTB = i;
-^
// Delay for 2 seconds
-^
delay_ms( 2000 );
// Print the voltage to the screen.
-^
value = read_adc( 0x0 );
-^
voltage = value * 5 / 1023;
-^
??????
-^
??????
14
0.00 Volts
0.0012 Volts
01
1.20 Volts
1.194 Volts
10
2.75 Volts
2.710 Volts
11
3.96 Volts
3.906 Volts