We do agree that almost every aspect of our life is processed by the digital processing system. It’s the reality that most of us already at least have a laptop, PC, or smartphone. However, the world we are living in at the moment is the analog world. It is logical that the data conversion from the digital world into the analog world would be demanded by the people. The simplest situation is when you need to hear some music, there the DAC (Digital to Analog Converter) is playing its role to provide you the analog output for the music to be listened to by you. The DAC could be found as a stand-alone DAC IC module or embedded into a microcontroller.
What is DAC?
A DAC (Digital to Analog Converter) is an electronic device that converts the digital signal (binary) to the analog signal. A typical DAC has several binary digit (bit) inputs and a single analog output.
DAC Working Principle
To get a basic understanding of DAC, you can see the following block diagram.
The underlying working mechanism of DAC is not as simple as above truthfully. The details are about to be explained in the DAC types section.
DAC Types
1. Weighted Resistor DAC
A weighted resistor DAC yields the analog signal output using the binary-weighted resistors that are added in the final process by the inverting adder circuit. The inverting adder circuit is built by one op-amp unit. Keep in mind that the binary digits only have 0 or 1 value.
Suppose we have 3-bit inputs, represented by b2, b1, and b0. The bit b2 acts as the MSB (Most Significant Bit) and the bit b0 acts as the LSB (Least Significant Bit). Each of the digital switches (inputs) will equal zero if connected to the ground and equal one if it is connected to the negative reference voltage (-VR). The op-amp non-inverting input is connected to the ground. It means that the non-inverting input is zero volts. The inverting input will also equal zero volts following the virtual short concept. Thus, the nodal equation (Kirchoff’s Current Law) can be used in the inverting input as below.
Because R = 2Rf, then
Then, the general formula will be:
The formula above can be used to calculate the output voltage of the weighted resistor DAC. Here, because we use the 3-bit weighted resistor, the possible output voltage values will vary from the binary input of 000 to 111 referred to reference voltage VR.
This DAC type has some drawbacks as it turns out:
- The resistance values gap between MSB and LSB will grow higher as the N-bits of digital input increase
- As the N-bits of digital input increase, it is harder to design more accurate resistors.
2. R-2R Ladder DAC
This DAC type gives solutions to the weighted resistor DAC drawbacks. The output analog voltage here is almost the same as the binary input using the R-2R ladder and added by the inverting adder circuit. Because this DAC type only uses two kinds of resistor values, the following advantages can be obtained by the users:
- Accurate design is easy and possible to get no matter the N-bit inputs.
- The resistor values are no longer the problem.
- The output impedance remains R.
The formula to find the Vo of the N-bits input is as the followings:
While the circuit diagram is the following:
3. PWM DAC
The PWM (Pulse Width Modulation) DAC is available and can be found in the microcontroller you may already be familiar with. The most popular microcontroller is the Arduino board that uses the ATMega IC series at its processing unit.
The Arduino can produce the PWM signal on its output terminal. This signal can be used to produce the analog output signal by using the RC low pass filter. This filter will bypass the AC component of the signal and block the DC component. Thus, the final output signal will be an analog signal whose value is proportional to PWM Duty Cycle.
Real-life Applications
1. DAC PCF9591 (A Stand-alone IC module for Arduino and Raspberry Pi)
The PCF8591 is the ADC and also DAC IC module with 8-bit resolution. It provides 4 (four) analog inputs and 1 (one) analog output. It requires 2.5-6V supply voltage to operate.
This module is compatible with either Raspberry Pi or Arduino. To interface between the two, you need to understand the I2C communication mechanism by using SCL (Serial Clock) and SDA (Serial Data Address). For Raspberry Pi, the I2C pins are disabled by default. So, there is a need to enable it by typing sudo raspi-config >> Interfacing options >> enable I2C.
2. IQaudio DAC+ (for Raspberry Pi)
The IQaudio DAC+ is the product of the IQaudio company and the lowest-cost audio output HAT (Hardware Attached on Top) for Raspberry Pi. It supports 24-bit 192kHz high-resolution digital audio.
This device uses the PCM5122 Digital to Analog Converter of Texas Instrument to produce the stereo analog audio to a phono connector pair and provides a headphone amplifier too. In daily use, the PCM5122 is mostly used for A/V receivers, DVD & BD players, and HDTV receivers.
Official Link: https://www.raspberrypi.org/blog/iqaudio-is-now-raspberry-pi/