cjheath / ad9959 Goto Github PK
View Code? Open in Web Editor NEWAD9959 4-channel Direct Digital Synthesis Arduino Library
AD9959 4-channel Direct Digital Synthesis Arduino Library
After a long time of trial and error, I was able to get the the sine wave generated from AD9959 evaluation board using ArduinoUNO. Thank you for your help.
Here is the evaluation board, arduino uno, and two level shifters
Below is an oscilloscope output plot.
However, when I try "Sweeps", it doesn't work yet. Is there something not right in my code? I attached my current code at the end of this message.
Here is warning messages from my Arduino IDE.
...\libraries\AD9959/AD9959.h:224:32: warning: invalid conversion from 'long int' to 'AD9959<10, 7, 2, 10000000, 100000, 13, 12, 11>::CFR_Bits' [-fpermissive]
...\libraries\AD9959/AD9959.h: In instantiation of 'void AD9959<ResetPin, ChipEnablePin, UpdatePin, reference_freq, SPIRate, SPIClkPin, SPIMISOPin, SPIMOSIPin>::sweepAmplitude(AD9959<ResetPin, ChipEnablePin, UpdatePin, reference_freq, SPIRate, SPIClkPin, SPIMISOPin, SPIMOSIPin>::ChannelNum, uint16_t, bool) [with unsigned char ResetPin = 10; unsigned char ChipEnablePin = 7; unsigned char UpdatePin = 2; long unsigned int reference_freq = 10000000; long int SPIRate = 100000; unsigned char SPIClkPin = 13; unsigned char SPIMISOPin = 12; unsigned char SPIMOSIPin = 11; uint16_t = unsigned int]':
...\transmitter_modulation2.ino:38:43: required from here
...\libraries\AD9959/AD9959.h:360:44: warning: left shift count >= width of type [-Wshift-count-overflow]
write(CW1, ((uint32_t)amplitude) * (0x1<<(32-10)));
~~~~^~~~~~~~~~
Below is the full code that worked to generate single tone signal and the "Sweeps" that I am trying.
`#include "AD9959.h"
class MyAD9959 : public AD9959<
10, // ResetPin
7, // ChipEnablePin
2, // UpdatePin
10000000, // (reference_frequency)
100000,//
13,//
12,//
11//
// SPIRate, SPIClkPin, SPIMISOPin, SPIMOSIPin
{};
void setup() {
pinMode(6, OUTPUT); //
//SPI.begin(); // start the SPI library:
MyAD9959 dds;
//delay(1);
dds.setClock(20, 0);
uint32_t delta;
delta = dds.frequencyDelta(5000);
delta=dds.frequencyDelta(455000);
dds.setFrequency(MyAD9959::Channel2, 5000000UL); // shorthand for:
dds.setDelta(MyAD9959::Channel2, dds.frequencyDelta(5000000UL)); // 7.14MHz
dds.setAmplitude(MyAD9959::Channel2, 1023); // Maximum amplitude value
dds.setPhase(MyAD9959::Channel2, 16383); // Maximum phase value (same as -1)
dds.update();
dds.sweepFrequency(MyAD9959::Channel2, 8000000); // Target frequency
dds.sweepDelta(MyAD9959::Channel2, delta, false);// Target frequency delta
dds.sweepAmplitude(MyAD9959::Channel2, 512); // Target amplitude (half)
//dds.sweepPhase(MyAD9959::Channel2, 8192); // Target phase (180 degrees)
dds.sweepRates(MyAD9959::Channel2, 100, 125, 1000, 250);
digitalWrite(6, HIGH);
delay(1000);
digitalWrite(6, LOW);
delay(1000);
}
void loop() {
digitalWrite(6, HIGH);
delay(1000);
digitalWrite(6, LOW);
delay(1000);
}`
Hi, I am testing this library with an Arduino DUE, but immediately run into a problem. I get the following error when trying to create the AD9959 class:
reset();
^
Documents\Arduino\libraries\AD9959/AD9959.h:212:10: error: invalid conversion from 'int' to 'AD9959<2u, 3u, 4u, 25000000ul>::CFR_Bits' [-fpermissive]
Could you help me along on how to fix this?
Best,
Sander
hey, i was using your code as reference to use an stm32 microcontroller to control the ad9959 and was wondering if you shouldn't have used a pre-increment (--len) or used a 'greater than' (>) signal at line 420:
Line 420 in 251e54b
this while loop will run an extra time (5 times if len=4)
Hi, to get read(reg)
to work for me, I had to make a small change to write(reg,value)
.
To read register reg
, you write 0x80|reg
. But this bit makes the write function always think the register's length is 4.
Line 448 in eefac4c
I got it to work for me by changing line 448 to:
int len = (reg&0x1F) < sizeof(register_length) ? register_length[reg&0x1F] : 4;
Hi Clifford,
I'd like to move on from si5351 VFOs in transceiver projects, and the AD9959 looks like an obvious candidate, now that the 5V boards are on eBay and Ali at good prices. The issue is update speed. Do you expect setFrequency() would adjust one of the channel's frequencies sufficiently fast to emulate an analogue VFO? You want to be able to spin an optical encoder and have the DDS keep up.
regards Paul VK3HN.
PS. We did CS together if I remember correctly!
Hi
I have been able to get your code working but I was wondering how to set the profile pins without making use of an external signal to the profile pins in the U2 header. As it is possible in the proprietary software I assume it should be possible to set these pins in the software as well. Could you please advise me.
I was able to use the GUI software with the AD9959 eval board included software from the manufacturer to correctly control and generate sinusoids on all four channels. So I felt confident the DDS board was clocked correctly and working. Then I changed the jumper headers as needed to take over control with a micro controller (Arduino MEGA) and found no sinusoid signal output. The details are as follows.
Is there a known issue with the SDIO_N pins not being set to "output" or having enough drive current capacity? The following is a screenshot of the the SDIO_0 trace with and without connection to the actual AD9959 DDS.
The actual connection is an Arduino MEGA Pin 51 to Bi-directional Level Shifter ([*1]) to the AD9959 SDIO_0 eval board pin.
Note, all the connections are the same as the AD9959.h file except the change for the MEGA SPI pins
The goal is to get a single tone out of each of the 4 channels with the following code;
`
void setup() {
dds = new MyAD9959();
DDS_D0 = dds->frequencyDelta(7140000UL); // slow-expensive operation
DDS_A0 = 1023;
DDS_P0 = 4096;
DDS_D1 = dds->frequencyDelta(7140000UL); // slow-expensive operation
DDS_A1 = 1023;
DDS_P1 = 8192;
DDS_D2 = dds->frequencyDelta(7140000UL); // slow-expensive operation
DDS_A2 = 1023;
DDS_P2 = 12288;
DDS_D3 = dds->frequencyDelta(7140000UL); // slow-expensive operation
DDS_A3 = 1023;
DDS_P3 = 16383;
dds->setDelta(MyAD9959::Channel0, DDS_D0);
dds->setAmplitude(MyAD9959::Channel0, DDS_A0);
dds->setPhase(MyAD9959::Channel0, DDS_P0);
dds->setDelta(MyAD9959::Channel1, DDS_D1);
dds->setAmplitude(MyAD9959::Channel1, DDS_A1);
dds->setPhase(MyAD9959::Channel1, DDS_P1);
dds->setDelta(MyAD9959::Channel2, DDS_D2);
dds->setAmplitude(MyAD9959::Channel2, DDS_A2);
dds->setPhase(MyAD9959::Channel2, DDS_P2);
dds->setDelta(MyAD9959::Channel3, DDS_D3);
dds->setAmplitude(MyAD9959::Channel3, DDS_A3);
dds->setPhase(MyAD9959::Channel3, DDS_P3);
dds->update();
}
`
Perhaps my C-code is missing something? Or the hardware is not able to correctly drive the SDIO_N pins with enough current thru the bi-directional level shifter? Any other obvious issues?
Thank you for this library. Hoping I am doing some simple error :)
[*1] Adafruit's 8-channel Bi-directional Logic Level Converter - TXB0108. link
Hi!
I found a typo in the code - it should be CFR_Bits::MatchPipeDelay
instead of CFR_Bits::MatchPipeDela
void sweepPhase(ChannelNum chan, uint16_t phase, bool follow = true) // Target phase (180 degrees)
{
setChannels(chan);
// Set up for phase sweep
write(
CFR,
CFR_Bits::PhaseModulation |
CFR_Bits::SweepEnable |
CFR_Bits::DACFullScale |
CFR_Bits::MatchPipeDela |
(follow ? 0 : CFR_Bits::SweepNoDwell)
);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.