PDA

View Full Version : Question on Counter applications



Steel
09-15-2007, 12:48 AM
I loaded the code for "Demonstration of PWM version of NCO/PWM counter mode"

I set up the filter with a 10k and a .1uF cap.

Everything works great.· I see the ramp from 0 to 3.3V.

I changed the period to 4096 for 12-bit resolution on the value.· The ramp is still there.

So I am trying to toggle 'parameter' from $FFF to $000 repeatedly to create a square wave:

·repeat
····· Parameter := $FFF
····· WAITCNT([clock cycles]+ CNT)
····· Parameter· := $000
····· WAITCNT([clock cycles]+ CNT)

Unfortunately, the fastest 'real' square wave that I can get is 200hz?· Anything faster than that, the square wave begins attenuating dramatically.

Am I doing something wrong, or does the NCO not handle audio-resolution.

I would *really* like to make a frequency generator that runs up to 20k and I was under the impression that this could be done.· Right now I would be lucky to get 1k?

Shaun

Post Edited (Steel) : 9/14/2007 4:57:04 PM GMT

Paul Baker
09-15-2007, 01:18 AM
It is your filter that is attenuating the higher frequencies, decrease either the resistor or capacitor value to increase the corner frequency of your filter.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker (mailto:pbaker@parallax.com)
Propeller Applications Engineer
[/url][url=http://www.parallax.com] (http://www.parallax.com)
Parallax, Inc. (http://www.parallax.com)

deSilva
09-15-2007, 05:14 AM
Filter frequeny is 1/(2*pi*10k* .1u) = 1/6.3m = ~150 Hz as you observed...

Fred Hawkins
09-15-2007, 07:19 AM
deSilva, what does m represent in the first result of your equation?

(http://en.wikipedia.org/wiki/Low-pass_filter)

Peter Jakacki
09-15-2007, 09:13 AM
Since he expressed capacitance in uf rather than farads I guess it's his notation to say "micros"? I guess as the equation reduces and rounds to 1,000,000/6,283 where the 1,000,000 is to convert back from using uf's.

*Peter*

mpark
09-15-2007, 02:16 PM
Clearly he meant ms (milliseconds).

deSilva
09-15-2007, 02:21 PM
Very clearly http://forums.parallax.com/images/smilies/smile.gif
I leftt out all units just to entertain you