MS45XX differential or gauge type of pressure sensor for e.g measuring airspeed.
This sensor module is using the MS45xxDO digital pressure sensor with readings via I2C. Needs to be a versions with 14bit pressure and 11bit temperature data output.
If the airspeed reading is badly calibrated, use the MS45XX_PRESSURE_SCALE to compensate. Use the MS45XX_AIRSPEED_SCALE only to change air density.
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_ms45xx_i2c">
b'<define name="MS45XX_I2C_DEV" value="i2cX" />\n '
b'<define name="MS45XX_I2C_ADDR" value="0x50" />\n '
b'<define name="MS45XX_PRESSURE_TYPE" value="0|1" />\n '
b'<define name="MS45XX_PRESSURE_RANGE" value="1|2|4|5|10|15|20|30|50|100|150" />\n '
b'<define name="MS45XX_OUTPUT_TYPE" value="0|1" />\n '
b'<define name="MS45XX_PRESSURE_SCALE" value="1.05" />\n '
b'<define name="MS45XX_PRESSURE_OFFSET" value="8618.4" />\n '
b'<define name="MS45XX_LOWPASS_TAU" value="0.15" />\n '
</module>
Module configuration options
Define Options
- name:
MS45XX_I2C_DEV
value: i2cX
Description: set i2c peripheral (default: i2c2)
- name:
MS45XX_I2C_ADDR
value: 0x50
Description: i2c slave address (default: 0x50)
- name:
MS45XX_PRESSURE_TYPE
value: 0|1
Description: Pressure Differential or Gauge, default is Differential
- name:
MS45XX_PRESSURE_RANGE
value: 1|2|4|5|10|15|20|30|50|100|150
Description: pressure range in psi (default: 1)
- name:
MS45XX_OUTPUT_TYPE
value: 0|1
Description: set to 0 for output type A, to 1 for output type B (default: type A)
- name:
MS45XX_PRESSURE_SCALE
value: 1.05
Description: pressure scaling factor to convert raw output to Pa (default: set according to pressure range and output type according to datasheet)
- name:
MS45XX_PRESSURE_OFFSET
value: 8618.4
Description: pressure offset in Pa (default: set according to pressure range and output type according to datasheet)
- name:
MS45XX_LOWPASS_TAU
value: 0.15
Description: Time constant for second order Butterworth low pass filter
Module functions
Init Functions
These initialization functions are called once on startup.
Event Functions
These event functions are called in each cycle of the module event loop.
Periodic Functions
These functions are called periodically at the specified frequency from the module periodic loop.
- ms45xx_i2c_periodic()
- Frequency in Hz: 100.
- 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_ms45xx_i2c.xml file:
<!DOCTYPE module SYSTEM "module.dtd">
<module name="airspeed_ms45xx_i2c" dir="sensors" task="sensors">
<doc>
<description>
MS45XX differential or gauge type of pressure sensor for e.g measuring airspeed.
This sensor module is using the MS45xxDO digital pressure sensor with readings via I2C.
Needs to be a versions with 14bit pressure and 11bit temperature data output.
If the airspeed reading is badly calibrated, use the MS45XX_PRESSURE_SCALE to compensate.
Use the MS45XX_AIRSPEED_SCALE only to change air density.
</description>
<define name="MS45XX_I2C_DEV" value="i2cX" description="set i2c peripheral (default: i2c2)"/>
<define name="MS45XX_I2C_ADDR" value="0x50" description="i2c slave address (default: 0x50)"/>
<define name="MS45XX_PRESSURE_TYPE" value="0|1" description="Pressure Differential or Gauge, default is Differential"/>
<define name="MS45XX_PRESSURE_RANGE" value="1|2|4|5|10|15|20|30|50|100|150" description="pressure range in psi (default: 1)"/>
<define name="MS45XX_OUTPUT_TYPE" value="0|1" description="set to 0 for output type A, to 1 for output type B (default: type A)"/>
<define name="MS45XX_PRESSURE_SCALE" value="1.05" description="pressure scaling factor to convert raw output to Pa (default: set according to pressure range and output type according to datasheet)"/>
<define name="MS45XX_PRESSURE_OFFSET" value="8618.4" description="pressure offset in Pa (default: set according to pressure range and output type according to datasheet)"/>
<define name="MS45XX_LOWPASS_TAU" value="0.15" description="Time constant for second order Butterworth low pass filter"/>
</doc>
<settings>
<dl_settings>
<dl_settings NAME="MS45XX">
<dl_setting min="0" max="1" step="1" values="FALSE|TRUE" var="ms45xx.autoset_offset" type="bool" shortname="autoset offset" module="modules/sensors/airspeed_ms45xx_i2c" persistent="true"/>
<dl_setting min="0.9" max="1.2" step="0.01" var="ms45xx.pressure_scale" type="float" shortname="PressScale" module="modules/sensors/airspeed_ms45xx_i2c" param="MS45XX_PRESSURE_SCALE" persistent="true"/>
<dl_setting min="0" max="1" step="1" values="FALSE|TRUE" var="ms45xx.pressure_type" type="bool" shortname="Type G" module="modules/sensors/airspeed_ms45xx_i2c" param="MS45XX_PRESSURE_TYPE" persistent="true"/>
<dl_setting min="8300.0" max="8900.0" step="0.1" var="ms45xx.pressure_offset" type="float" shortname="PressOffset" module="modules/sensors/airspeed_ms45xx_i2c" param="MS45XX_PRESSURE_OFFSET" persistent="true"/>
<dl_setting min="0" max="1" step="0.01" var="ms45xx.lowpass_tau" type="float" shortname="Tau" module="modules/sensors/airspeed_ms45xx_i2c" param="MS45XX_LOWPASS_TAU" handler="change_tau" persistent="true"/>
</dl_settings>
</dl_settings>
</settings>
<dep>
<depends>i2c</depends>
<provides>airspeed</provides>
</dep>
<header>
<file name="airspeed_ms45xx_i2c.h"/>
</header>
<init fun="ms45xx_i2c_init()"/>
<periodic fun="ms45xx_i2c_periodic()" freq="100."/>
<event fun="ms45xx_i2c_event()"/>
<makefile target="ap">
<configure name="MS45XX_I2C_DEV" default="i2c2" case="lower|upper"/>
<define name="MS45XX_I2C_DEV" value="$(MS45XX_I2C_DEV_LOWER)"/>
<define name="USE_$(MS45XX_I2C_DEV_UPPER)"/>
<file name="airspeed_ms45xx_i2c.c"/>
<test>
<define name="MS45XX_I2C_PERIODIC_PERIOD" value="0.001"/>
<define name="USE_I2C2"/>
<define name="DOWNLINK_TRANSPORT" value="pprz_tp"/>
<define name="DOWNLINK_DEVICE" value="uart0"/>
<define name="USE_UART0"/>
</test>
</makefile>
</module>