PIC + DDS = Frequency Synthesizer?

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
I asked a friend to post to this forum about desinging a PIC-based
PWM. Now that I have joined this forum, I'll get more specific about
my requirements. Thanks by the way for all your interesting and
informative responses.

What I am trying to do is make a frequency synthesizer that will
output 1Hz to say 40kHz in 1Hz resolution. I need to input via a
keypad, and have an LCD display show me the inputted frequency. I know
virtually zero about assembly language! I am presently programming
PICs with PicBasic Pro. That's the first hurdle - if I can either
program this in BASIC or cut-n-paste assembly code in areas that need
fast excecutuion then that's fine.

I have seen examples whereby one can make a PIC act like an Numerical
Controlled Oscillator (NCO), and one gets a cheap DDS. Cost is an
issue, so the cheaper and simpler the better. I do not mind using 2 x
PICs for the interface and control. The output frequency need only be
stable to +/-0.1 Hz.

I am totally new to DDS (Analog Device IC's, etc.) so that is hurdle
#2.

I would appreciate any information you can offer. I apologize in
advance if I ask some basic questions! Thanks kindly! Russ >:)

Re: PIC + DDS = Frequency Synthesizer?
Quoted text here. Click to load it

Take a look at this page:

http://www.myplace.nu/avr/minidds /


AVR's are faster than PIC, at a given clock frequency. Also, the
AVR has some very convenient instructions for table lookup, making
a software DDS more practical compared to PIC.

--
Thanks, Frank.
(remove 'x' and 'invalid' when replying by email)




Re: PIC + DDS = Frequency Synthesizer?
Quoted text here. Click to load it

***Yes, I did come across this! OK, can one program a PIC in a similar
fasion? Even though the PIC is slower, could it yield acceptable
results...perhaps 1Hz-20kHz in 1Hz steps? If not then I will bite the
bullet and use a DDS.
Thanks!
Russ :>)
Quoted text here. Click to load it

Re: PIC + DDS = Frequency Synthesizer?
snipped-for-privacy@sotainstruments.com (RussT) wrote in

Quoted text here. Click to load it

Russ:

If you are going to use a DDS chip, I would reconsider a DSP/DAC solution
instead of a PIC/DDS solution. ADI assembly language is very easy to
learn.

You have stated that you only want to go to 40kHz. What distortion
performance are you looking for? A digital audio DAC with a DSP will give
you very good distortion specs, much better than a DDS chip.

OTOH, a DDS chip can be used for much higher frequency range.

There is a DDS-DSP application note on the ADI web site.

Our DSP-8300 small module can do what you want to a 20kHz range. We have
sample code. It would be easy to adapt the software to your requirements
by substituting the AC'97 codecs with a 96k digital audio DAC.


--
Al Clark
Danville Signal Processing, Inc.
We've slightly trimmed the long signature. Click to see the full one.
Re: PIC + DDS = Frequency Synthesizer?
Quoted text here. Click to load it

***I am sorry I did not mention it but I am actually looking to
generate 50% Duty Cycle Squarewaves, not sine waves. Having said that,
is the DDS still the way to proceed?
Thanks!
Russ :>)

Quoted text here. Click to load it

Re: PIC + DDS = Frequency Synthesizer?
Quoted text here. Click to load it

If you just need square waves, a smal CPLD does the job.
Take one with 64 or 128 Flipflops and have it running with a
few dozend MHz.
Just make auto-reload counters counting down or up.
Then have a few registers for the period.
My website has a few examples :
http://www.ibrtses.com/electronics/fpgabasic.html

Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net


Re: PIC + DDS = Frequency Synthesizer?
snipped-for-privacy@sotainstruments.com (RussT) wrote in

Quoted text here. Click to load it

You can generate squarewaves from a sinusoid. I think the next question,
is how much phase jitter can your application tolerate?

