JQIamo / ADF4350-arduino

Arduino library for interfacing with Analog Devices ADF4350 (and similar) PLL chips.
23 stars 8 forks source link

Doesn´t generate a tone #4

Open fativii opened 7 years ago

fativii commented 7 years ago

Hi, I'm new to Arduino programming and I'm having issues with this code. I created the ADF4350 library and imported it to Arduino IDE. I created the sketch with the setup() function provided in the Readme file. I'm not writing anything in the loop() and I'm connecting the Arduino Uno to the computer and loading the code. The ADF4350 Evaluation Board is connected to the Arduino via SPI and to the Spectrum analyzer to see the output tone.

However, it does not seem to work. Could somebody tell me if this is the correct set up or if I'm doing something wrong? Do I have to write something in the loop()?

Thank you!

npisenti commented 7 years ago

Hmm! In principle you shouldn't need to put anything in loop(), if the PLL is programmed during the setup.

Two things that come to mind:

Anyways, hope that helps!

On Thu, Mar 9, 2017 at 8:32 AM fativii notifications@github.com wrote:

Hi, I'm new to Arduino programming and I'm having issues with this code. I created the ADF4350 library and imported it to Arduino IDE. I created the sketch with the setup() function provided in the Readme file. I'm not writing anything in the loop() and I'm connecting the Arduino Uno to the computer and loading the code. The ADF4350 Evaluation Board is connected to the Arduino via SPI and to the Spectrum analyzer to see the output tone.

However, it does not seem to work. Could somebody tell me if this is the correct set up or if I'm doing something wrong? Do I have to write something in the loop()?

Thank you!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JQIamo/ADF4350-arduino/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/AAwf8rFysklcKb6ZSkXNfXvKBynesPidks5rj_9ogaJpZM4MYFck .

fativii commented 7 years ago

Thank you! I will take a look and tell you if it works!

fativii commented 7 years ago

I've made the changes that you told me and I still continue having the same issue. I don't get to see a tone. Is there any other fact or parameter that could be affecting my system? As I told you, I'm using the Arduino Uno with the Sparkfun Redboard, which already has the integrated level shifter from 5V to 3V, so I guess that's not the problem. Thank you very much one more time!

kf4mot commented 7 years ago

I may be having the same issue, or at least it sounds similar. I have 2 PLL boards. A 4350 and a 4351. Each has its own level shifter and Pro Micro. Neither one will lock. The SPI bus is working. I can enable/disable and change the output power. The VCO output always comes up near the correct freq. but never budges. At the moment it's set to 2990 MHz but actually around 3100. If I change the set freq. the VCO will move to be close, but still never locking and never budges from it's initial freq. I was suspecting a hardware issue (hence me having 2 sets of hardware now) but now I'm not so sure. I'm not a programmer, so if a bug did exist I probably wouldn't even see it. The consistent behavior leads me to believe one may exist. I am using a 25 MHz clock vs. the default 10 and that's set in the initialization.

npisenti commented 7 years ago

Strange! Do you mind sharing your code? My mind jumped first to wondering if the right VCO band was being selected, but since that should happen automatically I'm not sure what the problem might be.

kf4mot commented 7 years ago

My code is your code. The only difference is adding an empty void loop at the end to keep the IDE from barfing. I was just thinking maybe the wrong VCO band was being used and it's at the end of its tuning range. This is with the 1.8.2 IDE. I did try 1.0.6 this morning and no luck there either.

kf4mot commented 7 years ago

Has this code been tested with a 25 MHz clock that you know of? I'm half tempted to get a couple 10 MHz clocks just to try. I'm just grasping at straws though.

npisenti commented 7 years ago

I've never tested them at anything other than 10MHz (I've only used the eval boards for these PLLs), and i'm not sure if i've ever tried running them at those frequencies either... haha honestly i've only used it as a 400MHz clock for some DDS boards. But if I recall some of the eval boards might've even used a 25MHz TCXO, and I can't think of a good reason why that shouldn't work with this chip....

