Go Down

Topic: Arduino DUE Dac sine wave form (Read 343 times) previous topic - next topic


Jan 06, 2019, 12:20 am Last Edit: Jan 08, 2019, 09:17 am by Emma_KellyJones
Hi, i'm new in this world of arduino and in this place with other developers in arduino, well i'm a developer software student and i have to do an aplicaction in arduino, this consist in generate a sine wave form, this starts in 7Hz until 14KHz, so the program begins in 7Hz and will be increase until 14KHz in the time.

how do i do?


Jan 06, 2019, 05:28 am Last Edit: Jan 06, 2019, 05:30 am by ard_newbie
There are 2 methods to output a frequency variable sin wave with a DUE:

1/ The PWM synchro feature with an automatic update of duty cycle by the PDC DMA with only PWM channel 0. Update the output frequency in loop() with PWM_CPRDUPD. Use an RC filter to output a sin wave from a PWM.

There is an example sketch here (reply #6) with 3 PWM channels.

2/ A DAC output (no need for an RC filter, but some hardware if you want the full range 0V - 3.3V) with a PDC DMA to output a sin wave buffer, triggered by a PWM event line. Update the output frequency with PWM_CPRDUPD in loop().

There is an example sketch with a PWM event line to trigger ADC conversions here (reply #9). There is an example sketch with DAC conversions and PDC DMA here ( reply #10).

For a full range DAC:


Jan 07, 2019, 07:25 am Last Edit: Jan 07, 2019, 07:49 am by Emma_KellyJones
I´m still having the same problem :(
everytime when i change something in the code this leaves to work correctly i realy need help, i dont understand the code of everything

I mean that what I want to get is that the arduino of a signal in the arduino sinusoidal, which I already achieve with the previous code but what I want is for me to give a signal of 22 KHz for example, and after 10 seconds change to a 23KHz and after another 10 seconds change to a 24KHz ....
If they helped me to understand the code or know what I would like to modify, I would greatly appreciate it, since I do not understand the code that I found, and this code is the one that has served me the most since it can generate up to 200KHz ....


Jan 07, 2019, 09:14 am Last Edit: Jan 07, 2019, 09:17 am by ard_newbie
Please, do not PM me.

If you don't understand the example sketches, begin by the beginning:

1/Output something to DAC0 with analogWrite() and measure with a voltmetre. Don't forget to hook at least a 2KOhms resistor in serie with DAC0 to avoid burning your DAC.

2/Read something from Serial with the basic example sketches given in  File>Example>Communication>SerialEvent , etc... up to the point where you understand how that works

3/Mix a DAC0 output with a command received from Serial

4/Open Sam3x datasheet and read the DAC section

5/ ....

Go Up