Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Universitaet Tuebingen thermocouple sensor.
- Loading branch information
Showing
4 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE module SYSTEM "module.dtd"> | ||
|
||
<module name="temp_tcouple_adc" dir="meteo"> | ||
<header> | ||
<file name="temp_tcouple_adc.h"/> | ||
</header> | ||
<init fun="temp_tcouple_adc_init()"/> | ||
<periodic fun="temp_tcouple_adc_periodic()" freq="60"/> | ||
<makefile target="ap"> | ||
<file name="temp_tcouple_adc.c"/> | ||
<define name="ADC_CHANNEL_TEMP_REF" value="ADC_4"/> | ||
<define name="USE_ADC_4"/> | ||
<define name="ADC_CHANNEL_TEMP_VAL" value="ADC_3"/> | ||
<define name="USE_ADC_3"/> | ||
</makefile> | ||
</module> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* $Id: temp_tcouple_adc.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 temp_tcouple_adc.c | ||
* \brief Universitaet Tuebingen thermocouple interface | ||
* | ||
* This reads the values for reference and measurement temperature | ||
* from the Universitaet Tuebingen thermocouple sensor. | ||
*/ | ||
|
||
|
||
#include "mcu_periph/adc.h" | ||
#include "mcu_periph/uart.h" | ||
#include "messages.h" | ||
#include "downlink.h" | ||
#include "modules/meteo/temp_tcouple_adc.h" | ||
|
||
#ifndef ADC_CHANNEL_TEMP_REF | ||
#define ADC_CHANNEL_TEMP_REF ADC_4 | ||
#endif | ||
#ifndef ADC_CHANNEL_TEMP_VAL | ||
#define ADC_CHANNEL_TEMP_VAL ADC_3 | ||
#endif | ||
|
||
#ifndef ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES | ||
#define ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES 16 | ||
#endif | ||
|
||
#ifndef DOWNLINK_DEVICE | ||
#define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE | ||
#endif | ||
|
||
uint16_t ref[TCOUPLE_NB], val[TCOUPLE_NB]; | ||
float fref[TCOUPLE_NB], fval[TCOUPLE_NB]; | ||
int32_t temp_cnt; | ||
|
||
static struct adc_buf buf_temp_tcouple_ref; | ||
static struct adc_buf buf_temp_tcouple_val; | ||
|
||
void temp_tcouple_adc_init( void ) { | ||
adc_buf_channel(ADC_CHANNEL_TEMP_REF, | ||
&buf_temp_tcouple_ref, | ||
ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES); | ||
adc_buf_channel(ADC_CHANNEL_TEMP_VAL, | ||
&buf_temp_tcouple_val, | ||
ADC_CHANNEL_TEMP_TCOUPLE_NB_SAMPLES); | ||
temp_cnt = 0; | ||
} | ||
|
||
void temp_tcouple_adc_periodic( void ) { | ||
val[temp_cnt] = buf_temp_tcouple_val.sum / buf_temp_tcouple_val.av_nb_sample; | ||
ref[temp_cnt] = buf_temp_tcouple_ref.sum / buf_temp_tcouple_ref.av_nb_sample; | ||
|
||
/* no voltage divider, 10 bits adc, 3.3V max */ | ||
/* T = U * 52.288899706 - 7.977784737996595 */ | ||
fval[temp_cnt] = ((float)(val[temp_cnt] * 3.3) / 1023.) | ||
* 52.288899706 - 7.977784737996595; | ||
fref[temp_cnt] = ((float)(ref[temp_cnt] * 3.3) / 1023.) | ||
* 100. - 13.; | ||
|
||
if (++temp_cnt >= TCOUPLE_NB) { | ||
DOWNLINK_SEND_TEMP_TCOUPLE(DefaultChannel, | ||
&fval[0], &fval[1], &fval[2], &fval[3], | ||
&fref[0], &fref[1], &fref[2], &fref[3], | ||
&val[0], &val[1], &val[2], &val[3], | ||
&ref[0], &ref[1], &ref[2], &ref[3]); | ||
temp_cnt = 0; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef TEMP_TCOUPLE_ADC_H | ||
#define TEMP_TCOUPLE_ADC_H | ||
|
||
#include "std.h" | ||
|
||
#define TCOUPLE_NB 4 | ||
|
||
extern uint16_t up[TCOUPLE_NB], dn[TCOUPLE_NB]; | ||
extern int32_t tcouple_cnt; | ||
|
||
void temp_tcouple_adc_init(void); | ||
void temp_tcouple_adc_periodic(void); | ||
|
||
#endif |