Add University of Reading solar radiation sensor.

This commit is contained in:
Martin Mueller
2011-07-22 17:13:15 +02:00
parent 3087da4bf9
commit df54ababd7
4 changed files with 133 additions and 1 deletions
+22 -1
View File
@@ -800,7 +800,28 @@
<field name="t9" type="uint16"/>
</message>
<!--119 is free -->
<message name="SOLAR_RADIATION" id="119">
<field name="up_t0" type="uint16"/>
<field name="dn_t0" type="uint16"/>
<field name="up_t1" type="uint16"/>
<field name="dn_t1" type="uint16"/>
<field name="up_t2" type="uint16"/>
<field name="dn_t2" type="uint16"/>
<field name="up_t3" type="uint16"/>
<field name="dn_t3" type="uint16"/>
<field name="up_t4" type="uint16"/>
<field name="dn_t4" type="uint16"/>
<field name="up_t5" type="uint16"/>
<field name="dn_t5" type="uint16"/>
<field name="up_t6" type="uint16"/>
<field name="dn_t6" type="uint16"/>
<field name="up_t7" type="uint16"/>
<field name="dn_t7" type="uint16"/>
<field name="up_t8" type="uint16"/>
<field name="dn_t8" type="uint16"/>
<field name="up_t9" type="uint16"/>
<field name="dn_t9" type="uint16"/>
</message>
<message name="TCAS_TA" ID="120">
<field name="ac_id" type="uint8"/>
+17
View File
@@ -0,0 +1,17 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="light_solar" dir="meteo">
<header>
<file name="light_solar.h"/>
</header>
<init fun="light_solar_init()"/>
<periodic fun="light_solar_periodic()" freq="60"/>
<makefile target="ap">
<file name="light_solar.c"/>
<define name="ADC_CHANNEL_LIGHT_SOLAR_UP" value="ADC_1"/>
<define name="USE_ADC_1"/>
<define name="ADC_CHANNEL_LIGHT_SOLAR_DN" value="ADC_2"/>
<define name="USE_ADC_2"/>
</makefile>
</module>
+80
View File
@@ -0,0 +1,80 @@
/*
* $Id: light_solar.c $
*
* Copyright (C) 2011 Martin Mueller
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/** \file light_solar.c
* \brief University of Reading solar radiation sensor interface
*
* This reads the values for intensity from the University of Reading solar sensor.
*/
#include "mcu_periph/adc.h"
#include "mcu_periph/uart.h"
#include "messages.h"
#include "downlink.h"
#include "modules/meteo/light_solar.h"
#ifndef ADC_CHANNEL_LIGHT_SOLAR_UP
#define ADC_CHANNEL_LIGHT_SOLAR_UP ADC_1
#endif
#ifndef ADC_CHANNEL_LIGHT_SOLAR_DN
#define ADC_CHANNEL_LIGHT_SOLAR_DN ADC_2
#endif
#ifndef ADC_CHANNEL_LIGHT_NB_SAMPLES
#define ADC_CHANNEL_LIGHT_NB_SAMPLES 16
#endif
#ifndef DOWNLINK_DEVICE
#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
#endif
uint16_t up[LIGHT_NB], dn[LIGHT_NB];
int32_t light_cnt;
static struct adc_buf buf_light_sol_up;
static struct adc_buf buf_light_sol_dn;
void light_solar_init( void ) {
adc_buf_channel(ADC_CHANNEL_LIGHT_SOLAR_UP, &buf_light_sol_up, ADC_CHANNEL_LIGHT_NB_SAMPLES);
adc_buf_channel(ADC_CHANNEL_LIGHT_SOLAR_DN, &buf_light_sol_dn, ADC_CHANNEL_LIGHT_NB_SAMPLES);
light_cnt = 0;
}
void light_solar_periodic( void ) {
up[light_cnt] = buf_light_sol_up.sum / buf_light_sol_up.av_nb_sample;
dn[light_cnt] = buf_light_sol_dn.sum / buf_light_sol_dn.av_nb_sample;
/* 10k/10k voltage divider, 10 bits adc, 3.3V max */
if (++light_cnt >= LIGHT_NB) {
DOWNLINK_SEND_SOLAR_RADIATION(DefaultChannel,
&up[0], &dn[0], &up[1], &dn[1], &up[2], &dn[2], &up[3], &dn[3],
&up[4], &dn[4], &up[5], &dn[5], &up[6], &dn[6], &up[7], &dn[7],
&up[8], &dn[8], &up[9], &dn[9]);
light_cnt = 0;
}
}
+14
View File
@@ -0,0 +1,14 @@
#ifndef TEMP_SOLAR_H
#define TEMP_SOLAR_H
#include "std.h"
#define LIGHT_NB 10
extern uint16_t up[LIGHT_NB], dn[LIGHT_NB];
extern int32_t light_cnt;
void light_solar_init(void);
void light_solar_periodic(void);
#endif