1

I new in Arduino environment. Found some code generate sine wave but frequency between 14kHz to 84kHz. URL is https://www.instructables.com/SineWave-Generator-for-Arduino-DUE/

I need to generate sine waze 400kHz frequency. Output should be on DAC0 or DAC1.

Any one can help to solve my problem.

5
  • Sorry, but how should we help you with that? You didn't give us any information. Show the code, that you have found. And also provide a detailed description of what your actual problem is.
    – chrisl
    Sep 21 at 7:51
  • I get some sample for generate sine wave in this link I need to generate sine wave with frequency 400KHz. Base on link above, I dont have any idea how can I write code to get freq 400KHz. Sorry I new student to learn arduino. @chrisl
    – Wan Aideed
    Sep 21 at 8:08
  • 2
    Please add this information to your question by editing it. It should be able to stand for itself, without important information in the comments. I'm no expert in the Due (never used it), but I don't think that will work for you. The sketch is just pumping out the samples by software as fast as it can. For the 84kHz it only uses 20 samples. So for 400kHz you would have only about 4 samples. Thats not really a sine wave anymore. Maybe a pure hardware wave generation would be better.
    – chrisl
    Sep 21 at 9:02
  • Googling gave me for example this site, which explains how to generate a sine wave using a 555 timer chip. They seem to go up to 250kHz. By changing the values of the components further, you might get to 400kHz. Though this is not my expertise field. You could ask a question about this at electrical stackexchange
    – chrisl
    Sep 21 at 9:03
  • For the STM32 there is app note AN4566 about Extending the DAC performance by disabling internal output buffer and using external one, and then they can go several times higher than usual 1Msps, but I'm not sure if microchip's SAM3X8E has this possibility too
    – KIIV
    Sep 21 at 18:11
3

The Due's DAC can go up to, and I quote direct from the datasheet:

Up to 350ksps conversion rate

That means you can set up to 350,000 data points on your waveform per second. With two datapoints (giving you a square wave or, more realistically, a waveform with a sharks fin shape) the maximum you could get is (350,000/2) 175kHz.

Given that you stipulate you want a sine wave you're going to need many more than just 2 data points in your waveform. Assuming a (reasonable) minimum of 32 data points (more would give a smoother waveform) you'd be looking at a maximum frequency of about 10kHz. Sacrificing waveform fidelity you could increase that, but the higher you go the less and less it resembles a sine wave.

2

I think you may be overestimating the capabilities of the Due DAC. My understanding and experimentation is that waveform generating code (e.g., https://forum.arduino.cc/t/funkgenie-a-wavetable-based-function-generator/214938) can generate consistent output waves up to “a few kHz”. After which the wave shapes suffer from distortion.

If wave shape is not critical (though you did mention you specifically needed a sine wave) you may be able to push further using PWM outputs (e.g., https://forum.arduino.cc/t/due-high-frequency-waveform-up-too-500khz/423392).

However, I think you may need to design a suitable electronic circuit to generate the wave you’re seeking. That may be a topic for the Electrical Engineering stack exchange though? There is an introduction to wave generation circuit options going up into the RF frequencies here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.