ad9854結(jié)構(gòu)框圖
如圖4-2所示,AD9854內(nèi)部包括一個具有48位相位累加器、一個可編程時鐘倍頻器、一個反sinc濾波器、兩個12位300MHzDAC,一個高速模擬比較器以及接口邏輯電路。其主要性能特點如下:
1.高達(dá)300MHz的系統(tǒng)時鐘;
2.能輸出一般調(diào)制信號,F(xiàn)SK,BPSK,PSK,CHIRP,AM等:
3.100MHz時具有80dB的信噪比:
4.內(nèi)部有4*到20*的可編程時鐘倍頻器:
5.兩個48位頻率控制字寄存器,能夠?qū)崿F(xiàn)很高的頻率分辨率。
6.兩個14位相位偏置寄存器,提供初始相位設(shè)置。
7.帶有100MHz的8位并行數(shù)據(jù)傳輸口或10MHz的串行數(shù)據(jù)傳輸口。
兩款ad9854應(yīng)用電路
電路一:
下面給出一種用AD9854開發(fā)高精度頻率信號發(fā)生器的簡易方法,開發(fā)者只需要熟悉MCS-51單片機編程即可。該系統(tǒng)具有開發(fā)周期短,開發(fā)成本低的特點,也可以作為探索AD9854功能的一種方法,它的電路原理圖見圖2。
系統(tǒng)主要由DDS芯片AD9854、單片機AT89C51、看門狗定時器X25045和LED顯示驅(qū)動芯片MAX7219組成。在這個系統(tǒng)中提供了8位七段LED顯示器,其中前五位為輸出頻率值,顯示范圍為00.000~99.999MHz,后三位為幅度顯示位,顯示范圍為0~999,表示幅值從零幅度到滿幅度的變化。
電路二:
正交信號源選擇了DDS芯片AD9854,具體實現(xiàn)電路見下圖。對AD9854進(jìn)行編程控制,使之輸出兩路幅度相同并且正交的信號,然后對輸出信號進(jìn)行濾波,使得正弦波變得更加平滑,濾波之后再把輸出峰值為512mV的信號放大2倍到1.24V。
ad9854單片機程序
//=====================================================================
// AD9854 驅(qū)動程序設(shè)計
//AD9854.c
//說明:10MHZ 有源晶振
//=====================================================================
#include 《reg52.h》
#include 《lcd1602.h》
#include 《intrins.h》
sfr P4 = 0xC0; //1111,1111 端口4
sbit KEY1 = P3^5;
sbit KEY2 = P3^4;
sbit KEY3 = P3^3;
sbit KEY4 = P3^2;
unsigned char FreqWord[6]; //6個字節(jié)頻率控制字
/*
CLK_Set為時鐘倍頻設(shè)置,可設(shè)置4~20倍倍頻,但最大不能超過300MHZ
Freq_mult_unsigned long和Freq_mult_doulle均為2的48次方除以系統(tǒng)時鐘,一個為長整形,一個為雙精度型
*/
#define CLK_Set 20
const unsigned long Freq_mult_ulong = 1407375;
const double Freq_mult_doulle = 1407374.88355328;
//**************************修改硬件時要修改的部分********************************
#define AD9854_DataBus P2
#define AD9854_AdrBus P0
sbit AD9854_RST = P3^6; //AD9854復(fù)位端口
sbit AD9854_UDCLK = P3^7; //AD9854更新時鐘
sbit AD9854_WR = P4^1; //AD9854寫使能,低有效
sbit AD9854_RD = P4^2; //AD9854讀使能,低有效
sbit AD9854_FDATA = P4^3; //AD9854 FSK,PSK控制
sbit AD9854_OSK = P4^4; //AD9854 OSK控制端
unsigned char flag = 1;
unsigned int fc = 1000;
unsigned long LFerq = 750;
unsigned long HFerq = 1250;
void AD9854_WR_Byte(unsigned char addr,unsigned char dat);
void AD9854_Init(void);
void Freq_convert(long Freq);
void AD9854_InitFSK(void);
void AD9854_SetFSK(unsigned long Freq1,unsigned long Freq2);
//void delay (unsigned int us);
void UpDisplay()
{
unsigned char disbuf[5];
LCD_Write_String(0, 0, “BaseFerq M”);
LCD_Write_String(0, 1, “Now Ferq M”);
disbuf[0] = fc / 1000 + ‘0’;
disbuf[1] = ‘?!?
disbuf[2] = fc % 1000 / 100 + ‘0’;
disbuf[3] = fc % 100 / 10 + ‘0’;
disbuf[4] = fc % 10 + ‘0’;
disbuf[5] = 0;
LCD_Write_String(9, 0, disbuf);
disbuf[0] = HFerq / 1000 + ‘0’;
disbuf[1] = ‘?!?
disbuf[2] = HFerq % 1000 / 100 + ‘0’;
disbuf[3] = HFerq % 100 / 10 + ‘0’;
disbuf[4] = HFerq % 10 + ‘0’;
disbuf[5] = 0;
LCD_Write_String(9, 1, disbuf);
}
void DownDisplay()
{
unsigned char disbuf[5];
LCD_Write_String(0, 0, “BaseFerq M”);
LCD_Write_String(0, 1, “Now Ferq M”);
disbuf[0] = fc / 1000 + ‘0’;
disbuf[1] = ‘。’;
disbuf[2] = fc % 1000 / 100 + ‘0’;
disbuf[3] = fc % 100 / 10 + ‘0’;
disbuf[4] = fc % 10 + ‘0’;
disbuf[5] = 0;
LCD_Write_String(9, 0, disbuf);
disbuf[0] = LFerq / 1000 + ‘0’;
disbuf[1] = ‘?!?
disbuf[2] = LFerq % 1000 / 100 + ‘0’;
disbuf[3] = LFerq % 100 / 10 + ‘0’;
disbuf[4] = LFerq % 10 + ‘0’;
disbuf[5] = 0;
LCD_Write_String(9, 1, disbuf);
}
void AD9854_SetSine(unsigned long Freq,unsigned int Shape)
{
unsigned char count;
unsigned char Adress;
Adress = 0x04; //選擇頻率控制字地址的初值
Freq_convert(Freq); //頻率轉(zhuǎn)換
for(count=6;count》0;) //寫入6字節(jié)的頻率控制字
{
AD9854_WR_Byte(Adress++,F(xiàn)reqWord[--count]);
}
AD9854_WR_Byte(0x21,Shape》》8); //設(shè)置I通道幅度
AD9854_WR_Byte(0x22,(unsigned char)(Shape&0xff));
AD9854_WR_Byte(0x23,Shape》》8); //設(shè)置Q通道幅度
AD9854_WR_Byte(0x24,(unsigned char)(Shape&0xff));
AD9854_UDCLK=1; //更新AD9854輸出
AD9854_UDCLK=0;
}
void main()
{
LCD_Init();
LCD_Clear();
/*LCD_Write_String(0,0,“BaseFerq 0.875 M”);
LCD_Write_String(0,1,“Now Ferq 1.125 M”);*/
UpDisplay();
AD9854_Init();
AD9854_SetSine(HFerq * 1000,4000);
// AD9854_SetSine(1000000,4000);
// while(1);
// AD9854_InitFSK();
//
// AD9854_SetFSK(HFerq * 1000, LFerq * 1000);
// AD9854_SetFSK(1000000,1000000);
// AD9854_FDATA = 1;
// while(1);
while(1)
{
if(!KEY1)
{
if (flag == 1)
{
AD9854_SetSine(0,0);
//AD9854_InitFSK();
flag = 0;
}
else
{
// AD9854_InitFSK();
// AD9854_SetFSK(HFerq * 1000, LFerq * 1000);
AD9854_SetSine(HFerq * 1000,4000);
flag = 1;
}
while (!KEY1);
}
if (flag == 1)
{
if (!KEY2)
{
AD9854_SetSine(0,0);
fc += 100;
if (fc == 7900) fc = 7800;
LFerq = fc * 3 / 4;
HFerq = fc * 5 / 4;
UpDisplay();
AD9854_SetSine(HFerq * 1000,4000);
// AD9854_InitFSK();
// AD9854_SetFSK(HFerq * 1000, LFerq * 1000);
while (!KEY2);
}
if (!KEY3)
{
AD9854_SetSine(0,0);
fc -= 100;
if (fc == 300) fc = 400;
LFerq = fc * 3 / 4;
HFerq = fc * 5 / 4;
UpDisplay();
AD9854_SetSine(HFerq * 1000,4000);
// AD9854_InitFSK();
// AD9854_SetFSK(HFerq * 1000, LFerq * 1000);
while (!KEY3);
}
if (!KEY4)
{
//AD9854_FDATA = 1;
AD9854_SetSine(LFerq * 1000,4000);
DownDisplay();
while (!KEY4);
AD9854_SetSine(HFerq * 1000,4000);
//AD9854_FDATA = 0;
UpDisplay();
}
}
}
}
//====================================================================================
//函數(shù)名稱:void AD9854_WR_Byte(unsigned char addr,unsigned char dat)
//函數(shù)功能:AD9854并行口寫入數(shù)據(jù)
//入口參數(shù):addr 6位地址
// dat 寫入的數(shù)據(jù)
//出口參數(shù):無
//====================================================================================
void AD9854_WR_Byte(unsigned char addr,unsigned char dat)
{
AD9854_AdrBus = (addr&0x3f) | (AD9854_AdrBus&0xc0);
AD9854_DataBus = dat;
AD9854_WR = 0;
AD9854_WR = 1;
}
//====================================================================================
//函數(shù)名稱:void AD9854_Init(void)
//函數(shù)功能:AD9854初始化
//入口參數(shù):無
//出口參數(shù):無
//====================================================================================
void AD9854_Init(void)
{
AD9854_WR=1;//將讀、寫控制端口設(shè)為無效
AD9854_RD=1;
AD9854_UDCLK=0;
AD9854_RST=1; //復(fù)位AD9854
AD9854_RST=0;
AD9854_WR_Byte(0x1d,0x10); //關(guān)閉比較器
AD9854_WR_Byte(0x1e,CLK_Set); //設(shè)置系統(tǒng)時鐘倍頻
AD9854_WR_Byte(0x1f,0x00); //設(shè)置系統(tǒng)為模式0,由外部更新
AD9854_WR_Byte(0x20,0x60); //設(shè)置為可調(diào)節(jié)幅度,取消插值補償
AD9854_UDCLK=1; //更新AD9854輸出
AD9854_UDCLK=0;
}
//====================================================================================
//函數(shù)名稱:void Freq_convert(long Freq)
//函數(shù)功能:正弦信號頻率數(shù)據(jù)轉(zhuǎn)換
//入口參數(shù):Freq 需要轉(zhuǎn)換的頻率,取值從0~SYSCLK/2
//出口參數(shù):無 但是影響全局變量FreqWord[6]的值
//說明: 該算法位多字節(jié)相乘算法,有公式FTW = (Desired Output Frequency × 2N)/SYSCLK
// 得到該算法,其中N=48,Desired Output Frequency 為所需要的頻率,即Freq,SYSCLK
// 為可編程的系統(tǒng)時鐘,F(xiàn)TW為48Bit的頻率控制字,即FreqWord[6]
//====================================================================================
void Freq_convert(long Freq)
{
unsigned long FreqBuf;
unsigned long Temp=Freq_mult_ulong;
unsigned char Array_Freq[4]; //將輸入頻率因子分為四個字節(jié)
Array_Freq[0]=(unsigned char)Freq;
Array_Freq[1]=(unsigned char)(Freq》》8);
Array_Freq[2]=(unsigned char)(Freq》》16);
Array_Freq[3]=(unsigned char)(Freq》》24);
FreqBuf=Temp*Array_Freq[0];
FreqWord[0]=FreqBuf;
FreqBuf》》=8;
FreqBuf+=(Temp*Array_Freq[1]);
FreqWord[1]=FreqBuf;
FreqBuf》》=8;
FreqBuf+=(Temp*Array_Freq[2]);
FreqWord[2]=FreqBuf;
FreqBuf》》=8;
FreqBuf+=(Temp*Array_Freq[3]);
FreqWord[3]=FreqBuf;
FreqBuf》》=8;
FreqWord[4]=FreqBuf;
FreqWord[5]=FreqBuf》》8;
}
//====================================================================================
//函數(shù)名稱:void AD9854_InitFSK(void)
//函數(shù)功能:AD9854的FSK初始化
//入口參數(shù):無
//出口參數(shù):無
//====================================================================================
void AD9854_InitFSK(void)
{
AD9854_WR=1; //將讀、寫控制端口設(shè)為無效
AD9854_RD=1;
AD9854_UDCLK=0;
AD9854_RST=1; //復(fù)位AD9854
AD9854_RST=0;
AD9854_WR_Byte(0x1d,0x10); //關(guān)閉比較器
AD9854_WR_Byte(0x1e,CLK_Set); //設(shè)置系統(tǒng)時鐘倍頻
AD9854_WR_Byte(0x1f,0x02); //設(shè)置系統(tǒng)為模式1,由外部更新
AD9854_WR_Byte(0x20,0x60); //設(shè)置為可調(diào)節(jié)幅度,取消插值補償
AD9854_UDCLK=1; //更新AD9854輸出
AD9854_UDCLK=0;
}
//====================================================================================
//函數(shù)名稱:void AD9854_SetFSK(unsigned long Freq1,unsigned long Freq2)
//函數(shù)功能:AD9854的FSK設(shè)置
//入口參數(shù):Freq1 FSK頻率1
// Freq2 FSK頻率2
//出口參數(shù):無
//====================================================================================
void AD9854_SetFSK(unsigned long Freq1,unsigned long Freq2)
{
unsigned char count=6;
unsigned char Adress1,Adress2;
const unsigned int Shape=4000; //幅度設(shè)置。 為12 Bit,取值范圍為(0~4095)
Adress1=0x04; //選擇頻率控制字1地址的初值
Adress2=0x0a; //選擇頻率控制字2地址的初值
……………………
-
信號發(fā)生器
+關(guān)注
關(guān)注
28文章
1443瀏覽量
108603 -
AD9854
+關(guān)注
關(guān)注
12文章
50瀏覽量
28061
發(fā)布評論請先 登錄
相關(guān)推薦
評論