Capture: sampling and windows
The “Capture” block sets the sampling rate of the four microphone signals and the length of the block of samples (window) transferred to the computer. These parameters determine the operating frequency band, the frequency resolution, the result update rate and the fraction of time during which the signal is available for processing.
Capture parameters
| Parameter | Values | Determines |
|---|---|---|
| Sampling rate fs | 7.81–48.83 kHz (8 values) | Upper band limit fs/2; amount of transferred data |
| Window length W | 256, 512, 1024, 2048 samples | Window duration W/fs; frequency resolution fs/W; window transfer time |
| Pause between windows | 0–5000 ms | Window request period (0 — no pause) |
| Test generator | on/off | Replacement of the microphone signals by a deterministic sequence |
The parameters can be changed only while the measurement is stopped. A configuration is rejected if the current filter cannot be realized at the new fs (a filter cutoff frequency exceeds fs/2).
Sampling and quantization
Sampling is the representation of a continuous signal x(t) by the sequence of its values at the time instants t = n·T, where T = 1/fs is the sampling period. Quantization is the representation of each value (sample) by a number of finite word length.
- At fs = 16,276 Hz the sampling period is 61.4 µs.
- Sample word length is 24 bits (two's complement, range −8,388,608…+8,388,607). Levels are given in dBFS (decibels relative to full scale) with respect to the maximum value 223.
- The self-noise level of the INMP441 microphone is about −80 dBFS; the effective resolution is approximately 15 bits.
Fig. 1. A 1 kHz sinusoid and its samples at fs = 8 kHz.
Sampling theorem (Kotelnikov — Nyquist — Shannon). A band-limited signal is uniquely reconstructed from its samples if its spectrum contains no components above fs/2 (the Nyquist frequency). After sampling, a component of frequency f > fs/2 is indistinguishable from a component of frequency |f − k·fs| in the range 0…fs/2. This phenomenon is called aliasing.
Fig. 2. Aliasing: the samples of a 7 kHz signal at fs = 8 kHz coincide with the samples of a 1 kHz signal (|7 − 8| = 1 kHz; phase inverted).
Sampling rates
The I2S bit clock (SCK) is generated by the FPGA by dividing the 50 MHz reference frequency. An I2S frame contains 64 SCK cycles (32 cycles for each of the left and right channels), so fs takes a discrete set of values:
| fs, kHz | fs/2, kHz | Application |
|---|---|---|
| 48.83 | 24.4 | Full audio range and high-frequency components; largest amount of data |
| 39.06; 32.55 | 19.5; 16.3 | Full operating range of the microphone (up to 15 kHz) |
| 24.41 | 12.2 | Speech, mechanical noise; continuous single-channel stream with 24-bit resolution |
| 16.28 | 8.1 | Default value; engines, machinery, speech |
| 12.21; 10.56 | 6.1; 5.3 | Low-frequency sources; 10.56 kHz is the maximum for continuous four-channel recording (16 bits) |
| 7.81 | 3.9 | Low-frequency components; largest fraction of the signal available for processing |
All microphones share the SCK and WS signals; the samples of the four channels belong to the same I2S frame. The channels are synchronous, which is required for cross-correlation analysis and direction-of-arrival estimation.
Data path
I2S, 24 bits→ FPGA
packing: 12 bytes per sample→ FIFO
2048 words × 96 bits→ UART
1 Mbit/s, 8N2→ CH340C
USB→ fpgad
The exchange is initiated by the computer: a command (5-byte frame) requests one window. The FPGA acknowledges the
command and then transmits the header AA 55 AA 55, the window number, the loss counter (2 bytes each) and
W samples of 12 bytes (4 channels × 3 bytes). A window is accepted if exactly 12·W + 8 bytes are received.
Windowed mode
The windowed mode is used because the data rate required for a continuous stream exceeds the channel capacity:
fs = 48.83 kHz: Rreq = 585,938 bytes/s = 6.4·RUART
fs = 16.28 kHz: Rreq = 195,313 bytes/s = 2.1·RUART
fs = 7.81 kHz: Rreq = 93,750 bytes/s = 1.03·RUART
Continuous transfer of four 24-bit channels is impossible at any value of fs. Therefore the FPGA operates in single-shot capture mode:
- on command, W consecutive samples of all channels are written into the FIFO buffer at the rate fs;
- transfer of samples from the FIFO to the UART starts immediately after the first sample is written and proceeds at the channel rate;
- after receiving the window, the computer processes it and requests the next window.
Within a window the samples follow without gaps and the channels are synchronous. Between windows the signal is not acquired.
Fig. 3. Timing diagram of the windowed mode based on measurements: signal acquisition and window transfer intervals.
Channel rate. The CH340C USB-UART converter loses data at 2 Mbit/s; at 1.5 Mbit/s rare losses occur in blocks aligned to USB packet boundaries (32 bytes). The operating rate is 1 Mbit/s. Incomplete windows (on average one in 150–300) are detected by their length and excluded from processing; their number is displayed as an error counter.
Maximum window length. The FIFO buffer of 2048 × 96 bits = 196,608 bits occupies 24 of the 30 M9K embedded memory blocks of the EP4CE6 FPGA. This limits the window length to 2048.
Streaming mode. Listening and continuous recording use a streaming mode with reduced data volume: one channel (16 bits — up to 43 kHz, 24 bits — up to 28.8 kHz) or four 16-bit channels at fs up to 10.8 kHz.
Timing characteristics
duty factor η = Twin / Tcycle
Tex includes command transmission, acknowledgement and window processing. Measurement results:
| fs, kHz | W | Twin, ms | Ttx, ms | Tcycle, ms | Windows/s | η |
|---|---|---|---|---|---|---|
| 48.83 | 2048 | 42 | 270 | 300 | 3.3 | 14 % |
| 48.83 | 256 | 5 | 34 | 39 | 25.6 | 13 % |
| 24.41 | 512 | 21 | 68 | 81 | 12.3 | 26 % |
| 16.28 | 1024 | 63 | 135 | 152 | 6.6 | 41 % |
Ttx does not depend on fs, while Twin is inversely proportional to fs. Consequently, the duty factor η increases as fs decreases. If the spectrum of the signal under study is limited to 8 kHz, fs = 16.28 kHz is preferable.
Window length
| Characteristic | W = 256…512 | W = 1024…2048 |
|---|---|---|
| Result update rate | 10–25 windows/s | 2–7 windows/s |
| Frequency resolution fs/W at fs = 16.28 kHz | 64…32 Hz | 16…8 Hz |
| Number of periods of low-frequency components in a window | small | large |
| Fraction of the window occupied by the filter transient | large | small |
| Accuracy of direction-of-arrival estimation | low | high |
The frequency resolution of the discrete Fourier transform of a window of length W equals fs/W: components separated by less than fs/W are not resolved. The accuracy of direction estimation is determined by the window duration W/fs, so W = 2048 and fs = 10.56…24.41 kHz are preferable for it.
Pause and test generator
The pause between windows increases the window request period and does not affect window contents. It is used for long-term monitoring to reduce the load.
The test generator replaces the microphone signals by sequences generated in the FPGA: ch0 — sample counter (increment 1); ch1 — counter with inverted sign; ch2 — constant 0x123456; ch3 — the low byte of the counter repeated in the three bytes of the word. The sequences make it possible to verify the integrity of the data path: loss or shift of bytes breaks the counter increment. In this mode dBFS levels have no physical meaning.
Choosing a mode
| Task | fs, kHz | W |
|---|---|---|
| Level monitoring | 16.28 | 1024 |
| Sources with bandwidth up to 2–4 kHz (engines, machinery) | 10.56…16.28 | 1024–2048 |
| High-resolution spectral analysis | 7.81…16.28 | 2048 |
| Direction-of-arrival estimation | 10.56…24.41 | 2048 |
| Acquisition of fast level changes | 16.28…24.41 | 256–512 |
| Analysis of high-frequency components (up to 24 kHz) | 39.06…48.83 | as required |
| Data path verification | any | any; test generator |