Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
humid_hih.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 Martin Mueller
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
29 #include <std.h>
34 #include "mcu_periph/adc.h"
35 #include "mcu_periph/uart.h"
36 #include "messages.h"
38 
39 #ifndef DOWNLINK_DEVICE
40 #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
41 #endif
42 
43 #ifndef ADC_CHANNEL_HUMID_HIH
44 #define ADC_CHANNEL_HUMID_HIH ADC_3
45 #endif
46 
47 #ifndef ADC_CHANNEL_HUMID_NB_SAMPLES
48 #define ADC_CHANNEL_HUMID_NB_SAMPLES 16
49 #endif
50 
52 float fhih_humid;
53 
54 static struct adc_buf buf_humid_hih;
55 
56 void humid_hih_init( void ) {
58 }
59 
60 void humid_hih_periodic( void ) {
61  float fvout, fhih_temp;
62 
63  /* get temperature from external source */
64  fhih_temp = ftempsht;
65  /****************************************/
66 
68 
69  /* 36k/68k voltage divider, 3.3V full sweep, 10 bits adc */
70  fvout = (adc_humid_hih / 1024.) * 3.3 * (104./68.);
71 
72  /* 5V supply, 1st order curve fit */
73  fhih_humid = ((fvout / 5.0)-0.16)/0.0062;
74 
75  /* temperature compensation */
76  fhih_humid = fhih_humid/(1.0546 - (0.00216 * fhih_temp));
77 
78  DOWNLINK_SEND_HIH_STATUS(DefaultChannel, DefaultDevice, &adc_humid_hih, &fhih_humid, &fhih_temp);
79 }
80 
unsigned short uint16_t
Definition: types.h:16
static struct adc_buf buf_humid_hih
Definition: humid_hih.c:54
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
DigiPicco I2C sensor interface.
uint16_t adc_humid_hih
Definition: humid_hih.c:51
void adc_buf_channel(uint8_t adc_channel, struct adc_buf *s, uint8_t av_nb_sample)
Registers a buffer to be used to store the specified converted channel Usage:
Definition: adc_arch.c:59
void humid_hih_init(void)
Definition: humid_hih.c:56
#define ADC_CHANNEL_HUMID_NB_SAMPLES
Definition: humid_hih.c:48
uint8_t av_nb_sample
Definition: adc.h:64
#define ADC_CHANNEL_HUMID_HIH
Definition: humid_hih.c:44
arch independent ADC (Analog to Digital Converter) API
uint32_t sum
Definition: adc.h:61
void humid_hih_periodic(void)
Definition: humid_hih.c:60
Generic interface for all ADC hardware drivers, independent from microcontroller architecture.
Definition: adc.h:60
float fhih_humid
Definition: humid_hih.c:52
float ftempsht
Definition: humid_sht.c:23