Enter 2.0 for the theoretical minimum (Nyquist Rate). Practical engineering often uses 2.2, 5.0, or 10.0.
Please enter a valid positive frequency.
Theoretical Minimum (Nyquist Rate):–
Recommended Sampling Rate:–
Nyquist Frequency (of Result):–
function calculateSamplingRate() {
var freqInput = document.getElementById('maxFrequency');
var unitSelect = document.getElementById('freqUnit');
var factorInput = document.getElementById('oversamplingFactor');
var resultBox = document.getElementById('srcResult');
var errorBox = document.getElementById('srcError');
var freqValue = parseFloat(freqInput.value);
var unitMultiplier = parseFloat(unitSelect.value);
var factorValue = parseFloat(factorInput.value);
// Validation
if (isNaN(freqValue) || freqValue <= 0) {
errorBox.style.display = 'block';
resultBox.style.display = 'none';
return;
}
if (isNaN(factorValue) || factorValue 2 * f_max
var nyquistRateHz = freqHz * 2;
// 3. Calculate Recommended Rate -> f_max * factor
var recommendedRateHz = freqHz * factorValue;
// 4. Calculate Nyquist Frequency of the recommended rate -> recommended / 2
var resultingNyquistFreqHz = recommendedRateHz / 2;
// Determine best unit for display
var displayUnit = "Hz";
var divisor = 1;
if (recommendedRateHz >= 1000000000) {
displayUnit = "GHz";
divisor = 1000000000;
} else if (recommendedRateHz >= 1000000) {
displayUnit = "MHz";
divisor = 1000000;
} else if (recommendedRateHz >= 1000) {
displayUnit = "kHz";
divisor = 1000;
}
// Format outputs
var nyquistDisplay = (nyquistRateHz / divisor).toLocaleString(undefined, {maximumFractionDigits: 3}) + " " + displayUnit;
var recDisplay = (recommendedRateHz / divisor).toLocaleString(undefined, {maximumFractionDigits: 3}) + " " + displayUnit;
var resNyquistFreqDisplay = (resultingNyquistFreqHz / divisor).toLocaleString(undefined, {maximumFractionDigits: 3}) + " " + displayUnit;
// Special case: if user selected a unit, maybe force that unit?
// Current logic auto-scales. Let's stick to auto-scaling for readability,
// but ensure the unit matches the magnitude.
document.getElementById('resNyquist').innerHTML = nyquistDisplay;
document.getElementById('resRecommended').innerHTML = recDisplay;
document.getElementById('resNyquistFreq').innerHTML = resNyquistFreqDisplay;
resultBox.style.display = 'block';
}
How to Calculate Sampling Rate from Frequency
Calculating the correct sampling rate is a fundamental step in digital signal processing (DSP), data acquisition, and audio engineering. The sampling rate determines how often an analog signal is measured to convert it into a digital sequence. If the rate is too low, the signal cannot be reconstructed correctly, leading to a distortion phenomenon known as aliasing.
The Nyquist-Shannon Sampling Theorem
The core principle governing this calculation is the Nyquist-Shannon sampling theorem. It states that to perfectly reconstruct a continuous signal from its samples, the sampling frequency ($f_s$) must be greater than twice the highest frequency component ($f_{max}$) present in the signal.
fs > 2 · fmax
Here:
fs is the Sampling Rate (Samples per second).
fmax is the highest frequency in the analog signal (Bandwidth).
Step-by-Step Calculation Logic
To calculate the required sampling rate manually, follow these steps:
1. Identify the Maximum Frequency (fmax)
Analyze the signal source to determine the highest frequency it contains. For example, the range of human hearing typically spans from 20 Hz to 20,000 Hz (20 kHz). Therefore, $f_{max}$ is 20 kHz.
2. Calculate the Nyquist Rate
Multiply the maximum frequency by 2. This is the absolute theoretical minimum required to capture the signal without aliasing.
Example: 20 kHz × 2 = 40 kHz.
3. Apply an Oversampling Factor
In the real world, "perfect" filters do not exist. If you sample exactly at the Nyquist rate, separating the signal from the sampling artifacts requires a filter with an infinitely steep slope (a "brick-wall" filter), which is physically impossible. To accommodate real-world analog-to-digital converters (ADCs), engineers use a sampling rate slightly higher than the Nyquist rate.
Common oversampling factors:
Audio (CDs): The standard is 44.1 kHz. Since $f_{max}$ is 20 kHz, the Nyquist rate is 40 kHz. The extra 4.1 kHz allows for a transition band for anti-aliasing filters.
Oscilloscopes: Digital oscilloscopes often sample at 2.5x to 5x the bandwidth to accurately capture waveform shapes, not just frequency content.
Why is Oversampling Important?
Using a sampling rate higher than the minimum reduces the complexity and cost of the analog anti-aliasing filters required before the ADC. It also improves the signal-to-noise ratio (SNR) and helps in accurately reconstructing the shape of non-sinusoidal waves (like square waves) in time-domain analysis.
Example Calculation: Vibration Analysis
Suppose you are analyzing machinery vibration where the critical data exists up to 2,500 Hz.
Identify fmax: 2,500 Hz.
Minimum Rate: 2,500 Hz × 2 = 5,000 Hz (5 kS/s).
Recommended Rate: For better waveform resolution, you might choose a factor of 2.56 (common in vibration analysis). 2,500 Hz × 2.56 = 6,400 Hz.