Pages: [1]   Go Down
Author Topic: [Solved] How do I do cheap DAC?  (Read 1148 times)
0 Members and 1 Guest are viewing this topic.
Seattle, WA
Offline Offline
God Member
*****
Karma: 11
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi.  I'd appreciate any help with this problem...  I have an I2C device (MCP23018) with a single pin to set one of 8 possible bus addresses.  It does so by putting a 3-bit ADC behind the pin.

Well, what I actually want to do is control the address in this case using a DIP switch.  So I figure I need to do a DAC conversion first to put voltage in at the right level.

Of course, everything I know about electronics, I know from searching the web or asking on this forum...  So I found this: http://www.ikalogic.com/dac08.php that seemed to do what I needed.  It mentioned a R/2R resistor ladder, so I bought this: RGSD8L102G Datasheet.

But that doesn't seem to do what I expect.  Even before connecting the chip, I am just measuring the voltages at different dip settings.  With a 4.98v voltage, I get these readings, which is nothing like what I would expect from a digital progression...

SwitchesVoltage%
000
11.65933.2%
22.48949.8%
32.98859.8%
1 & 23.16863.4%
1 & 33.55771.1%
2 & 33.73574.7%
1 & 2 & 34.0581%

Also, switch 0 had no impact ever.
« Last Edit: March 28, 2011, 10:41:13 pm by maniacbug » Logged


0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The big difference between your circuit with DIP switches and the R-2R ladder circuit you referenced is that, for each pin, your circuit either makes a connection to 5V (right?) or not, while the R-2R ladder circuit either makes a connection to 5V OR 0V!!! That's a big difference.

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 74
Posts: 7255
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Something is wrong here. Can you post your diagram and your project pic? Unless you have some SPDT switches you can't do this, not with simple dip swtiches, they're SPST.
Logged


Seattle, WA
Offline Offline
God Member
*****
Karma: 11
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The big difference between your circuit with DIP switches and the R-2R ladder circuit you referenced is that, for each pin, your circuit either makes a connection to 5V (right?) or not, while the R-2R ladder circuit either makes a connection to 5V OR 0V!!! That's a big difference.

Oooooh, I never would have figured that out!  Yes, you're right, I am connecting 5v or nothing.  I think that's the same point as the SPDT switch point.  Could I do this with pull-down resistors?

Anyway, I will try it with pull-downs and if that fails, I'll post schematics tonite.
Logged


Central MN, USA
Offline Offline
Tesla Member
***
Karma: 74
Posts: 7255
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You need arduino pins to drive those 0-3 switches.
Logged


Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 40
Posts: 5594
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Another way might be to use a digital potentiometer to feed it, then set the potentiometer using the DIP switch.
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Seattle, WA
Offline Offline
God Member
*****
Karma: 11
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, thanks guys.  This is clear now.  I re-wrote this using Arduino pins, just to understand what's going on, and it now behaves as expected.  Sadly it means that I had a fubar solution to my problem, though, so I will still have to figure out how to solve that.

1111: 4.73V
1101: 4.09V
1100: 3.777
1011: 3.516
1010: 3.195
1001: 2.874
1000: 2.553
0111: 2.185
0110: 1.865
0101: 1.546
0100: 1.227
0011: 0.964
0010: 0.643
0001: 0.3242
0000: 0.0017
Logged


Pages: [1]   Go Up
Jump to: