The Digital-to-Analog Converter (DAC) is a peripheral for taking digital data and producing a variable (i.e. analog) output level. The PIC® MCU output supplies a variable voltage reference that is ratiometric with the input source. The input source is spread across a resistor ladder within the device and the output off the ladder is controlled by the digital signal. This peripheral is built into many different PIC® MCU devices. Some internal DACs have a 5-bit (32 levels) resolution and some have an 8-bit (256 levels) resolution. On some devices you get both. In all cases, the limited output current drive capability will typically require a buffer to boost the output drive capability. The circuit below shows a typical example:
The 5-bit DAC offers 32 levels of output while the 8-bit DAC offers 256 selectable output levels of resolution. Depending on the device, the output can be selected to connect to other peripherals within the device such as:
- Comparator Positive Output
- ADC Input Channel
- Op-amp Positive Input
- DAC1OUTx I/O pin
The input voltage can come from the following sources:
- External Vref+ pin
- Vdd Supply Voltage
- Fixed Voltage Reference (FVR)
Ratiometric Output Level
The DAC output value is derived using a resistor ladder with each end of the ladder tied to a positive and negative voltage reference input source. If the voltage of either input source fluctuates, a similar fluctuation will result in the DAC output value.
DAC Project Example
The MPLAB® Code Configurator (MCC) makes it easy to setup the DAC for your specific device. Refer to the data sheet for your device for detail on the various DAC options as it can vary slightly from device to device.