Change external turbine trigger into a module.

This commit is contained in:
Martin Mueller
2010-10-19 19:26:31 +00:00
parent 9b601c8a61
commit e4ccae957e
10 changed files with 167 additions and 219 deletions
+40 -122
View File
@@ -1,17 +1,34 @@
<!DOCTYPE airframe SYSTEM "../../airframe.dtd">
<!-- Funjet Multiplex (http://www.multiplex-rc.de/), Jeti ECO 25
Tiny 2.11 board (http://paparazzi.enac.fr/wiki/index.php/Tiny_v2)
PerkinElmer TPS334 IR Sensors
Tilted infrared sensor (http://paparazzi.enac.fr/wiki/index.php/Image:Tiny_v2_1_Funjet.jpg)
XBee modem
/* Payload: Sensirion humidity/temp, VTI pressure/temp */
K66, LEA 5H
-->
<!-- Turbine Trigger -->
<airframe name="Funjet mm 1 K66">
<airframe name="TurbineTrigger">
<firmware name="fixedwing">
<target name="ap" board="tiny_2.11">
</target>
<subsystem name="telemetry" type="xbee_api">
<param name="MODEM_BAUD" value="B57600"/>
</subsystem>
<subsystem name="control"/>
<subsystem name="attitude" type="infrared"/>
<subsystem name="gps" type="ublox_lea5h">
<param name="GPS_BAUD" value="B38400"/>
</subsystem>
<subsystem name="navigation"/>
</firmware>
<firmware name="setup">
<target name="tunnel" board="tiny_2.11"/>
<target name="usb_tunnel_0" board="tiny_2.11"/>
<target name="usb_tunnel_1" board="tiny_2.11"/>
</firmware>
<!-- modules -->
<modules>
<load name="trigger_ext.xml"/>
</modules>
<!-- commands section -->
<servos>
<servo name="MOTOR" no="0" min="1000" neutral="1000" max="2000"/>
<servo name="AILEVON_LEFT" no="2" min="1900" neutral="1442" max="1100"/>
@@ -77,18 +94,14 @@
<define name="IR1_SIGN" value="1"/>
<define name="IR2_SIGN" value="-1"/>
<define name="TOP_SIGN" value="-1"/>
<define name="ROLL_NEUTRAL_DEFAULT" value="0" unit="deg"/>
<define name="PITCH_NEUTRAL_DEFAULT" value="0" unit="deg"/>
</section>
<section name="BAT">
<!--define name="MILLIAMP_AT_FULL_THROTTLE" value="10000."/-->
<define name="ADC_CHANNEL_CURRENT" value="ADC_4"/>
<define name="MilliAmpereOfAdc(adc)" value="(88*adc)"/>
<define name="CATASTROPHIC_BAT_LEVEL" value="9.3" unit="V"/>
<!-- 0.0247311828 -->
<!-- 0.02432905 -->
<define name="VoltageOfAdc(adc)" value="(0.02454*adc)"/>
</section>
@@ -97,59 +110,41 @@
<define name="CARROT" value="5." unit="s"/>
<define name="KILL_MODE_DISTANCE" value="(1.5*MAX_DIST_FROM_HOME)"/>
<define name="CONTROL_RATE" value="60" unit="Hz"/>
<!-- <define name="XBEE_INIT" value="\"ATPL2\rATRN1\rATTT80\r\""/> -->
<!-- <define name="NO_XBEE_API_INIT" value="TRUE"/> -->
<define name="ALT_KALMAN_ENABLED" value="FALSE"/>
<define name="TRIGGER_DELAY" value="1."/>
<define name="DEFAULT_CIRCLE_RADIUS" value="120."/>
</section>
<section name="VERTICAL CONTROL" prefix="V_CTL_">
<define name="POWER_CTL_BAT_NOMINAL" value="11.1" unit="volt"/>
<!-- outer loop proportional gain -->
<define name="ALTITUDE_PGAIN" value="-0.06"/> <!-- -0.024 -->
<!-- outer loop saturation -->
<define name="ALTITUDE_PGAIN" value="-0.06"/>
<define name="ALTITUDE_MAX_CLIMB" value="2."/>
<!-- auto throttle inner loop -->
<define name="AUTO_THROTTLE_NOMINAL_CRUISE_THROTTLE" value="0.45"/>
<define name="AUTO_THROTTLE_MIN_CRUISE_THROTTLE" value="0.25"/>
<define name="AUTO_THROTTLE_MAX_CRUISE_THROTTLE" value="0.85"/>
<define name="AUTO_THROTTLE_LOITER_TRIM" value="1000"/>
<define name="AUTO_THROTTLE_DASH_TRIM" value="-1200"/>
<define name="AUTO_THROTTLE_CLIMB_THROTTLE_INCREMENT" value="0.2" unit="%/(m/s)"/>
<define name="AUTO_THROTTLE_PGAIN" value="-0.023"/> <!-- -0.012 -->
<define name="AUTO_THROTTLE_PGAIN" value="-0.023"/>
<define name="AUTO_THROTTLE_IGAIN" value="0.01"/>
<define name="AUTO_THROTTLE_PITCH_OF_VZ_PGAIN" value="0.05"/>
<!-- auto pitch inner loop -->
<define name="AUTO_PITCH_PGAIN" value="-0.06"/> <!-- -0.03 -->
<define name="AUTO_PITCH_PGAIN" value="-0.06"/>
<define name="AUTO_PITCH_IGAIN" value="0.0"/>
<define name="AUTO_PITCH_MAX_PITCH" value="0.35"/>
<define name="AUTO_PITCH_MIN_PITCH" value="-0.35"/>
<define name="THROTTLE_SLEW" value="0.1"/>
<define name="THROTTLE_SLEW" value="0.1"/>
</section>
<section name="HORIZONTAL CONTROL" prefix="H_CTL_">
<define name="COURSE_PGAIN" value="-0.9"/>
<define name="ROLL_MAX_SETPOINT" value="0.70" unit="radians"/> <!-- 0.5 -->
<define name="ROLL_MAX_SETPOINT" value="0.70" unit="radians"/>
<define name="PITCH_MAX_SETPOINT" value="0.5" unit="radians"/>
<define name="PITCH_MIN_SETPOINT" value="-0.5" unit="radians"/>
<define name="ROLL_PGAIN" value="6600."/>
<define name="AILERON_OF_THROTTLE" value="0.0"/>
<define name="PITCH_PGAIN" value="-5500."/>
<define name="PITCH_DGAIN" value="0.4"/>
<define name="ELEVATOR_OF_ROLL" value="2400"/>
<!--define name="ROLL_ATTITUDE_GAIN" value="-7500"/>
<define name="ROLL_RATE_GAIN" value="-1500"/-->
</section>
<section name="NAV">
@@ -158,13 +153,13 @@
</section>
<section name="AGGRESSIVE" prefix="AGR_">
<define name="BLEND_START" value="50"/><!-- Altitude Error to Initiate Aggressive Climb CANNOT BE ZERO!!-->
<define name="BLEND_END" value="15"/><!-- Altitude Error to Blend Aggressive to Regular Climb Modes CANNOT BE ZERO!!-->
<define name="CLIMB_THROTTLE" value="0.9"/><!-- Gaz for Aggressive Climb -->
<define name="CLIMB_PITCH" value="0.35"/><!-- Pitch for Aggressive Climb -->
<define name="DESCENT_THROTTLE" value="0.05"/><!-- Gaz for Aggressive Decent -->
<define name="DESCENT_PITCH" value="-0.35"/><!-- Pitch for Aggressive Decent -->
<define name="CLIMB_NAV_RATIO" value="0.8"/><!-- Percent Navigation for Altitude Error Equal to Start Altitude -->
<define name="BLEND_START" value="50"/>
<define name="BLEND_END" value="15"/>
<define name="CLIMB_THROTTLE" value="0.9"/>
<define name="CLIMB_PITCH" value="0.35"/>
<define name="DESCENT_THROTTLE" value="0.05"/>
<define name="DESCENT_PITCH" value="-0.35"/>
<define name="CLIMB_NAV_RATIO" value="0.8"/>
<define name="DESCENT_NAV_RATIO" value="1.0"/>
</section>
@@ -176,82 +171,5 @@
<define name="HOME_RADIUS" value="100" unit="m"/>
</section>
<section name="DATALINK" prefix="DATALINK_">
<define name="DEVICE_TYPE" value="XBEE"/>
<define name="DEVICE_ADDRESS" value="...."/>
</section>
<section name="SIMU">
<define name="YAW_RESPONSE_FACTOR" value="0.5"/>
</section>
<section name="MICROMAG">
<define name="MM_SS_PIN" value="20"/>
<define name="MM_SS_IODIR" value="IO0DIR"/>
<define name="MM_SS_IOSET" value="IO0SET"/>
<define name="MM_SS_IOCLR" value="IO0CLR"/>
<define name="MM_RESET_PIN" value="29"/>
<define name="MM_RESET_IODIR" value="IO0DIR"/>
<define name="MM_RESET_IOSET" value="IO0SET"/>
<define name="MM_RESET_IOCLR" value="IO0CLR"/>
<define name="MM_DRDY_PINSEL" value="PINSEL1"/>
<define name="MM_DRDY_PINSEL_BIT" value="0"/>
<define name="MM_DRDY_PINSEL_VAL" value="1"/>
<define name="MM_DRDY_EINT" value="0"/>
<define name="MM_DRDY_VIC_IT" value="VIC_EINT0"/>
</section>
<makefile>
CONFIG = \"tiny_2_1.h\"
include $(PAPARAZZI_SRC)/conf/autopilot/tiny.makefile
FLASH_MODE=IAP
ap.CFLAGS += -DFBW -DAP -DBOARD_CONFIG=$(CONFIG) -DLED -DTIME_LED=1
ap.srcs = sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c main_fbw.c main_ap.c main.c
ap.srcs += commands.c
ap.CFLAGS += -DACTUATORS=\"servos_4017_hw.h\" -DSERVOS_4017
ap.srcs += $(SRC_ARCH)/servos_4017_hw.c actuators.c
ap.CFLAGS += -DDOWNLINK -DUSE_UART1 -DDOWNLINK_TRANSPORT=XBeeTransport -DXBEE_UART=Uart1 -DDATALINK=XBEE -DUART1_BAUD=B57600
ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c datalink.c xbee.c
ap.CFLAGS += -DINTER_MCU
ap.srcs += inter_mcu.c
ap.CFLAGS += -DADC -DUSE_ADC_0 -DUSE_ADC_1 -DUSE_ADC_2 -DUSE_ADC_4
ap.srcs += $(SRC_ARCH)/adc_hw.c
ap.CFLAGS += -DGPS -DUBX -DUSE_UART0 -DGPS_LINK=Uart0 -DUART0_BAUD=B38400 -DGPS_USE_LATLONG
# -DGPS_LED=2
ap.srcs += gps_ubx.c gps.c latlong.c
ap.CFLAGS += -DINFRARED -DALT_KALMAN -DWIND_INFO -DWIND_INFO_RET
ap.srcs += infrared.c estimator.c
ap.CFLAGS += -DNAV -DAGR_CLIMB -DLOITER_TRIM
ap.srcs += nav.c fw_h_ctl.c fw_v_ctl.c
ap.srcs += nav_line.c
ap.srcs += nav_survey_rectangle.c
ap.srcs += $(SRC_ARCH)/trig_ext_hw.c
ap.CFLAGS += -DTRIG_EXT_PULSE_TYPE=TRIG_EXT_EDGE_FALLING -DTRIGGER_EXT
ap.CFLAGS += -DGPS_TIMESTAMP
# Config for SITL simulation
include $(PAPARAZZI_SRC)/conf/autopilot/sitl.makefile
sim.CFLAGS += -DBOARD_CONFIG=\"tiny.h\" -DAGR_CLIMB -DLOITER_TRIM -DALT_KALMAN
sim.srcs += nav_line.c nav_survey_rectangle.c
</makefile>
</airframe>
+20
View File
@@ -0,0 +1,20 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="trigger_ext" dir="sensors">
<header>
<file name="trigger_ext.h"/>
</header>
<init fun="trigger_ext_init()"/>
<periodic fun="trigger_ext_periodic()" freq="10"/>
<makefile>
<raw>
ap.srcs += $(SRC_ARCH)/trig_ext_hw.c
</raw>
<file name="trigger_ext.c"/>
<flag name="TRIGGER_EXT"/>
<flag name="TRIG_EXT_PULSE_TYPE" value="TRIG_EXT_EDGE_FALLING"/>
<flag name="TURBINE_ID" value="42"/>
<flag name="GPS_TIMESTAMP"/>
</makefile>
</module>
+1 -1
View File
@@ -53,7 +53,7 @@ uint32_t sys_time_chrono; /* T0TC ticks */
#endif
#ifdef TRIGGER_EXT
#include "trig_ext.h"
#include "trig_ext_hw.h"
#endif
#define TIMER0_IT_MASK (ACTUATORS_IT |\
+26 -5
View File
@@ -1,12 +1,33 @@
//#include "trig_ext.h"
#include "std.h"
#include "sys_time.h"
#include "LPC21xx.h"
#include "trig_ext_hw.h"
#include BOARD_CONFIG
uint32_t trigger_t0;
uint32_t delta_t0;
volatile bool_t trig_ext_valid;
void TRIG_ISR() {
static uint32_t last;
trigger_t0 = PPM_CR;
delta_t0 = trigger_t0 - last;
last = trigger_t0;
trig_ext_valid = TRUE;
}
void trig_ext_init ( void ) {
/* select pin for capture */
PPM_PINSEL |= PPM_PINSEL_VAL << PPM_PINSEL_BIT;
/* enable capture 0.2 on falling or rising edge + trigger interrupt */
#if defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == TRIG_EXT_PULSE_TYPE_RISING
T0CCR = PPM_CCR_CRR | PPM_CCR_CRI;
#elif defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == TRIG_EXT_PULSE_TYPE_FALLING
T0CCR = PPM_CCR_CRF | PPM_CCR_CRI;
#else
#error "trig_ext_hw.h: Unknown PULSE_TYPE"
#endif
trig_ext_valid = FALSE;
}
+6 -27
View File
@@ -1,6 +1,7 @@
#ifndef TRIG_EXT_HW_H
#define TRIG_EXT_HW_H
#include "std.h"
/**
* falling/rising edge
@@ -8,34 +9,12 @@
#define TRIG_EXT_EDGE_RISING 1
#define TRIG_EXT_EDGE_FALLING 0
extern uint32_t trigger_t0;
extern uint32_t delta_t0;
extern volatile bool_t trig_ext_valid;
#include "LPC21xx.h"
#include BOARD_CONFIG
static inline void trig_ext_init ( void ) {
/* select pin for capture */
PPM_PINSEL |= PPM_PINSEL_VAL << PPM_PINSEL_BIT;
/* enable capture 0.2 on falling or rising edge + trigger interrupt */
#if defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == TRIG_EXT_PULSE_TYPE_RISING
T0CCR = PPM_CCR_CRR | PPM_CCR_CRI;
#elif defined TRIG_EXT_PULSE_TYPE && TRIG_EXT_PULSE_TYPE == TRIG_EXT_PULSE_TYPE_FALLING
T0CCR = PPM_CCR_CRF | PPM_CCR_CRI;
#else
#error "trig_ext_hw.h: Unknown PULSE_TYPE"
#endif
trig_ext_valid = FALSE;
}
#define TRIG_ISR() { \
static uint32_t last; \
trigger_t0 = PPM_CR; \
delta_t0 = trigger_t0 - last; \
last = trigger_t0; \
trig_ext_valid = TRUE; \
}
void TRIG_ISR(void);
void trig_ext_init( void );
#endif /* TRIG_EXT_HW_H */
-25
View File
@@ -123,10 +123,6 @@
#include "baro_ets.h"
#endif // USE_BARO_ETS
#ifdef TRIGGER_EXT
#include "trig_ext.h"
#endif // TRIGGER_EXT
/*code added by Haiyang Chao for using Xsens IMU for fixed wing UAV 20080804*/
#ifdef UGEAR
#include "osam_imu_ugear.h"
@@ -773,10 +769,6 @@ void init_ap( void ) {
power_switch = FALSE;
#ifdef TRIGGER_EXT
trig_ext_init();
#endif
/************ Multi-uavs status ***************/
#ifdef TRAFFIC_INFO
@@ -932,23 +924,6 @@ void event_task_ap( void ) {
}
#endif
#ifdef TRIGGER_EXT
if (trig_ext_valid == TRUE) {
uint8_t turb_id = 0;
uint32_t sync_itow, cycle_time;
sync_itow = itow_from_ticks(trigger_t0);
cycle_time = MSEC_OF_SYS_TICS(delta_t0);
DOWNLINK_SEND_WINDTURBINE_STATUS_(DefaultChannel,
&turb_id,
&turb_id,
&sync_itow,
&cycle_time );
trig_ext_valid = FALSE;
}
#endif
if (inter_mcu_received_fbw) {
/* receive radio control task from fbw */
inter_mcu_received_fbw = FALSE;
+1 -1
View File
@@ -28,7 +28,7 @@
* This reads the values for humidity from the Honeywell HIH-4030 sensor.
*/
#include <std.h>
#include "humid_hih.h"
#include "temp_tmp102.h"
#include "adc.h"
+63
View File
@@ -0,0 +1,63 @@
/*
* $Id$
*
* Copyright (C) 2010 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 trigger_ext.c
* \brief Measure external trigger pulse at PPM input
*
* This measures a trigger pulse length (e.g. duration of a wind turbine
* rotation) and sends a message with the info.
*/
#include "trigger_ext.h"
#include "trig_ext_hw.h"
#include "gps.h"
#include "sys_time.h"
#include "uart.h"
#include "messages.h"
#include "downlink.h"
void trigger_ext_init ( void ) {
trig_ext_init();
}
void trigger_ext_periodic( void ) {
if (trig_ext_valid == TRUE) {
uint8_t ac_id = 0;
uint8_t turb_id = TURBINE_ID;
uint32_t sync_itow, cycle_time;
sync_itow = itow_from_ticks(trigger_t0);
cycle_time = MSEC_OF_SYS_TICS(delta_t0);
DOWNLINK_SEND_WINDTURBINE_STATUS_(DefaultChannel,
&ac_id,
&turb_id,
&sync_itow,
&cycle_time );
trig_ext_valid = FALSE;
}
}
+10
View File
@@ -0,0 +1,10 @@
#ifndef TRIGGER_EXT_H
#define TRIGGER_EXT_H
void trigger_ext_init ( void );
void trigger_ext_periodic( void );
#endif
-38
View File
@@ -1,38 +0,0 @@
/* $Id: ppm.h 4281 2009-10-19 18:32:12Z mmm $
*
* (c) 2005 Pascal Brisset, Antoine Drouin
*
* 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 TRIG_EXT_H
#define TRIG_EXT_H
#if defined TRIGGER_EXT
#include "std.h"
extern uint32_t trigger_t0;
extern uint32_t delta_t0;
extern volatile bool_t trig_ext_valid;
#include "trig_ext_hw.h"
#endif /* TRIGGER_EXT */
#endif