mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-06 16:58:48 +08:00
[actuators] first test with 2 drivers
- actuators are now in signed int16 (need to check size again) (int32 ?) - servo_switch module replaces booz_drop - booz_pwm is now handled by actuators_direct
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
<airframe name="BOOZ2_G1">
|
||||
|
||||
<modules main_freq="512">
|
||||
<!--load name="booz_pwm.xml">
|
||||
<define name="USE_PWM1"/>
|
||||
</load>
|
||||
<load name="booz_drop.xml"/>
|
||||
<load name="booz_cam.xml"/-->
|
||||
<load name="servo_switch.xml"/>
|
||||
<!--load name="booz_cam.xml"/-->
|
||||
<!--load name="sonar_maxbotix_booz.xml"/-->
|
||||
<!--load name="adc_generic_booz.xml"/-->
|
||||
<!--load name="sys_mon.xml"/-->
|
||||
@@ -54,8 +51,8 @@
|
||||
</servos>
|
||||
|
||||
<servos driver="Pwm">
|
||||
<servo name="CAM" no="0" min="1000" neutral="1500" max="2000"/>
|
||||
<servo name="DROP" no="5" min="1000" neutral="1500" max="2000"/>
|
||||
<servo name="CAM" no="5" min="1000" neutral="1500" max="2000"/>
|
||||
<servo name="SWITCH" no="0" min="2120" neutral="1500" max="1060"/>
|
||||
</servos>
|
||||
|
||||
<commands>
|
||||
@@ -63,13 +60,15 @@
|
||||
<axis name="ROLL" failsafe_value="0"/>
|
||||
<axis name="YAW" failsafe_value="0"/>
|
||||
<axis name="THRUST" failsafe_value="0"/>
|
||||
<axis name="SWITCH" failsafe_value="0"/>
|
||||
</commands>
|
||||
|
||||
<command_laws>
|
||||
<set servo="PITCH" value="@PITCH"/>
|
||||
<set servo="ROLL" value="@ROLL"/>
|
||||
<set servo="YAW" value="@YAW"/>
|
||||
<set servo="PITCH" value="@PITCH - TRIM_PITCH"/>
|
||||
<set servo="ROLL" value="@ROLL - TRIM_ROLL"/>
|
||||
<set servo="YAW" value="@YAW - TRIM_YAW"/>
|
||||
<set servo="THRUST" value="@THRUST"/>
|
||||
<set servo="SWITCH" value="@SWITCH"/>
|
||||
</command_laws>
|
||||
|
||||
<section name="IMU" prefix="IMU_">
|
||||
@@ -230,12 +229,6 @@
|
||||
<define name="SetPwm(_v)" value="BoozSetPwm1Value(_v)"/>
|
||||
</section>
|
||||
|
||||
<section name="DROP">
|
||||
<define name="DROP_SERVO_CLOSED" value="2120"/>
|
||||
<define name="DROP_SERVO_OPEN" value="1060"/>
|
||||
<!--define name="BoozDropPwm(_v)" value="BoozSetPwm0Value(_v)"/-->
|
||||
</section>
|
||||
|
||||
<section name="MISC">
|
||||
<define name="BOOZ_ANALOG_BARO_THRESHOLD" value="800"/>
|
||||
<define name="FACE_REINJ_1" value="1024"/>
|
||||
|
||||
+1
-1
@@ -737,7 +737,7 @@
|
||||
</message>
|
||||
|
||||
<message name="ACTUATORS" id="105">
|
||||
<field name="values" type="uint16[]" unit="none"/>
|
||||
<field name="values" type="int16[]" unit="none"/>
|
||||
</message>
|
||||
|
||||
<message name="BETH" id="106">
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
<!DOCTYPE module SYSTEM "module.dtd">
|
||||
<!--
|
||||
DROP_SERVO_CLOSED and DROP_SERVO_OPEN can be redefined in airframe file
|
||||
units: PWM width in us
|
||||
-->
|
||||
|
||||
<module name="drop">
|
||||
<doc>
|
||||
<description>Drop control for BOOZ board</description>
|
||||
<define name="DROP_SERVO_OPEN" value="pwm" description="PWM value when servo is in open position in us (optional)"/>
|
||||
<define name="DROP_SERVO_CLOSED" value="pwm" description="PWM value when servo is in closed position in us (optional)"/>
|
||||
</doc>
|
||||
<!-- depend require="booz_pwm" -->
|
||||
<header>
|
||||
<file name="booz_drop.h"/>
|
||||
</header>
|
||||
<init fun="booz_drop_init()"/>
|
||||
<periodic fun="booz_drop_periodic()" freq="10."/>
|
||||
<makefile>
|
||||
<define name="USE_DROP"/>
|
||||
<file name="booz_drop.c"/>
|
||||
</makefile>
|
||||
</module>
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<!DOCTYPE module SYSTEM "module.dtd">
|
||||
|
||||
<!--
|
||||
Allow to use PWM output on booz boards
|
||||
PWM0 is activated by default (PWM5 on lpc21 output)
|
||||
PWM1 can be activated with USE_PWM1 flag (PWM2 on lpc21 output)
|
||||
-->
|
||||
|
||||
<module name="booz_pwm" dir="core">
|
||||
<doc>
|
||||
<description>Allow to use PWM output on booz boards, PWM0 is activated by default (PWM5 on lpc21 output)</description>
|
||||
<define name="USE_PWM1" description="flag to activate with USE_PWM1 flag (PWM2 on lpc21 output)"/>
|
||||
</doc>
|
||||
<header>
|
||||
<file name="booz_pwm_arch.h"/>
|
||||
</header>
|
||||
<init fun="booz_pwm_init_arch()"/>
|
||||
<makefile target="ap">
|
||||
<file_arch name="booz_pwm_arch.c"/>
|
||||
</makefile>
|
||||
</module>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<description>Servo switch</description>
|
||||
<define name="SERVO_SWITCH_ON_VALUE" value="pwm" description="servo value in usec"/>
|
||||
<define name="SERVO_SWITCH_OFF_VALUE" value="pwm" description="servo value in usec"/>
|
||||
<define name="SERVO_SWITCH_SERVO" value="nb" description="Id of the servo to use"/>
|
||||
<define name="SERVO_SWITCH_SERVO" value="nb" description="Id of the switch command (default: COMMAND_SWITCH)"/>
|
||||
</doc>
|
||||
<header>
|
||||
<file name="servo_switch.h"/>
|
||||
@@ -17,10 +17,14 @@
|
||||
<!-- these parameters should be set for that module in the airframe file unless you want the defaults
|
||||
Servo value in usec
|
||||
<load name="servo_switch.xml">
|
||||
<define name="SERVO_SWITCH_ON_VALUE" value="2000"/>
|
||||
<define name="SERVO_SWITCH_OFF_VALUE" value="1000"/>
|
||||
<define name="SERVO_SWITCH_SERVO" value="SERVO_SWITCH"/>
|
||||
<define name="SERVO_SWITCH_ON_VALUE" value="MAX_PPRZ"/>
|
||||
<define name="SERVO_SWITCH_OFF_VALUE" value="-MAX_PPRZ"/>
|
||||
<define name="SERVO_SWITCH_SERVO" value="COMMAND_SWITCH"/>
|
||||
</load>
|
||||
|
||||
The SWITCH servo, the SWITCH command and the command_law (usually <set servo="SWITCH" value="@SWITCH"/>
|
||||
must be defined correctly
|
||||
The min and max positions of the servo are defined in the servo section
|
||||
-->
|
||||
|
||||
<file name="servo_switch.c"/>
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 ENAC
|
||||
*
|
||||
* 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 "modules/core/booz_pwm_arch.h"
|
||||
|
||||
#define PWM_PERIOD CPU_TICKS_OF_USEC(20000)
|
||||
#define PWM_DUTY CPU_TICKS_OF_USEC(1500)
|
||||
|
||||
void booz_pwm_init_arch( void ) {
|
||||
|
||||
/* start PWM5 */
|
||||
/* select P0.21 as PWM5 */
|
||||
PWM0_PINSEL |= PWM0_PINSEL_VAL << PWM0_PINSEL_BIT;
|
||||
/* select pwm period */
|
||||
PWMMR0 = PWM_PERIOD;
|
||||
/* select pwm value to 50% at init (1500 us) */
|
||||
PWMMR5 = PWM_DUTY;
|
||||
/* commit values */
|
||||
PWMLER = PWMLER_LATCH0 | PWMLER_LATCH5;
|
||||
/* prescle timer to match TIMER 0 (15MHz) */
|
||||
PWMPR = T0_PCLK_DIV - 1;
|
||||
/* enable counter and pwm mode */
|
||||
PWMTCR = PWMTCR_COUNTER_ENABLE | PWMTCR_PWM_ENABLE;
|
||||
/* enable PWM5 */
|
||||
PWMPCR = PWMPCR_ENA5;
|
||||
|
||||
#ifdef USE_PWM1
|
||||
/* start PWM2 */
|
||||
PWM1_PINSEL |= PWM1_PINSEL_VAL << PWM1_PINSEL_BIT;
|
||||
/* select pwm value to 50% at init (1500 us) */
|
||||
PWMMR2 = PWM_DUTY;
|
||||
/* commit values */
|
||||
PWMLER = PWMLER_LATCH2;
|
||||
/* enable PWM2 */
|
||||
PWMPCR |= PWMPCR_ENA2;
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 ENAC
|
||||
*
|
||||
* 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 BOOZ_PWM_ARCH_H
|
||||
#define BOOZ_PWM_ARCH_H
|
||||
|
||||
#include "std.h"
|
||||
#include "mcu_periph/sys_time.h"
|
||||
|
||||
extern void booz_pwm_init_arch(void);
|
||||
|
||||
// Default PWM is PWM0
|
||||
#define BoozSetPwmValue(_v) BoozSetPwm0Value(_v)
|
||||
|
||||
#define BoozSetPwm0Value(_v) { \
|
||||
PWMMR5 = CPU_TICKS_OF_USEC(_v); \
|
||||
PWMLER = PWMLER_LATCH5; \
|
||||
}
|
||||
|
||||
#define BoozSetPwm1Value(_v) { \
|
||||
PWMMR2 = CPU_TICKS_OF_USEC(_v); \
|
||||
PWMLER = PWMLER_LATCH2; \
|
||||
}
|
||||
|
||||
#endif /* BOOZ_PWM_ARCH_H */
|
||||
@@ -136,6 +136,12 @@
|
||||
#define PERIODIC_SEND_PPM(_trans, _dev) {}
|
||||
#endif
|
||||
|
||||
#ifdef ACTUATORS
|
||||
#define PERIODIC_SEND_ACTUATORS(_trans, _dev) DOWNLINK_SEND_ACTUATORS(_trans, _dev, ACTUATORS_NB, actuators)
|
||||
#else
|
||||
#define PERIODIC_SEND_ACTUATORS(_trans, _dev) {}
|
||||
#endif
|
||||
|
||||
#define PERIODIC_SEND_IMU_GYRO_SCALED(_trans, _dev) { \
|
||||
DOWNLINK_SEND_IMU_GYRO_SCALED(_trans, _dev, \
|
||||
&imu.gyro.p, \
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2009 Flixr
|
||||
*
|
||||
* 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 "modules/drop/booz_drop.h"
|
||||
#include "modules/core/booz_pwm_arch.h"
|
||||
#include "generated/airframe.h"
|
||||
|
||||
bool_t booz_drop_ball;
|
||||
int16_t booz_drop_servo;
|
||||
|
||||
#ifndef DROP_SERVO_OPEN
|
||||
#define DROP_SERVO_OPEN 1700
|
||||
#endif
|
||||
#ifndef DROP_SERVO_CLOSED
|
||||
#define DROP_SERVO_CLOSED 900
|
||||
#endif
|
||||
|
||||
// PWM definition
|
||||
#ifndef BoozDropPwm
|
||||
#define BoozDropPwm(_v) BoozSetPwmValue(_v)
|
||||
#endif
|
||||
|
||||
void booz_drop_init(void) {
|
||||
booz_drop_ball = FALSE;
|
||||
booz_drop_periodic();
|
||||
}
|
||||
|
||||
void booz_drop_periodic(void) {
|
||||
if (booz_drop_ball == TRUE)
|
||||
booz_drop_servo = DROP_SERVO_OPEN;
|
||||
else
|
||||
booz_drop_servo = DROP_SERVO_CLOSED;
|
||||
BoozDropPwm(booz_drop_servo);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2009 Flixr
|
||||
*
|
||||
* 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 BOOZ_DROP_H
|
||||
#define BOOZ_DROP_H
|
||||
|
||||
#include "std.h"
|
||||
|
||||
extern bool_t booz_drop_ball;
|
||||
|
||||
extern void booz_drop_init(void);
|
||||
extern void booz_drop_periodic(void);
|
||||
|
||||
#define NavDropNow() ({ booz_drop_ball = TRUE; FALSE; })
|
||||
#define NavDropClose() ({ booz_drop_ball = FALSE; FALSE; })
|
||||
|
||||
#endif /* BOOZ_DROP_H */
|
||||
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2010 Flixr
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
@@ -23,10 +21,9 @@
|
||||
|
||||
#include "servo_switch/servo_switch.h"
|
||||
#include "generated/airframe.h"
|
||||
#include "actuators.h"
|
||||
#include "firmwares/rotorcraft/commands.h"
|
||||
|
||||
bool_t servo_switch_on;
|
||||
int16_t servo_switch_value;
|
||||
|
||||
void servo_switch_init(void) {
|
||||
servo_switch_on = FALSE;
|
||||
@@ -35,7 +32,7 @@ void servo_switch_init(void) {
|
||||
|
||||
void servo_switch_periodic(void) {
|
||||
if (servo_switch_on == TRUE)
|
||||
SetServo(SERVO_SWITCH_SERVO, SERVO_SWITCH_ON_VALUE)
|
||||
commands[SERVO_SWITCH_SERVO] = SERVO_SWITCH_ON_VALUE;
|
||||
else
|
||||
SetServo(SERVO_SWITCH_SERVO, SERVO_SWITCH_OFF_VALUE)
|
||||
commands[SERVO_SWITCH_SERVO] = SERVO_SWITCH_OFF_VALUE;
|
||||
}
|
||||
|
||||
@@ -31,13 +31,13 @@ extern bool_t servo_switch_on;
|
||||
extern int16_t servo_switch_value;
|
||||
|
||||
#ifndef SERVO_SWITCH_ON_VALUE
|
||||
#define SERVO_SWITCH_ON_VALUE 2000
|
||||
#define SERVO_SWITCH_ON_VALUE MAX_PPRZ
|
||||
#endif
|
||||
#ifndef SERVO_SWITCH_OFF_VALUE
|
||||
#define SERVO_SWITCH_OFF_VALUE 1000
|
||||
#define SERVO_SWITCH_OFF_VALUE -MAX_PPRZ
|
||||
#endif
|
||||
#ifndef SERVO_SWITCH_SERVO
|
||||
#define SERVO_SWITCH_SERVO SERVO_SWITCH
|
||||
#define SERVO_SWITCH_SERVO COMMAND_SWITCH
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#if ACTUATORS_NB
|
||||
|
||||
uint16_t actuators[ACTUATORS_NB];
|
||||
int16_t actuators[ACTUATORS_NB];
|
||||
|
||||
void actuators_init(void) {
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
extern void actuators_init(void);
|
||||
|
||||
/** Temporary storage (for debugging purpose, downlinked via telemetry) */
|
||||
extern uint16_t actuators[ACTUATORS_NB];
|
||||
extern int16_t actuators[ACTUATORS_NB];
|
||||
|
||||
#endif /* ACTUATORS_NB */
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ let rec parse_section = fun s ->
|
||||
print_actuators_idx ();
|
||||
|
||||
printf "#define SetActuatorsFromCommands(values) { \\\n";
|
||||
printf " uint32_t servo_value;\\\n";
|
||||
printf " int32_t servo_value;\\\n";
|
||||
printf " float command_value;\\\n";
|
||||
|
||||
List.iter parse_command_laws (Xml.children s);
|
||||
|
||||
Reference in New Issue
Block a user