AnsweredAssumed Answered

AD9959 - Arduino Due - strange behavior from frequency sweeps.

Question asked by Chris2017 on Jan 28, 2018

EDIT: I have managed to get my code working - leaving this as unanswered for the time being as if anyone can shed some light on the odd behavior I observed, or at least why it happened, it would be greatly appreciated. 



Hello all,

For context:

My project is to prototype a frequency generator that could be used with an AOM (I have found that the AD9910 would likely be much better for this, so I will play around with it at some stage), where 2 channels are sweeping frequency and a third channel is staying at a constant amplitude and frequency. The 2 channels ramping need to be able to do multiple consecutive ramps. I have been able to achieve this by creating a sequence of commands writing to the DDS registers.

I am using an arduino due to control the DDS, so I have a loop where all the code for sweeps/etc is located.

Due to limitations of the AD9959, I have had to make a manual amplitude ramp using an array of values being called/sent to the registers in a for loop - this is/will be synced to any frequency sweeps that I am doing using the inbuilt DDS functions. I have also made a correction for how the amplitude varies with frequency.


Now, the issue I am having is with the DDS frequency sweeps, my AM works fine.


As the 'no dwell linear sweep' mode/option on the DDS resets the the frequency to the start of the sweep, I cannot use it (unless I try time the sweep and write to the CTW0 register to set the frequency as the final frequency just before the frequency value resets, but I am unsure how feasible this is).

So what I am doing is:


void setup(){

write to CSR register

write to FR registers and CFR register (specify linear sweep, dont enable no dwell mode)

generate array of (corrected) amplitude values


void loop(){

write to CSR register (as I will be using multiple channels doing different functions)

write to CTW0 

write to delta word register (either RDW or FDW)

write to LSRR

write to CTW1

IO update

Profile pin -> High (to trigger the frequency sweep)

Do AM, by calling values from a pre generated array (which takes the exact amount of time as the frequency sweep)

Profile pin -> Low


// do the above again for another sweep if desired


// occasionally may need to put a 'buffer' here - CTW0 set to the final frequency of the sweep as on occasion the frequency just hangs and the sweep is not repeated, mostly an issue for single 'ramps'




-putting all of my code in the loop does not work, one of my attempted solutions was to toggle the DDS reset pin and then rewrite to all the registers for each loop iteration, but that does not give me any output which is quite odd.



My issue being is that I would think that my above example would just force the DDS back into the desired/written sweep with each iteration of the loop - and although it does indeed do another frequency sweep, the starting frequency is NOT the one I specify on the second,third,fourth,etc iteration.

i.e. (and code attached that produces this behavior "debug_attempt8")

- Freq sweep 20MHz -> 90MHz with corrected AM

- delay

- Freq sweep 90MHz -> 110MHz w/ AM

- (buffer here if needed)



EDIT: THIS DELAY SEEMS TO AFFECT THE OFFSET OF THE INITIAL FREQUENCY - I cannot just get rid of the delay either, as the freq sweep will be cut off before completion AND I need to have my AM here ideally, which will have the same affect this delay has


- restart loop.



The above gets me:

20 MHz -> 90MHz, 90MHz-110MHz, and then for each following loop,

~45MHz -> 90MHz, 90MHz - 110MHz.


I am finding this quite puzzling, as I have not input any other commands other than 'initial freq', 'interval time + step size' and 'final freq'.


For the time being, this incorrect starting frequency is my main issue and the one I would like some assistance with (as I can also provide my code for this issue). It should be noted that enabling 'no dwell' does give the correct starting frequency.


Any ideas or suggestions would be greatly appreciated.






EDIT: I have attached another piece of code - this has NO frequency offset to it (the code with "attempt9" in the name)

EDIT 2: I have gotten it working - it seems the delay commands I had introduced  to 'hold' the frequency had an effect on following loops, whereas just putting in my AM had no effect on following loops. Also introducing a "buffer" at the end of each of my individual ramps was needed. However, I have no idea why it was behaving the way it was or why a delay from my arduino would have any effect on the DDS frequency output.