pythoncoder wrote: ↑Fri Feb 18, 2022 10:04 am
The general approach is as follows. Create a bytearray to hold a single cycle of sine wave, and populate it with data scaled to lie in the range 0-255 (for a 8-bit DAC). Then use a timer interrupt to output a value from the array and increment the array pointer (modulo the length of the array). The timer rate then determines the frequency.
This won't work particularly well on ESP32 as interrupts are soft, meaning that their timing is imprecise. A Pyboard has the means to do this with high precision and speed: it is possible to create sinewaves of tens of KHz.
#####
mattyt wrote: ↑Sat Feb 19, 2022 11:24 am
See #
5514 for an alternative way to generate a sine wave using extra features of the ESP32 DAC.
Note that this is a non-standard MicroPython feature (since it's quite particular to the ESP32) and my guess is that it's unlikely to be merged. An alternative that might have a better chance would be to add the cosine methods to the esp32 module and have them take a DAC object...
Thank you for your answer.
Now I tried to do it using Ad9833 wave generation module. But I could not change 11,12 and 15th lines in the test code here according to Esp32.I was able to generate the signal with arduino-Esp32. but I couldn't do it with micropython.
my main goal is actually implement of this lockin amplifier block diagram. What do you think. I've been struggling with it for over 2 months.
Can it be done or should I give up? I depressed and tired thank you