Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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 "pprzlink/messages.h"
38 
39 
40 #ifndef ADC_CHANNEL_HUMID_HIH
41 #define ADC_CHANNEL_HUMID_HIH ADC_3
42 #endif
43 
44 #ifndef ADC_CHANNEL_HUMID_NB_SAMPLES
45 #define ADC_CHANNEL_HUMID_NB_SAMPLES 16
46 #endif
47 
49 float fhih_humid;
50 
51 static struct adc_buf buf_humid_hih;
52 
53 void humid_hih_init(void)
54 {
56 }
57 
59 {
60  float fvout, fhih_temp;
61 
62  /* get temperature from external source */
63  fhih_temp = ftempsht;
64  /****************************************/
65 
67 
68  /* 36k/68k voltage divider, 3.3V full sweep, 10 bits adc */
69  fvout = (adc_humid_hih / 1024.) * 3.3 * (104. / 68.);
70 
71  /* 5V supply, 1st order curve fit */
72  fhih_humid = ((fvout / 5.0) - 0.16) / 0.0062;
73 
74  /* temperature compensation */
75  fhih_humid = fhih_humid / (1.0546 - (0.00216 * fhih_temp));
76 
77  DOWNLINK_SEND_HIH_STATUS(DefaultChannel, DefaultDevice, &adc_humid_hih, &fhih_humid, &fhih_temp);
78 }
79 
uint16_t
unsigned short uint16_t
Definition: types.h:16
humid_sht.h
humid_dpicco.h
DigiPicco I2C sensor interface.
ADC_CHANNEL_HUMID_HIH
#define ADC_CHANNEL_HUMID_HIH
Definition: humid_hih.c:41
adc_buf_channel
void adc_buf_channel(uint8_t adc_channel, struct adc_buf *s, uint8_t av_nb_sample)
Link between ChibiOS ADC drivers and Paparazzi adc_buffers.
Definition: adc_arch.c:289
buf_humid_hih
static struct adc_buf buf_humid_hih
Definition: humid_hih.c:51
adc.h
arch independent ADC (Analog to Digital Converter) API
adc_buf::sum
uint32_t sum
Definition: adc.h:54
ftempsht
float ftempsht
Definition: humid_sht.c:87
humid_hih.h
std.h
uart.h
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
fhih_humid
float fhih_humid
Definition: humid_hih.c:49
adc_humid_hih
uint16_t adc_humid_hih
Definition: humid_hih.c:48
adc_buf::av_nb_sample
uint8_t av_nb_sample
Definition: adc.h:57
humid_hih_periodic
void humid_hih_periodic(void)
Definition: humid_hih.c:58
humid_hih_init
void humid_hih_init(void)
Definition: humid_hih.c:53
ADC_CHANNEL_HUMID_NB_SAMPLES
#define ADC_CHANNEL_HUMID_NB_SAMPLES
Definition: humid_hih.c:45
temp_tmp102.h
adc_buf
Generic interface for all ADC hardware drivers, independent from microcontroller architecture.
Definition: adc.h:53