PIC + DDS = Frequency Synthesizer? - Page 2

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

Translate This Thread From English to

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

You're welcome.


The post I saw, from Richard posting as "The Mind Factory INC",
specified 0 - 20 kHz.  If you do this with a PIC and no hardware DDS,
you will probably need to run it at least 2 MIPS (8 MHz clock, I think),
in order to get enough instructions per transition.  This is not a
concern if you use an external hardware DDS.

Two software only techniques were mentioned, constant clock and variable
clock.  I was recommending the variable clock, since it can produce
lower jitter, but the other is simpler.

? I need to input via a
Quoted text here. Click to load it

It should be a good learning exercise.  ;-)

Quoted text here. Click to load it

Stability is specified change in the output over changes in another
variable.  For frequency, this is usually vs. a temperature range,
supply voltage, or deterioration over time.  Stability without the
variable being changed has no meaning.

If you mean accuracy, rather than stability, this will primarily depend
on the accuracy of your reference frequency.  If you are using a
software-only implementation, it would be the processor oscillator
accuracy.  If you want 40 kHz to be accurate to 0.1 Hz, you are asking
for for 2.5 ppm accuracy.  A standard crystal isn't that accurate.  You
can buy TXCOs (temperature controlled oscillators) which can achieve
this.  They usually provide a means to fine tune the oscillator.
 
Quoted text here. Click to load it

The DDS will typically provide a signal with less jitter because it will
run at a higher clock frequency than you can achieve with a PIC.  As far
as how to interface or use a DDS, you can ask specific questions here.

In general, the external DDS solution will give less jitter (a more pure
signal) and will be easier to program, but will cost more.  In contrast,
the processor only solution will give you a good programming exercise.
;-)
 
Quoted text here. Click to load it

Here's a hint: the more specific question you ask, the better and more
relevant the responses are likely to be.

Thad

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

***Sorry for the misuse of wording! I was visualizing seeing the
output squarewave on a frequency counter and I thought it would be
good not to see the 1Hz digit jumping around. I saw this as
"instability". But you are correct that 0.1Hz accuracy is a better
definition of what I am looking for.

So, from all these threads I think that a DDS chip is what I need.
Perhaps AD9833? It is the cheapest, and has a "simple" serial
interface. I do not know much about interfacing so it might not be
simple to me. :>)

Quoted text here. Click to load it

***I have been monkeying around with MeLabs PIC Basic Pro (PBP). This
allows me to get the PIC up and running and has served my needs
extremely well. My issues are what I need to do to program the DDS.
Specifically, how do I get the PIC to talk to the DDS using BASIC
commands? PBP has commands like SERIN, SEROUT etc. that seems to me to
be the command I need. Do I simply output SEROUT on say PORTA.1? How
do I initialize the DDS? Let's say I use a 4MHz oscillator on the DDS,
and want a maximum 50kHz output. AD's interactive tool tells me that
the codewords will be 2100 7333 40CC 8000 9000 C000 E000 2000. What
BASIC code gets this word to the DDS from the PIC, if this is the
codeword that is used? Do I have to run other code first? I really
don't have a clue.

I think I can work my way around the keypad and LCD interfacing. I was
thinking of using 2 x PICs + DDS. The first PIC does the keypad and
LCD, and sends a SEROUT command to the second PIC to pass on the
desired frequency as inputted. The second PIC only interfaces with the
DDS and nothing more. Would I use the SERIN command on the 2nd PIC and
have it waiting and listening for the data from #1 PIC? OK, do I setup
a loop to scan the port?

Also, can all PICs and the DDS run off the same 4MHz crystal? or does
each chip need their own crystal?

BTW, why do posts to this forum take 3-9 hours to post? Seems very
strange.

So, hope this provides more detailed info. I am learning as I go here,
so I might not know what questions to ask next. Thanks again for your
patience and help!! Much appreciated.
Russ :>)

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

Put simply, it's like sending sort of a 'morse code' to the DDS
chip. You have to convert the code words to bits, set an output
low or high depending the bit you want to sent, and the generate
a clock pulse using another output. This way you can load the entire
code word, bit by bit, until all bits are transferred. This will
not work in one go, and you will get surprising result. But after
a couple of hours messing around, you will probably be able to
put all those code words into the DDS.

Quoted text here. Click to load it

With a DDS chip, the loading of the keywords isn't much extra work.
It is probably more difficult to get two pics communicating properly,
than to just load that DDS chip with the correct data.

Quoted text here. Click to load it

I guess you can hookup the DDS to the output drive of the PIC's
crystal, but I would use a seperate crystal for the DDS, as fast
as possible. It will increase the quality of the signal produced.

