Digital-to-analog converters (DACs) are often built into microcontrollers but tend to be slow, noisy, and lack resolution. So, we frequently use specialized DAC chips.
Today's example is a digitally controlled voltage regulator module that could be used in a lab power supply. The workhorse here is the LM317T chip, which has the DAC0832 digital-to-analog converter at its core.
The DAC0832 is a pretty advanced chip, with not one but two latches arranged in sequence. This setup allows it to store digital data from the microprocessor bus and convert it to an analog value at just the right moment.
In the post about the 74HC374 latch, we used it to freeze the readings on seven-segment displays for a second while counting input pulses.
After a second, the data from the counters was sent out to the display decoders, showing the frequency of the input signal measured a second earlier. Meanwhile, the next count of pulses was happening. This made for a good frequency counter.
Each of the two latches in the DAC0832 can be made transparent, meaning asynchronous. In this mode, data from the input instantly appears in the output.
A logic high on the ¬LE (¬LATCH ENABLE) pin is needed to set the input latch to transparent asynchronous mode. You could call it LATCH DISABLE without the ¬ sign.
¬LE = ILE & (¬¬CS & ¬¬WR1) = ILE & ¬(¬CS | ¬WR1).
In simpler terms, you need a logic high on the ILE (INPUT LATCH ENABLE) input and a logic low on at least one of the two inputs, ¬CS (¬CHIP SELECT) or ¬WR1 (¬WRITE1). The ¬WRITE1 and ¬WRITE2 inputs are used for strobe signals.
For the 8-bit DAC latch register, the logic for ¬LATCH ENABLE is more straightforward:
¬LE = ¬¬XFER & ¬¬WR2 = ¬(¬XFER | ¬WR2).
So, you need a low logic level on at least one of the inputs: ¬XFER (¬TRANSFER) or ¬WR2 (¬WRITE2).
The heart of the DAC0832 is the analog-to-digital converter. This analog multiplexer switches precision silicon-chromium resistors deposited on a silicon chip.
This manufacturing technique ensures high accuracy and temperature stability, which is why we use DAC chips in our favorite high-fidelity audio gear.
Plus, a multiplexer can work much faster than pulse-width modulation (PWM) analog-to-digital conversion, which we often use in Arduino DIY projects.
Also, PWM produces square pulses with different duty cycles with a broad frequency spectrum. The frequencies might be inaudible, but their interference with other frequencies in the device can create audible noises, which can be pretty unpleasant.
The homemade tube amplifier article mentioned that asymmetrical and softly clipped waveforms sound pleasant and musical to human ears because they're full of even harmonics.
But a square, symmetrical waveform has many odd harmonics, which aren't so nice to listen to, especially when they create dissonance with the overtones of other sounds played at the same time.
The DAC0832 needs an external operational amplifier to convert the current through switched precision resistors into an output voltage.
We'd probably go with the NE5532 for audio output, which we used for a simple, affordable, and high-quality headphone amp.
But the good old LM358 will do fine for a power supply. Here, op-amp IC4A converts the output current of the DAC0832 into voltage, and IC4B amplifies the resulting signal by six times.
The TL431 chip generates the DAC0832's reference voltage, which is adjusted with the potentiometer RP1. The voltage ranges from 5×1100/1200=0.42V to 4.58V.
The output of IC4B is connected to the adjustment input of the LM317. Therefore, this chip's output voltage, and therefore our homemade power supply's, will be 1.25 volts higher than IC4B's.
So, the output voltage formula is:
Vout = 1.25 + 6 * Vref * DIGITAL INPUT / 256 = 1.25 + 0.024 * Vref * DIGITAL INPUT.
Adjusting the reference voltage can change the increment and decrement steps when pressing the corresponding buttons on the power supply's front panel.
The digital value for converting to a voltage is set by two 74HC193 four-bit up/down counters.
These are presettable counters, similar to the ones we used as registers in our DIY 4-bit CPU.
Each CPU's four registers used one SN74HC161L chip as a latch. The increment function was only used in the program counter (PC) register. The other three registers disabled it by grounding the CEP and CET control inputs.
We used the decrement function in a countdown timer that could be set to any number of seconds from 0 to 99.
Thanks to the preset function, the chosen value from the PRESET ROM of our electronic traffic light tells the second counter how long the current signal combination should last. The decrement function was also used there.
In today's power supply, we do not use the preset function but both increment and decrement counting. There's also a reset button to set both counters to zero.
Accordingly, the digital-to-analog converter will also be set to zero since both of its internal latches are permanently in transparent asynchronous mode.
To lock the chip in this mode, the ¬CS, ¬WR1, ¬WR2, and ¬XFER control inputs are soldered to ground.
The video shows how this DIY digitally controlled analog voltage regulator works.
We could make a power supply with non-volatile preset memory if we used a microcontroller instead of up/down counters. The microcontroller's analog-to-digital converter could be used for the voltmeter and ammeter.
And if the microcontroller doesn't have enough pins to connect the 8-bit DAC data bus, we could use a shift register for serial data transfer.
In this case, the DAC0832's latch registers could be very handy if the shift register doesn't have a built-in latch.
After all, to convert a binary number into a voltage, you must wait until the binary number is fully received from the microcontroller via the serial bus. Otherwise, you’d get meaningless voltage jumps, which are unacceptable in a power supply.
Hi! I'm Kevin! I am a very curious engineer :))
I'm the website founder and author of many posts.
I invite you to follow exciting experiments, research, and challenges.
Let's go on to new knowledge and adventures!