Sensor Processing

Multi-stage sensor validation: range, rate, stuck-at, and plausibility.

Header: core/ecu_sensor.h

SENSOR_FAULT_NONE

No fault detected.

SENSOR_FAULT_RANGE

Value outside valid range.

SENSOR_FAULT_RATE

Rate-of-change limit exceeded.

SENSOR_FAULT_STUCK

Value stuck (unchanging).

SENSOR_FAULT_PLAUSIBLE

Cross-check plausibility failure.

void ecu_sensor_init(ecu_sensor_state_t *state)

Initialise sensor state.

Parameters:
  • state[out] Sensor state to initialise.

ecu_sensor_reading_t ecu_sensor_validate(float raw, const ecu_sensor_config_t *cfg, ecu_sensor_state_t *state)

Validate a raw sensor reading.

Applies range, rate-of-change, and stuck-at checks.

Parameters:
  • raw[in] Raw sensor value.

  • cfg[in] Validation configuration.

  • state[inout] Sensor state (updated in place).

Returns:

Processed reading with validity and fault flags.

bool ecu_sensor_egt_plausible(float egt, float rpm, float rpm_idle)

Cross-check EGT plausibility against RPM.

Parameters:
  • egt[in] Exhaust gas temperature (deg C).

  • rpm[in] Current shaft RPM.

  • rpm_idle[in] Idle RPM threshold.

Returns:

true if the EGT is plausible for the given RPM.

struct ecu_sensor_reading_t
#include <ecu_sensor.h>

Processed sensor reading with validation result.

Public Members

float value

Processed (validated) value.

float raw

Original raw reading.

bool valid

true if all checks pass.

uint32_t faults

Bitmask of SENSOR_FAULT_* flags.

struct ecu_sensor_config_t
#include <ecu_sensor.h>

Per-sensor validation configuration.

Public Members

float range_min

Minimum valid value.

float range_max

Maximum valid value.

float rate_limit

Maximum change per step.

float stuck_tolerance

Threshold for stuck detection.

int stuck_count_limit

Consecutive stuck counts to trigger fault.

struct ecu_sensor_state_t
#include <ecu_sensor.h>

Per-sensor runtime state (history for stuck detection).

Public Members

float last_value

Previous validated value.

int stuck_count

Consecutive stuck readings.

bool initialized

true after first reading processed.