Hi and welcome to Module 7.3, which will wrap up the module on Quantization. So, in this module, we're going to look at what happens when we go back and forth from the analog to the digital world in practice. So, for instance, look at this box. This box is a high quality A to D and D to A, analog to digital and digital to analog converter, that I can use to record my bass or my guitar. Now, what's inside this box? How does this box work? And so, what we will do, is look at very simple circuits that illustrate how digital to analog and analog to digital converter work. Now, of course, we cannot go too deep into the description because this is not an electronics class, but even the simple overview will give you a pretty good idea of how things work. And you will see that it's not too complicated. Hi and welcome to Module 7.3 of Digital Signal Processing. In this module we will talk about analog to digital and digital to analog conversion. Try to understand how these things are done in practice. We have seen that sampling discretizes time and quantization discretizes amplitude. But how is it done in, In practice? The answer is cheaply and in a very compact way. This photograph shows you the few discrete electronic components that you have to put together to build an analog to digital converter. And if you did so, you would probably end up with one of the largest digital to analog converters in existence because in most cases, like in your cell phone, the whole circuit would be integrated and miniaturized. At the heart of both digital to analog and analog to digital converters is a circuit called the operational amplifier or op-amp for short. The op-amp has two inputs, the inverting input and the non inverting input, and one output. And the input-output relationship is that the voltage, at the output is equal to the difference between the voltages at the inverting and non inverting input, times a gain factor. We idealize the op-amp by saying that it has infinite input gain and zero input current. And although these are, of course, idealizations, practical implementations of operational amplifiers are remarkably close to this ideal. And not very complex either, because this, for instance, is the schematics for an operational amplifier and you can see that it only requires six transistors and one resistor. The operational amplifier can be used in two configurations, the open loop and closed loop. In the open loop configuration, the op-amp works as a comparator. You put a reference voltage at the inverting input and a test voltage at the non-inverting input. As soon as the difference between these 2 voltages is non-zero, the output due to the infinite gain will shoot up or down to the maximum or minimum allowed output voltage, which coincides with the voltage of the power supply that powers the op-amp. In the closed loop configuration, we have a feedback path that links the output to the inverting input. So, what happens when we apply a voltage to the non-invertant input? Well, if the voltage at the inverting input is less than x, then the difference between inverting and non-inverting would drive the output up. Conversely, if the voltage here was larger than x, the difference would be negative and this would drive the output down. So, the only equilibrium point for this system is when the voltage at the inverting input is exactly equal to x, which of course means the output voltage is equal to x as well. So, the input-output relationship of the closed loop is output equal to the input. This configuration is known as a buffer stage because although the output has the same voltage as the input. The second property of the ideal op-amp prevents any current from flowing into the amplifier. Therefore there is a separation between this side and that side of the amplifier. This is very useful for taking measurements without perturbing the measured quantity. We can complexify the closed loop a little bit by adding a couple of resistors. In this case, we have what is called an inverting amplifier. This is always likely more complex than the simple closed loop we saw before. Again, the system will stabilize when the difference between inverting and non-inverting inputs is zero. So, we can say that the voltage here, let's call it V0, is equal to zero, because the non-inverting input is connected to ground. That means that the current flow in, in the first resistor will be according to Ohm's Law i0 equal to x over R1. This current will not be able to flow into the operational amplifier because of the second law. So, we'll have to flow into this resistor here. And therefore, the output voltage will be just the voltage drop over R2, caused by i0. And so y is equal to minus R2 over i0, which gives us the final input-output relationship for the inverting amplifier. The output is a fraction of the input, with a change of sign. We're now ready to look at an A to D converter. The device starts with a sample and hold circuit that performs the sampling. So we have our analog input here. Here we have an op-amp in buffer configuration. And here we have a MOSFET which is really like a switch. And here we have a train of pulses at the sampling frequency. When a pulse reaches the gate at the MOSFET, the MOSFET closes very briefly and allows the first buffer to charge this capacitor to the instantaneous level of the input signal. The capacitor is connected to another buffer stage that will put out the volume measured by the capacitor for the duration of the interval between pulses. We put a buffer stage here so that we can put out a constant voltage without discharging the capacitor, between sample in instance. An analog to digital converter needs not only to sample the input signal, but also to quantize it. So, the sample and hold provides a stable voltage level between sample and times, and now we need a circuit that converts that to binary format. Here we have a simple diagram of a two-bit quantizer. What this quantizer does is take a maximum positive voltage, V0, and a minimum negative voltage minus V0. This could be the A and B extrema that we used in our quantization example. And then, uses a series of four resistors of equal value to produce intermediate boundary levels. The iK's in our quantization example that will be used to define the quantization regions. Here, you have plus 0.5 Volts. Here, you have zero Volts. Here, you have minus 0.5 Volts. So, we're dividing the interval from V0 to minus V0 into four equally spaced intervals. These reference voltages here are used with a bank of comparators so, operational amplifiers in open loop, to determine which quantization interval the current sample value belongs to. So, let's work out an example with an input voltage of 0.2 V0. So, what have here is that the first comparator will have 0.2 Volts at the non-inverting input with the reference of 0.5 Volts. So, the reference is higher. So, here the output will be a negative voltage. This comparator will compare 0.2 Volts to 0 Volts. And so, this comparator will output a positive voltage and similarly this one will compare 0.2 to minus 0.5. So, again the output will be positive. Next, we have a logic network that will encode this comparison levels into a binary value. These are Exclusive OR gates and the truth table for this gates Is the following. So, the output will be positive only if the inputs are of different sign. So, this gate will output a positive level and this gate will output a negative level. Now, we have a network of diodes that acts as a parallel to serial converter. So, we have a negative voltage here that will be blocked by these two diodes so nothing happens here. A positive voltage here that will go through, and will indicate the most significant bit out of the quantizer. Since this is positive, the most significant bit will be one. And here, the negative voltage will not go through the diode so the least significant bit will be connected to the ground and it will be equal to zero. So, the voltage of 0.2 V0 will be encoded by the binary notation 1 0. Finally, let's look at a D to A converter. Suppose we have a sample in binary notation, so x of n is equal to a set of bits from zero, b1 to bR minus 1, so we use R bits per sample. We use this binary representation to drive a bank of voltage generators at voltage V0. So, in the previous example, we had a 2 bit quantizer that gave us a representation for our current value of 1 0. So, in that case, if we were to apply that value to this backup of generators, this voltage generator would be on and this voltage generator would be off. These generator are connected to a resistors structure that is known under the name of R2R ladder. Now the details of this structure are a little bit tedious to work out. But if you're patient and you apply Thevenin's Theorem to this ladder, you will see that the system seen by this point in the circuit, is equivalent to a resistor of value R, connected to a voltage source of value V equal to the sum for K that goes from zero to R minus one of V0 divided by two to the K times bK. So, in other words, each bit in the minor representation of the sample contributes a voltage source of value V0 over 2K where K is the position of the bit in the binary representation. So, if this is equivalent to a voltage source of value K, V0 over 2K b0, plus a resistor of value R, this is simply an inverting amplifier and the value out here will be minus V0 times x, where x is our binary representation of the input. The resulting signal will be a piecewise constant signal where the transitions between levels will be dictated by the speed which new samples appear at the voltage generator bank.