Starting with a fast clock and dividing with programmable counters is not
going to give you nice 1 Hz frequency steps. With a sinusoidal signal
(DDS synthesis) you can generate exact frequencies but it will be
important to have a low noise zero crossing detector and a good quality
sinusoid if phase jitter needs to be minimal.  


--
Al Clark
Danville Signal Processing, Inc.
We've slightly trimmed the long signature. Click to see the full one.
Re: PIC + DDS = Frequency Synthesizer?
Quoted text here. Click to load it


You can also implement a DDS in CPLD when the output
is to be rectangular. Going analog is not necessary.

Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net


Re: PIC + DDS = Frequency Synthesizer?

Quoted text here. Click to load it

I 've never considered a DDS with values of just 1 & 0 before, but it
seems to me that you are essentially creating a table with values of 0
from 0 to almost PI & 1 from PI to almost 2 PI. This would be very easy
to implement in a PLD if the sample rate is 2^n x resolution.

For example, to get 40k at 1 Hz resolution, clock at 131072 Hz. This
creates a programmable DDS that can go up to 65535 Hz in 1 Hz steps. You
just need an adder (add 40000 to a 17 bit accumulator) and use the most
significant bit as your output.

The results should look fine to a frequency counter but be aware that the
phase jitter will be excessive! If you make the clock much higher,
perhaps 2^25 or 2^24, the phase jitter will be much smaller.

This is why a sine derived DDS and a squaring circuit might be better.
Also be aware that most DDS chips have long accumulators but much shorter
DACs. This also contributes to phase jitter. A DDS designed with a higher
resolution DAC will have less phase jitter (and usually less frequency
range). This may be a reason to use a sigma delta digital audio DAC and
some kind of DSP or microcontroller based DDS.


--
Al Clark
Danville Signal Processing, Inc.
We've slightly trimmed the long signature. Click to see the full one.
Re: PIC + DDS = Frequency Synthesizer?
Quoted text here. Click to load it
not

Assuming a serial loaded 32 bit adder value, and a 32 bit
accumulator, with 12 MSB output, what speeds can be achieved?
What would your (wild) guess be?

I'm impressed by the 180MHz DDS chips from Analog, but would
like to play with something that can be hooked up to an external
LUT, stored in fast ram.

--
Thanks, Frank.
(remove 'x' and 'invalid' when replying by email)



Re: PIC + DDS = Frequency Synthesizer?
Quoted text here. Click to load it

That may depend on the FPGA family, I guess.
I made 27bit synchroneous counters running in excess of 120MHz
in an ACEX chip. So I'd assume somewhere between 150MHz and 250MHz
clocking rate should be doable with an average fast family.

Quoted text here. Click to load it

I'm indeed impress by these parts too.
I'm thinking along that line too. The external RAM is far too slow.
I had a look at the Cypress static RAMs, they achieve 10ns. The internal
RAM of FPGAs is much faster, I guess somewhere between 150 and 200MHz
should be doable. The DAC isn't going to be easy, too.

Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net


Re: PIC + DDS = Frequency Synthesizer?
Quoted text here. Click to load it
question,

Yes, a counter. But an adder, with all the carry stuff?

Quoted text here. Click to load it

No, not easy. It's interesting to see that professional DDS based
function generators don't go much above 100KHz, when generating
triangle waves and sawtooth waves. Sine waves are easier, allowing
steep alias filters.

--
Thanks, Frank.
(remove 'x' and 'invalid' when replying by email)





Re: PIC + DDS = Frequency Synthesizer?
Quoted text here. Click to load it

Knowing that, why don't you use a PLL? Like CY22393 from Cypress (5 bucks at
DigiKey), though for your frequency range that's an overkill. You can
program it using the I2C bus, clock it from a crystal, and your PIC is free
to do all the UI and stuff.

regards,
Andras Tantos



Re: PIC + DDS = Frequency Synthesizer?

Quoted text here. Click to load it

The CY22393 is a programmable clock that uses internal flash to store
changes. The flash has a maximum write count of about 1000. It does an
excellent job of generating ref frequencies for frequencies where a xtal
is not easily obtained or in cases where the clock needs to be over 25-30
MHz.

