• Support PF! Buy your school textbooks, materials and every day products via PF Here!

Sampling frequency and square waves

  • Thread starter Deathfish
  • Start date
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.
 

Ibix

Science Advisor
Insights Author
4,858
3,186
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.
 

CWatters

Science Advisor
Homework Helper
Gold Member
10,525
2,289
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".

http://en.wikipedia.org/wiki/Square_wave

For a reasonable approximation to the square-wave shape, at least the fundamental and third harmonic need to be present, with the fifth harmonic being desirable
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.
 

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top