Signal generator with >8-bit DAC

Hey guys,

I've recently been trying to use the Arduino Uno as a signal generator, and I've been fairly successful by using digital ports (0-7) and a resistor ladder to output 8-bit analog signals. I've attached a quick schematic, even though you probably know what I'm referring to.

My question is - can this be generalized to 10 bits or higher? The PORTD command only seems to cover the first 8 pins, and I need the signal to be as fast as possible while still maintaining stability. I've thought about taking the next two pins and using them as the two LSBs, but I'm afraid that I'll sacrifice speed in the process (with all that ORing with the previous bits and such). Is there any way to have direct digital writes similar to PORTD but with additional pins?

Any help is welcome!

Is there any way to have direct digital writes similar to PORTD but with additional pins?

Basically no. It is an 8 bit processor and you are stuck with 8 bits at a time.
You do not need to OR just shift and output.
I doubt if you are getting a true 8 bits with that circuit any way, you won't have monoticity.

You can only access one port at a time but if accessed directly after each other the glitch will be in the 1 micro second range.

I would first set the high 8 bits and then the 8 low bits to minimize the disruption in the signal (maybe add a small capacitor to dampen the noise effect?).

leafiness0:
...
My question is - can this be generalized to 10 bits or higher? ...

Yes you can have a ladder like this for any resolution you want (4, 5, 8 ,10, 16 and so on).

Not sure if it's under your expectations about speed but one good way of doing it is using latched shift registers to output the bits to the ladder, this way all the bits will show up on shift register output at same time (or almost ?).
Using direct port manipulation to drive the shift register will take approximately 30uS to 50us to shift all the 16 bits to 2 chained, latched shift registers.

Hope it helps

Yes you can have a ladder like this for any resolution you want (4, 5, 8 ,10, 16 and so on).

The problem with going to higher bit counts is the resistor matching. The more resistors you use the tighter they have to be matched to each other. With normal 1% resistors you will not get more than about 6 bits and maintain monoticity.

Grumpy_Mike:

Yes you can have a ladder like this for any resolution you want (4, 5, 8 ,10, 16 and so on).

The problem with going to higher bit counts is the resistor matching. The more resistors you use the tighter they have to be matched to each other. With normal 1% resistors you will not get more than about 6 bits and maintain monoticity.

That's interesting Mike. I suppose that error from resistor matching will just adds up error more and more to the ladder as whole until you stop adding resolution bits?
I guess that if you really need to rely on math to expect accurate results a DAC chip is the way to go and not R/2R ladders.
By the other hand ladders can be useful (even for more than 6 bits or wathever), if you can accept constructing a calibration table from empirical measures, I mean when you don't need direct math processing out from ladder outputs but just input/output know values.

I had a interesting experiment on this some months ago assembling a simple synth. I wanted the synth to be able to play exact notes in a 5 octaves range and I got it playing exact notes after scanning (or finding), exact notes (voltages), on output by trying input values. It was a R/2R ladder tied to 2x VCO's and was able to tune perfect notes this way. To be able to find exact note frequencies (exact as 0.5Hz of tolerance), in a 5 octaves range I needed a 14bit ladder. This is some result about this experiment: Stream VCO x 2 by rodrigonh | Listen online for free on SoundCloud

Yes just matching a specific voltage is not so critical because you do not need monoticity so for any one piece of hardware there will be more than one set of bit patterns that give you the same voltage.
That is a ladder by the way.
Ladders no not require accuracy in the resistor's absoloute value just the relitave value. Some people think you can just keep extending ladders as long as you like but it depends on how closely they are matched. Without monoticity for generating an audio wave you get increased quantisation noise.

Depending on your end application you might like to know about those 'dirt' cheap AD9850 DDS modules on ebay and china-wholesale site (<5$) , there are arduino lib's available.

Maybe you can use digital output in PWM(with max. value for all) mode? I am a newbie so be careful :).