From 88ff740f9ef03366d144b56eeba3d4da4d87bdcd Mon Sep 17 00:00:00 2001 From: Martin Mueller Date: Fri, 22 Jul 2011 18:32:24 +0200 Subject: [PATCH] Allow other sensors to be used for HIH humidity sensor temperature compensation. --- sw/airborne/modules/meteo/humid_dpicco.h | 2 ++ sw/airborne/modules/meteo/humid_hih.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sw/airborne/modules/meteo/humid_dpicco.h b/sw/airborne/modules/meteo/humid_dpicco.h index 7272e5763e..1b95a76d0a 100644 --- a/sw/airborne/modules/meteo/humid_dpicco.h +++ b/sw/airborne/modules/meteo/humid_dpicco.h @@ -10,6 +10,8 @@ #define DPICCO_TEMP_RANGE 165.0 #define DPICCO_TEMP_OFFS -40.0 +extern float dpicco_temp; + extern void dpicco_init( void ); extern void dpicco_periodic( void ); extern void dpicco_event( void ); diff --git a/sw/airborne/modules/meteo/humid_hih.c b/sw/airborne/modules/meteo/humid_hih.c index 2e61b5ca45..6904c54d80 100644 --- a/sw/airborne/modules/meteo/humid_hih.c +++ b/sw/airborne/modules/meteo/humid_hih.c @@ -31,6 +31,8 @@ #include #include "modules/meteo/humid_hih.h" #include "modules/meteo/temp_tmp102.h" +#include "modules/meteo/humid_dpicco.h" +#include "modules/meteo/humid_sht.h" #include "mcu_periph/adc.h" #include "mcu_periph/uart.h" #include "messages.h" @@ -58,8 +60,12 @@ void humid_hih_init( void ) { } void humid_hih_periodic( void ) { - float fvout; + float fvout, fhih_temp; + /* get temperature from external source */ + fhih_temp = ftempsht; + /****************************************/ + adc_humid_hih = buf_humid_hih.sum / buf_humid_hih.av_nb_sample; /* 36k/68k voltage divider, 3.3V full sweep, 10 bits adc */ @@ -69,8 +75,8 @@ void humid_hih_periodic( void ) { fhih_humid = ((fvout / 5.0)-0.16)/0.0062; /* temperature compensation */ - fhih_humid = fhih_humid/(1.0546 - (0.00216 * ftmp_temperature)); + fhih_humid = fhih_humid/(1.0546 - (0.00216 * fhih_temp)); - DOWNLINK_SEND_HIH_STATUS(DefaultChannel, &adc_humid_hih, &fhih_humid, &ftmp_temperature); + DOWNLINK_SEND_HIH_STATUS(DefaultChannel, &adc_humid_hih, &fhih_humid, &fhih_temp); }