Shop OBEX P1 Docs P2 Docs Learn Events
Question on Counter applications — Parallax Forums

Question on Counter applications

SteelSteel Posts: 313
edited 2007-09-15 06:21 in Propeller 1
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([noparse][[/noparse]clock cycles]+ CNT)
····· Parameter· := $000
····· WAITCNT([noparse][[/noparse]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

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-09-14 17:18
    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
    Propeller Applications Engineer

    Parallax, Inc.
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-14 21:14
    Filter frequeny is 1/(2*pi*10k* .1u) = 1/6.3m = ~150 Hz as you observed...
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-09-14 23:19
    deSilva, what does m represent in the first result of your equation?

    (http://en.wikipedia.org/wiki/Low-pass_filter)
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-09-15 01:13
    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*
  • mparkmpark Posts: 1,305
    edited 2007-09-15 06:16
    Clearly he meant ms (milliseconds).
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-15 06:21
    Very clearly smile.gif
    I leftt out all units just to entertain you
Sign In or Register to comment.