Back to the 2025 paper

Module 5: Data Processing

20257m

Describe various data storage options available in microcontroller systems and explain how data can be logged or stored using programming techniques.

Worked SolutionAI Assisted

Solution: Data Storage Options and Data Logging

Data Storage Options

Storage Nature Typical use
SRAM Volatile, fast Temporary buffers
EEPROM Non-volatile Calibration/configuration data
Internal Flash Non-volatile Firmware and small datasets
External Flash Non-volatile Larger embedded storage
SD card Removable, high capacity Continuous data logging
USB/Computer External Long-term transfer/storage

Data Logging Process

Sensor → ADC → MCU → RAM Buffer → Storage Interface → File/Memory

Steps

  1. Initialize the sensor and ADC.
  2. Configure the sampling timer.
  3. Acquire a sample at every sampling instant.
  4. Convert the ADC code into the required format.
  5. Add a timestamp or channel identifier when necessary.
  6. Store samples in a RAM buffer.
  7. When the buffer is sufficiently full, write a block to non-volatile storage.
  8. Repeat until logging ends.

Why Buffering is Important

Storage devices such as SD cards may have variable write latency. A RAM buffer allows acquisition to continue while data is being written in blocks.

Example Pseudocode

while (logging)
{
    sample = read_adc();
    buffer[index++] = sample;

    if (index == BUFFER_SIZE)
    {
        storage_write(buffer, BUFFER_SIZE);
        index = 0;
    }
}

A real implementation should also handle write failures, buffer overflow, timestamps, file-system errors and safe shutdown.

Storage Selection

  • Use EEPROM for small calibration/configuration data.
  • Use Flash for firmware and moderate non-volatile data.
  • Use SD cards for large continuous logs.
  • Use computer/USB/network storage when very large datasets must be transferred or archived.

Conclusion

Efficient data logging depends on selecting suitable storage, using buffering and ensuring that the sustained storage throughput is greater than the incoming data rate.

Similar questions