# DAC chips (short question).

so the digital to analog converting chips that i know have a Reference voltage pin that sets the top voltage then you supply data to the port of a certain number of bits .

can i find a DAC chip that has a two reference inputs instead of one ? one for the lowest voltage and an other of the highest .

so for example i want to the voltage to vary between 4v and 5v if the port is set to 0 the chip outputs 4v , 128 → 4.5v and so on .

i don’t want to use a resistor ladder for this .

I think you want a differential input DAC, some of the AVR chips can do this, I don't know about the MEGA328.

thank you for the response jcallen . the matter is outputting a voltage from the avr , i did not mention analog input .

can i find a DAC chip that has a two reference inputs instead of one ? one for the lowest voltage and an other of the highest .

I have never seen one like that.

So, based on your description, you want to prevent the analog output from going below X volts(4v), and not going over Y volts (5V). The arduino can do that.

You didn't mention if you had any concern with resolution, so we will assume that resolution is not a factor.

If you give us more detail, we can offer more accurate suggestions.

Quote: " i did not mention analog input ."
"can i find a DAC chip that has a two reference inputs".

resolution is one of the most important factors , this can be done with some resistors , but i need a chip

resolution is one of the most important factors

So why are you keeping such a vital thing a secret?

OOPS! I read that looking in the mirror. ;D

Couldn't you use arithmetic, something like:

analogOut = 204 +(val / 255 * 51);

analogOut = 204 +(val / 255 * 51);

And what do you think the result of an integer division by 13005 actually be?

amine2:
resolution is one of the most important factors , this can be done with some resistors , but i need a chip

I would appreciate learning how this can be done with some resistors. I have hundreds laying around I could put to use.

In the case of operations of the same level of precedence, evaluation proceeds from left to right.

It would be divided first by 255, and the result would then be multiplied by 51.

Not "division by 13005".

analogOut = 204 +(val / 255 * 51);
if val is 1000, then the result
analogOut = 357

Maybe that should be:

analogOut = val / 255.0 * 51.0 + 204;

Or use a 16 bit DAC, 1 volt would be 13107 steps.

hey Jack , so to get your own resistor ladder with a base voltage for the needed number of bits of yours , this is the mathematical method that i usually use . n being the number of bits

— R -------------/
— 2R------------/
— 4R------------/
.
.
—(2^(n-1))R—/
VCC-----R’-----------/----------------output
/
R’’
/
GND

first you must understand how a voltage divider works .

(Voltage input - Vin) ---------- R1 ------/------------R2-----------GND Vout = Vin* R2/(R1+R2)
/
(Voltage output - Vout) Vout = 5 * R2/(R1+R2)

the bit input pins resistances must be in power of two from they each other . so you have to figure out three values R , R’ and R’’ . if you set R’’ to 100R . (R’ is connected to VCC for the base voltage
then all you need is to do the rest of the calculation using the simple laws .
so if all the input bits are at a low state ,then for the voltage divider circuit you have R1 = R’ since it’s the only pin connected to VCC (input) . and for R2 you have all the R power resistors in parallel connected to ground
in parallel with the R’’ resistor

the resistance of that in this case would be 1/Req = 1/R + 1/2R + 1/4R + … + 1/(2^(n-1))R
can be calculated → x = R/Req = 1 + 1/2 + 1/4 + … + 1/(2^(n-1))
Req = R/x
so 1/R2 = x/R + 1/100 ← (R’’=100ohms)
1/R2 = (100x + R)/100R -------> R2 = 100R/(100x + R) ← only unknown here is R

so the voltage divider equation for the first part is
(Vout here is the base voltage . Vb) ( we need R and R’ in an equation)

Vb = 5 * R2/(R1+R2) = 5 * 100R/( (100x+R)*(R’+(100R/(100x + R))))

so the first equation is 500R/( (100x+R)*(R’+(100R/(100x + R)))) = Vb ← base voltage

the second part covers the output case , that is the top voltage
when both R’ and the power resistors are all set to 5v so Req and R’ are both connected to VCC and R" is connected to ground . so now R2 = R" = 100
and 1/R1 = 1/R’ + x/R
then 1/R1 = (R+ R’x)/RR’
so R1 = RR’/(R+R’x)
then we simply do the voltage divider equation again but with Vout = Vtop = top voltage
so Vtop = 5* R2/(R1+R2) = 500/(100 + (RR’/(R+R’x)))

then we must combine both the equations for Vtop and Vbase in the same equation then solve it .
so Vtop-Vbase = 500 * ( 1/(100 + (RR’/(R+R’x))) - R/( (100x+R)*(R’+(100R/(100x + R))))
so this is the needed equation . for R" = 100ohms
what you need now is to firstly calculate your X for your number of bits n
X= 1 + 1/2 + 1/4 + … 1/(2^(n-1))
then determine your needed Vtop and Vbase .
then input that equation that now only has two unknowns that are R and R’ in an online equation solver .
it will output the possible solutions .

for x rounded to 1.9
Vtop = 5 and Vbase = 4
and R"=100
R’ is named a
the equation is : 500*(1/(100+(Ra/(R+a1.9)))-R/((190+R)(a+(100R/(190+R)))))=1
go to this site to solve it with your parameters “www.wolframalpha.com” ← best one i know
you would propably find many solutions , get one where R and R’ are positive and work with it
solutions for that case are :
tell me if i did get something wrong .

-amine2

"tell me if i did get something wrong ."

Yes you did.

and that would be ?

amine2:
i want to the voltage to vary between 4v and 5v if the port is set to 0 the chip outputs 4v , 128 -> 4.5v and so on .

i don't want to use a resistor ladder for this .

Not complicated.
Just use a 1:4 resistor divider on the output of the DAC (or the PWM output of the Arduino).
e.g. 1k and 3k9 in series.
1k to +5volt, 3k9 to output pin.
Tap will be 4-5volt.
Cap accross the 1k resistor for smoothing.
Leo..

Wawa:
Not complicated.
Just use a 1:4 resistor divider on the output of the DAC (or the PWM output of the Arduino).
e.g. 1k and 3k9 in series.
1k to +5volt, 3k9 to output pin.
Tap will be 4-5volt.
Cap accross the 1k resistor for smoothing.
Leo..

i already mentioned that it can be done with some resistors , but i want a chip to do it .