Skip to main content

sampler.getsampleratehz()

Returns the ADC’s current sampling rate

Availability

Device
Not available on the imp004m, imp005 or imp006

Returns

Float — the ADC’s sample rate in Hz

Description

This method provides the actual sample rate used by the sampler, which may not exactly equal the requested sample rate.

Because the sampler is driven from a 60MHz clock, the result will in all cases equal

local rate = 60000000.0 / math.floor(60000000.0 / f);

where f is the requested sample rate in Hz.

Sample rates which divide 60,000,000 exactly — such as 48,000 — are thus exact, whereas others may be fractionally out. For instance, attempting to sample at 44,100Hz will in fact sample at 44,117Hz, which is 400ppm or 0.04 per cent out. Note that the imp’s crystal timebase is only accurate to 30ppm or 0.003 per cent at the best of times.