Page 1 of 1

ESP32 DAC1 and DAC2 not synchronous on Arduino IDE

Posted: Sun Jun 03, 2018 4:27 pm
by mauroh
Hi, I'm playing with DACs and using dac_output_voltage(DAC_CHANNEL_1, a); dac_output_voltage(DAC_CHANNEL_2, b); i'm able to write 2 separate values on the ADCs.
The issue is that using this 2 separate instructions, the 2 outputs are not updated simultaneously.
Is it possible accessing directly the DACs registers to load the 2 values and update the 2 outs simultaneously?

This is the source of information I'm using:
http://esp-idf.readthedocs.io/en/latest ... s/dac.html

Thanks
Mauro

Re: ESP32 DAC1 and DAC2 not synchronous on Arduino IDE

Posted: Mon Jun 04, 2018 9:18 pm
by dmaxben
Why not use ledcWrite?

Re: ESP32 DAC1 and DAC2 not synchronous on Arduino IDE

Posted: Tue Jun 05, 2018 1:02 pm
by mauroh
Hi, thank you for your suggestion...

I was reading all the documentation regarding ledc.h but if I got it correctly I think I'll have the same issue, because all the ledc channels are separated and I'll have to call 2 separate ledc_set_duty and ledc_update_duty for each channel.
This will end up again on a time difference between the voltages output change.

For my porpose the DACs are perfect, because the output voltage change is super fast and precise.
I hope I can find a way to load the value to be set on the 2 DACs and update the output voltages simultaneously like a common I2C or SPI commercial dual DAC IC.

Mauro

Re: ESP32 DAC1 and DAC2 not synchronous on Arduino IDE

Posted: Wed Jun 06, 2018 5:01 pm
by Archibald
You could put a sample-and-hold circuit on the output of each DAC. The output voltages of the sample-and-hold circuits could be held while the the software changes one DAC voltage then the other. A GPIO digital output would control both sample-and-hold circuits so their outputs would change simultaneously when the control changes from 'hold' to 'sample'.

Re: ESP32 DAC1 and DAC2 not synchronous on Arduino IDE

Posted: Fri Jun 08, 2018 1:05 pm
by mauroh
How about dual core??
The sampling and hold circuit will work for sure but it require external hardware and keeping the external circuit simple it will slow down the performance.
I've already purchase a MCP4802 that should do the trick for my test jig, but I was really hoping to find a software/register/trick as workaround.
While I'm waiting for the MCP4802 I was playng with the dual core!!!
The idea is to synchronize the call of dac_output_voltage(DAC_CHANNEL_x, a-b), one for each core.
If one of the 2 will finish, it will wait for the other to complete the operation and will start again simultaneusly.
What do you think?

I'll write the code and will let you know how it goes.
If you already know this can't work please stop me :)

Mauro

Re: ESP32 DAC1 and DAC2 not synchronous on Arduino IDE

Posted: Sat Jun 09, 2018 7:54 am
by rin67630
mauroh wrote:How about dual core??
While I'm waiting for the MCP4802 I was playng with the dual core!!!
The idea is to synchronize the call of dac_output_voltage(DAC_CHANNEL_x, a-b), one for each core.
Mauro
Remember: the second core is not idling uselessly, it provides WiFi+Bluettoth and needs some prime time to do that.