[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paparazzi-commits] [6176] add a airspeed ADC module
From: |
Gautier Hattenberger |
Subject: |
[paparazzi-commits] [6176] add a airspeed ADC module |
Date: |
Tue, 19 Oct 2010 11:41:10 +0000 |
Revision: 6176
http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=6176
Author: gautier
Date: 2010-10-19 11:41:10 +0000 (Tue, 19 Oct 2010)
Log Message:
-----------
add a airspeed ADC module
Added Paths:
-----------
paparazzi3/trunk/conf/modules/airspeed_adc.xml
paparazzi3/trunk/sw/airborne/modules/sensors/airspeed_adc.c
paparazzi3/trunk/sw/airborne/modules/sensors/airspeed_adc.h
Added: paparazzi3/trunk/conf/modules/airspeed_adc.xml
===================================================================
--- paparazzi3/trunk/conf/modules/airspeed_adc.xml
(rev 0)
+++ paparazzi3/trunk/conf/modules/airspeed_adc.xml 2010-10-19 11:41:10 UTC
(rev 6176)
@@ -0,0 +1,27 @@
+<!DOCTYPE module SYSTEM "module.dtd">
+
+<!--
+ Airspeed ADC module
+ @param ADC_AIRSPEED on which ADC the sensor is connected
+ @param AIRSPEED_SCALE/AIRSPEED_QUADRATIC_SCALE scale factor, quadratic is
used if defined
+ @param AIRSPEED_BIAS offset on ADC
+ -->
+
+<module name="airspeed_adc" dir="sensors">
+
+ <header>
+ <file name="airspeed_adc.h"/>
+ </header>
+ <init fun="airspeed_adc_init()"/>
+ <periodic fun="airspeed_adc_update()" freq="10."/>
+
+ <makefile>
+ <file name="airspeed_adc.c"/>
+ </makefile>
+ <makefile target="ap">
+ <flag name="ADC_CHANNEL_AIRSPEED" value="$(ADC_AIRSPEED)"/>
+ <flag name="USE_$(ADC_AIRSPEED)"/>
+ </makefile>
+
+</module>
+
Copied: paparazzi3/trunk/sw/airborne/modules/sensors/airspeed_adc.c (from rev
6163, paparazzi3/trunk/sw/airborne/airspeed.c)
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/sensors/airspeed_adc.c
(rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/sensors/airspeed_adc.c 2010-10-19
11:41:10 UTC (rev 6176)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2010 The Paparazzi Team
+ *
+ * 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.
+ *
+ */
+
+#include "sensors/airspeed_adc.h"
+#include "adc.h"
+#include BOARD_CONFIG
+#include "airframe.h"
+#include "estimator.h"
+
+uint16_t adc_airspeed_val;
+
+#ifndef SITL // Use ADC if not in simulation
+
+#ifndef ADC_CHANNEL_AIRSPEED
+#error "ADC_CHANNEL_AIRSPEED needs to be defined to use airspeed_adc module"
+#endif
+
+#ifndef ADC_CHANNEL_AIRSPEED_NB_SAMPLES
+#define ADC_CHANNEL_AIRSPEED_NB_SAMPLES DEFAULT_AV_NB_SAMPLE
+#endif
+
+struct adc_buf buf_airspeed;
+
+#endif
+
+void airspeed_adc_init( void ) {
+#ifndef SITL
+ adc_buf_channel(ADC_CHANNEL_AIRSPEED, &buf_airspeed,
ADC_CHANNEL_AIRSPEED_NB_SAMPLES);
+#endif
+}
+
+void airspeed_adc_update( void ) {
+#ifndef SITL
+ adc_airspeed_val = buf_airspeed.sum / buf_airspeed.av_nb_sample;
+#ifdef AIRSPEED_QUADRATIC_SCALE
+ float airspeed = (adc_airspeed_val - AIRSPEED_BIAS);
+ if (airspeed <= 0.0f)
+ airspeed = 0.0f;
+ airspeed = sqrtf(airspeed) * AIRSPEED_QUADRATIC_SCALE;
+#else
+ float airspeed = AIRSPEED_SCALE * (adc_airspeed_val - AIRSPEED_BIAS);
+#endif
+ EstimatorSetAirspeed(airspeed);
+#else // SITL
+ extern float sim_air_speed;
+ EstimatorSetAirspeed(sim_air_speed);
+ adc_airspeed_val = 0;
+#endif //SITL
+}
Copied: paparazzi3/trunk/sw/airborne/modules/sensors/airspeed_adc.h (from rev
6163, paparazzi3/trunk/sw/airborne/airspeed.h)
===================================================================
--- paparazzi3/trunk/sw/airborne/modules/sensors/airspeed_adc.h
(rev 0)
+++ paparazzi3/trunk/sw/airborne/modules/sensors/airspeed_adc.h 2010-10-19
11:41:10 UTC (rev 6176)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2010 The Paparazzi Team
+ *
+ * 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.
+ *
+ */
+
+#ifndef AIRSPEED_ADC_H
+#define AIRSPEED_ADC_H
+
+#include <inttypes.h>
+
+extern uint16_t adc_airspeed_val;
+
+void airspeed_adc_init( void );
+void airspeed_adc_update( void );
+
+#endif /* AIRSPEED_ADC_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paparazzi-commits] [6176] add a airspeed ADC module,
Gautier Hattenberger <=