DAC Interfacing
DAC Interfacing
• The generation of current reference (setting Iref=2mA) by using the standard 5-V
power supply and 1K and 1.5K ohm standard resistors.
• Zener diode (LM336) overcomes any fluctuation with the power supply voltage.
• Assuming that Iref=2mA, if all the inputs to the DAC are high, the maximum
output current is 1.99mA.
Converting Iout to voltage in DAC0808
• Ideally, the output pin Iout to a resistor is connected, convert this
current to voltage and monitor the output on the scope.
• In real life, however this can cause inaccuracy since the input
resistance of the load where it is connected will also affect the output
voltage.
• For this reason, the Iref current output is isolated by connecting it to an
op-amp such as 741 with Rf=5K ohms for the feedback resistor.
• Assuming that R=5K ohms, by changing the binary input, the output
voltage changes.
Generating a sine wave
• To generate a sine wave, a table shown below is required whose value represents the magnitude of
the sine of angles between 0 and 360 degrees.
• The values for the sine function vary from -1.0 to +1.0 for 0 to 360 degree angles.
• The table values are integer numbers representing the voltage magnitude for the sine of theta.
• Table shows the angles, the sine values, the voltage magnitudes, and
the integer values representing the voltage magnitude for each angle
(with 30 degree increment).
• It is assumed that the full-scale voltages of 10V for DAC output is
designed.
• To achieve the full-scale 10V output, the following equation is used
• Vout = 5V+(5x sin )
• Verify the values given for the following angles: (a) 300 (b) 600
• (a) Vout = 5V + (5Vx sin )= 5V+5 x sin300= 5V+5 x 0.5 =7.5V
DAC input values = 7.5v X 25.6= 192 (decimal)
• (b) Vout = 5V + (5Vx sin ) = 5V+5x sin600= 5V+5x0.866= 9.33V
DAC input values = 9.33Vx 25.6 = 238 (decimal)
• To find the value sent to the DAC for various angles, multiply the Vout
by 25.6 because there are 256 steps and full-scale Vout is 10 volts.
• Therefore 256 steps/10V=25.6 steps per volt.
Programming DAC in C
#include <reg51.h>
sfr DACDATA = P1;
void main ()
{
unsigned char WAVEVALUE [12]= (128,192,238,255,238,192,128,64,17,0,17,64);
unsigned char x;
while (1)
{
for (x=0;x<12;x++)
{
DACDATA = WAVEVALUE [x];
}
}
}
Angle vs. Voltage Magnitude for Sine Wave