Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Determining the Fundamental Frequency Component

  1. Feb 1, 2017 #1
    Suppose you periodically receive samples of a periodic waveform at fixed instances in time Δt. It is known ahead of time that the periodic waveform will have a fundamental frequency component of 50Hz or 60Hz, but perhaps with some higher order harmonics present.

    What is the easiest way to go about determining the peak value of the fundamental frequency component of the waveform from the samples?

    I suppose by buffering a number of samples and preforming a DFT one could retrieve the fundamental frequency component, and from there I could use a low pass filter with a large time constant to recover the peak value.

    Is there an easier way?
  2. jcsd
  3. Feb 1, 2017 #2


    User Avatar
    Homework Helper
    Gold Member

    To me, DFT sounds like the easiest way. I did a project on ac power measurement on arduino with the exact same method.
  4. Feb 1, 2017 #3
    Hopefully you're Δt is not a multiple of 300Hz. If it is, then 50Hz, 60Hz, and DC will be indistinguishable.
    The optimum solution depends hugely on what your processing environment is, how many samples you want to collect, how stable your Δt, 50Hz, and 60Hz are, your Δt, and whether your samples are digital or analog.

    Let's say that your Δt is 7msec, your sampling is 10-bit adc, you want a decision in 500msec, your DC component is zero, and you want to be stingy with processor resources. What I would suggest is to set up 8 bins, 4 for 50Hz (bins F), 4 for 60Hz (bins S). Within each frequency, the bins will represent phase angles of 0, 45, 90, and 135 degrees. Take the first sample to be at a phase of 0 degrees for both 50Hz and 60Hz and so add that sample to bins F0 and S0. The next sample will be at 7msec.

    The S Bin period is 16.66msec (1000/60) so 7msec represents 7/(1000/60) 60Hz cycles (0.42 cycles). The number of 45-degree bin increments would be eight times that (3.36 bin increments). To keep track of this bin position, we will initialize an S Bin Phase counter to 0, then on each sample increment it by 336 and compute the increment by doing an integer divide by 100. So for the first 5 samples we would have phase counter values of 0, 336, 672, 1008, and 1344 and bin numbers of 0, 3, 6, 10, and 13. Eight bin counts is 360 degrees, so every time the phase count exceeds 800, we can subtract 800 from it. This makes the phase counts 0, 336, 672, 208, and 544 and the bin increments 0, 3, 6, 2, and 5. The reason we only need four bins is because we will add the sample when it is bins 0 to 3, and subtract the sample when it is 4 to 7. So the first sample (bin increment 0) is added to S0, the second (3) is added to S3 (the 135-degree bin), the 3rd (6) is subtracted from S2, the 4th (2) is added to S2, and the 5th (5) is subtracted from S1.

    The F Bin period is 20msec (1000/50) so 7msec represents 7/20 50Hz cycles (0.35 cycles). The number of 45-degree bin increments would be eight times this (2.80 bin increments).
    So for 50Hz, we will add 280 to the phase count each time, force the phase count to the range 0 to 799, and compute the increment by doing an integer divide by 100. The first 5 phase counts would thus be 0, 280, 560, 40, and 320 and the increments would be 0, 2, 5, 0, and 3. So the sample would be: added to F0, added to F2, subtracted from F1, added to F0, and added to F3.

    Once all of the sample have been collected, a simple and crude method for determining if there is a 50Hz and/or 60Hz component would simply be to take the absolute value of each of the 8 bins, then take the largest value of F0, F1, F2, F3 as proportional to the amplitude of the 50Hz component and the largest value of S0, S1, S2, S3 as proportional to the amplitude of the 60Hz component.
  5. Feb 1, 2017 #4


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

    Getting unequivocal answers from sparse samples can be a problem. If you have any side information about the possible frequency range of the signal you're looking for - perhaps choosing between spot frequency possibilities then it can be a good idea to choose your sample frequency such that it is not harmonically related.
    As .scott says, the detail of the situation are important if you want to make the right choice.
  6. Feb 4, 2017 #5


    User Avatar
    Gold Member

    As the second harmonic will be 100 or 120Hz it is easily separated. So why not pass the unknown waveform through a LPF to remove harmonics and use a voltmeter?
  7. Feb 4, 2017 #6


    User Avatar
    Science Advisor

    The best way to identify the fundamental frequency will depend on the choice of dt.
    Who gets to select dt. What range of values might dt take?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted