Using Arduino Uno to generate 3 different frequency sinewaves (1kHz) by using DAC

when I output 3 sinewaves simultaneously by using MCP4725 (3 pieces), the wave frequencys are very low (resolution is low). If I want to realize >1kHz sinewaves on each DAC chips, could someone give me some advices? whether I have to change DAC chips? or some other methods can realize 3 different frequency sinewaves generating? Thank you!

Lot depends on your code ........and how you generate the data for the DAC

You maybe up against the speed limitation of addressing 3 DAC’s and sending the data by i2c - have a look at that .

I don’t know but my fag packet suggests it’s hard : I kHz implies sending , at nyquest rate 4000bytes per second ( two bytes per value ?) plus the addressing overhead , times 3, gives 12000 bytes a second , prob lot more without addressing overhead and running much faster than the nyquest rate .

The reason you want to do this may hold the answer ... why not use some voltage controlled oscillator or something else ( get a better sine wave too)

Thank you very much for your replying.
I just followed the method below using MCP4725s to generate 3 waves:
I am also trying to use DDS module like AD9850/AD9851 to realize that, but I am confused about how to control 3 devices.

Wire them as SPI and use a separate chip enable pin for each.

1 Like

Thank you very much!
Could you show some examples about this? I also saw the "word discription" like below, but I am still confused.

The answer is literally on the page you linked.

1 Like

That is way too slow for your needs as you have found out. You will have to replace them with the AD9850/AD9851.

To get more than 2 of these working together you need to use what it said in the read me file of the link you posted.
In case you missed it said:-

[quote]The AD985X board can be connected with a SPI bus like interface. However there is no Chip Select pin (CS) so one must take other measures to control multiple AD985X devices.

Trivial solution

The trivial implementation is to give each device a set of unique pins. If you have pins to spare this is the perfect solution. [/quote]

1 Like

You just common the clock and data, but use a separate word-load wire for each DDS chip I think.

2 Likes

I used the follwing method, but I found that I cannot get continuous wave, the phase of waves is disorder, maybe something wrong with the frequency, below is my code. Where is the problem? Synchronous problem?

#include "AD985X.h"

AD9850 freqGen;

uint32_t freq1 = 25000;
uint32_t freq2 = 30000;
uint32_t freq3 = 40000;
uint32_t prev = 10000;
uint32_t maxFreq = 30000000;
unsigned long previousMillis1 = 0;
unsigned long previousMillis2 = 0;
unsigned long previousMillis3 = 0;
const long period1 = 0;
const long period2 = 0;
const long period3 = 0;
unsigned long currentMillis = millis();

void setup()
{
  Serial.begin(115200);
  Serial.println(__FILE__);
  Serial.print("AD985X_LIB_VERSION: \t");
  Serial.println(AD985X_LIB_VERSION);

  freqGen.begin(2, 9, 10);
  freqGen.powerUp();
  maxFreq = freqGen.getMaxFrequency();
  Serial.println(maxFreq);
}


void loop()
{
 if (currentMillis - previousMillis1 >= period1) {
     int select = 2;
       if (prev != freq1){
           prev = freq1;
           freqGen.setFrequencyF(freq1 * 0.01);
           Serial.println(freq1);
           previousMillis1 = currentMillis;
       }
 }
 if (currentMillis - previousMillis2 >= period2) {
     int select = 3;
       if (prev != freq2){
           prev = freq2;
           freqGen.setFrequencyF(freq2 * 0.01);
           Serial.println(freq2);
           previousMillis2 = currentMillis;
       }
 }
 if (currentMillis - previousMillis3 >= period3) {
     int select = 3;
       if (prev != freq3){
           prev = freq3;
           freqGen.setFrequencyF(freq3 * 0.01);
           Serial.println(freq3);
           previousMillis3 = currentMillis;
       }
  }
 }

You seem to have one of these in every section but you never use them.
Also declaring them in each section is very wasteful.

You only have one "prev" variable for 3 different frequencies, so they are going to interfere...

Why is the update period zero? That will lead to a constant hammering of frequency updates to the chip at full rate.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.