1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-994 Refactor/Cleanup of cpu temp measurement

This commit is contained in:
Alessio Morale 2013-05-26 16:17:03 +02:00
parent e7f48593c8
commit 6671a404ca
5 changed files with 28 additions and 15 deletions

View File

@ -470,19 +470,9 @@ static void updateStats()
} // else: TickCount has wrapped, do not calc now
lastTickCount = now;
idleCounterClear = 1;
#if defined(PIOS_INCLUDE_ADC) && defined(PIOS_ADC_USE_TEMP_SENSOR)
#if defined(STM32F4XX)
float temp_voltage = 3.3f * PIOS_ADC_PinGet(3) / ((1 << 12) - 1);
const float STM32_TEMP_V25 = 0.76f; /* V */
const float STM32_TEMP_AVG_SLOPE = 2.5f; /* mV/C */
stats.CPUTemp = (temp_voltage - STM32_TEMP_V25) * 1000.0f / STM32_TEMP_AVG_SLOPE + 25.0f;
#else
float temp_voltage = 3.3f * PIOS_ADC_PinGet(0) / ((1 << 12) - 1);
const float STM32_TEMP_V25 = 1.43f; /* V */
const float STM32_TEMP_AVG_SLOPE = 4.3f; /* mV/C */
stats.CPUTemp = (temp_voltage - STM32_TEMP_V25) * 1000.0f / STM32_TEMP_AVG_SLOPE + 25.0f;
#endif
float temp_voltage = PIOS_ADC_VOLTAGE_SCALE * PIOS_ADC_PinGet(PIOS_ADC_TEMPERATURE_PIN);
stats.CPUTemp = (temp_voltage-PIOS_ADC_STM32_TEMP_V25) * 1000.0f / PIOS_ADC_STM32_TEMP_AVG_SLOPE + 25.0f;
#endif
SystemStatsSet(&stats);
}

View File

@ -213,6 +213,11 @@ extern uint32_t pios_com_hkosd_id;
#define PIOS_ADC_RATE (72.0e6f / 1.0f / 8.0f / 252.0f / (PIOS_ADC_NUM_CHANNELS >> PIOS_ADC_USE_ADC2))
#define PIOS_ADC_MAX_OVERSAMPLING 36
#define PIOS_ADC_VOLTAGE_SCALE 3.30/4096.0
#define PIOS_ADC_TEMPERATURE_PIN 0
#define PIOS_ADC_STM32_TEMP_V25 1.43f /* V */
#define PIOS_ADC_STM32_TEMP_AVG_SLOPE 4.3f /* mV/C */
// ------------------------
// PIOS_RCVR
// See also pios_board.c

View File

@ -223,7 +223,13 @@ extern uint32_t pios_com_telem_usb_id;
#define PIOS_ADC_NUM_CHANNELS 7
#define PIOS_ADC_MAX_OVERSAMPLING 10
#define PIOS_ADC_USE_ADC2 0
#define PIOS_ADC_USE_TEMP_SENSOR 1
#define PIOS_ADC_USE_TEMP_SENSOR
#define PIOS_ADC_VOLTAGE_SCALE 3.30f/4096.0f
#define PIOS_ADC_TEMPERATURE_PIN 6 /* V */
#define PIOS_ADC_STM32_TEMP_V25 0.76f /* mV/C */
#define PIOS_ADC_STM32_TEMP_AVG_SLOPE 2.5f
// *****************************************************************
// USB

View File

@ -293,7 +293,13 @@ extern uint32_t pios_packet_handler;
#define PIOS_ADC_MAX_OVERSAMPLING 2
#define PIOS_ADC_USE_ADC2 0
#define PIOS_ADC_VOLTAGE_SCALE 3.30f / 4096.0f
#define PIOS_ADC_USE_TEMP_SENSOR 1
#define PIOS_ADC_USE_TEMP_SENSOR
#define PIOS_ADC_VOLTAGE_SCALE 3.30f/4096.0f
#define PIOS_ADC_TEMPERATURE_PIN 3
#define PIOS_ADC_STM32_TEMP_V25 0.76f /* V */
#define PIOS_ADC_STM32_TEMP_AVG_SLOPE 2.5f /* mV/C */
// -------------------------
// USB

View File

@ -255,7 +255,13 @@ extern uint32_t pios_com_hkosd_id;
#define PIOS_ADC_MAX_OVERSAMPLING 2
#define PIOS_ADC_USE_ADC2 0
#define PIOS_ADC_VOLTAGE_SCALE 3.30f / 4096.0f
#define PIOS_ADC_USE_TEMP_SENSOR 1
#define PIOS_ADC_USE_TEMP_SENSOR
#define PIOS_ADC_VOLTAGE_SCALE 3.30f/4096.0f
#define PIOS_ADC_TEMPERATURE_PIN 3 /* V */
#define PIOS_ADC_STM32_TEMP_V25 0.76f /* mV/C */
#define PIOS_ADC_STM32_TEMP_AVG_SLOPE 2.5f
// -------------------------
// USB