Help wanted

Hi to all Newsgroup,

I need of your little help.

With an 8 bit microcontroller I must to calculate the AD9558 DDS input data, with the formula: Data = (2^48/Fclk)*Fout

i.e. : Fclock =100MHz Fout = 11300000 Hz Data = 1CED 9168 72B0 or 31,806,672,368,304

With an 16 bit processor I don't have any problem, but with an 8bit processor I don't find/know the right way to calculate the *exact* Data. Have you an solution?? Thanks in advance and sorry for bandwidth...

--
73's de IZ5FCY Roberto
Reply to
Roberto IZ5FCY
Loading thread data ...

If you're using an 8-bit microprocessor, simply translate doing long division by hand into steps of subtract, store if positive/jump if negative, shift and bring in new bits. If you can't do long division by hand, you're hosed.

Reply to
John_H

Thanks John, but in "C" language....??

--
73's de IZ5FCY Roberto
Reply to
Roberto IZ5FCY

If you use a C compiler, it probably knows how to do math with long values...

--
Uwe Bonnes                bon@elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Reply to
Uwe Bonnes

No dear Uwe, the 8bit PIC or AVR don't have 16bit math library....

--
73's de IZ5FCY Roberto
Reply to
Roberto IZ5FCY

What about "long long"? Depends on your compiler, but if it is available, it may be 64 bits wide.

If there is no suitable data type, then you need to handle the carry-out manually. Unfortunately C does not let you access a carry flag inside the CPU. So you got two choices: Make the most significant bit the carry-out and handle it manually or use inline assembly. Inline assembly is quite easy to handle for GCC.

But I think, we are very off-topic!

Ralf

Reply to
Ralf Hildebrandt

Uwe,

I actually had a real problem finding something that would deal with 48 bit long words for integer division...and multiplication.

I like John's approach: write a program to do what you would do by hand (in whatever language you like).

2E48 is only ~ 2.8E14. It isn't the scientific notation value that is large (or small), it is the fact that you really want 48 digits of accuracy so that you are +/- 1/2 lsb, or within 3.6E-15 * fclk of the frequency you want. 100 Micro-hertz resolution in this case?

I think for Ham radio, 2E48 is a bit overkill, unless you are doing coherent detection...

Aust> Roberto IZ5FCY wrote:

Reply to
Austin Lesea

int can_solve_problem(usenet_poster *op) { if (op->can_do_long_division) { think(op); write(op, SOME_CODE); return 1; } else { hosed++; return 0; } }

Reply to
Ben Jones

Hi there

wrong! AVR GCC suports int (16bit) long, and long long.

Aurash

Roberto IZ5FCY wrote:

Reply to
Aurelian Lazarut

If your PIC doesn't have a math library that can handle the large numbers, do it with an array of 8-bit integers or chars. Loop through the 8-bit values the way you loop through the digits to do long division.

If your base frequency will never change, however, forget calculating

2^n*Fout/Fclk but instead perform the multiplication of Fout*const where const=2^n/Fclk. You may need to calculate the constant by hand, but you end up with a number that will give you your phase increment value for your DDS with a simple multiplication. If the PIC's C support doesn't provide multiplies for numbers that big, try doing multiplication "by hand" in C.
Reply to
John_H

Thanks John..

--

73's de IZ5FCY Roberto
Reply to
Roberto IZ5FCY

Thanks Ralph!

I'm sorry, but before FPGA implementation... where I could find one large reunion of "great brain people" like this? :-)))

Bye..

--
73's de IZ5FCY Roberto
Reply to
Roberto IZ5FCY

Look for mailing lists. Look at the website of the compiler you use. If there is GCC available for your MCU, then its quite possible, that there is a mailing list - and a documentation and a FAQ...

Ralf

Reply to
Ralf Hildebrandt

Use the shift and subtract method :

formatting link

This method is suited for 16-bit but can be easily extended to your bit length.

Reply to
Isaac Bosompem

Excelent point.

Why 48 bits? If you need to provide a 3Hz signal with 1ppm accuracy from a 100 MHz clock, that's roughly 35 bits. If the accuracy requirement is determined different from raw frequency, a limited number of bits could be used with a simple shift, much like a floating point value.

Reply to
John_H

Thanks Austin but isn't an Ham project...in the Web we can find thousand projects/kits ready-to-use for Ham. Bye.

--
73's de IZ5FCY Roberto
Reply to
Roberto IZ5FCY

Roberto,

I build many ham kits for fun.

Good luck with your project!

73 IZ5FCY de AB6VU sk

Roberto IZ5FCY wrote:

Reply to
Austin Lesea

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.