Skip to content

NOTES

RT Processing — Three Architectures, Compile-Time Selectable

Three concurrent acquisition-and-processing architectures, switched via the compile-time macro RT_PROCESS_ARCH_TYPE. Each trades off throughput, latency, and complexity.

Intuition

Why RT Architectures?

Online/Offline only capture data; RT architectures process data immediately as it arrives (threshold detection, feature extraction), responding to anomalies in real time.

The core challenge: when acquisition rate > processing speed, data piles up and drops. Each architecture solves this differently.

Selection Guide

Architecture Macro Core idea Throughput Best for
Producer-Consumer RT_ARCH_PRODUCER_CONSUMER Ring buffer decouples acquisition & processing Medium Default, general purpose
DMA + Double Buffer RT_ARCH_DMA_DOUBLE_BUFFER DMA moves data, CPU processes High High-rate acquisition
DMA + Dual Core RT_ARCH_DMA_DUAL_CORE Two cores share the work Highest Most demanding real-time

Unified API

#define RT_PROCESS_ARCH_TYPE RT_ARCH_DMA_DUAL_CORE
// Same code below:
rt_process_init(&config);
rt_process_start();

Unified API

esp_err_t rt_process_init(const rt_process_config_t *config);
esp_err_t rt_process_set_sensor_handle(adxl355_handle_t *handle);
esp_err_t rt_process_start(void);
esp_err_t rt_process_stop(void);
esp_err_t rt_process_deinit(void);
esp_err_t rt_process_get_status(rt_process_status_t *status);
esp_err_t rt_process_get_stats(rt_process_stats_t *stats);

Data Types

typedef struct {
    float x, y, z;           // 3-axis acceleration (g)
    float temp;
    uint64_t timestamp_us;
} rt_process_sample_t;

typedef struct {
    float processed_x, y, z;
    float features[8];
    uint64_t process_time_us;
} rt_process_result_t;

Notes

Threshold detection

When enabled, if |axis| exceeds the configured threshold, an event is triggered.

Monitor dropped_samples

If dropped_samples (in rt_process_stats_t) keeps climbing, your architecture can't keep up — switch to a faster one or reduce sample rate.