ADF4351 Synth 35Mhz-4.4Ghz

code :

/* ————————————————————————- *

 * Name   : ADF4351 Controled Board 35Mhz-4.4Ghz with 10Mhz OCXO Reference

 * Author : Stéphane HELAIEM – F4IRX

 * Date   : july 12, 2025

 * Purpose: ADF 4351 Synth

 * Versions:

 *    1.0  : ARDUINO NANO  

 *    1.1a : Change to ESP32 C3 ( 3.3v compatible )

 *    

 *    

 *    

 *    

 *    

 *    

 *    

 *  

 * ————————————————————————- */

/* ————————————————————————- *

 *       Include libraries

 * ————————————————————————- */

#include <adf4351.h> // need bignumber library see adf4351 lib

#include <Arduino.h>

#include <LCD-I2C.h>

#include <Wire.h>

#include <Preferences.h>

/* ————————————————————————- *

 *       Other definitions

 * ————————————————————————- */

#define PIN_CE   10  // Not connected Enable CE Pin on ADF4351 short 3.3v+CE on board

#define PIN_SS   7   // LE of ADF4351

#define PIN_MOSI  6  // DAT Pin on ADF4351

#define PIN_MISO  5  // not Connected

#define PIN_SCK  4   // CLK Pin on ADF4351

static char freq_string[11];                  // string of Frequency

String SaveMemory;                            // Frequency in memory

/* ————————————————————————- *

 *       Object

 * ————————————————————————- */

Preferences preferences;

LCD_I2C lcd(0x27, 16, 2);

ADF4351  vfo(PIN_SS, SPI_MODE0, 250000UL , MSBFIRST) ; // See ADF4351 example

/* ————————————————————————- *

 *       SET FRENQUENCY TIO ADF4351

 * ————————————————————————- */

void SetFrequency()

{

 if ( vfo.setf(strtoul(freq_string,NULL,0)) == 0 )      // convert and send frequency

      {                                      

        Serial.println(«  »);

        Serial.println(« setf() réussi. »);

        Serial.print(« VFO CFREQ: « );

        Serial.println(vfo.cfreq) ;

        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(«  »);

        // store new frequency in memory

        preferences.begin(« adf4351 », false);

        preferences.putString(« frequency », freq_string);

        Serial.println(« Actual:  » + preferences.getString(« AutoManS », « 0 »));

        preferences.end();

      }

      else Serial.println(« Erreur de setf() ») ;    

}

/* ————————————————————————- *

 *       UPDATE LCD

 * ————————————————————————- */

void LCD_Update()

{

  static char buff[16];

  sprintf(buff, « % 10lu », strtoul(freq_string,NULL,0)); // %.2f.

  buff[11] = buff[9];

  buff[10] = buff[8];

  buff[9] = buff[7];

  buff[8] = ‘,’;

  buff[7] = buff[6];

  buff[6] = buff[5];

  buff[5] = buff[4];

  buff[4] = ‘.’;    

  buff[3] = buff[3];

  buff[2] = buff[2];

  buff[1] = buff[1];

  buff[0] = buff[0];

  Serial.print(« frequency : »);

  Serial.println(buff);

  lcd.clear();

  lcd.setCursor(0, 0);

  lcd.print(« Frequency : »);

  lcd.setCursor(0, 1);

  lcd.print(buff);

  lcd.setCursor(13, 1);

  lcd.print(« Mhz »);

}

/* ————————————————————————- *

 *       SETUP

 * ————————————————————————- */

void setup()

{

  Serial.begin(9600);

  delay(2000);

  Wire.begin() ;    

  lcd.begin(&Wire);

  lcd.display();

  lcd.backlight();

  vfo.pwrlevel = 3;  // amplitude de sortie à -4 dBm (valeurs 0, 1, 2, 3 correspondent à -4dBm, -1dBm, +2 dBm, +5dBm)

  vfo.RD2refdouble = 0 ;  // ref doubleur off

  vfo.RD1Rdiv2 = 0 ;      // ref diviseur off

  vfo.ClkDiv = 150 ;

  vfo.BandSelClock = 80 ;

  vfo.RCounter = 1 ;    

  vfo.ChanStep = steps[2] ;

  if ( vfo.setrf(10000000UL) ==  0 ) Serial.println(« Fréquence de référence Interne 10Mhz OCXO »);

  else Serial.println(« Erreur de setrf() (fréquence de référence) ») ;                    // Sinon, afficher un message d’erreur

  vfo.init();

  vfo.enable();

  Serial.println(« F4IRX – ADF4351 Synth – 35Mhz -> 4.4Ghz ») ;

  Serial.println(« ======================================= ») ;

  Serial.println(« Entrez la  Fréquence (Hz): et Puissance « ) ;

  lcd.clear();

  lcd.setCursor(0, 0); // Or setting the cursor in the desired position.

  lcd.print(« ADF4351 USB-9600 »);

  lcd.setCursor(0, 1);

  lcd.print(« Waiting 10MhzRef »);

  delay(9000);

  Serial.println(« Please wait for heating and stablize the OCXO Ref 10Mhz ») ;

  preferences.begin(« adf4351 », false);

  Serial.println(« Store Frequency :  » + preferences.getString(« frequency », « 0 »));

  SaveMemory=preferences.getString(« frequency », « 0 »);

  SaveMemory.toCharArray(freq_string,11);

  preferences.end();

  SetFrequency();

  LCD_Update();

}

/* ————————————————————————- *

 *       LOOP

 * ————————————————————————- */

void loop()

{

  static unsigned char i;

  if (Serial.available() > 0)

  {    

    freq_string[i] = Serial.read();

    if (freq_string[i] == 10)      

    {

      freq_string[i] = NULL;  

      SetFrequency();

      LCD_Update();

      Serial.print(« Entrez la Fréquence (Hz) {example 135000000 for 135Mhz} : « ) ;  

      i = 0;        

    }

    else i++;      

  }

}

ref : https://github.com/dfannin/adf4351

Ref : https://www.youtube.com/watch?v=vJ-pmoxcYvI&ab_channel=%C3%89lectro-Bidouilleur

Search

Popular Posts

  • KENWOOD TS850S

    https://www.rigpix.com/kenwood/ts850s.htm Le Kenwood TS-850SAT est un émetteur-récepteur HF haut de gamme destiné aux radioamateurs. Lancé au début des années 1990, il est encore aujourd’hui très apprécié pour la qualité de son récepteur, son ergonomie et sa robustesse. Caractéristiques principalesCouverture des bandes amateur HF de 160 à 10 mètres, y compris les bandes WARC.Puissance d’émission de…

  • QRZ.COM Page BIO

    Visu PDF Pages CSS .container{max-width:900px;margin:auto;font-family:Arial, Helvetica, sans-serif;} .card{background:#1e293b;color:#e5e7eb;padding:20px;border-radius:12px;margin-bottom:20px;box-shadow:0 5px 15px rgba(0,0,0,0.3);} .card h1{color:#38bdf8;margin-bottom:10px;} .card h2{color:#7dd3fc;border-bottom:1px solid #334155;padding-bottom:5px;} .badge{display:inline-block;background:#0284c7;color:white;padding:5px 10px;border-radius:8px;margin:4px 2px;font-size:14px;} .gallery {display: grid;grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));gap: 12px;margin-top: 10px;} .gallery img {width: 100%;height: auto;border-radius: 10px;box-shadow: 0 4px 10px rgba(0,0,0,0.4);}a{color:#38bdf8;} a:hover{text-decoration:underline;}#t_bio.biodiv {background-color:#FFFFFF}

Categories

Tags