Shop OBEX P1 Docs P2 Docs Learn Events
Frequency Measurement — Parallax Forums

Frequency Measurement

Andrew.GAndrew.G Posts: 5
edited 2008-10-09 12:33 in Propeller 1
Hi,

Ive been snooping around the object exchange however i have not come across any accurate objects to measure frequency.

i have tried the Frequency meter object. But i was not able to achieve less than 1.5% error of the desired result. I also tried offsetting the 1.5% error
which gave me about about 0.5% error.

I used the Synth object to generate a reference frequency to measure the accuracy.

I found the Synth object to be extremely precise and i was hoping there exists an equally accurate object that measures frequency.

A great advantage would be to have the ability to measure low frequencies down to .01 of a hertz.

My current application requires measurement between DC to about 100 Hertz.

Are there any objects floating around that can achieve this??

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-10-08 15:42
    For frequencies this low, it's probably better to measure the period and convert the result to a frequency, rather than counting edges over a certain length of time. This can easily be accomplished using WAITPEQ and the CNT register. You need to refine your desired range, though. "DC" does not produce a period that can be measured. Also, with an 80MHz clock and beyond a period of 53 seconds, use of the CNT register gets a little tricky, since it rolls over in that amount of time.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-10-08 15:46
    Andrew,
    one thing you might want to look at: are there any opportunities for interference causing spurious counts? If you are getting a consistently higher-than-expected count, it might be due to pulses being picked up from your Propeller's environment. You also could be experiencing "ringing" of the signal in your leads to the pins. Or crosstalk between lines. I've been doing some frequency counting lately and I've found my protoboard to be extremely sensitive to wire positions, and the use of "T" junctions, etc. for my BNC connections. Also, check to see if your errors are affected by what sort of wave you test it with: for example does a square wave count differently than a sine wave? Also, does the amplitude of your test signal affect the count? Ringing caused by resonance in your lines is often affected by the shape of your test wave signal and/or the amplitude of that signal.

    You also might want to check the accuracy of your frequency meter, oscilloscope, etc. Being off by 1 percent wouldn't be unthinkable due to calibration or warm-up issues.

    cheers,
    Mark

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    It might be the Information Age but the Eon of Ignorance has yet to end.
  • Beau SchwabeBeau Schwabe Posts: 6,560
    edited 2008-10-08 16:00
    Andrew.G,

    Much of your result will depend on the circuit that you use on the "front-end" before the input and what kind of signal you have... saw-tooth, traingle, sine, square (<-and duty cycle?).. and how pure the signal is. Does it have multiple frequencies?

    The Propeller has a resolution of 12.5ns and .01 Hz is certainly attainable.

    For example:
    50.00 Hz at 12.5ns resolution would produce an 80MHz clock count of 1600000 ... actually half of that if you’re just looking at the time ON verses the time OFF.
    50.01 Hz at 12.5ns resolution would produce an 80MHz clock count of 1599680 ... actually half of that if you’re just looking at the time ON verses the time OFF.

    But as I mentioned, how you condition your signal also makes a big difference. Even at 12.5ns resolution, the difference of .01 Hz produces a point spread of only 160 clocks.

    It gets even worse as you go up in frequency...

    For example:
    100.00 Hz at 12.5ns resolution would produce an 80MHz clock count of 800000 ... actually half of that if you’re just looking at the time ON verses the time OFF.
    100.01 Hz at 12.5ns resolution would produce an 80MHz clock count of 799920 ... actually half of that if you’re just looking at the time ON verses the time OFF.

    Here at 12.5ns resolution, the difference of .01 Hz produces a point spread of only 40 clocks.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 10/8/2008 4:05:35 PM GMT
  • Andrew.GAndrew.G Posts: 5
    edited 2008-10-09 07:17
    Thanks for the replys,

    I was actually using the Synth object to generate my reference square wave signal. Originally i just checked it with a counter and found to be very accurate.
    However I never actually checked the signal waveform until now.

    I have found the the signal generated by the synth object actually contains a fair amount of harmonic distortion. Which may be one possible cause for error.

    As "ElectricAye" has mentioned interference may also be affecting desired results. I had performed a test where i was measuring the phsa value using a positive level counter mode on p0 of the demo board.

    i found placing my hand near ,within 20cm of the demo board and rubbing my feet on the floor actually caused the readings to spike even though i was using a 200 ohm pull down resistor with a 100nF cap parallel. albeit my floor is carpeted atm.

    I have an idea or two on alternative methods i may try to get around the issue of measuring low frequencies below 1Khz. will post result.

    Thanks for the hints n tips.
    regards.
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-10-09 12:33
    I recommend using the positive edge counter rather than the positive level counter. The positive edge counter is good for counting pulses, the positive level counter is better for measuring duty cycle or pulse width.

    I would program the Prop to take an initial reading to determine whether you are above or below a certain frequency, say 1 kHz for example.· If you are below that frequency, measure time between pulses.· If you are above that frequency, count the pulses over a time interval.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup

    Post Edited (Ken Peterson) : 10/9/2008 12:39:34 PM GMT
Sign In or Register to comment.