Airspeed sensor (ADC).
Using the internal ADC.
Example for airframe file
Add to your firmware section: This example contains all possible configuration options, not all of them are mandatory!
<module name="airspeed_adc">
b'<define name="AIRSPEED_ADC_SCALE" value="scale factor" />\n '
b'<define name="AIRSPEED_ADC_QUADRATIC_SCALE" value="quadratic scale factor" />\n '
b'<define name="AIRSPEED_ADC_BIAS" value="sensor bias" />\n '
b'<define name="USE_AIRSPEED_ADC" value="TRUE|FALSE" />\n '
b'<configure name="ADC_AIRSPEED" value="ADCX" />\n '
</module>
Module configuration options
Configure Options
- name:
ADC_AIRSPEED
value: ADCX
Description: ADC on which sensor is connected
Define Options
- name:
AIRSPEED_ADC_SCALE
value: scale factor
Description: linear scale factor (used if AIRSPEED_QUADRATIC_SCALE is not defined
- name:
AIRSPEED_ADC_QUADRATIC_SCALE
value: quadratic scale factor
Description: it is recommended to use quadratic scale
- name:
AIRSPEED_ADC_BIAS
value: sensor bias
Description: offset on ADC
- name:
USE_AIRSPEED_ADC
value: TRUE|FALSE
Description: set airspeed in state interface (default:TRUE)
Module functions
Init Functions
These initialization functions are called once on startup.
Periodic Functions
These functions are called periodically at the specified frequency from the module periodic loop.
- airspeed_adc_update()
- Running at maximum module frequency.
- Autorun: LOCK
Periodic function automatically starts after init and can't be stopped.
Files
Header Files
The following headers are automatically included in modules.h
Source Files
Raw airspeed_adc.xml file:
<!DOCTYPE module SYSTEM "module.dtd">
<module name="airspeed_adc" dir="sensors" task="sensors">
<doc>
<description>Airspeed sensor (ADC).
Using the internal ADC.
</description>
<configure name="ADC_AIRSPEED" value="ADCX" description="ADC on which sensor is connected"/>
<define name="AIRSPEED_ADC_SCALE" value="scale factor" description="linear scale factor (used if AIRSPEED_QUADRATIC_SCALE is not defined"/>
<define name="AIRSPEED_ADC_QUADRATIC_SCALE" value="quadratic scale factor" description="it is recommended to use quadratic scale"/>
<define name="AIRSPEED_ADC_BIAS" value="sensor bias" description="offset on ADC"/>
<define name="USE_AIRSPEED_ADC" value="TRUE|FALSE" description="set airspeed in state interface (default:TRUE)"/>
</doc>
<settings>
<dl_settings>
<dl_settings name="airsp">
<dl_setting max="4095" min="0" step="1" module="sensors/airspeed_adc" var="airspeed_adc.offset" shortname="air_bias"/>
<dl_setting max="3" min="0" step="0.001" module="sensors/airspeed_adc" var="airspeed_adc.scale" shortname="air_scale"/>
</dl_settings>
</dl_settings>
</settings>
<dep>
<depends>adc</depends>
<provides>airspeed</provides>
</dep>
<header>
<file name="airspeed_adc.h"/>
</header>
<init fun="airspeed_adc_init()"/>
<periodic fun="airspeed_adc_update()" />
<makefile target="ap|sim">
<file name="airspeed_adc.c"/>
<test arch="test">
<define name="AIRSPEED_ADC_QUADRATIC_SCALE" value="1"/>
<define name="AIRSPEED_ADC_BIAS" value="0"/>
<define name="ADC_CHANNEL_AIRSPEED" value="0"/>
</test>
</makefile>
<makefile target="ap">
<define name="ADC_CHANNEL_AIRSPEED" value="$(ADC_AIRSPEED)"/>
<define name="USE_$(ADC_AIRSPEED)"/>
</makefile>
</module>