AD9959 Freq Sweep with Arduino Due

Hello,

I'll preface by saying that I am relatively new to using DDS' - I've only been using the AD9959 for around 2 weeks now. The project I am working on is to build a function generator using the AD9959 and an SPI connection to an Arduino Due (and a 25MHz reference clock).

I have been able to get everything up and running and am able to get any desired single tone frequency by just writing to the registers of the DDS.

Where I am having difficulties is in trying to create a basic frequency sweep - I know how and what to set all the registers to as per the AD9959 datasheet and using the AD9959 eval board software as a guide (Reg Map Debug window).

I believe the issue that I am having is in triggering the sweep - specifically writing to the profile pins (P3 in my case where I am using channel 3 from the DDS) to change their "logic from 0 to 1" which I figured I could accomplish by just writing to the digital output pins I had attached from the arduino to just go high, but unfortuantely this does not work. I believe I am correct in saying that the 'logic from 0 to 1' has nothing to do with the bytes I am sending to my registers, but is something I need toggle outside of the function registers.

I have considered that it may be a clocking issue but I have played around a bit with putting delays in my code to no avail.

Also oddly enough, when I run the attached code, I just get an output of 20MHz, but if I toggle the power of the board (so turn it off and on again) I then get an output of 45.8MHz.

I have attached the arduino code that I am using.

For my hardware connections, Arduino -> DDS (U2 row):

-Pin 10 -> CSB (my slave select pin)

-Pin 9 -> Reset

-Pin 4 -> IO_UPDATE

-SPI MOSI -> SDIO_0

-SPI SCLK -> SCLK

-Pin 6 -> P2

-Pin 7 -> P3

The adjacent pin on the DDS for each of the above is also grounded to the various grounds on the Due board:

-Digital Pin GND: IO_UPDATE + RESET + P3 + P2

-Analog Pin GND: CSB

-SPI GND: SDIO_0 + SCLK
(Using different grounds as for some reason grounding to the same ground on the arduino meant I couldnt get an output FROM the arduino, perhaps due to crosstalk??)

Any and all help will be greatly appreciated.

Cheers,

Chris.

EDIT: I managed to resolve my issue - the problem was the 1K pull down resistor on the profile pins on the actual PCB board of the DDS. So what was happening is my trigger signal was not strong enough to actually trigger the sweep. I solved this by just putting the arduino output for that pin through a digital buffer and then to the DDS board. My attached code does in fact work fine except for some reason the no-dwell mode does not seem to work.

EDIT 2: Turns out I did not need the buffer, I had stupidly not defined my lines going from the arduino to P3 and P2 on the DDS as being outputs; pinMode(7,OUTPUT) was missing so it was not drawing the required current.

Chris_Summer_DDS_FreqSweep.ino.zip
  • Hi,

    Good to hear that your board is now working and thank you for sharing the solution.

    Best regards,

    Mark

  • Hi Chris,

    I am also new on the AD9959 DDS, received a week ago, and my project is to build a RF generator using a AD9959 board and an Arduino Mega.

    I have read you code exemple and find it very usefull, especially for sweep) nethertheless I would like to start by trying with a simple code to generate an output frequency sent by my Arduino board (I am much more skilled on HW than SW)
    Would it be possible to share a code doing this ? and also the DDS.h library version you are using (I have found several versions, not sure which one to use...).

    Thank you !

    Phil

  • Hi Phil,

    I'm happy to share what knowledge I have managed to dig up - although take it with a grain of salt that as I am new, my code/etc is likely crude. The DDS library code is not mine so I will need to ask if I can share it - however I can give you a run down of what commands in it I actually use (the library code was originally made for something different). You can actually do all this defining in the actual arduino as far as I am aware.

    -> define slaveselectpin (in this case for me 1)

    ->define IO_updatepin (for me 4)

    ->define reset pin (for me 9)

    ->define IO update and reset pins as being outputs

    ->initialize DDS, SPI begin commands specifying the clock, SPI_MODE and if LSB or MSB

    ->reset and io update - just a high-> low transition for reset or io pin.

    As for testing for if the arduino is actually outputting correctly:


    #include <SPI.h>
    const int CSPin =10;
    void setup() {
    pinMode(CSPin,OUTPUT);
    digitalWrite(CSPin,HIGH); //ensure SS is HIGH to begin with
    SPI.begin();
    SPI.setClockDivider(SPI_CLOCK_DIV128);
    }
    void loop() {
      // enable slave select
    digitalWrite(CSPin,LOW);
    SPI.transfer(0x11);
    // disable SS pin
    digitalWrite(CSPin,HIGH);
    delay(1000);
    }

    Just connect the pins to an oscilloscope and you should see the bit transfer.

    I also very much recommend looking through the data sheet to see what bytes need to be sent to generate your desired functions.

    One other thing, ensure you are connected to the correct SPI terminals - there is the ICSP and SPI sets on opposite sides of the board which look identical, use the SPI set of pins. Also if you are wanting to do some AM aswell as FM: AD9959 Increasing Rising Step Interval for AM - you will need to manually make a for loop in the arduino to get a gradual amplitude sweep.

    Hope this helps.

    Regards,

    Chris

  • Hi Chris,

    Thank you very much for your answer, it helps me !

    Please, let me know if you get the right to share the DDS.h you are using, or at least where to find it or a similar one

     

     

    Best regards

    Philippe

     

    De : Chris2017 

    Envoyé : mardi 12 décembre 2017 23:05

    À : Philippe Cimadomo <cimadomo@bluewin.ch>

    Objet : Re:  - Re: AD9959 Freq Sweep with Arduino Due

     

    <https://ez.analog.com/?et=watches.email.thread> EngineerZone

     

    Re: AD9959 Freq Sweep with Arduino Due

    reply from Chris2017 <>  in Direct Digital Synthesis (DDS) - View the full discussion <https://ez.analog.com/message/328981-re-ad9959-freq-sweep-with-arduino-due?commentID=328981&et=watches.email.thread#comment-328981>

  • This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.

    Thank you,
    EZ Admin