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

Homework Help: Sampling frequency and square waves

  1. Jul 18, 2012 #1
    1. The problem statement, all variables and given/known data

    Lets say I have a square wave of 10Hz. I want a good sampling frequency or the Nyquist rate (minimum) to accurately capture its characteristics without aliasing. Is it enough to use 10Hz x 2 as nyquist rate, or must I break it down into harmonic frequencies? and use maximum harmonic frequency as the sampling rate?

    What if I do not use the square wave function, but instead sum together harmonic frequencies? Do i still use Fmax as 10 Hz, or use the highest harmonic frequency as Fmax?

    2. Relevant equations

    sin 2πft + 1/3 sin 2π3ft + 1/5 sin 2π5ft +1/7 sin 2π7ft ...

    am asking that if i use eg. 4 harmonics, must I use Fmax = 70Hz ?
    or if i sum together 20 harmonics and use Fmax = 10Hz can i still preserve the signal.
    (not necessarily using 2 x Fmax - nicer shape plot may use 10 x Fmax.)

    3. The attempt at a solution

    something to do with too few sampling points not being able to reproduce shape of square waves and instead getting it wrong. But not sure whether this affects the frequency information extracted during plotting. not sure how summing together harmonics affects result.
  2. jcsd
  3. Jul 18, 2012 #2


    User Avatar
    Science Advisor

    I'm afraid I don't think that your question is well specified. The answer depends very much on what information you have and what information you need to know.

    For example, if you already know you've got a 10Hz square wave, the only question remaining is when the discontinuities occur (i.e. the phase, if that's a well defined term for a square wave). Off the top of my head, I can think of two ways to do that.

    If you know you've got a 10Hz wave, but don't know the form then you need a different strategy.

    If you don't know the frequency but do know that it's a square wave then you need a different strategy; if you have an idea of the frequency (<100Hz, for example), there's a different strategy again.

    If you can specify your question more precisely, the answer might come to you and/or we might be able to help more.
  4. Jul 18, 2012 #3


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    In theory a square wave is made up of an infinite number of odd harmonics. So the issue is determining how many you need to meet your definition of "accurately capture its characteristics".


    You can probably find (or plot using a spreadsheet) a picture of what a square wave looks like when built from only "n" harmonic sine waves.

    If the rise time of the square wave is known and important it should be possible to calculate how the accurately the rise time of a reconstruction built from n harmonics matches. At least over say 10-90% of the amplitude. You could probably also calculate the magnitude of any under/overshoot. Been 35 years since I did anything like that.

    You will need to sample at at least twice the required highest harmonic.

    Sampling theory is a subject in it's own right.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook