Coder Social home page Coder Social logo

adf4351's Introduction

adf4351

Arduino Library for the ADF4351 Wideband Frequency Synthesizer chip

Introduction

This library supports the ADF4351 Chip from Analog Devices on Arduinos. The chip is a wideband (35 MHz to 4.4 GHz ) Phase-Locked Loop (PLL) and Voltage Controlled Oscillator (VCO), covering a very wide range frequency range under digital control. Just add an external PLL loop filter, Reference frequency source and a power supply for a very useful frequency generator for applications as a Local Oscillator or Sweep Generator.

The chip generates the frequency using a programmable Fractional-N and Integer-N Phase-Locked Loop (PLL) and Voltage Controlled Oscillator (VCO) with an external loop filter and frequency reference. The chip is controlled by a SPI interface, which is controlled by a microcontroller such as the Arduino.

The library provides an SPI control interface for the ADF4351, and also provides functions to calculate and set the frequency, which greatly simplifies the integration of this chip into a design. The calculations are done using the excellent Big Number Arduino Library by Nick Gammon, as the integter calculations require great than 32bit integers that are not available on the Arduino. The library also exposes all of the PLL variables, such as FRAC, Mod and INT, so they examined as needed.

For projects, you should consider using the SV1AFN ADF4351 PLL Synthesizer Module, a low cost PCB module built and designed by Makis Katsouris, SV1AFN. This board provides a loop filter, as well as providing most of the chip control pins, SPI inteface and RF input/output ports. This library was developed using this board.

A low phase noise stable oscillator is required for this module. Typically, an Ovenized Crystal Oscillator (OCXO) in the 10 MHz to 100 MHz range is used.

A project using this library for a wideband signal generator project siggen4351.

Features

  • Frequency Range: 35 MHz to 4.4 GHz
  • Output Level: -4 dBm to 5 dBm (in 3 dB steps)
  • In-Band Phase Noise: -100 dBc/Hz (3 kHz from 2.1 Ghz carrier)
  • PLL Modes: Fraction-N and Integer-N (set automatically)
  • Step Frequency: 1 kHz to 100 MHz
  • Signal On/Off control

Library Use

The library is documented in the docs directory, and was created using Doxygen. An example program using the library is provided in the source directory example4351.ino.

Please note that you should install the provided BigNumber library in your Arduino library directory. This library was modified from the one provided by Nick Gammon in order to allow conversion of unsigned long types into BigNumber format, so the stock library will not work with code.

Installation

Copy the src/ directory to your Arduino sketchbook directory (named the directory example4351), and install the libraries in your Arduino library directory. You can also install the adf4351 files separatly as a library.

References

adf4351's People

Contributors

dfannin avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

adf4351's Issues

Internal 25 MHz reference

Hi, I have a board with 25MHz oscillator.
I tried to modify the settings according to another issue here, but I always get setf error.
Can you help me?

Problem generating 404MHz. The example with 80Mhz works. Reference is 25MHz.

I have a problem generating 404MHz out with the code below. If I modify the code below to set frequency to 80MHz with vfo.setf(80000000UL) it works fine as seen on the oscilloscope. There is a sine out at 80Mhz.

If I try to set it to 404MHz with vfo.setf(404000000UL) I don't get 404MHz out.

The reference is 25MHz.

Is there something with some dividers I have set wrong since this is a higher frequency or is there a bug in the library? I have used your example code as a basis but simplified it a bit (see below). Can you say what is wrong?


#include <Arduino.h>
#include "adf4351.h"

#define SWVERSION "1.0"

#define PIN_SS 9  ///< SPI slave select pin, default value

ADF4351  vfo(PIN_SS, SPI_MODE0, 1000000UL , MSBFIRST) ;


void setup()
{
  delay(5000);
  Serial.begin(9600) ;
  Serial.print("Hello adf4351 demo v") ;
  Serial.println(SWVERSION) ;
  Wire.begin() ;
  /*!
     setup the chip (for a 10 mhz ref freq) EDIT I did use 25 MHz as reference input, not 10 MHz
     most of these are defaults
  */
  vfo.pwrlevel = 0 ; ///< sets to -4 dBm output
  vfo.RD2refdouble = 0 ; ///< ref doubler off
  vfo.RD1Rdiv2 = 0 ;   ///< ref divider off
  vfo.ClkDiv = 150 ;
  vfo.BandSelClock = 80 ;
  vfo.RCounter = 1 ;  ///< R counter to 1 (no division)
  vfo.ChanStep = steps[2] ;  ///< set to 10 kHz steps


  if ( vfo.setrf(25000000UL) ==  0 )
    Serial.println("ref freq set to 25 Mhz -- modded") ;
    else
         Serial.println("ref freq set error") ;
     vfo.init() ;
     vfo.enable() ;
}

void loop()
{
  delay(1000);
 
  // ERROR! Doesn't generate 404MHz out.  
  // However if I edit this to 80MHz it works and the freq out is correct.
  Serial.println("setf() to 404 MHz instead of 80MHz") ;

  if ( vfo.setf(404000000UL) == 0 ) {
    Serial.print("setf() success freq:") ;
    Serial.println(vfo.cfreq) ;
  } else {
    Serial.println("setf() error") ;
  }
}
 

Difficulty running with Adafruit Feather M4 Express

Somewhat of a noob at copying in libraries and other code beside the example sketches. I thought I had followed the instructions but am getting the errors below when I attempt to compile the example4351 sketch. Changed my username to xxxxx but other than that just copy/pasted the text from the Arduino IDE.

Any help would be greatly appreciated.

Arduino: 1.8.16 (Mac OS X), Board: "Adafruit Feather M4 Express (SAMD51), Enabled, 120 MHz (standard), Small (-Os) (standard), 50 MHz (standard), Arduino, Off"

