Professional Documents
Culture Documents
Testing 2011/2012
DAC lab
Objectives: 1. Learn how to design DAC. 2. Learn how to use DAC. 3. Learn how to generate wave forms and control there amplitude and frequency. 4. Learn how to use Pic16f628 with the DAC
Figure 1: Digital-to-Analog Converter (DAC) and Analog-to-Digital Converter (ADC) Input and Output Definitions
In converter technology, full-scale (abbreviated FS) is independent of the number of bits of resolution, N. A more useful coding is fractional binary which is always normalized to full-scale. Integer binary can be interpreted as fractional binary if all integer values are divided by 2N. For example, the MSB has a weight of , the next bit has a weight of , and so forth down to the LSB, which has a weight of 1/2N (i.e., 2-N). When the weighted bits are added up, they form a number with any of 2N values, from 0 to (1 - 2-N) of full-scale. Additional bits simply provide more fine structure without affecting full-scale range. The relationship between base-10 numbers and binary numbers (base 2) are shown in Figure 2 along with examples of each.
UNIPOLAR CODES
In data conversion systems, the coding method must be related to the analog input range (or span) of an ADC or the analog output range (or span) of a DAC. The simplest case is when the input to the ADC or the output of the DAC is always a unipolar positive voltage (current outputs are very popular for DAC outputs, much less for ADC inputs). The most popular code for this type of signal is straight binary and is shown in Figure 3 for a 4-bit converter. Notice that there are 16 distinct possible levels, ranging from the all-zeros code 0000, to the all-ones code 1111. It is important to note that the analog value represented by the all-ones code is not full-scale (abbreviated FS), but FS - 1 LSB. This is a common convention in data conversion notation and applies to both ADCs and DACs. Figure 3 gives the base-10 equivalent number, the value of the base-2 binary code relative to full-scale (FS), and also the corresponding voltage level for each code (assuming a +10 V full-scale converter. The Gray code equivalent is also shown, and will be discussed shortly.
111 110 101 100 011 010 001 000 0 1/8 2/8 3/8 4/8 5/8 6/8 7/8 8/8 x VFS Analog Input
BIPOLAR CODES
In many systems, it is desirable to represent both positive and negative analog quantities with binary codes. Either offset binary, twos complement, ones complement, or sign magnitude codes will accomplish this, but offset binary and twos complement are by far the most popular. The relationships between these codes for a 4-bit systems is shown in Figure 9. Note that the values are scaled for a 5-V full-scale input/output voltage range.
111 110 101 100 011 010 001 000 -8/8 -6/8 -4/8 -2/8 0 2/8 4/8 6/8 8/8 x VFS Analog Input
Figure 5: Bipolar Codes, 3-bit Converter
For offset binary, the zero signal value is assigned the code 100. The sequence of codes is identical to that of straight binary. The only difference between a straight and offset binary system is the half-scale offset associated with analog signal. The most negative value (-FS + 1 LSB) is assigned the code 001, and the most positive value (+FS - 1 LSB) is assigned the code 111. Note that in order to maintain perfect symmetry about mid-scale, the all-zeros code (000) representing negative full-scale (-FS) is not normally used in computation. It can be used to represent a negative offrange condition or simply assigned the value of the 001 (-FS + 1 LSB).
Digital-to-analog converter
A digital-to-analog converter (DAC or D-to-A) is a device that converts a digital (usually binary) code to an analog signal (current, voltage, or electric charge). An analog-to-digital converter (ADC) performs the reverse operation. Signals are easily stored and transmitted in digital form, but a DAC is needed for the signal to be recognized by human senses or other non-digital systems. A common use of digital-to-analog converters is generation of audio signals from digital information in music players. Digital video signals are converted to analog in televisions and cell phones to display colors and shades. Digitalto-analog conversion can degrade a signal, so conversion details are normally chosen so that the errors are negligible. Due to cost and the need for matched components, DACs are almost exclusively manufactured on integrated circuits (ICs). There are many DAC architectures which have different advantages and disadvantages. The suitability of a particular DAC for an application is determined by a variety of measurements including speed and resolution.
Figure
2- Motor control
While a complete review of numerous motor types will not be covered in this article, it is important to know some of the most common motors used today. The primary types include: DC motors (brushed, brushless), AC motors (synchronous, inductive), electrostatic motors, as well as other variants. While there are some motor applications that require no closed-loop control, most do require some method of control. That control is typically achieved with a controller, DAC, motor driver and a feedback path containing the data measured by a sensor. One of the most popular motors is the DC brushless motor (BLDC). It has some significant advantages over the DC Brushed Motor, including higher efficiency, less mechanical wear, and lower cost of service and maintenance. The DC brushless motor itself has sub-types, including stepper and reluctance-type motors. DC brushless motors have become very common among consumer products, industrial and factory systems, robotics, tools and other applications. The DC motor is typically used with a variable reluctance sensor (VRS) or a Hall Effect sensor, which is used to measure the position and speed of the motor. In the newest DC motors available, the sensor electronics may be integrated into the entire mechanism of the motor. system using a DAC.
The DAC will typically be driven by a microcontroller or a specialized controller IC for motor control applications. The DAC will receive the input data code, in this case, via a parallel interface, and convert the data code to current outputs. The motor driver circuit shown can be implemented in several ways. While there are integrated ICs specifically for that task, it can also be designed with simple power operational amplifiers such as the LM675. The architecture of the driver circuit will depend on the requirements of the DC motor, such as the total power, continuous and maximum current, and voltage range among other requirements. During operation, the motor/encoder sends velocity and position signals to the microcontroller. Depending on the encoder, these signals may also include an index pulse signal. The microcontroller then adjusts the speed and direction of the motor by changing the data codes sent to the DAC. In this regard, the DAC serves a role in closing the controlloop. As you can see, the DAC plays a key role in motor control applications. The DACs importance can be seen by the number of manufacturers integrating the DAC function into their motor driver ICs, thereby adding value to the product.
A basic R-2R resistor ladder network is shown in Figure 8. Bit an-1 MSB (most significant bit) to Bit a0 LSB (least significant bit) are driven from digital logic gates. Ideally, the bits are switched between 0 volts (logic0) and Vref (logic 1). The R-2R network causes the digital bits to be weighted in their contribution to the output voltage Vout. For a digital value VAL, of a R-2R DAC of N bits of 0 V/Vref, the output voltage Vout is: Vout = Vref VAL / 2N If, N = 5 and hence 2N = 32. With Vref = 3.3 V (typical CMOS logic 1 voltage), Vout will vary between 00000, VAL = 0 and 11111, VAL = 31. Minimum (single step) VAL = 1, we have Vout = 3.3 1 / 32 = 0.1 volts Maximum output (11111) VAL = 31, we have Vout = 3.3 31 / 32 = 3.2 volts The R-2R ladder is inexpensive and relatively easy to manufacture since only two resistor values are required (or 1, if R is made by placing a pair of 2R in parallel, or if 2R is made by placing a pair of R in series). It is fast and has fixed output impedance R. The R-2R ladder operates as a string of current dividers whose output accuracy is solely dependent on how well each resistor is matched to the others. Small inaccuracies in the higher significant bit resistors can entirely overwhelm the contribution of the less significant bits. This may result in non-monotonic behavior at major crossings, such as from 01111 to 10000. Depending on the type of logic gates used and design of the logic circuits, there may be transitional voltage spikes at such major crossings even with perfect resistor values. These can be filtered, with capacitance at the output node for instance (the consequent reduction in bandwidth may be significant in some applications). Finally, the 2R resistance is in series with the digital output impedance. For all of the above
reasons (and doubtless others), this type of DAC tends to be restricted to a relatively small number of bits, although integrated circuits may push the number of bits to 14 or even more, 8 bits or fewer is more typical.
Configure Pic16f628 with internal RC Osc, no CLKout and with 4,000,000 HZ oscillator frequency and Master Clear pin disabled
7
Lab Work
1. Measure the period, the frequency, and the amplitude of the generated wave.
2. Discuss how to control and change its amplitude (e.g., maximum and minimum values) and frequency. 3. Change the code to generate other waveforms: square, triangle and sinusoidal. Note that provides us with a programmable function generator. 4. Explain how to convert the above circuit to bipolar DAC with a full scale of 5V. 5. What is the maximum resolution of DAC that can be designed by PIC16f628? What is the step voltage in this case?