Library / Signal processing and digital filters / DSP-17
Signal processing and digital filters
Tone phase from sine and cosine projections
Phase of a coherent tone at interior bin k in the form A cos(θn + φ), from the sine and cosine projections of the first N samples (up to 8 here), taken relative to sample zero.
- Ref
- DSP-17
- Rev
- v1
- Field
- Signal processing and digital filters
- Result
- φ [rad]
For a tone A cos(θn + φ) with θn = 2πkn/N, the sums Σx cos θn = (AN/2) cos φ and Σx sin θn = −(AN/2) sin φ for a coherent tone at an interior bin. So φ = atan2(−Σx sin θn, Σx cos θn), relative to sample zero, and the amplitude is 2√(sc² + ss²)/N. An absent tone has no meaningful phase.
Phase of a coherent tone at interior bin k in the form A cos(θn + φ), from the sine and cosine projections of the first N samples (up to 8 here), taken relative to sample zero. A tone that is absent (both sums zero) has no meaningful phase.
Calculator
- Cosine projection, Σ x cos θ2 V
- Sine projection, Σ x sin θ−2 V
- Tone amplitude, 2√(sc² + ss²)/N1.414 V
What drives the result
Each variable is moved across its typical range while the others stay at the values above. The longest bar is the key driver.
- The tone has a phase of 0.7854 rad (45°) relative to sample zero, and an amplitude of 1.414 V.
- The phase is measured against the record start, so a delay of d samples changes it by −2πkd/N; compare two channels over the same record.
Chart data as tables
Ranked variables
| Variable | Typical range | Lowest result | Highest result | Swing (rad) | Local step | Change in result |
|---|---|---|---|---|---|---|
| x0 Sample 0 | −10 to 10 V | 0.1799 | 2.923 | 2.743 | +0.4 V | −11.5 % |
| x1 Sample 1 | −10 to 10 V | −1.352 | 1.391 | 2.743 | +0.4 V | −14.1 % |
| x2 Sample 2 | −10 to 10 V | 0.1799 | 2.923 | 2.743 | +0.4 V | +14.1 % |
| x3 Sample 3 | −10 to 10 V | −1.352 | 1.391 | 2.743 | +0.4 V | +11.5 % |
| k Bin index | 1 to 7 | −1.571 | 0.7854 | 2.356 | +1 | −300 % |
| N Record length | 2 to 8 samples | 6.123e-17 | 1.963 | 1.963 | +1 samples | +60 % |
| x4 Sample 4 | −10 to 10 V | 0.7854 | 0.7854 | 0 | +0.4 V | 0 % |
| x5 Sample 5 | −10 to 10 V | 0.7854 | 0.7854 | 0 | +0.4 V | 0 % |
| x6 Sample 6 | −10 to 10 V | 0.7854 | 0.7854 | 0 | +0.4 V | 0 % |
| x7 Sample 7 | −10 to 10 V | 0.7854 | 0.7854 | 0 | +0.4 V | 0 % |
Sweep of Sample 1
| Sample 1 (V) | Tone phase (rad) |
|---|---|
| −10 | 1.391 |
| −7.5 | 1.34 |
| −5 | 1.249 |
| −2.5 | 1.052 |
| 0 | 0.4636 |
| 2.5 | −0.6435 |
| 5 | −1.107 |
| 7.5 | −1.272 |
| 10 | −1.352 |
Sweep one variable
Variables and how each one contributes
Tone phase
What the equation gives you. Everything else feeds it.
Record length
The number of samples, up to 8 here. Sets the angle step 2πk/N and the normalisation. Raising it by 10 % (to 4.4) moves the result by +0 %, from 0.7854 to 0.7854 rad.
Bin index
The bin index of the tone. Sets how many cycles the tone completes in the record. Raising it by 10 % (to 1.1) moves the result by +0 %, from 0.7854 to 0.7854 rad.
Sample 0
The sample at index 0, in V (ignored if 0 ≥ N). Adds to the cosine and sine projections with weights cos and sin of 2πk0/N. Raising it by 10 % (to 1.1) moves the result by −3.1 %, from 0.7854 to 0.761 rad.
Sample 1
The sample at index 1, in V (ignored if 1 ≥ N). Adds to the cosine and sine projections with weights cos and sin of 2πk1/N. Raising it by 10 % (to −1.1) moves the result by +3.1 %, from 0.7854 to 0.8098 rad.
Sample 2
The sample at index 2, in V (ignored if 2 ≥ N). Adds to the cosine and sine projections with weights cos and sin of 2πk2/N. Raising it by 10 % (to −1.1) moves the result by −3.1 %, from 0.7854 to 0.761 rad.
Sample 3
The sample at index 3, in V (ignored if 3 ≥ N). Adds to the cosine and sine projections with weights cos and sin of 2πk3/N. Raising it by 10 % (to 1.1) moves the result by +3.1 %, from 0.7854 to 0.8098 rad.
Sample 4
The sample at index 4, in V (ignored if 4 ≥ N). Adds to the cosine and sine projections with weights cos and sin of 2πk4/N. Raising it by 10 % (to 0) moves the result by +0 %, from 0.7854 to 0.7854 rad.
Sample 5
The sample at index 5, in V (ignored if 5 ≥ N). Adds to the cosine and sine projections with weights cos and sin of 2πk5/N. Raising it by 10 % (to 0) moves the result by +0 %, from 0.7854 to 0.7854 rad.
Sample 6
The sample at index 6, in V (ignored if 6 ≥ N). Adds to the cosine and sine projections with weights cos and sin of 2πk6/N. Raising it by 10 % (to 0) moves the result by +0 %, from 0.7854 to 0.7854 rad.
Sample 7
The sample at index 7, in V (ignored if 7 ≥ N). Adds to the cosine and sine projections with weights cos and sin of 2πk7/N. Raising it by 10 % (to 0) moves the result by +0 %, from 0.7854 to 0.7854 rad.
Worked example with the values above
- Cosine sum: Σ x cos θ = 2; sine sum: Σ x sin θ = −2.
- Ratio: −Σ x sin θ over Σ x cos θ = 2 / 2.
- φ = atan2(2, 2) = 0.7854 rad, or 45°.
Assumptions and limits
- A stationary signal with a tone of constant amplitude and frequency, and a record that holds a whole number of cycles for the coherent formulas.
- A single, well-isolated spectral peak for interpolation, and a bandwidth that is stated.
Common mistakes
- Using these coherent formulas on a record with a non-integer number of cycles.
- Adding noise or a DC offset into the harmonic sum.
- Using a peak that is not the largest of its three neighbouring bins in the parabolic interpolation.
Statistics and uncertainty
Tone amplitude and phase from a single FFT line are accurate to a fraction of a per cent only for a coherent record; for a non-coherent tone, scalloping loss of up to 3.9 dB (rectangular window) or 1.4 dB (Hann) adds error unless it is corrected.
Where it is used
- Measuring amplitude, phase and distortion of tones in an FFT record.
- Refining a frequency estimate without a longer record.
Maths you need
- Coherent sampling: a whole number of signal cycles in the record
- Spectral peak: a local maximum in the spectrum
- Parseval’s theorem: power in the time domain equals power in the frequency domain