/Users/xxxxx/Documents/Arduino/libraries/adf4351-master/src/adf4351.cpp: In constructor 'ADF4351::ADF4351(byte, uint8_t, long unsigned int, uint8_t)':
/Users/xxxxx/Documents/Arduino/libraries/adf4351-master/src/adf4351.cpp:94:37: error: invalid conversion from 'uint8_t' {aka 'unsigned char'} to 'BitOrder' [-fpermissive]
94 | spi_settings = SPISettings(speed, order, mode) ;
| ^~~~~
| |
| uint8_t {aka unsigned char}
In file included from /Users/xxxxx/Documents/Arduino/libraries/adf4351-master/src/adf4351.h:12,
from /Users/xxxxx/Documents/Arduino/libraries/adf4351-master/src/adf4351.cpp:51:
/Users/xxxxx/Library/Arduino15/packages/adafruit/hardware/samd/1.7.5/libraries/SPI/SPI.h:66:40: note: initializing argument 2 of 'SPISettings::SPISettings(uint32_t, BitOrder, uint8_t)'
66 | SPISettings(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) {
| ~~~~~~~~~^~~~~~~~
/Users/xxxxx/Documents/Arduino/libraries/adf4351-master/src/adf4351.cpp: In member function 'int ADF4351::setf(uint32_t)':
/Users/xxxxx/Documents/Arduino/libraries/adf4351-master/src/adf4351.cpp:156:3: error: 'dtostrf' was not declared in this scope
156 | dtostrf(PFDFreq, cntdigits + 8 , 3, tmpstr) ;
| ^~~~~~~
exit status 1
Error compiling for board Adafruit Feather M4 Express (SAMD51).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Chinese ADF4351 able to set module to 2.401ghz but not 2.4Ghz (on board 100 Mhz crystal oscillator )

I have been working with your library and a chinese ADF4351 board which has onboard 100 Mhz crystal oscillator. I was able to set it to 2.401Ghz and the lock led lights up but when I try to set it to 2.4Ghz I get error mod out of range. When I set the ref freq to 10Mhz there is no mod error but the lock led does not light up and I think it is because there is onboard 100Mhz crystal. So since I have a 100 Mhz crystal and your library appears to work well with 10Mhz ref freq coded in, what shall I do? Is it possible that even after setting the ref freq to 100 Mhz I do not get a mod error and that I can set it to 2.4Ghz as well? Is there anything that I need to change in the code like vfo.ClkDiv = 150 ; vfo.BandSelClock = 80 ; to values other than you mentioned? Please let me know.

Cannot calculate the frequency error

Hi, I am currently using your library for the ADF4351 chip with arduino uno. My ADF4351 board has a reference clock at 25 Mhz. I change the example code to generate 40 Mhz, Here is the main code file:

#include <Arduino.h>
#include "adf4351.h"

#define SWVERSION "1.0"

#define PIN_SS 9  ///< SPI slave select pin, default value

ADF4351  vfo(PIN_SS, SPI_MODE0, 1000000UL , MSBFIRST) ;
void setup()
{
  Serial.begin(9600) ;
  Serial.print("Hello adf4351 demo v") ;
  Serial.println(SWVERSION) ;
  Wire.begin() ;
  /*!
     setup the chip (for a 10 mhz ref freq)
     most of these are defaults
  */
  vfo.pwrlevel = 0 ; ///< sets to -4 dBm output
  vfo.RD2refdouble = 0 ; ///< ref doubler off
  vfo.RD1Rdiv2 = 0 ;   ///< ref divider off
  vfo.ClkDiv = 150 ;
  vfo.BandSelClock = 80 ;
  vfo.RCounter = 1 ;  ///< R counter to 1 (no division)
  vfo.ChanStep = steps[4] ;  ///< set to 100 kHz steps

  /*!
     sets the reference frequency to 10 Mhz
  */
  if ( vfo.setrf(25000000UL) ==  0 )
    Serial.println("ref freq set to 10 Mhz") ;
    else
      Serial.println("ref freq set error") ;
      /*!
         initialize the chip
      */
      vfo.init() ;

  /*!
     enable frequency output
  */
  vfo.enable() ;
}
void loop()
{
  /*!
     do a set of freq changes (40 Mhz, 4 GHz, and 1Ghz, )
  */
  vfo.disable();
  delay(2000);
  Serial.println("setf() to 40 MHz") ;

  if ( vfo.setf(40000000UL) == 0 ) {
    Serial.print("setf() success freq:") ;
    Serial.println(vfo.cfreq) ;
  } else {
    Serial.println("setf() error") ;
  }
  vfo.enable();
  

  Serial.print("PLL INT:");
  Serial.println(vfo.N_Int);
  Serial.print("PLL FRAC:");
  Serial.println(vfo.Frac);
  Serial.print("PLL MOD:");
  Serial.println(vfo.Mod);
  Serial.print("PLL PFD:");
  Serial.println(vfo.PFDFreq);
  Serial.print("PLL output divider:");
  Serial.println(vfo.outdiv);
  Serial.print("PLL prescaler:");
  Serial.println(vfo.Prescaler);
  Serial.println("");
  delay(2000);
}

I get this error:

setf() to 40 MHz
output freq diff than requested
Mod out of range
setf() error
cfreq: 22349
PLL INT:0
PLL FRAC:-23
PLL MOD:2147483246
PLL PFD:25000000.00
PLL output divider:64
PLL prescaler:0

It is weird because I also try to use Analog software to calculate, and it calculates that INT is 102, FRAC is 2, PFD is 25 Mhz, Div is 64.
image

I look at the code but still don't understand why it cannot calculate the right value like the software.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.