Back to the 2025 paper

Module 4: DAQ Systems

20257m

Describe hardware communication interface programming used to connect data loggers in microcontroller-based DAQ systems.

Worked SolutionAI Assisted

Solution: Hardware Communication Interface Programming for Data Loggers

A data logger needs communication interfaces to transfer acquired data between the microcontroller, sensors, memory devices and computers.

1. SPI

SPI (Serial Peripheral Interface) is a synchronous, high-speed interface using signals such as SCLK, MOSI, MISO and CS.

MCU SCLK ───────── Device
MCU MOSI ───────── Device
MCU MISO ───────── Device
MCU CS   ───────── Device

It is commonly used with SD cards, external ADCs and DACs.

Programming sequence

  1. Configure SPI clock and mode.
  2. Configure GPIO pins.
  3. Select the slave using CS.
  4. Transmit command/address/data bytes.
  5. Read returned data when required.
  6. Release CS.

2. I²C

I²C uses two lines:

  • SDA: data
  • SCL: clock

It supports multiple addressed devices on the same bus.

Typical sequence:

START → Address + R/W → ACK → Data → ACK → STOP

It is useful for EEPROMs, sensors and low-speed peripherals.

3. UART/USART

UART is an asynchronous serial interface using TX and RX. A typical frame contains a start bit, data bits, optional parity and stop bit(s).

Typical configuration includes:

  • Baud rate
  • Data bits
  • Parity
  • Stop bits

UART is commonly used to transfer logged data to a PC or another controller.

4. USB

USB provides higher-speed communication between the embedded data logger and a host computer. Firmware must configure the appropriate USB device class and endpoints according to the application.

Basic Data Logger Flow

Sensor → ADC → MCU RAM/Buffer → Communication Interface → Storage/PC

The firmware normally uses a buffer so that data acquisition can continue while blocks of data are written to storage.

Interface Selection

Interface Main advantage Typical use
SPI High speed, simple SD card, ADC/DAC
I²C Addressed multi-device bus Sensors, EEPROM
UART Simple point-to-point PC/debug/modem
USB High-speed host connection PC data transfer

Conclusion

Communication interface programming involves configuring the peripheral, transferring data according to its protocol, handling errors/timeouts and buffering acquired samples so that continuous logging is reliable.

Similar questions