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.

HELP on PIC PROGRAMING with AD9850 SIGNAL GENERATOR

Status
Not open for further replies.
You should grab a good book for learning C. Search around for recommendations.

C does not have HEX or DEC variables. The variable tuning_freq is an unsigned long int. In most C compilers, that is a 32-bit binary value.

If you explain exactly how you stored your keypad input digits, someone can help you convert it to the required format for the DDS.

Don't forget - if your enter Hertz into your keypad, you must scale that value before writing the bytes to the DDS.
 

maybe it doesnt matter if in C i have decimal values or hexadecimal, right? i mean, in C, i can do an AND operation between a decimal (ex. 100Hz*prescale) and a hexadecimal (0xFF000000), right? i think it doesnt matter coz the compiler will convert all values to zeros and ones, right? am i right? at least, that's what i think.. hehhehe..
 
Yes, you can use decimal and hex constants in your C source code. The compiler converts them to binary for its internal use.

However, you haven't explained the format of your keypad digits, or how you stored them in memory. We need that info to help you convert it to DDS format.
 

sir,

how can we design an effective LOWPASS FILTER?

we are having problems in minimizing the distortion of the output signals.

any suggestions?
 

the suggested filter to use in the datasheet was a 5-pole elliptical low pass filter 42MHz.. how do we implement this? our sine wave output needs a lot of work.. its not really distorted, its a DAC sine wave output, we have a hard time refining the signal to have a smooth sine wave..
 
What is your difficulty in implementing the filter? The datasheet gives a schematic, parts list, and PCB layout. Use good RF construction techniques, not a rat's-nest breadboard.

If you are using a slower clock than the datasheet example (100 MHz), don't forget to proportionally scale down the low-pass filter frequency. The filter needs to pass your highest desired sinewave frequency, and block everything above the clock frequency minus your highest desired sinewave frequency.
 

we dnt have an instrument that can measure inductance in nH.

can we use gauge 18 magnetic wire for our inductor?

if its possible how many turns to make 960nH and 680nH?

do we need a core for our inductor?
 

Hi ..
i just know a thing about PIC
which pic mcu compatibility USB in high speed with a sample frimware ?
and
if i want compare PIC with AVR which them is nice for waste time and learn?
 

can someone help me send the 40 bits tuning word of the AD9850 correctly via serial loading from PIC16F877A? I used this style below but my output frequency is far from the expected output frequency. When i input 1 from my keypad(interfaced on the microcontroller), about 128Hz is produced. Likewise, 10Hz input outputs about 1.28kHz.

INPUT is the value entered from keypad. TUNINGWORD is my 32bit tuning word. Since my desired frequency resolution is 1Hz, I multiplied/scale my INPUT.

TUNINGWORD=INPUT*53.687091;
//53.687091 is from the formula 32bit tuning word = Fout X 2^32 / ref. clock of the DDS
//Fout of course is 0.000001MHz(1Hz resolution), ref. clock is 80MHz

This is the C code i used to send the 40bits(32bits tuning word + 8 bits phase control word).

#define data RC0
#define w_clk RC1
#define fq_ud RC2

unsigned int x,y;
unsigned long TUNINGWORD,INPUT;
unsigned char temp;

void send40bit(void)
{
fq_ud=0;
for(x=0;x<32;x++) //32bits tuning word
{
temp=TUNINGWORD>>x;
data=temp;
w_clk=1; w_clk=0;
}
for(y=0;y<8;y++) //8bits phase control all zeros
{
data=0;
w_clk=1; w_clk=0;
}
fq_ud=1;
}
 

Do you have a C debugger in order to watch the variables contents ?

1. Do you need to cast "INPUT*53.687091" ? Try to direct assign 53 to TUNINGWORD before calling send40bit function and notes the Fout value.
2. Are you sure after shifting TUNINGWORD "x" times to right, the temp variable (unsigned char) hold b7-b0 of 32bits TUNINGWORD ?
3. Are you sure after "data=temp" the RC0 (it's only a bit) will get the LSBit of "temp" (unsigned char) ? How the C compiler handles these assignments ? Have you ever killed your curiosity about how the compiled code looks in assembler ?

This is a stupid sequence or a bad C skill programmer (and as a result a waste of memory code ) if I'm doing this way ?
Definitely shifting 4 concatenated registers (TUNINGWORD>>31) will be waste of execution times rather than memory code.
Code:
for (i = 0; i < 32; i++)
	{
		if ((TUNINGWORD & 1) == 1)
			data=1;     //the most stupid embedded C assignment
		else
			data=0;
		tuning_word = tuning_word >> 1;
   w_clk=1; w_clk=0;  //these are stupid as well, you can write in assembler as well
	}

If you're not sure how C compiler handles the code (and never complains about them) let's write in HighLevelLanguage style.
I mean "if"......"else"...... rather than skip next instruction if bit is set or reset (assembler style).

You wrote that for input 1 you got 128 Hz and for input 10 -> output 1,28KHz.
It's quite linear, isn't ?. Hence a straight look at the bit streams delivered to AD9850 will clear your confussion :
it's a bug in code or AD9850 don't behaves as expected ?

For input 1 the bit stream should look like 0000000000110101 or 53 decimal for 0,987Hz output frequency, but you got 128Hz output.
If the bit stream looks like 0001101011010111 or 6871 decimal (for input 1), then you have a software bug.

Just play a little and can solve the problem yourself.
 

sir silvio:

thanks for the help! sori for my bad programming skills. im new to this. thanks so much..

me & gentxtelmer2003 are groupmates..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top