Page 1 of 1

DAC Problem

Posted: Thu Apr 15, 2021 8:38 pm
by msg_otomasyon
Hi to everyone..
I am having a problem with DAC hardware for ESP32.

My code is as follows.

from machine import DAC
from machine import Pin
d = DAC(Pin(25,Pin.OUT))
d.write(0)

While I should read 0 volts on pin 25, I am reading about 0.1 volts.
This is a serious problem for me.

Does anyone have a solution suggestion on the subject.

Best Regards.

Re: DAC Problem

Posted: Fri Apr 16, 2021 3:36 am
by stanely
I'm also dealing with this issue. It is not uncommon for ADC outputs not to swing rail-to-rail. It could also be the result of input offset voltage. Either way, an external circuit might be needed. I'm getting better than 0.1V, but it's still not 0.

I plan to use a low voltage rail-to-rail opamp configured as a differential amplifier to get 0 at the oputput. I'll add a small offset voltage to the (-) input to force the output to 0. Scale range can be set by the gain of the resistors. Equations can be seen here: https://www.electronics-tutorials.ws/opamp/opamp_5.html

There's a brief discussion of this issue here, https://electronics.stackexchange.com/q ... zero-volts

I'm waiting for parts. I ordered some MCP602 chips. They're about the only through-hole low-voltage, rail-to-rail opamps I found. The LM358LV (not to be confused with the LM358P) has the right specs but is only available in surface-mount.

Hope this helps.

Re: DAC Problem

Posted: Fri Apr 16, 2021 11:26 am
by pythoncoder
The other option is to use a host with a decent DAC such as a Pyboard. Note that, in my testing, the ESP32 DAC is also adrift at the high end of its range.

Re: DAC Problem

Posted: Fri Apr 16, 2021 7:38 pm
by msg_otomasyon
Apparently we can't handle it without using extra hardware.
I will try with difference amplifier or external DAC.
Thank you very much for your answers.

Re: DAC Problem

Posted: Sun Apr 18, 2021 1:48 pm
by wangshujun@tom.com
This situation is determined by the internal circuit of the chip. As described in the manual, the internal DAC output goes through an operational amplifier to the pin, and it is difficult to achieve the rail to rail output with this structure
The DAC of STM32 has a similar feature after the buffer is turned on, but the buffer of STM32 can be turned off.