PCsound card frequency resolution - Page 1
Forum section: electronics / general

author: Circlotron
author_rank: Super Contributor
timestamp: November 04, 2021, 05:07:18 am
content: Just musing about the possibilities of using a PC sound card to record a sine wave of varying frequency that represents an analog measured value. For a given sampling rate, is there a fundamental limit to how finely a frequency could be resolved? Assuming there would be some degree of sampling clock jitter, how much would this affect things. This is not a real project, just something that popped in to my head.

author: dtmouton
author_rank: Contributor
timestamp: November 04, 2021, 07:33:57 am
content: The state-of-the art converts can sample at 192 kHz with 24 bit resolution. The converter will be designed in such a way that it doesn't require a very expensive low-jitter clock. Audio Precision have books on there website that provide a lot of interesting information.

author: Berni
author_rank: Super Contributor
timestamp: November 04, 2021, 07:56:31 am
content: The resolution depends on your measurement method.Even a card that samples at 8KHz could measure the frequency of a signal down to the precision of nanoseconds if you are willing to average the signal for minutes, hours, days, years...etc. Frequency measurement has a tradeoff between speed and resolution.The jitter of the sample clock doesn't really matter unless you are trying to measure the phase noise of your sine wave- What matters is the absolute precision of the clock, if its running slow then all signals look faster. Typically this clock gets derived from some sort of crystal oscillator so you can assume about 20 to 100 ppm/°C of drift for it.If you want more precision then you can get a ovenised crystal oscillator, use that to generate a 1KHz calibration signal and feed that into the other stereo channel of the card. Then you can measure exactly how far off the sample rate is and correct for it. Any higher level of precision will require you to have an atomic clock or GPS disciplined oscillator.

