Back to the 2025 paper

Module 5: Data Processing

20257m

A DAQ system samples 4 channels simultaneously at 25 kS/s per channel. Each sample is 12 bits. The microcontroller writes data to an SD card via SPI at 12 Mbps. The SD card uses 512-byte sectors and write operations must be in whole sectors. The MCU packs samples channel-wise into frames and writes continuously.
(i) Compute the raw data rate in Mbps and the required sustained write throughput in MB/s (account for packing).
(ii) Design a framing strategy: pack samples into 512-byte sectors with minimal wasted space—compute how many samples per sector and how many sectors per second must be written.

Worked SolutionAI Assisted

Solution: Multichannel DAQ Data Rate and SD-Card Framing

Given:

  • Number of channels = 4
  • Sampling rate per channel = 25 kS/s
  • ADC resolution = 12 bits/sample
  • SPI rate to SD card = 12 Mbps
  • Sector size = 512 bytes

(i) Raw Data Rate

Total samples per second across all channels:

4×25,000=100,000 samples/s4\times25,000=100,000\text{ samples/s}

Each sample contains 12 bits, so:

Rraw=100,000×12=1,200,000 bits/sR_{raw}=100,000\times12=1,200,000\text{ bits/s}

Therefore:

Rraw=1.2 Mbps\boxed{R_{raw}=1.2\text{ Mbps}}

In bytes/s:

1,200,0008=150,000 bytes/s\frac{1,200,000}{8}=150,000\text{ bytes/s}

So:

Rraw=0.15 MB/s\boxed{R_{raw}=0.15\text{ MB/s}}

Account for packing

Because SD-card writes are byte-addressable, 12-bit samples cannot simply occupy 12 bits independently unless the firmware packs them.

A convenient packing scheme stores two 12-bit samples in 3 bytes:

2×12=24 bits=3 bytes2\times12=24\text{ bits}=3\text{ bytes}

Thus efficient packing produces exactly the theoretical raw rate of 0.15 MB/s, excluding filesystem and protocol overhead.

The available SPI bandwidth is:

12 Mbps=1.5 MB/s12\text{ Mbps}=1.5\text{ MB/s}

Therefore the nominal raw data rate is only:

0.151.5=10%\frac{0.15}{1.5}=10\%

of the stated SPI link capacity, leaving substantial bandwidth margin.

(ii) 512-Byte Sector Framing

A 512-byte sector contains:

512×8=4096 bits512\times8=4096\text{ bits}

With 12-bit samples, the maximum number of complete samples is:

409612=341 samples\left\lfloor\frac{4096}{12}\right\rfloor=341\text{ samples}

341 samples use:

341×12=4092 bits=511.5 bytes341\times12=4092\text{ bits}=511.5\text{ bytes}

So one sector can contain 341 complete 12-bit samples if the packing is bit-level, leaving:

40964092=4 bits4096-4092=4\text{ bits}

unused.

However, a cleaner byte-aligned scheme is to pack 340 samples:

340×12=4080 bits=510 bytes340\times12=4080\text{ bits}=510\text{ bytes}

leaving exactly 2 bytes for metadata, a timestamp, frame counter, CRC, or padding.

Recommended framing

Use 340 samples per 512-byte sector and reserve 2 bytes for metadata, or use a 341-sample bit-packed payload with 4 unused bits plus a defined header/trailer.

At 100,000 samples/s:

100,000340=294.12 sectors/s\frac{100,000}{340}=294.12\text{ sectors/s}

Thus the system needs approximately:

295 sectors/s\boxed{295\text{ sectors/s}}

with 340 samples/sector, ignoring additional metadata.

For maximum packing efficiency using 341 samples/sector:

100,000341=293.26 sectors/s\frac{100,000}{341}=293.26\text{ sectors/s}

so approximately 294 sectors/s are required.

Final Answer

  • Raw data rate: 1.2 Mbps = 0.15 MB/s
  • SPI capacity: 12 Mbps = 1.5 MB/s
  • Maximum complete 12-bit samples in 512 bytes: 341 samples
  • Efficient practical framing: 340 samples + 2 bytes metadata/padding
  • Sectors/s: approximately 295 sectors/s for 340-sample frames, or 294 sectors/s with 341-sample bit packing.

The stated SPI bandwidth is comfortably sufficient for the raw acquisition rate.

Similar questions