From 5c520497730ac3dc3667f2b29e9e976488e90583 Mon Sep 17 00:00:00 2001 From: Pascal Brisset Date: Wed, 23 May 2007 12:37:29 +0000 Subject: [PATCH] PID sensor measurement --- sw/airborne/enose.c | 13 ++++++++++++- sw/airborne/enose.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sw/airborne/enose.c b/sw/airborne/enose.c index 0aa22376bd..196d5b374b 100644 --- a/sw/airborne/enose.c +++ b/sw/airborne/enose.c @@ -1,8 +1,11 @@ +#include + #include "enose.h" #include "i2c.h" +#include "adc.h" +#include CONFIG -#include uint8_t enose_status; @@ -20,6 +23,8 @@ uint8_t enose_conf_requested; volatile bool_t enose_i2c_done; +static struct adc_buf buf_PID; + void enose_init( void ) { uint8_t i; for (i=0; i< ENOSE_NB_SENSOR; i++) { @@ -29,6 +34,8 @@ void enose_init( void ) { enose_status = ENOSE_IDLE; enose_conf_requested = TRUE; enose_i2c_done = TRUE; + + adc_buf_channel(ADC_CHANNEL_PID, &buf_PID, ADC_CHANNEL_PID_NB_SAMPLES); } @@ -39,8 +46,12 @@ void enose_set_heat(uint8_t no_sensor, uint8_t value) { #include "led.h" +uint16_t enose_PID_val; + void enose_periodic( void ) { + enose_PID_val = buf_PID.sum / buf_PID.av_nb_sample; + if (enose_i2c_done) { if (enose_conf_requested) { const uint8_t msg[] = { ENOSE_PWM_ADDR, enose_heat[0], enose_heat[1], enose_heat[2] }; diff --git a/sw/airborne/enose.h b/sw/airborne/enose.h index 2f6183f884..456734d494 100644 --- a/sw/airborne/enose.h +++ b/sw/airborne/enose.h @@ -7,6 +7,7 @@ extern uint8_t enose_heat[ENOSE_NB_SENSOR]; extern uint16_t enose_val[ENOSE_NB_SENSOR]; +extern uint16_t enose_PID_val; #define ENOSE_IDLE 0 #define ENOSE_SETTINGS 1