Library / Signal processing and digital filters / DSP-01
Signal processing and digital filters
Sample of a phase-offset sinusoid
Value of sample n of a sampled sinusoid of peak amplitude A and frequency f, taken at sampling rate fs, with initial phase φ in radians.
- Ref
- DSP-01
- Rev
- v1
- Field
- Signal processing and digital filters
- Result
- x[n] [V]
Sampling a cosine of frequency f at rate fs puts sample n at time t = n/fs, so its phase has advanced by 2πfn/fs radians since the start, and x[n] = A cos(2πfn/fs + φ). Each sample advances the phase by the fixed step 2πf/fs. If f is above fs/2 the samples are identical to those of a lower alias frequency.
Value of sample n of a sampled sinusoid of peak amplitude A and frequency f, taken at sampling rate fs, with initial phase φ in radians. Sampling begins at t = 0. For an unambiguous baseband representation use 0 ≤ f < fs/2.
Calculator
- Phase advance per sample, 2πf/fs0.7854 rad
- Samples per cycle, fs/f8 samples
- Total phase at this sample, 2πfn/fs + φ1.085 rad
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.
- Sample 1 of this tone is 0.9331 V, 46.7 % of the peak amplitude of 2 V.
- There are 8 samples per cycle, comfortably above the minimum of 2 required to avoid aliasing.
Chart data as tables
Ranked variables
| Variable | Typical range | Lowest result | Highest result | Swing (V) | Local step | Change in result |
|---|---|---|---|---|---|---|
| A Peak amplitude | 0.001 to 100 V | 4.666e-4 | 46.66 | 46.66 | +10% | +10 % |
| φ Initial phase | −3.142 to 3.142 rad | −1.997 | 1.997 | 3.995 | +0.12566370600000001 rad | −24.5 % |
| fs Sampling rate | 10 to 1,000,000 Hz | −1.911 | 2 | 3.911 | +10% | +13.3 % |
| f Signal frequency | 1 to 100,000 Hz | −1.994 | 1.911 | 3.905 | +10% | −15.2 % |
| n Sample index | 0 to 1,000 | −1.911 | 1.911 | 3.821 | +1 | −163 % |
Sweep of Sample index
| Sample index | Sample value (V) |
|---|---|
| 0 | 1.911 |
| 125 | −0.9331 |
| 250 | −0.591 |
| 375 | 1.769 |
| 500 | −1.911 |
| 625 | 0.9331 |
| 750 | 0.591 |
| 875 | −1.769 |
| 1,000 | 1.911 |
Sweep one variable
Variables and how each one contributes
Sample value
What the equation gives you. Everything else feeds it.
Peak amplitude
The peak amplitude of the sinusoid, in V. Scales every sample in direct proportion. Raising it by 10 % (to 2.2) moves the result by +10 %, from 0.9331 to 1.026 V.
Signal frequency
The signal frequency, in Hz. A higher frequency advances the phase faster per sample; above fs/2 it aliases. Raising it by 10 % (to 137.5) moves the result by −15.2 %, from 0.9331 to 0.7915 V.
Sample index
The sample index, counted from zero. Moves along the waveform; the pattern repeats every fs/f samples. Raising it by 10 % (to 1.1) moves the result by +0 %, from 0.9331 to 0.9331 V.
Sampling rate
The sampling rate, in Hz. A higher rate gives a smaller phase step per sample and a smoother sampled waveform. Raising it by 10 % (to 1,100) moves the result by +13.3 %, from 0.9331 to 1.057 V.
Initial phase
The initial phase at t = 0, in radians. Shifts the whole waveform in time without changing its shape. Raising it by 10 % (to 0.33) moves the result by −5.73 %, from 0.9331 to 0.8796 V.
Worked example with the values above
- Phase step per sample: 2πf/fs = 2π × 125 / 1,000 = 0.7854 rad.
- Phase at n = 1: 0.7854 × 1 + 0.3 = 1.0854 rad.
- x[n] = A cos(…) = 2 × 0.46656 = 0.93312 V.
Assumptions and limits
- Uniform sampling at a fixed, known rate with a clean, stable clock unless the page names a jitter term.
- Ideal, linear converters and a signal that stays inside full scale.
Common mistakes
- Using a frequency above fs/2, which aliases to a different baseband frequency.
- Mixing hertz with radians per second or rad/sample.
- Counting jitter or quantisation as the only noise source and forgetting thermal and clock noise.
Statistics and uncertainty
Real converters add offset, gain error, nonlinearity and thermal noise to the ideal quantisation and jitter limits, so a measured SNR is typically 3 dB to 10 dB below the ideal figure. Treat these formulas as upper bounds on performance.
Where it is used
- Generating test signals and predicting what a converter can resolve.
- Choosing a sampling rate, a bit depth and a clock source for an acquisition chain.
Maths you need
- Sampling theorem: a signal bandlimited below fs/2 is fully described by its samples
- Decibel: dB = 20 log₁₀ of an amplitude ratio
- Nyquist frequency: half the sampling rate