I know some PLLs have restrictions, eg, on the maximum PFD frequency, which require certain prescalars to be used for particular output frequencies. I haven't looked at the ADF4350 datasheet in a while to know if this is an issue, but out of curiosity, can you output lower frequencies without trouble?

Another option, although it can sometimes be a bit of work, is to piece through the datasheet and figure out exactly what register values you want to write (UPDATE IDEA: use the analog devices evaluation software to compute which register values you need). You can then write to the SPI directly, eg,

#include <SPI.h>
#define SS 10 // or whatever pin you're using as chip select

void setup(){
    SPI.begin();          // for communicating with DDS/PLLs
    SPI.setClockDivider(4);
    SPI.setDataMode(SPI_MODE0);
    delay(500); // give it a sec to warm up

    digitalWrite(SS, LOW);
    SPI.transfer(0x00); // put real data here though!
    SPI.transfer(0x00);
    // ... etc, transfer in each byte MSB first
   digitalWrite(SS, HIGH);

    // repeat for each additional register, starting with R5 ... R0
}
kf4mot commented 7 years ago

I've been through the freq. range from min to max with plenty of steps in between. The behaviour is the same. I've thought about writing to the registers directly. That may even be the best option since all I need is this to be a LO at a fixed freq. and power. And this may not even be the PLL going into the final product so if I have to be the one to code it that's probably the simplest solution.

kf4mot commented 7 years ago

Writing directly does the job on both PLL's. Output freq. and power is correct now.

npisenti commented 7 years ago

Nice! Do you mind sharing what register values you ended up writing? When I get a moment, I'd like to chase down what the bug was exactly...

kf4mot commented 7 years ago

/ Code to program the ADF4350/4351 to output 4400 MHz at the highest power setting. For Pro Micro MOSI = 16 CLK = 15 SS = 10 /

include

define SS 10 // whatever pin you're using as chip select

void setup(){ pinMode(SS, OUTPUT); digitalWrite(SS, HIGH); delay(1000); // give it a sec for the vacuum tubes to warm up SPI.begin();
SPI.setClockDivider(4); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(MSBFIRST);

// Transfer all 6 registers starting with R5 and going down to R0. MSB first
digitalWrite(SS, LOW); delay(1); SPI.transfer(0x00); // R5 SPI.transfer(0x58); SPI.transfer(0x00); SPI.transfer(0x05); digitalWrite(SS, HIGH);

delay(1);
digitalWrite(SS, LOW);
SPI.transfer(0x00);  // R4
SPI.transfer(0x0C);
SPI.transfer(0x80);
SPI.transfer(0x3C);
digitalWrite(SS, HIGH);

delay(1);
digitalWrite(SS, LOW);
SPI.transfer(0x00); // R3
SPI.transfer(0x40);
SPI.transfer(0x04);
SPI.transfer(0xB3);
digitalWrite(SS, HIGH);

delay(1);
digitalWrite(SS, LOW);
SPI.transfer(0x00); //R2
SPI.transfer(0x00);
SPI.transfer(0x4F);
SPI.transfer(0x42);
digitalWrite(SS, HIGH);

delay(1);
digitalWrite(SS, LOW);
SPI.transfer(0x08); //R1
SPI.transfer(0x00);
SPI.transfer(0x87);
SPI.transfer(0xD1);
digitalWrite(SS, HIGH);

delay(1);
digitalWrite(SS, LOW);
SPI.transfer(0x00); // R0
SPI.transfer(0x58);
SPI.transfer(0x00);
SPI.transfer(0x00);
digitalWrite(SS, HIGH);

}

void loop() { // put your main code here, to run repeatedly:

}

tbejos commented 3 years ago

Hello, I know this is an old issue however I reading through your register values and experimenting with the ADF435x software I think I have found the issue. It looks like currently this library always uses a Prescalar value of 4/5, however the maximum frequency for that prescalar value on the ADF4350 is 3000 MHz (ADF4351 is 3600 MHz). In this case a prescalar value of 8/9 should be selected so R1 was likely being configured incorrectly