Tutorial for learning AVR assembly language for AVR single chip controllers AT90S, ATtiny, ATmega and ATxmega from ATMEL using practical examples Simple 8-bit-Digital-to-Analog-Converter with a R/2R Network Calculation basics of a R/2R network |

Depending from the state on the input on bit 0 the DAC generates two different analog voltages:

- If bit 0 is zero or low, the resulting output voltage is zero multiplied by
the operating voltage V
_{Op}, 0. - If bit 0 is one or high, the output voltage is half of the operating voltage
V
_{Op}

The upper half of the operating voltage is consumed by the upper resistor.

For the starter three additional notes:

- Why "2*R" and not simply "R" is shown below, when more bits are added. If that occurs, additional resistors with half the value of "2*R" play an essential role. So be patient.
- The horizontal line in the lower part of the second resistor means " connected to zero Volt" or ground or GND. In our case, the minus pole of the operating voltage.
- It makes no difference which type of or value of resistors are used. They should not be too small because if the portpin would have to drive a too large current, its output voltage is slightly higher than 0.0 Volt or slightly smaller than the operating voltage if he has to drive current. Currents of a few mA are ok for an AVR. The resistors should not be too large, too, because any added load on the output of the resistor network can reduce the produced R/2R voltage. If too large in (overall) resistance even small capacitive loads, such as an FET input with a few Picofarad, can speed down any voltage changes (if your R2R network works at higher frequencies).

Depending from the state of the two bits not only two different but four voltages result. The binary output states 00, 01, 10 and 11 generate this. Here, the "2R" on the output on the lower part, and the "2R" to ground) are connected with the upper bit via a R, which is half the resistance of the 2R. That causes the name R/2R network.

The same principle can be continued to construct a 3-, a 4-, an 8- or a 10-bit DAC: just add additional output port pins, a "2R" and a "R" for each of these.

How it works that the two input pins 0 and 1 contribute so differently to the resulting voltage at V

- The current in the lower part divides into two tracks: one part flows to the input pin Bit 0 via 2R, the other part to minus, also via 2R.
- This current equals the current that flows from the output pin to the lower part, through R.
- And finally this current equals the current that flows from the
input pin Bit 1 to the output pin at V
_{R1}.

The result of all those calculations in equation (18) is rather simple, all resistors and currents have disappered and the result is nice: both bits contribute to the output voltage by their binary part. Bit 1 one half, bit 0 one fourth.

Equation (19) writes this as a general formula for n bits. Without having to write down douzends of currents through 9 times 2R and 7 times R. That would not fit to a HTML screen, and especially not onto the screen of a mobile phone.

The maximum voltage that a R/2R network provides is not the operating voltage but slightly smaller (due to the lowest 2R to ground). It rather is:

In case of an 8-bit network and 5.0 V the maximum is 4.98 V.

There is a simpler method to calculate the eight-bit-resistor network. We again start with the lowest bit, bit 0, and calculate the voltage on the lowest cross point of the network, V

The currents are simple: I

We now multiply all components by 2R and, by that, get rid of all the resistors, formula (3).

Now we sort all V

The result is rather simple to understand: V

Now we have to take care of the next higher voltage, V

We again multiply all this by 2R and again get rid of R, formula (8). In the next step we replace V

And again do all the same for V

And: doing the same for the next four higher pins yields the formula for the complete 8-bit-R2R network. Now pin 0 contributes only 1 / 256 to V

Now, what happens if all higher bits are zero and only pin 0 is high? The pin 0 then feeds current into all upper pins, all currents have a negative sign, and the farer above the pin the lower is the current feeded. But pin 0 has to serve them all a bit.

Which bit combinations out of the 256 possible cause the largest source and sink currents?

Consult the attached Libre-Office-Calc file here for the interesting answers to this academic question.

To the top of that page

©2017/2021 by http://www.avr-asm-tutorial.net