ESP32 DAC1 and DAC2 not synchronous on Arduino IDE

mauroh
Posts: 3
Joined: Sat Jun 02, 2018 7:14 pm

ESP32 DAC1 and DAC2 not synchronous on Arduino IDE

Postby mauroh » Sun Jun 03, 2018 4:27 pm

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

dmaxben
Posts: 108
Joined: Thu Nov 16, 2017 6:04 pm

Re: ESP32 DAC1 and DAC2 not synchronous on Arduino IDE

Postby dmaxben » Mon Jun 04, 2018 9:18 pm

Why not use ledcWrite?

mauroh
Posts: 3
Joined: Sat Jun 02, 2018 7:14 pm

Re: ESP32 DAC1 and DAC2 not synchronous on Arduino IDE

Postby mauroh » Tue Jun 05, 2018 1:02 pm

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

Archibald
Posts: 110
Joined: Mon Mar 05, 2018 12:44 am

Re: ESP32 DAC1 and DAC2 not synchronous on Arduino IDE

Postby Archibald » Wed Jun 06, 2018 5:01 pm

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'.

mauroh
Posts: 3
Joined: Sat Jun 02, 2018 7:14 pm

Re: ESP32 DAC1 and DAC2 not synchronous on Arduino IDE

Postby mauroh » Fri Jun 08, 2018 1:05 pm

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

rin67630
Posts: 141
Joined: Sun Mar 11, 2018 5:13 pm

Re: ESP32 DAC1 and DAC2 not synchronous on Arduino IDE

Postby rin67630 » Sat Jun 09, 2018 7:54 am

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.

Who is online

Users browsing this forum: No registered users and 130 guests