mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-24 05:45:59 +08:00
[modules] Rotating wing better ADC sensor integration (#3251)
* Make adc sensor mappable from the airframe. Better interface for adc in the rotwing state. * Added parameters to v3b airframe * Addressed the comments * Removed external variable
This commit is contained in:
committed by
GitHub
parent
25ec86275f
commit
afa93784ed
@@ -40,7 +40,10 @@
|
||||
<configure name="USE_TFMINI_AGL" value="TRUE"/>
|
||||
</module>
|
||||
|
||||
<module name="wing_rotation_adc_sensor"/>
|
||||
<module name="wing_rotation_adc_sensor">
|
||||
<define name="ADC_WING_ROT_SCALE" value="0.00247111"/>
|
||||
<define name="ADC_WING_ROT_OFFSET" value="-25.635294"/>
|
||||
</module>
|
||||
|
||||
<!-- <module name="mavlink">
|
||||
<configure name="MAVLINK_BAUD" value="B115200"/>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<configure name="ADC_CHANNEL_WING_ROTATION_CONTROLLER_POSITION" default="ADC_5" case="lower|upper"/>
|
||||
<define name="ADC_CHANNEL_WING_ROTATION_CONTROLLER_POSITION" value="$(ADC_CHANNEL_WING_ROTATION_CONTROLLER_POSITION_UPPER)"/>
|
||||
<define name="USE_$(ADC_CHANNEL_WING_ROTATION_CONTROLLER_POSITION_UPPER)"/>
|
||||
<define name="ADC_WING_ROTATION" value="TRUE"/>
|
||||
<file name="wing_rotation_adc_sensor.c"/>
|
||||
</makefile>
|
||||
</module>
|
||||
|
||||
@@ -105,6 +105,13 @@
|
||||
#define ROTWING_STATE_FW_PREF_PITCH 8.0
|
||||
#endif
|
||||
|
||||
// stream ADC data if ADC rotation sensor
|
||||
#ifndef ADC_WING_ROTATION
|
||||
#define ADC_WING_ROTATION FALSE
|
||||
#endif
|
||||
#if ADC_WING_ROTATION
|
||||
#include "wing_rotation_adc_sensor.h"
|
||||
#endif
|
||||
/** ABI binding feedback data.
|
||||
*/
|
||||
#ifndef ROTWING_STATE_ACT_FEEDBACK_ID
|
||||
|
||||
@@ -39,21 +39,35 @@
|
||||
#define ADC_CHANNEL_WING_ROTATION_CONTROLLER_POSITION_NB_SAMPLES 16
|
||||
#endif
|
||||
|
||||
static struct adc_buf buf_wing_rot_pos;
|
||||
#ifndef ADC_WING_ROT_OFFSET
|
||||
#error "ADC_WING_ROT_OFFSET not defined"
|
||||
#endif
|
||||
|
||||
#ifndef ADC_WING_ROT_SCALE
|
||||
#error "ADC_WING_ROT_SCALE not defined"
|
||||
#endif
|
||||
|
||||
#ifdef ADC_WING_ROT_OFFSET
|
||||
static float adc_offset = ADC_WING_ROT_OFFSET;
|
||||
#endif
|
||||
|
||||
#ifdef ADC_WING_ROT_SCALE
|
||||
static float adc_scale = ADC_WING_ROT_SCALE;
|
||||
#endif
|
||||
|
||||
static struct adc_buf buf_wing_rot_pos;
|
||||
// Initialization
|
||||
void wing_rotation_adc_init(void)
|
||||
{
|
||||
// ADC init
|
||||
adc_buf_channel(ADC_CHANNEL_WING_ROTATION_CONTROLLER_POSITION, &buf_wing_rot_pos,
|
||||
ADC_CHANNEL_WING_ROTATION_CONTROLLER_POSITION_NB_SAMPLES);
|
||||
ADC_CHANNEL_WING_ROTATION_CONTROLLER_POSITION_NB_SAMPLES);
|
||||
}
|
||||
|
||||
void wing_rotation_adc_to_deg(void)
|
||||
{
|
||||
float adc_wing_rotation = buf_wing_rot_pos.sum / buf_wing_rot_pos.av_nb_sample;
|
||||
float wing_angle_deg = 0.00247111 * adc_wing_rotation - 25.635294;
|
||||
|
||||
float wing_angle_deg = adc_scale * adc_wing_rotation + adc_offset;
|
||||
|
||||
// SEND ABI Message to ctr_eff_sched and other modules that want Actuator position feedback
|
||||
struct act_feedback_t feedback = {0};
|
||||
|
||||
Reference in New Issue
Block a user