Quoted text here. Click to load it

? Ask your provider?

Quoted text here. Click to load it


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




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

***Actually this message came from Google! I quote: "Your message has
been posted. Your message has been posted to Usenet. Please note that
it may take anywhere from 3 to 9 hours for your message to appear on
Google Groups. The text of your message is included below for your
convenience. Return to Google Groups". That is why I asked. :>)



Quoted text here. Click to load it

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

Yes, having the units digit "jumping around" is an indication of short
term instability, but probably a poor way to go about determining your
requirements.

Quoted text here. Click to load it

Accuracy is a more stringent requirement that stability.  I honestly
don't know what you are looking for.  What determines you frequency
range, accuracy, resolution, and signal purity requirements?

Quoted text here. Click to load it

I haven't looked at the data sheet, but you should be able to connect
the DDS control lines to I/O lines on the PIC.  The easiest way to send
data serially is probably to write a subroutine to set the data bit on
the data line, pulse the clock line, then repeat until all bits have
been sent, then pulse a strobe line.  It might be possible to use some
internal serial peripheral for that, I don't know.

Quoted text here. Click to load it

Just set one output line at a time, looping through all the bits you
want to send.
In general, make sure that you program all the required registers.

Quoted text here. Click to load it

That's the third number I have seen for the upper frequency limit.
Sounds like a little stability in requirements is called for.  ;-)

Quoted text here. Click to load it

I think you should be able to handle everything with a single PIC,
assuming that you have enough I/O lines, especially if you use an
external DDS, which, once set, will continue to generate the requested
frequency.

Quoted text here. Click to load it

You should be able to use a single oscillator.  To reiterate an earlier
point, if you really need 0.1 Hz accuracy from 40 kHz, you need to go to
a precision oscillator, not a simple crystal.  If 50 ppm is sufficient,
you can probably use a simple crystal, but your accuracy will be less.
 
Thad

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

***That should work. I will roll up my sleeves and see if I can get
the DDS to accept some data.

Quoted text here. Click to load it

***Yup. Sorry, but I got thinking that DDS opens the doors so much I
felt I could get even higher frequencies without a problem. I
originally thought 20kHz would be good, but when I see DDS chips
generating far higher...I got hungry for more. It is more of a
convenience thing to get the higher frequencies. The application is to
pulse a bank of LEDs at high rates. The higher I can pulse them, the
more experimentation can be done. The LEDs are going to be used in a
study to determine cellular response (ATP production) of tissue cells
when subjected to a pulsed monochromatic light source. I just want to
be able to vary the frequency in 1Hz steps up as high as I can. 20kHz
is great, but if I can get more that's even better.

 
Quoted text here. Click to load it

***I will look into the different PICs available. Thanks.

Quoted text here. Click to load it

***Yes, I may have gotten ahead of myself. A simple crystal souce
should be fine. I really appreciate your suggestions and comments (as
I do the others who have responded as well). Now, I'll see if I can
put all this together. Again, thanks.
Cheers!
Russ :>)

Re: PIC + DDS = Frequency Synthesizer?
snipped-for-privacy@sotainstruments.com (RussT) wrote in message
Quoted text here. Click to load it
I think (I don't know the application) that 1Hz resolution at 20 Khz
would be overkill. Maybe if you specified the resolution in terms of
percentage of the actual frequency (say 1%, ie 200Hz at 20Khz) then it
would be fairly easy to code using the PWM generator or even in
interrupts.
If the PIC is running at 20MHz then you have 5 mips or so or a 100
counts on one of the timers at the rate of 50 K timeouts per second.
It would be easy to get 25KHz with a resolution of on percent.

Regards
Robert

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

  Given the actual usage, you should allow for control of pulse width
(LED On Time) as well as repetition rate. (not quite DDS anymore)
  Also, since the tissue is likely to be time-based, not frequency based,
you might like to think in TIME rather than frequency.
  I would imagine 1Hz steps would be getting coarse, for slower tissue
reactions - you are going to get 1000ms/500ms/250ms/125ms - better
might be to run > 10Mhz, and define to 100ns (jitter free)
ON time, and OFF time for your LEDS.
  Also LEDs have thermal effects, and some time-degrade, so depending on
your target precision, you might like to add a (fast) light-sensor, to
confirm the actual exposure given.
  Most uC can use capture/compare channels, to give 15-16 bits of time
step. The better ones include prescalers on the capt/comp to allow very
wide set ranges, close to 32 bits, but still with one part in 2^15-2^16
region.
  If you need finer resolution than 2^15-2^16 region, or >> 10MHz
then you are moving into CPLD/FPGA solutions.
  CPLD/FPGA could be designed for decimal setpoints, even from
thumbwheels, if you want a PC-free setup :)

  Cygnal uC have very fast cores, and 25/50/100MHz clocks to the
