Skip to content

knedl1k/R2R_Arduino

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 

Repository files navigation

R2R Digital to Analog Converter using Arduino

Digital to Analog Converters (DACs) are used within transfers of binary signals to analog signals. The resolution of the DAC is determined by the number of possible output voltage values. These depend on the number of bits of the input data word — binary signal. To calculate it, divide the output voltage range by (2n -1), where n is the number of bits of the input word. DACs are commonly used in digital power supplies, programmable generators or automation technology.

Circuit

Stripes on resistors have no meaning, but the coloring of the resistors itself seprates them both.
Yellow ones has some fixed value. The blue ones have two times bigger value than the yellow ones.

Used parts

name pieces
resistor 220 kΩ 8
resistor 440 kΩ 8
operation amplifier 1
Arduino 1
wires 10
breadboard 1

The type of Arduino is not important, it only affects how many outputs are usable as outputs of the binary signal.

DACs in general

Recognized parameters of DACs

  • Accuracy of the conversion depends on the stability of the reference voltage, on the accuracy of the components (resistors and switches) and is also determined by the size (number of bits) of the converted word - of the binary signal
  • Conversion rate defines the number of input words converted to analog value per unit time
  • Resolution tells how many values the output signal can be (if we have a 3-bit converter, then there can be 23 different values at the output = this corresponds to the resolution 1008 = 12.5 %

Real DACs errors

  • Quantization error cannot be removed, it is an error caused by the resolution of the converter (=rounding)
  • Zero Offset or Drift is a state when the output is a non-zero with a grounded input (or when there's a zero output with a non-zero input)
  • Non-linearity error means the shape of the average characteristic of a real DAC is not a straight line
  • Quality of reference voltage source Uref and quality of used resistors

R2R DAC — parallel Digital to Analog Converter

Basically, it is a summing amplifier (input resistors that are in parallel go to the inverting input of an operational amplifier that has negative feedback). Using the input controlled switches, we apply a constant reference voltage to the input resistors to be converted. The resistor values range from 2n-1R, which is referred to as LSB, to 20R, which is referred to as MSB. MOSFET transistors are most often used as switches because they meet the required characteristics - not to introduce error into the conversion (when not switched they have infinite resistance and when switched they have very low resistance, ideally zero). Parallel DACs are quite expensive (because of the quality and values of the resistors, or the number of them), but they are fast and accurate.

Example of calculation

Circuit

Connection of 3 bit parallel DAC.

The following equation applies to this circuit:
Amplification of inverting operational amplifier Au= -(RfRpar) = (U0Uref), Rpar is parallel combination of resistors b0 to bn, where n is number of bits.
Hence the relationship for the output signal is: U0= -(RfRpar) ∙ Uref
If Rf=R & Uref=10 V, then:

Table of calculus

BIN IN Analog OUT
b2 b1 b0 U0/V
0 0 0 0
0 0 1 -(R4R)∙10= -2.5
0 1 0 -(R2R)∙10= -5
0 1 1 -(R4R+R2R)∙10= -7.5
1 0 0 -(RR)∙10= -10
1 0 1 -(R4R+RR)∙10= -12.5
1 1 0 -(RR+R2R)∙10= -15
1 1 1 -(R4R+RR+R2R)∙10= -17.5

With this 3-bit converter we are able to express voltage levels (in binary form) from 0 to 7 as voltage from 0 V to -17.5 V.
If the positive values of output voltage are required, subsequently invert the signal using an inverting operational amplifier with amplification Au=1, or connect a source Uref of opposite polarity.

License

GNU General Public License v3.0


©2022 knedl1k