# Potientiometer + Nano + DAC output

Hello everyone,

I am trying to control a DAC MAX5217 16 Bits using Arduino NANO with I2C. to get a voltage from 0 .. 5V. I need this accurate resolution cause i am designing adjustable power supply and the DAC will drive the LDO adjustable PIN in my powersupply.

My question is: Can someone hint me to how this will look like in the end? or the steps i have to be aware of?.

Is this picture in my head correct? connect the poti 10k to the analouge pin in Arduino which i will have range from 0 .. 1023 and then write the software which gonna store the value of the Poti? and in the same time the connection I2C to the DAC? I am missing something in this imagination, true?

Can someone simplify this for me so i can know how to write the code?! thanks.

how come this will happen when the ADC in the Arduino is 10 bits and my DAC is 16 bits? how am gonna be able to have all those step voltages from my DAC with using my 10k Poti?

Best Regards,
Abuelfeed

how am gonna be able to have all those step voltages from my DAC with using my 10k Poti?

If you are expecting to, somehow, get 16 bit resolution from a 10 bit ADC you will need to adjust your expectations because you cannot. I would suggest that you look into using a rotary encoder. One with a integral momentary switch. The encoder can have 2 (or more) modes. Say, course and fine. Set the output near the desired output, push the switch to change to fine mode for the final adjustment.

Abuelfeed:
But i am getting the 16 bit from my DAC and not my ADC!

That's the point, as the ADC is only 10 bits. One thing you won't be able to do is write the value of the 10 bit ADC directly to the 16 bit DAC. Your only option using those two components is to lose resolution of the DAC.

DAC value = 65535 * (ADC /1023)

thus when

ADC = 500, DAC = 32030
ADC = 501, DAC = 32094

there will be no way to get the 62 steps lost in the DAC. For all intents and purposes you are turning a 16 bit DAC into a 10 bit DAC. It may simpler to save the money and purchase a 10 bit DAC and do as you stated in the OP.

People do use the 12 and 14 DACs with the arduino. It is easy to control. It is based on their design and design parameters. Maybe they don't mind losing the resolution, maybe they don't need the resolution but it was the easiest or cheapest DAC to get.

Use an external ADC that matches you DAC.

How does using a rotary encoder as an input cause the loss of a DAC output?

this means also with a rotary encoder i will lose my 16 bit DAC?

No. If you use a rotary encoder(or perhaps buttons) to increment/decrement the variable passed to the software DAC setting you can have 16 bits of resolution because the minimum resolution of the increment/decrement input can be one.

Google "arduino quadrature rotary encoder with switch" for lots of info and some tutorials like this one.

groundFungus:
Google "arduino quadrature rotary encoder with switch" for lots of info and some tutorials like this one.

Thanks alot!!

so with a rotary encoders i will solve the problem of losing hte 16 bits.

Yes. Rotary encoders output a certain number of switch transitions per revolution. Call each switch transition a “click”. Through programming, a click can mean to increase or decrease a count by 1 or 10 or 100 or 47 or whatever. With the integral push button you can switch from one resolution (count change per click) on the fly. So a course adjustment might be 500 counts per click and the fine adjustment, 1 count per click. Also, with a quadrature encoder you can sense the direction that the encoder is turned. So decrease count for CCW and increase for CW. This is explained in the tutorials.

[u]deja vu[/u]

…I still don’t get why you want to convert analog-to-analog with a digital microcontroller in the middle.

Your resolution will mostly be limited by the analog pot. Have you played-around with the Analog Read Serial Example? I think you’ll find it difficult to adjust it exactly to some number or to adjust it up/down by one count.

…If the pot turns 270 degrees, one count on a 10-bit ADC is 0.27 degrees… That’s possible if the pot is “perfectly smooth”, put they aren’t. It can be “touchy” and frustrating tying to get an exact setting. With 16-bits, 1 count is 0.004 degrees!

In the old days, if you needed lots of “analog resolution” you might use a 10-turn pot and/or a “course” and “fine” pot. Nowadays, it’s usually done digitally with a “smart” rotary encoder that makes big-steps when you turn it fast or far, and tiny steps when you move it slowly. (Of course, the “smarts” are not in the encoder, they are in the software.

P.S.
… I realize I’m not helping with your DAC problem but if you want to “go digital”, a cheap & easy alternative to a rotary encoder (or pot) are “up” and “down” buttons. Again, these can be smart so a quick push & release counts up/down by one count, and the longer you hold the button the faster it goes. (I have clocks that are set this way.)