Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need help in ad9833 programing

Status
Not open for further replies.

ud23

Advanced Member level 3
Joined
Apr 20, 2011
Messages
926
Helped
185
Reputation
370
Reaction score
180
Trophy points
1,323
Activity points
6,138
hi i am using ad9833 for sine wave generator with 89s52 micro controller i am getting 2 channel sine wave and after changing frequency i am getting same frequency not Chang in also frequency getting constant 90k frequency.
 

Hi,

Seems quiet a complicated programming proceedure , easy to get wrong.

Have you tried to get it working with a different frequency when starting up - it might be you are activating it but it is just defaulting to 90khz and your second attempt to change it is having no effect.

Seems a few sites using the chip if you google it.
 

Hi,

I have some Chinese source code for the AT89S52 with routines for controlling the AD9833. The original files were filed with unicode Chinese comments, which is why the comments are now filled with '?' characters.

Hope it helps solve your problem.
 

Attachments

  • C51_AD9833.zip
    4.1 KB · Views: 74

Here's another library I had laying around, in English this time:
 

Attachments

  • ad9833.zip
    7.7 KB · Views: 74

thanx for your post and help but still having problem frequency remains same not changing
here my code


#include <reg51.h>
sbit dds_clk=P3^1;

sbit dds_dat=P3^0;

sbit dds_en=P3^2;
unsigned char control;
void delay(unsigned int T)
{
while(T){
T--;
}
}
void write_2byte(unsigned int a){ //write 2 byte to dds
unsigned char i ;
dds_clk=1;
dds_dat=1;
dds_en=1;
// control=0;
delay(1000);
dds_clk=1;
delay(2);
dds_en=0;
for(i=0;i<16;i++){
if(a&0x8000)
{dds_dat=1;}
else
{dds_dat=0;}
dds_clk=0;
delay(5);
dds_clk=1;
a=a<<1;
dds_dat=0;
}
delay(2);
dds_en=1;
dds_clk=0;
delay(1000);
// control=1;
}

void init_dds(void){
write_2byte(0x2100);
// write_2byte(0x2000);
// write_2byte(0x4219);
// write_2byte(0x4000);
write_2byte(0x8219);
write_2byte(0x8000);
write_2byte(0xC000);
write_2byte(0xE000);
write_2byte(0x2000);

}
void main()

{
init_dds();


}
 

Looks like the answer lies in these two routines:

/*************************************************************************
Function: Freq_change()
Purpose: change the frequency and select AD9833 onboard register
Input: unsigned short freq_out = frequency, unsigned int select = register 0 or 1
Returns: none
Comment: uses 14 bit filter and adds control words,
**************************************************************************/
void Freq_change ( unsigned short freq_out, unsigned int select ) // take base10 frequency and do frequency hop
{

unsigned long freq_reg = freq_out * 13.4217728; // make freq register from frequency // set for 20 MHz Mclk
unsigned short MS_reg = ((freq_reg>>14) & 0x3FFF); // filter out MS -- make 2 x 14 bit frequency words
unsigned short LS_reg = (freq_reg & 0x3FFF); // filter out LS -- make 2 x 14 bit frequency words

MS_reg += 0x4000; // add control bits hex = 0x4000
LS_reg += 0x4000; // add control bits hex = 0x4000

if (select == 0 ) { SPI_write16(0x2000);} // prep ad9833 to recieve full 28bit word for freq 0
if (select == 1 ) { SPI_write16(0x2800);} // prep ad9833 to recieve full 28bit word for freq 1

SPI_write16(LS_reg); // send the LS word first, to the ad9833
SPI_write16(MS_reg); // send the MS word last, to the ad9833
}


/*************************************************************************
Function: AD9833_init()
Purpose: Init the AD9833
Input: none
Returns: none
Comment: this function isn't nessecary, can be done manually
**************************************************************************/
void AD9833_init (void)
{

SPI_write16(0x2100); // control word, set output to mid value voltage

SPI_write16(0x7288); // Freq0 registerdata MSB = approx. 29 khz
SPI_write16(0x4017); // Freq0 registerdata LSB = approx. 29 khz

SPI_write16(0xACEA); // Freq1 registerdata MSB = approx. 24 khz
SPI_write16(0x8013); // Freq1 registerdata LSB = approx. 24 khz

SPI_write16(0xC000); // Phase offset of Freq0 = 0
SPI_write16(0xE000); // Phase offset of Freq1 = 0

SPI_write16(0x2000); // control word, set output = sine

}

I do not have the datasheet for the AD9833 handy, but you should be able to make sense of the command and data sent to the device.

Try sending the same commands and data in the routines above to the AD9833 and see if you can get a frequency change.
 

hi i am having too much offset voltage and still getting double channel out put so do i need filter my input signal from controller?If yes which type filter is suited for it?
 

I'll need to see a schematic of your current design. Can you post or upload it?

So are you now able to change the frequency?
 

i am see change in frequency not sure its true or not output duty cycle veried too much. see attachments have look in ad9833 section
 

Attachments

  • schematic dia.pdf
    34.4 KB · Views: 79

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top