author: RoGeorge
author_rank: Super Contributor
timestamp: November 04, 2021, 10:00:36 am
content: Quote from: Circlotron on November 04, 2021, 05:07:18 am- The sampling rate only gives the upper frequency limit. So, if your sound card can sample, for example, at maximum 44kSa/s (kilo samples per second), then the maximum frequency will be 22 kHz.- How finely can a frequency be resolved is given by the total number of samples from your sound card. For example, if you take 11 thousands of samples in total (at 44 kSa/s), each frequency bin will be 44000/11000 in width, so if you record 0.25 seconds of signal at 44 kSa/s you will be able to distinguish in theory 4 Hz.Now, if you have the time for a 10 seconds long record at 44kSa/s (so 440 000 samples in total), that will give you a bin width of 44 000 / 440 000 = 0.1 Hz.Clock jitter is different story, it was considered so far to be zero.As a very general rule, tomeasuresomething (and it doesn't matter what you measure, or how you measure) meansto compare with a reference unit(or etalon unit). From this definition it is clear that the final value you measure is affected by how good your reference is, and by how good is the process of comparing the reference with the value to measure.

author: NiHaoMike
author_rank: Super Contributor
timestamp: November 05, 2021, 01:13:25 am
content: Quote from: RoGeorge on November 04, 2021, 10:00:36 amI wonder if the finer frequency resolution of HD audio might in fact give a (small) audio quality improvement.

author: Berni
author_rank: Super Contributor
timestamp: November 05, 2021, 06:32:43 am
content: Quote from: NiHaoMike on November 05, 2021, 01:13:25 amThat can be quite a debate if going over 48KHz actually sounds better, offten depending on lots of factors like the shape of oversampling,reconstruction..etc filters and how well things have been resampled (alisased images etc). In my opinion higher sample rates are useful because they sidestep the problem of requiring good filters.I do have a DIY sound card that features a 192KHz 24bit ADC and DAC along with galvanic isolation from USB and differential inputs. It is meant as a piece of test equipment as it can see everything from 0Hz to 90KHz down to a noise floor of about -145dB and very little distortion. Pretty much like having a slow oscilloscope that can see volts and microvolts simultaneously. Tho i didn't pay much attention to the sample clock accuracy, it just has a decent quality crystal oscillator with proper clock distribution (Since its sigma delta so it is sensitive to phase noise)

author: Kleinstein
author_rank: Super Contributor
timestamp: November 05, 2021, 09:16:15 am
content: The frequency resolution depends a lot on the method used and the time interval. One can more or less use the methods of normal frequency counters:Simple counting of zero crossing, like an old classic counter gives a frequency resolution of 1/T.Simple zero crosssing detection and than reciprocal counting usually gives high resolution ( f_sample/ f / T).Fitting multiple zero crossing can improve on this a little.The highest resolution is optained from a least squares fit to the sine wave. This is especially an advantage of the signal has noise.The frequency resoltion usually improves wth 1/T or with the better method with 1/T to a power of 1.5.Jitter in the clock adds some noise. In some cases this can be quite high as some PCs use intentional clock dithering. In non dithering mode the jitter is usually acceptable low. A higher sampling rate has relatively little effect, kind of some averaging for amplitude and jitter. As jitter is often not white but with more low frequency part the gain from a higher sampling rate can be low. Amplitude noise often does not get much better (SD ADCs tend to just use different decimation). The reciprocal counting method is more effected by the sampling rate, the other methods are less effected. In some cases the additional filtering with a lower sampling rate may even be helpful.The clock of simply oscillators can dirft quite a bit, but short time the clock is usually reasonable good. I had implemented the Fit and a similar method to get some 9 digit resolution for 1 seconds measurment interval for a 1 kHz sine.

author: Circlotron
author_rank: Super Contributor
timestamp: November 05, 2021, 12:56:05 pm
content: Let's assume we had a perfect clock in our sound card. Dead accurate and zero jitter Sampling frequency is 44.1kHz.We record anexact1kHz sine wave. Maximum amplitude so noise is not a factor. At some random point during the playback we measure the time between two positive going zero crossings. If the post-DAC filtering is good enough, could we expect the time between the positive going zero crossings of thereconstructedsine wave to beexactly1mS? Or will it dither about some tiny amount because the 44.1kHz sampling frequency is not a multiple of the 1kHz recorded frequency?

author: TimFox
author_rank: Super Contributor
timestamp: November 05, 2021, 01:05:35 pm
content: An advantage of oversampling the original waveform is that reconstructing it from the samples is easier at higher oversample rates.

author: RoGeorge
author_rank: Super Contributor
timestamp: November 05, 2021, 01:28:36 pm
content: Quote from: Circlotron on November 05, 2021, 12:56:05 pmThat's too abstract to get a meaningful solution. Now that you are asking about zero crossing timing, maybe the frequency resolution is not so important after all.Better tell what you want to do exactly, preferably with a brief drawing, a schematic, or at least a block diagram.

author: Kleinstein
author_rank: Super Contributor
timestamp: November 05, 2021, 02:02:29 pm
content: Under the assumption that the signal is mainly the 1 kHz signal one can interpolate the position of the zero crossings very well, no extra error from the limited sampling frequency. Ideal interpolation would look at the whole set of sampled data and multiple periods. With a modern PC there should be no problem with the computing power to do this as fast as the data come in.With real hardware not all sampling frequenies may work ideal. The soundcard may need to do some interpolation to get a fine resolution on the sampling rates. So 48 kHz may be OK, but 47997 Hz sampling rate may be a bit more noisy.The amplitude noise is usually quite low with a sound card, but there is still some noise and this does translates to noise in the calculated frequency.The real world reconstruction / anti aliasing filter will also not be perfect (though pretty good with oversampling) - so there can be a small contribution of the aliased part. In this sense the slightly odd sampling frequency can matter.

author: ejeffrey
author_rank: Super Contributor
timestamp: November 05, 2021, 05:18:33 pm
content: Quote from: NiHaoMike on November 05, 2021, 01:13:25 amThe frequency resolution of an FFT only depends on the total measurement duration, not on anything else.However, if you want to measure the frequency of a known sine wave you can interpolate between bins and get much more precision in frequency estimation than suggested by the raw FFT resolution. How well you can do this depends on the signal to noise ratio. It doesn't directly depend on the sample rate but increasing the sample rate may or may not improve the SNR.