- Discrete LEDs
- Dot/Bar LEDs
- Matrix LEDs
- 7-Seg LEDs
- Serial -- Software
- Serial -- Hardware
- RS-232 via the MAX3232
- I2C -- EEPROM
- I2C -- DS1307 Real Time Clock
- 1-Wire -- DS18B20, Powered, Single-Drop
- 1-Wire -- DS18B20, Powered, Multi-Drop
- 1-Wire -- DS18B20, Parasitic, Multi-Drop
- TI Link Protocol -- Calculator Demo
- Infrared Communication
- MIDI -- Output Demo
- MIDI -- Input Demo
- MIDI to Analog Synth
3-Bit DAC Demo
In this section of the exercises, we now turn our attention to analog--analog output in particular. This will also include learning how to do some audio-based things as well.
Let's begin with digital-to-analog conversion (DAC). Perhaps the first approach to occur is simply to use binary weighted resistors, and let three port pins drive them. To lower the output impedance and make the affair into something usable, we'll buffer the result with an op-amp. Here's the circuit:
You'll note that the resistors follow a doubling progression. Because each is twice as large as the previous, there are definite limits in how easily this can be extended to more bits. However, three-bits works out just fine with standard 5% resistor values.
The PMP software is ingenuous and straightforward. The waveform created by it in this demo is just a staircase, with eight steps. But obviously, other patterns are possible through software manipulation.
You'll note that the waveform has an amplitude of about 5V, and a frequency of about 1 kHz. If you'd like to change the frequency, look for the Pascal delay() command in the main loop.
Click to get the source code.
Click to get the schematic PDF.
Next Project: 4-Bit DAC Demo