Shop OBEX P1 Docs P2 Docs Learn Events
Measuring freq on pin. — Parallax Forums

Measuring freq on pin.

labsmokelabsmoke Posts: 38
edited 2007-10-27 12:57 in Propeller 1
Hi


I would really appreciate some guidance in the CTR/FRQ/PHS labyrinth.

i realise there are some extensive posts in this forum about these registers but nothing
really explains an easy way to measure a frequency on a pin and output it in a variable.

maybe im missing something or the answer allready exists in the manual and in this forum in some post.

if someone could post a very simple code snippet or give some guidelines i would be very happy, if theres really is such a thing as an "easy" way doing this.

i bought the prop kit a few days ago and it seems i just got a hang of the programming architeure, i think its relevant to point out that ive mastered many compilers thru the years so im not mega noob.

But its just these CTR/FRQ/PHS·registers that makes my head "spin"...ha...ha...ha...

thanks anyway.·

Comments

  • RaymanRayman Posts: 14,162
    edited 2007-10-27 12:14
  • RaymanRayman Posts: 14,162
    edited 2007-10-27 12:15
    There's a frequency count application included...
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-27 12:15
    @labsmoke: As a beginner to the Propeller, everything should look strange and - maybe difficult - to you. This is normal. The Timers&Counters though are most straightforward and behave as in most microcontrollers, so there is no need to fear, and there is no labyrinth at all. Do as you have done in all your former projects!

    There is a fine application note AN001 from Parallax that explains everything from the ground.

    With respect to your specific question:
    - Clear PHSA
    - Set FRQA to 1
    - set CTRA to POSEDGE detection and the pin
    - Wait for 1 ms
    - read PHSA

    Now PHSA is the exact kHz value.

    For fast lower frequency detection you should measure the time of a pulse.

    Edit: I again post the basic timer/counter diagram from tha data sheet because it is so immensely instructive, and I have not given up the hope that somebody will have a look at it.

    The propeller without machine code gives you 10% of its performance
    The propeller without machine code and timer/counters gives you 1% of its performance

    Post Edited (deSilva) : 10/27/2007 12:26:59 PM GMT
    650 x 586 - 33K
  • labsmokelabsmoke Posts: 38
    edited 2007-10-27 12:57
    As i said, the answer was under my nose. I knew there was a simple answer. Thats why god created forums, to make the process a little quicker..





    You shall have thanks
Sign In or Register to comment.