The idea is to go for a serial DAC, in order to save pins on the microcontroller. But higher resolution applications are demanding in terms of numbers of pins used.Ī serial Digital to Analog converter using R/2R network We can connect the R/2R logic entries directly to the microcontroller I/O pins and setting them LOW (0) or HIGH (Vref). Here we have a total of 256 possible values, so this higher resolution DAC is better suited for representing data with smaller errors 8 bits will increase the number of possible steps, and offer better granularity: 5x 1/256=0,01953125V.That means a total of 8 values is possible only: 0.625V, 1.25V, 1.875V, 2.5V. 3 bits will go from 0 to 5V in 5×1/8=0.625V increments.Obviously using a higher number of bits (higher DAC resolution) would allow us to generate a DC with a better granularity: Depending on which bits of a R-2R DAC of N bits are set, the output voltage Vout ranges from Vout = Vred x 1/2^N to Vout = Vref × (2^N-1) / 2^N The R-2R network causes the digital bits to be weighted in their contribution to the output voltage Vout. Ideally, the bits are switched between 0 volts (logic 0) and Vref (logic 1). The resistors act as voltage dividers between the referenced voltages:īit a(n-1) (most significant bit) to Bit a(0) (least significant bit) are driven from digital logic gates (eg. A resistor ladder network, also called a R/2R ladder that consists of resistors and digital logic gates. A 50% duty cycle will produce 2.5V, while the 100% duty cycle will output 5V.Īs for choosing the capacitor and resistor values, it’s a compromise: less ripple comes with a slower response to changes in the PWM value. The DC voltage at the output isn’t smooth, it keeps going up and down slightly around the average voltage, and effect called ripple.įor an Atmega8 microcontroller connected to Vcc=5V, this would allow us to generate discrete voltage values between 0 and 5V by changing the duty cycle for the PWM signal. When the PWM signal goes low again, it starts discharging the capacitor and the output voltage starts falling. When the PWM signal goes high, it starts charging the capacitor, so the output voltage starts rising. A low pass filter consisting of a resistor and a small capacitor is added:
#SERIAL ANALOG TO DIGITAL CONVERTER GENERATOR#
A PWM generator with a low pass filter: we generate a variable duty cycle PWM signal. I’m going to discuss two methods for building the DAC module: The purpose of this article is to discuss DAC and practical implementation options. Here’s the same function rebuilt using a smaller resolution: The resolution refers to the number of discrete values available over the range of analog values.
Here as well we must deal with approximations, acceptable error levels and resolution: DAC versus ADCĪ DAC or a digital to analog converter, is a system doing the opposite of what ADC does, and that is converting digital values into analog signals. We need all this, because humans and computers can’t handle infinite entropy data. The ADC can also be seen as a measuring device. These all imply comparing the real world analog values to a discrete measuring tool, and introduce acceptable errors in order to have a finite representation of the original data. To work with continuous data (analog) we usually require a measuring device: Ruler, stop watch, thermometer, speedometer, etc. On the other hand, a set of data is said to be discrete if the values belonging to the set are distinct and separate (unconnected values). To handle numeric data, we encode it in digital, meaning all content is expressed by sequences of 0 and 1.Ī set of data is said to be continuous if the elements belonging to the set can take on any value within a finite or infinite interval. Their purpose is translating a given signal to a numeric representation. We’re used to Analog to Digital converters (ADC) in a variety of applications such as voltmeters, thermometers or various other sensors.