timers, so you could use those to push the uC solution.

-jg


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

***Thanks jg, you've made some very interesting points. The current
research shows that at low enough frequencies from DC-5kHz, the
effects of the pulsed LED light (660nm and 880nm wavelengths) vary
quite a bit. DC seems to sedate, 73-584Hz appears to speed tissue
regeneration, and 4-5kHz are good for pain relief. I wanted to see if
there are other effects at much higher frequencies. Incidentally,
there is evidence showing that the cells can become acclimatized to
the stimulus. That might occur over time (dosage) or at certain higher
frequencies whereby the cell can no longer respond and sees the
stimulus as steady DC in a way. I built a prototype unit and treated a
rotator-cuff injury I have nursed for over 3 years. It has really
affected me - especially my golf swing! I tried 660nm at 584 Hz (a
bank of 60 x 3,000 mcd LEDs) for an abitrary treatment time of 20
minutes. To my utter amazement, I had nearly completely cured my
injury. I would say 95% positive effect. The range of motion is nearly
back to normal and the pain has all but vanished. I even have a better
golf swing. :>)
Russ :>)

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

You might have described the application first, and you would have
gotten to better recommendations much faster.  I suggest you think
in terms of pulse generators and repetition period, which are very
easily implemented.  A master counter recycles at some value,
setting repetition period.  At the recycle point you can set the
output on, and at some other count you can set it off.  Everything
is calibrated directly in terms of time.  Should you want
sequences of pulses that is also easily implemented (say red, then
yellow, then green leds, for example).  Jim Granville has gotten
to the heart of the matter.

No DDS needed.  A PIC will probably be overkill.  A simple control
mechanism will allow you to increase/decrease period and pulse
width, displaying values.  Control may need one selector toggle
switch, one up button, and one down button.

--
Chuck F ( snipped-for-privacy@yahoo.com) ( snipped-for-privacy@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
We've slightly trimmed the long signature. Click to see the full one.
Re: PIC + DDS = Frequency Synthesizer?
snipped-for-privacy@sotainstruments.com (RussT) wrote in

Quoted text here. Click to load it

I wrote an article for Analog Devices that uses a low cost DSP. A DSP and
a low cost 96k sigma delta DAC could give you a 1 Hz to 40k synthesizer
with very low distortion. There is a link on our homepage:  
http://www.danvillesignal.com

--
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

In order to generate a sine signal at the maximum frequency f, you
need to update the DAC at least twice during each cycle, however, in
order to be able to filter out the aliases, the update frequency has
to be at least 2.5f to 3f. Thus, in this case the update rate has to
be at least 100 kHz, thus the software calculation loop cycle time
must be _exactly_ 10 us, thus, if the processor runs at 2 MIPS, there
are 20 instructions available to update the phase accumulator, do the
sine(x), lookup and control the DAC.

However, if the frequency step needs to be exactly 1.0 Hz, then the
phase accumulator has to have at least 17 bits and be clocked at
131.072 kHz and a new value must be outputed every 7.62939453125 us,
thus with a 2 MIPS processor speed 15.258... instructions are
available. In practice you would have to tune the CPU crystal
frequency in order to have an integer number of instructions for each
software loop cycle.        

Quoted text here. Click to load it

If no high frequency timer interrupts or a free running hardware
counters are available, then the software calculation loop must
contains exactly the same amount of CPU clock cycles during each
iteration. This means no conditional branching (other than constant
loop counting) or if a conditional loop is used, in cases the branch
is _not_ taken, some dummy instructions must be included that
consumes_exactly_ the same number of clock cycles as the other path
when the conditional branch is taken.

How you are going to handle the keyboard and display during the
available 15 instructions in addition to the DDS is a mystery. You can
not simply handle these every 100th main loop iteration, since this
would upset the timing.
 
Quoted text here. Click to load it

Then I suggest that you should learn it before going any further with
this project.


Quoted text here. Click to load it

It might be doable if the phase accumulator increment is transferred
through parallel ports from one controller to the other and the
parallel ports can be read with a single instruction (to avoid race
conditions, if the user interface is currently changing the value).

I would really suggest that you should look for a faster processor,
preferably with a high frequency timer interrupt (in which case the
DAC can be written during the interrupt service routine without too
much jitter) or at least contain a free running high resolution
counter (and use a busy wait to wait for a specific value to be
reached). By using these kinds of tricks, the actual calculation time
does not have to be _exactly_ the cycle time, but now it can (and
must) be shorter than the DAC update interval.
  
Paul


Re: PIC + DDS = Frequency Synthesizer? [LZ87010]

Quoted text here. Click to load it
<snip>
Quoted text here. Click to load it
<snip>
Quoted text here. Click to load it

  The Sharp LZ87010 uC has two DACs, with 128 Byte WaveTable RAMS, so it
would seem to be well suited to this.

  Not sure how real this is: There is data, and also an errata,
(which is promising) but no sign it has hit 'critical-mass'
- has anyone designed in the LZ87010 yet ?

-jg


Re: PIC + DDS = Frequency Synthesizer?

Quoted text here. Click to load it

The specification of stabilitiy is ambiguous unless you give some
averaging period over which the measurements of frequency are taken.
It is easy to make a programmable signal generator, 1 Hz to 40 kHz in
steps of 1 Hz with 0.1 Hz stability if the averaging periods are 10
seconds.  There would just be a lot of short-term jitter.  But if the
averaging periods are 10 msec, then you would need a lot of extra
hardware to help out the PIC to produce that kind of stability.
Perhaps you could restate the requirements and explain your
application more clearly.  This would help to understand what sort of
averaging period is appropriate in evaluating the performance of the
signal generator.

By the way, the term "DDS" is not usually applied to the generation of
a square wave signal, but rather to the generation of an analog
waveform, like a sine wave, using table-drive DAC lookups.



-Robert Scott
 Ypsilanti, Michigan
(Reply through this forum, not by direct e-mail to me, as automatic reply
address is fake.)


Re: PIC + DDS = Frequency Synthesizer?
no-one@dont-mail-me.com (Robert Scott) wrote in message
Quoted text here. Click to load it

***Yes agreed. My application is to produce squarewaves, not sines. I
forgot to clarify that. I just thought I would Schmidt Trigger the
sines to get squares. Having said that, is there an easier way to
generate 50% Duty Cycle squarewaves?
Russ :)

