Temperature Monitoring with ADS7830 ADC and Thermal Shutdown Thresholds in PLFM-RADAR
The PLFM-RADAR firmware implements a three-layer temperature monitoring subsystem using the ADS7830 8-channel ADC, with configurable thermal shutdown thresholds that trigger emergency stop events when exceeded.
This article examines how the NawfalMotii79/PLFM_RADAR repository handles temperature monitoring for radar hardware protection. The implementation combines a low-level I²C driver, temperature aggregation logic, and safety-critical shutdown mechanisms—all validated through comprehensive unit tests.
ADS7830 Hardware Abstraction Layer
The foundation of temperature monitoring rests in 9_Firmware/9_1_Microcontroller/9_1_1_C_Cpp_Libraries/ADS7830.c, which provides direct control over the ADS7830 8-channel ADC via I²C.
Initialization and Communication Verification
The driver initializes the ADC with configurable shutdown and power-down modes:
ADS7830_HandleTypeDef adc_handle;
bool ok = ADS7830_Init(&adc_handle, &hi2c1, 0x4D << 1,
ADS7830_SDMode_NORMAL, ADS7830_PDMode_NORMAL);
As implemented in ADS7830_Init() at lines 14-15, this function configures the I²C peripheral and ADC operating modes. The driver immediately performs a test read of channel 0 (line 33) to verify communication integrity before returning control to the caller.
Single-Ended Temperature Measurements
Temperature acquisition uses ADS7830_Measure_SingleEnded() (lines 75-112), which issues the proper command byte for single-ended conversions and returns raw 8-bit ADC codes:
uint8_t raw = ADS7830_Measure_SingleEnded(&adc_handle, channel);
Error handling for I²C transmit/receive failures is centralized in lines 121-132, where DIAG_ERR macros log communication faults for diagnostic purposes.
Temperature Processing and Maximum Aggregation
The firmware reads all eight temperature sensor channels and computes the worst-case value. The logic appears in 9_Firmware/9_1_Microcontroller/tests/test_gap3_temperature_max.c, which demonstrates production-grade temperature aggregation.
The Maximum Temperature Algorithm
The compute_max_temperature() function (lines 20-31) iterates across eight readings to identify the highest temperature:
float temps[8];
for (uint8_t ch = 0; ch < 8; ++ch) {
uint8_t raw = ADS7830_Measure_SingleEnded(&adc_handle, ch);
/* Sensor-specific scaling: 8-bit code → voltage → temperature */
temps[ch] = (float)raw * (3.3f / 255.0f) * 100.0f;
}
float max_temp = compute_max_temperature(temps);
This maximum-value approach ensures the system responds to the most critical thermal condition across all monitored zones, rather than averaging conditions that might mask localized overheating.
Thermal Shutdown Thresholds and Safety Enforcement
The safety layer compares the maximum temperature against a thermal shutdown threshold each monitoring cycle. When crossed, the system raises an over-temperature emergency stop event.
Emergency Stop Implementation
The test suite 9_Firmware/9_1_Microcontroller/tests/test_gap3_overtemp_emergency_stop.c validates this critical safety behavior. The production implementation follows this pattern:
#define THERMAL_SHUTDOWN_LIMIT 85.0f /* °C */
if (max_temp > THERMAL_SHUTDOWN_LIMIT) {
raise_emergency_stop(EMERGENCY_OVER_TEMPERATURE);
}
This deterministic response protects power amplifiers, RF components, and other heat-sensitive hardware from thermal damage during sustained operation or cooling system failures.
Complete Temperature Monitoring Example
The following integrated example shows the full workflow from ADC initialization through thermal shutdown evaluation:
#include "ADS7830.h"
#define THERMAL_SHUTDOWN_LIMIT 85.0f
void temperature_monitor_cycle(void)
{
static ADS7830_HandleTypeDef adc_handle;
static bool initialized = false;
/* Initialize on first call */
if (!initialized) {
if (!ADS7830_Init(&adc_handle, &hi2c1, 0x4A << 1,
ADS7830_SDMode_NORMAL, ADS7830_PDMode_NORMAL)) {
DIAG_ERR("ADC init failed");
return;
}
initialized = true;
}
/* Acquire all eight temperature channels */
float temps[8];
for (uint8_t ch = 0; ch < 8; ++ch) {
uint8_t raw = ADS7830_Measure_SingleEnded(&adc_handle, ch);
/* Apply sensor-specific transfer function */
temps[ch] = adc_code_to_celsius(raw);
}
/* Determine worst-case temperature */
float max_temp = compute_max_temperature(temps);
/* Enforce thermal shutdown threshold */
if (max_temp > THERMAL_SHUTDOWN_LIMIT) {
raise_emergency_stop(EMERGENCY_OVER_TEMPERATURE);
DIAG_ERR("Thermal shutdown: %.1f°C exceeds limit", max_temp);
}
}
Test-Driven Validation
The PLFM-RADAR project verifies temperature monitoring through targeted unit tests:
| Test File | Purpose | Key Validation |
|---|---|---|
test_gap3_temperature_max.c |
Maximum aggregation logic | Correct identification of peak temperature across 8 channels |
test_gap3_overtemp_emergency_stop.c |
Safety threshold enforcement | Emergency stop trigger when limit exceeded |
stm32_hal_mock.c |
Hardware abstraction | Mock HAL_I2C functions for isolated driver testing |
These tests enable continuous integration validation without physical hardware, using mock implementations of STM32 HAL functions to simulate ADC responses.
Summary
- ADS7830 driver (
ADS7830.c) provides I²C-based ADC control with single-ended measurement capability and diagnostic error logging. - Temperature aggregation uses maximum-value selection across eight channels to identify worst-case thermal conditions.
- Thermal shutdown thresholds are enforced through deterministic emergency stop events when the maximum temperature exceeds configurable limits.
- Test coverage validates both the aggregation algorithm and safety response through isolated unit tests with HAL mocks.
Frequently Asked Questions
What is the ADS7830 ADC resolution and how does it affect temperature accuracy?
The ADS7830 provides 8-bit resolution (0-255 codes), which maps to voltage steps of approximately 12.9 mV at 3.3V reference. Temperature accuracy depends on the sensor's voltage-to-temperature transfer function—common NTC thermistors or LM35-style sensors require appropriate scaling in software. The PLFM-RADAR firmware applies sensor-specific conversion factors in adc_code_to_celsius().
How does the thermal shutdown threshold get configured in the firmware?
The thermal shutdown threshold is defined as a compile-time constant (THERMAL_SHUTDOWN_LIMIT, typically 85.0°C) in the safety configuration header. This value is compared against the computed maximum temperature each monitoring cycle. For deployments with different thermal requirements, the threshold can be adjusted at compile time or extended to support runtime configuration through the parameter system.
What happens when the ADS7830 I²C communication fails during temperature monitoring?
I²C failures in ADS7830_Measure_SingleEnded() are caught in lines 121-132 and logged via DIAG_ERR macros. The function returns an error indicator that calling code should handle—typically by flagging the temperature reading as invalid and potentially triggering a conservative safety response. The unit tests in stm32_hal_mock.c simulate these failure modes to verify fault tolerance.
Why does the firmware use maximum temperature rather than average temperature for shutdown decisions?
Maximum temperature selection protects against localized hotspots that averaging would mask. In radar systems, individual power amplifiers or RF components may overheat while others remain cool—average temperatures could remain below threshold even as critical components reach damage levels. The compute_max_temperature() algorithm ensures the most stressed component drives safety responses.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →