# How could I create a high-precision voltage with the atmega128?

In my solution i have to replace an 10 turn potentiometer ( 5 K Ohms ) with a digital circuit. the potentiometer is dividing a voltage between 4v to 21v. so it seems if i could generate a voltage between 4v to 21v with a Atmega8 or Atmega128 ( indeed it must meet high accuracy ) I'm done ! I have tried to use Digital potentiometer , but got in to 2 problems :

1 - first they can not stand the current going throw the potentiometer : (21-4)/5K = 3.4mA

2 - they don't have the required accuracy (21-4)/256 = 66 mV ( but i need 0.5mV)

Is there any way i could do this?

-
Do you really need this kind of accuracy? I made this calculation: (21V-4V) / 0.5mV = 34000 Steps. Can the user currently set the pot this precise? For a 10 turn pot you have an total rotation angle of 10*360°, this is only 0.1° for a 0.5mV increment. However, you can achieve this easily with 16Bits (2^16=65536) DAC resolution. –  0x6d64 Aug 30 '11 at 6:55
Yes , I Do need it, actually I need more and I'm thinking that the DAC is a good idea specially when using it with an Op-Amp to bring up the voltage level to 4-21 Volts. –  Ehsan Ershadi Sep 1 '11 at 6:50

First the accuracy. Your total range is 17V, so 0.5mV in 17V is 1/34000, just a little bit over 15 bits. As 0x6d64 notes that's a lot to get from even a multiturn potmeter. Let's see. Most multiturn potmeters are wirewound, the one I have here in front of me has a diameter of about 15mm for the wire path. If the wire is wound at a 0.5mm spacing then you can have $10 \times \dfrac{2 \pi \times 7.5mm}{0.5mm}$ < 1000 steps or less than 10 bits.
But let's look for a 16 bit resolution anyway, then you're safe. The same type of solution applies for a lower resolution as well.

Then there's the current. As I understand it you want to draw several mA from the potmeter's wiper, CMIIW.

A good solution may be to use a Multiplying DAC, or MDAC, followed by an opamp to give us the required output current. The LTC1595 will work:

$V_{IN}$ is your 4V-21V input voltage, and via the serail digital interface you can set the output voltage as a ratio of $V_{IN}$ like a potmeter would.

The LTC1597 is a similar device with parallel inputs instead of serial.

-
Thanks @stevenvh , That was what i needed. –  Ehsan Ershadi Sep 1 '11 at 6:54