--
Al Clark
Danville Signal Processing, Inc.
We've slightly trimmed the long signature. Click to see the full one.
Re: PIC + DDS = Frequency Synthesizer?

Quoted text here. Click to load it

I've learned it on the hard way (:-)). It *can* be programmed to store a
configuration, but comes unconfigured out of the factory and needs a special
programmer to update the stored configuration. However you can download and
change it's 'runtime' configuration through the I2C interface any time and
as many times as you whish. Of course that configuration cannot be stored
and will be lost upon the next powerup.

Regards,
Andras Tantos



Re: PIC + DDS = Frequency Synthesizer?
Quoted text here. Click to load it

Do you want a square-wave or a sine-wave? If sine-wave, you need
a lookup-table, and with 256 entries in your LUT, you will have to
skip samples at 20KHz. An alias-filter will help to remove the
steps. For audio purposes, an 8 bit LUT/DAC is not enough, you will
hear all kinds of funny noises, even at 15KHz, where you expect
to hear almost nothing but a very high tone. You also need an
alias filter that changes it's cutoff frequency, or else you will
hear funny noises at 20Hz etc. A 16 bit ADC is better ;) If you only
want a square wave, things are a lot easier.

You can get 20KHz out of a PIC DDS, assuming a 20MHz PIC and a
tight DDS accumulator loop. Don't attempt to program the loop
as a timer interrupt, it will be too slow. But an AVR is highly
recommended.

Been there, done that:
www.euronet.nl/~fbemel
where you can find more information on a DDS using an AVR.

For a better audio sinewave, you better use a AD9834 that uses
an internal 12bit LUT and DAC.

OTH, the PIC or AVR route is a great learning experience.

--
Thanks, Frank.
(remove 'x' and 'invalid' when replying by email)




Re: PIC + DDS = Frequency Synthesizer?
Quoted text here. Click to load it

***Yes, 50% Duty Cycle Squarewaves.

Quoted text here. Click to load it

***Hmmm, I would not know how to program the PIC...any sample code?

Don't attempt to program the loop
Quoted text here. Click to load it

***What exactly is an AVR?
Thanks,
Russ :>)

Quoted text here. Click to load it

Re: PIC + DDS = Frequency Synthesizer?
Quoted text here. Click to load it

Well, I gave the URL to that minidds, which you had found
yourself also. That one uses an AVR microcontroller, so you
have to rewrite/port the code, but the principles are the
same. I am not going to write it for you ;)

Quoted text here. Click to load it

Just another family of 8 bit microcontrollers, made by Atmel.
Less variety compared to PIC's but faster, more effycient.

--
Thanks, Frank.
(remove 'x' and 'invalid' when replying by email)




Re: PIC + DDS = Frequency Synthesizer?
snipped-for-privacy@sotainstruments.com (RussT) writes:

Quoted text here. Click to load it

A few points:

- with the variable rate interrupt system, you can make a low-jitter
  square wave without loading the processor very much (see the
  previous thread)

- for the 20 kHz repetition rate, you'll have 200 clock cycles at
  4 MHz clock. With a PIC this means 50 instructions, which should
  be just possible. With an AVR at the same clock, you'd have 200
  cycles which would be certainly enough. Using a higher frequency
  or another processor would help (I know, studying a new processor
  takes some time and effort. It is usually worth it, though.)

- for your application: please note that LEDs are not strictly
  monochromatic. They have a wide bandwidth, and their wavelength
  varies on unit-to-unit basis and also as a function of temperature.
  If you need a narrower bandwidth, see laser diodes or RCLEDs
  might fit the bill

Good luck!

- Ville

--
Ville Voipio, Dr.Tech., M.Sc. (EE)

Re: PIC + DDS = Frequency Synthesizer?
Hi, you will never get that resolution by just using a pic. There are several
synth chips around, use 1 of those.


Site Timeline