Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
AOA_adc.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 The Paparazzi Team
3  *
4  * Autor: Bruzzlee
5  * Angle of Attack ADC Sensor
6  * US DIGITAL MA3-A10-236-N
7  *
8  * This file is part of paparazzi.
9  *
10  * paparazzi is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2, or (at your option)
13  * any later version.
14  *
15  * paparazzi is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with paparazzi; see the file COPYING. If not, write to
22  * the Free Software Foundation, 59 Temple Place - Suite 330,
23  * Boston, MA 02111-1307, USA.
24  *
25  */
26 
28 #include "mcu_periph/adc.h"
29 #include BOARD_CONFIG
30 #include "generated/airframe.h"
31 #include "estimator.h"
32 #include "std.h"
33 //Messages
34 #include "mcu_periph/uart.h"
35 #include "messages.h"
37 
39 
40 //Downlink
41 #ifndef DOWNLINK_DEVICE
42 #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
43 #endif
44 
45 #ifndef SITL // Use ADC if not in simulation
46 
47 #ifndef ADC_CHANNEL_AOA
48 #error "ADC_CHANNEL_AOA needs to be defined to use AOA_adc module"
49 #endif
50 
51 #ifndef ADC_CHANNEL_AOA_NB_SAMPLES
52 #define ADC_CHANNEL_AOA_NB_SAMPLES DEFAULT_AV_NB_SAMPLE
53 #endif
54 
57 float AOA, AOA_old;
58 #endif
59 
60 
61 void AOA_adc_init( void ) {
62  AOA_offset = AOA_OFFSET;
63  AOA_filter = AOA_FILTER;
64  AOA_old = 0;
65 #ifndef SITL
67 #endif
68 }
69 
70 void AOA_adc_update( void ) {
71 #ifndef SITL
73 
74 // PT1 filter and convert to rad
75  AOA = AOA_filter * AOA_old + (1 - AOA_filter) * (adc_AOA_val*(2*M_PI)/1024-M_PI+AOA_offset);
76  AOA_old = AOA;
77 #endif
78  RunOnceEvery(30, DOWNLINK_SEND_AOA_adc(DefaultChannel, DefaultDevice, &adc_AOA_val, &AOA));
79 
80 #ifdef USE_AOA
82 #endif
83 }
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
uint8_t av_nb_sample
Definition: adc.h:64
struct adc_buf buf_AOA
Definition: AOA_adc.c:55
arch independent ADC (Analog to Digital Converter) API
uint32_t sum
Definition: adc.h:61
float AOA_filter
Definition: AOA_adc.c:56
uint16_t adc_AOA_val
Definition: AOA_adc.c:38
float AOA
Definition: AOA_adc.c:57
#define EstimatorSetAOA(AOA)
Definition: estimator.h:133
Generic interface for all ADC hardware drivers, independent from microcontroller architecture.
Definition: adc.h:60
void AOA_adc_init(void)
Definition: AOA_adc.c:61
#define ADC_CHANNEL_AOA_NB_SAMPLES
Definition: AOA_adc.c:52
float AOA_offset
Definition: AOA_adc.c:56
void adc_buf_channel(uint8_t adc_channel __attribute__((unused)), struct adc_buf *s __attribute__((unused)), uint8_t av_nb_sample __attribute__((unused)))
Required by infrared.c:ir_init()
Definition: jsbsim_ir.c:35
State estimation, fusioning sensors.
float AOA_old
Definition: AOA_adc.c:57
void AOA_adc_update(void)
Definition: AOA_adc.c:70