Quoted text here. Click to load it
address is fake.)

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

Same principle, but you don't need a LUT, just use the MSB
of the calculated index you would use to acces the LUT.
That saves a lot of time, such a software DDS would result
in a much shorter accumulator loop, and therefore reduce jitter.

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



Re: PIC + DDS = Frequency Synthesizer?

Quoted text here. Click to load it

For signal purity, it's advisable to generate and filter a sine wave from a
DDS and the square it. There is a Schmitt-trigger in the AD98xx series DDS
chips for this purpose - see the data sheets from <http://www.analog.com/.

The reason is that the intermediate values of a sine wave convey some phase
information, but the intermediate values of a square wave do not.

HTH

Tauno Voipio
tauno voipio @ iki fi




Re: PIC + DDS = Frequency Synthesizer?


Quoted text here. Click to load it

Just use values for a square wave in the lookup table.

Leon
--
Leon Heller, G1HSM
Email: snipped-for-privacy@dsl.pipex.com
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


***Upon looking at the APP Note, there is a output on AD9835 s pin 16
which toggles on the MSB change. A perfect squarewave output! I
by-pass the DAC entirely. This is getting interesting...
Russ :)

Quoted text here. Click to load it

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

Let's do a little math here:

First, let's assume first that you want to go for pure DDS (Digital in all
sense), meaning you won't rely on an analog filter to remove aliasing
effects.

For an 8-bit precision sine output (meaning the smallest step on the output
is 1/256th of the full-scale) you would need ~0.22deg. of phase resolution,
or in other words you would have to generate 1602 samples per cycle. This
would give you 48dB of signal-to-noise ratio. For 12-bit resolution you
would need 25736 samples per cycle and would achieve 72dB of SNR.

Now, for your 40kHz specification this would mean a 64MHz update rate for
8-bit and 1.029GHz for 12-bit resolution. I don't think either of this would
be possible with a PIC. The first one is probably doable with an ADI fixed
point DSP, but a small FPGA would surely do the trick. The second one would
not be possible without special-purpose and expansive ICs.

If you don't mind having an analog filter, you can get much more reasonable
specifications but you would rely on your analog circuitry to give you the
precision and noise you need.

As others pointed out one easy path would be to use a sigma-delta converter
with 96kHz sampling rate. That would have a high-precision converter and an
integrated filter to provide a smooth output signal. However that would
generate nothing but sine at 40kHz.

I think to decide what you need to do you should come up with numbers for
the following:
- Required signal bandwidth (or maximum output slew-rate)
- Required signal to noise ratio

Regards,
Andras Tantos



Site Timeline