Omnimaga

General Discussion => Technology and Development => Other => Topic started by: Spyro543 on May 31, 2013, 02:42:00 pm

Title: R-2R resistor ladder
Post by: Spyro543 on May 31, 2013, 02:42:00 pm
An R-2R resistor ladder is a nice little method of doing digital to analog conversion.
The one I made is 8-bit, so it can output 256 different voltages from 0V to 3.3V. Here are some pics:

http://i.imgur.com/GPynZsR.jpg (http://i.imgur.com/GPynZsR.jpg)
You can see on my oscilloscope that I'm generating a saw wave. All I'm doing is counting from 0 to 255 really fast over and over again, and putting the number onto the 8 pins of the PIC that are connected to the resistor ladder. You can also see on the oscilloscope that the wave isn't perfectly straight, and that's because of the resistors' tolerance that is differing the resistance slightly. There's nothing I can do to fix that, except use resistors with smaller tolerance.

Here's a close up pic of the ladder:
http://i.imgur.com/VObI1xr.jpg (http://i.imgur.com/VObI1xr.jpg)

If you want to learn more about this take a look at the wikipedia page here (http://en.wikipedia.org/wiki/Resistor_ladder#R-2R_resistor_ladder_network_.28digital_to_analog_conversion.2C_or_DAC.29).
Title: Re: R-2R resistor ladder
Post by: Keoni29 on June 01, 2013, 05:35:41 am
I made a 4 bit one for use with calcs once. I tested that one with different waveforms as well. I even tried converting sound samples to calc format, but it did not quite work.
Title: Re: R-2R resistor ladder
Post by: aeTIos on June 01, 2013, 05:42:09 am
Nice oscilloscope you have there :o
Title: Re: R-2R resistor ladder
Post by: Keoni29 on June 01, 2013, 05:44:05 am
Hmm that scope gives me a cool idea :P
(calc ADC with scope software)
Title: Re: R-2R resistor ladder
Post by: aeTIos on June 01, 2013, 05:44:47 am
will that work?
Title: Re: R-2R resistor ladder
Post by: Keoni29 on June 01, 2013, 05:46:35 am
Of course that will work. If you have a 12 bit analog to digital converter with an I2C bus you could interface it with the 84+. You'd need to implement the I2C protocol in software though.
Title: Re: R-2R resistor ladder
Post by: Streetwalrus on June 01, 2013, 05:47:12 am
It will. Because here we're all awesome and there's nothing we can't do. :P
Edit : Why I2C ? wouldn't your soundchip interface work ?
Title: Re: R-2R resistor ladder
Post by: Keoni29 on June 01, 2013, 05:53:04 am
The atmega 328 has a built in 10 bit ADC, so I could use one of those and use the same protocol as my soundchip uses.
Title: Re: R-2R resistor ladder
Post by: Streetwalrus on June 01, 2013, 05:55:17 am
Yeah so you can actually make it in less than 10 seconds. :P (not counting display but that's pretty easy in Axe)
Title: Re: R-2R resistor ladder
Post by: Keoni29 on June 01, 2013, 07:34:25 am
No you can't do it in so little time. You have to write some code for handling data streams.
Title: Re: R-2R resistor ladder
Post by: Streetwalrus on June 01, 2013, 07:35:31 am
Yeah I was just sayin' that it wouldn't take really long to do it. :)
Title: Re: R-2R resistor ladder
Post by: Keoni29 on June 01, 2013, 07:36:23 am
About 1 hour to write the code and about 10 hours to find that one annoying bug.
Title: Re: R-2R resistor ladder
Post by: Streetwalrus on June 01, 2013, 07:37:11 am
BUGS ! D: I HATE BUGS !/me runs away from them
Title: Re: R-2R resistor ladder
Post by: aeTIos on June 01, 2013, 07:40:20 am
This is getting off-topic. <_<
Really.
And I actually shouldn't post this either because it's also off-topic <_<
Title: Re: R-2R resistor ladder
Post by: Streetwalrus on June 01, 2013, 07:41:21 am
Haha yeah.

This is looking pretty awesome, Spyro. :D
Title: Re: R-2R resistor ladder
Post by: Keoni29 on June 01, 2013, 07:44:57 am
What else can we say about r2r ladders? We're talking about digital to analogue and vice versa converters.
Title: Re: R-2R resistor ladder
Post by: SpiroH on June 12, 2013, 09:37:23 am
What else can we say about r2r ladders? We're talking about digital to analogue and vice versa converters.
Well, why do you bother to build yourself such a thing? If that's only for learning purposes i can take that, but otoh the simulator ouput should be enough. Else why don't you just buy an off-the-shelf component (dac/adc) with much higher resolution/precision and smaller footprint?  FYI R-2R networks are normally built with integrated matched resistor values. Building it with discrete components is doomed to failure. Cheers,
Title: Re: R-2R resistor ladder
Post by: leafy on June 12, 2013, 10:50:33 am
The ADC on the atmega/arduino chipset is notoriously slow, however. If you need speed, you might want to get a dedicated high-speed ADC (I generally use the SPI interface with an Arduino)
Title: Re: R-2R resistor ladder
Post by: Keoni29 on June 12, 2013, 11:17:32 am
DAC and ADC are very expensive. Especially i2c ones.
Title: Re: R-2R resistor ladder
Post by: leafy on June 12, 2013, 12:10:19 pm
You can get free samples from TI for some fairly powerful ADCs.
Title: Re: R-2R resistor ladder
Post by: Keoni29 on June 12, 2013, 12:16:58 pm
Samples? I never get those. I am not a university nor big company (not even a small one). TI is not known for throwing samples at everyone.
Title: Re: R-2R resistor ladder
Post by: leafy on June 12, 2013, 12:45:55 pm
they actually have options for individuals, IIRC. Just find the chips you want and request a free sample if they're available (sometimes they're not, but I've always found the chips I need).