We're test-driving a Digital-to-Analogue Converter idea this week in The Factory. R-2R DACs are a parallel input DAC that are really easy to experiment with. We want to see how viable this kind of DAC is for driving our Makerverse Class-D Amplifier from a Raspberry Pi Pico. Picos are digital-only devices, which means they can't generate the analogue voltages required to create (pleasant) sound. We're hoping this DAC will be both educational and practical. Let us know what you think!

Transcript

Welcome back to the factory! This week we have just received some brand new robots that we can't wait to commission and put to work doing some through-hole soldering. We are also working on a Makerverse digital to analog converter project. These shots are of an automatic through-hole soldering robot and this is going to be a game changer for the factory's capabilities. Until now, we were doing single-sided load surface mount only, but now with the capability to do through-hole soldering, we can bring in more user-friendly parts like bigger through-hole potentiometers or interesting connectors.

In the last episode, we asked what your favourite connector was for future dev boards. The votes are in and it seems like everyone is a fan of USB-C. Liam says that he loves the idea of USB-C being able to pull enough current for motors through a USB connection. Paul chimed in that he really dislikes micro, and now that he has experienced USB-C, he is inclined to agree. Graham chimed in with "USB-C for everything please". So, your votes are in and we will proceed with that.

In the last episode of the factory, we were talking about the Makerverse Class D amplifier. The obvious implementation for these is to connect your phone with a breakout lead that's wired directly into this and you can play some audio over a speaker. That's really easy.

We thought it would be nice to squeeze some audio right out of a Raspberry Pi Pico, a purely digital device. It can only turn its pins on and off, and can read analog voltages, but not create the analog voltages required to drive something like this. To do this, we need a digital to analog converter (DAC). There are a large number of types of DACs available, such as I2C based modules and I2S modules which are typically audio specific.

Today, we are exploring a simple type of DAC called an R2R ladder, which is just a bunch of resistors. If we imagine a switch connected to VCC and another switch connected to ground, we have a 2R resistance going to VCC. Doing the maths on the resistor network on the left, we have two 2Rs in parallel that both go to ground, which is a resistance of R. This is in series with another resistance of R, making the whole thing 2 times R. This means that the output voltage is just half of VCC.

If the first switch is grounded and the second goes to VCC, we end up with a quarter of VCC on the V out pin. If they are both on VCC, we end up with three quarters of VCC. This is a binary counting system, where each step in the binary number gives us an extra quarter of the VCC at the output of the op amp. This is a two bit digital to analog converter, which can be extended. a batch of resistors that are all slightly off the nominal value then we can still get a good output.

We are prototyping a 10-bit digital to analog converter (DAC) R2R ladder. This allows us to have finer control over the output voltage, with 1024 different levels to choose from. This reduces quantization noise in the output, making it more accurately track an analog waveform. Compared to buying a DAC, this design is simpler and easier to understand, and it is also easier to synchronize the output to the sample rate of an audio file. Additionally, this design only requires a single value of resistor, which helps to reduce systematic errors in the batches of resistors we get. the resistor has to be less than that.

We have designed a device that fits between I2S DACs and I2C DACs. It is capable of creating a usable signal to noise ratio and can be synchronized with something like the PIO on the Raspberry Pi Pico or with MicroPython code. This device is very versatile, however there are a few design challenges.

The tolerance on the resistors chosen must be very tight. The error in the value of the resistor must be less than the effect of the least significant bit, which is one part in about 1024 on the output. This means that a reel of 1k and a reel of 2k resistors, even if they are all half a percent too big, does not matter because the systemic change is reflected in every single resistor. The only thing that matters in this circuit is the ratio between the R and the 2 times R.

By only choosing a single value of resistor, the design is made simpler in terms of part sourcing. We only need to find one part that is plentiful and then we can use that for every resistor on this board.

Those resistors need to be 0.1 percent and that's really starting to get a little bit niche. Not everyone has 0.1 percent resistors floating around their workshop. If we're using 1k, the allowable error is one ohm.

If you are familiar with the details of microcontroller GPIO pins, you'll know that they have some output resistance. The two R's going into the data pins on a microcontroller can't assume that the 3.3 volts coming into the D0 pin has a source impedance of zero. The Raspberry Pi Pico source impedance on the GPIO pins is in the range of 30 to 50 ohms. This means that we have to choose reasonably large values for these resistors so that the GPIO pin source resistance is insignificant or at least within the 0.1 tolerance of the parts we're trying to use.

At the other end of the circuit, we have some kind of load that the DAC is trying to drive. If that load has some input impedance that's not very large, then it will introduce an error into the output voltage. For the circuit we have here, we're choosing a non-inverting op-amp buffer. This particular op-amp has an input impedance on the non-inverting pin of 10 to the power of 13 ohms. This is significantly larger than the resistance of the FR4 circuit board between the two pins. The input impedance of the op-amp is so high, it might as well be infinite. This means that if we use very large resistors in our resistor ladder, they won't be affected and the output voltage won't be affected by having the op-amp there.

The last thing we're going to look at is the prototype model. Here we have all the components we need.

We have designed a board with resistors and an op-amp that can plug straight into the side of a Raspberry Pi Pico. It uses GPIO pins from GP6 to GP15, but still has access to an SPI bus, an I2C bus, and the UART bus. The prototype is being manufactured and the parts are in the mail. Once it arrives, we will put it together and test it. We will start by throwing a sine wave through it and use that to measure noise and distortion.

This is a bare bones but affordable implementation of a DAC that you can build during a silicon shortage. If you have any questions or recommendations, let us know on the Core Electronics forums. We are full-time makers and we look forward to hearing from you. Until next time, thanks for watching.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.