ESP32-DAC-Examples
ESP32-DAC-Examples copied to clipboard
ESP32: DAC or PWM
Hi, in my project I need to send voltage's clear and short signals to a PCB. So I tried first using the ESP32's DAC feature but I realized that the lower signal never goes back to zero (remainning around 0.08V). I also realized that the higher signal gotten is 3.18V a bit lower than the feeded tension 3.29V. These voltages were measured in my MH ET Live ESP32 MiniKit).
While using PWM I get 0V and 3.28V in the same conditions. So I'm wondering if the DAC feature has any advantage against the PWM.
But there is also another issue calling my attention. In the short code attached both features do not work together. I tried in various variants without success. The dacWrite() overlaps the ledcWrite() command.
int PinPulsos = 25;
int FrecPulsos = 5000;
int CanalPulsos = 0;
int Resolucion = 8;
int Pausa = 1500;
void setup()
{
Serial.begin(115200);
ledcSetup(CanalPulsos, FrecPulsos, Resolucion);
ledcAttachPin(PinPulsos, CanalPulsos);
}
void loop()
{
dacWrite(PinPulsos, 255);
delay(Pausa);
dacWrite(PinPulsos, 78);
delay(Pausa);
dacWrite(PinPulsos, 0);
delay(Pausa);
ledcWrite(CanalPulsos, 255);
delay(Pausa);
ledcWrite(CanalPulsos, 78);
delay(Pausa);
ledcWrite(CanalPulsos, 0);
delay(Pausa);
}
Am I doing something wrong? I'll appreciate your comments.
The DAC will be significantly faster than the PWM method, plus you would need some form of filter/smoothing on the PWM output and that will take some time to settle.
I’m not aware of any interaction between the DAC and PWM outputs, ha e you tried using DAC2 to see if the problem follows it.