Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
airspeed_ms45xx_i2c.c File Reference

Airspeed sensor module using the MS45xxDO digital pressure sensor via I2C. More...

#include "std.h"
#include "mcu_periph/i2c.h"
#include "modules/sensors/airspeed_ms45xx_i2c.h"
#include "filters/low_pass_filter.h"
#include "modules/core/abi.h"
#include "mcu_periph/uart.h"
#include "pprzlink/messages.h"
#include "modules/datalink/downlink.h"
#include "modules/datalink/telemetry.h"
+ Include dependency graph for airspeed_ms45xx_i2c.c:

Go to the source code of this file.

Macros

#define AIRSPEED_MS45XX_SEND_ABI   true
 
#define MS45XX_I2C_DEV   i2c2
 Default I2C device. More...
 
#define MS45XX_I2C_ADDR   0x50
 Sensor I2C slave address (existing defaults 0x50, 0x6C and 0x8C) More...
 
#define MS45XX_PRESSURE_OUTPUT_TYPE_InH2O   0
 MS45xx sensors pressure output type can be in PSI or InH2O, as defined in the datasheet if not defined to be MS45XX_PRESSURE_OUTPUT_TYPE_InH2O then PSI is used. More...
 
#define MS45XX_PRESSURE_RANGE   1
 MS45xx pressure range in PSI or InH2O The sensor is available in many ranges, the datasheet of your pressure sensor will tell which one and what this range represents. More...
 
#define MS45XX_PRESSURE_TYPE   0
 Pressure Type 0 = Differential, 1 = Gauge note there are theoretical more types than 2, e.g. More...
 
#define USE_AIRSPEED_LOWPASS_FILTER   TRUE
 Use low pass filter on pressure values. More...
 
#define MS45XX_OUTPUT_TYPE   0
 MS45xx output Type. More...
 
#define InH2O_TO_PA   249.08891
 Conversion factor from InH2O to Pa. More...
 
#define PSI_TO_PA   6894.75729
 Conversion factor from psi to Pa. More...
 
#define OutputPressureToPa   PSI_TO_PA
 
#define MS45XX_PRESSURE_SCALE   (2 * MS45XX_PRESSURE_RANGE / (0.8 * 16383) * OutputPressureToPa)
 
#define MS45XX_PRESSURE_OFFSET   (16383 / 2)
 
#define MS45XX_RHO_DIV_2   1.6327
 Quadratic scale factor for indicated airspeed. More...
 
#define MS45XX_LOWPASS_TAU   0.15
 Time constant for second order Butterworth low pass filter Default of 0.15 should give cut-off freq of 1/(2*pi*tau) ~= 1Hz. More...
 
#define AUTOSET_NB_MAX   200
 

Functions

static void ms45xx_downlink (struct transport_tx *trans, struct link_device *dev)
 
void ms45xx_i2c_init (void)
 
void airspeed_ms45xx_i2c_change_tau (float new_tau)
 
void ms45xx_i2c_periodic (void)
 
void ms45xx_i2c_event (void)
 

Variables

struct AirspeedMs45xx ms45xx
 
static struct i2c_transaction ms45xx_trans
 
static Butterworth2LowPass ms45xx_filter
 

Detailed Description

Airspeed sensor module using the MS45xxDO digital pressure sensor via I2C.

Needs to be one of the versions with 14bit pressure and 11bit temperature.

Definition in file airspeed_ms45xx_i2c.c.

Macro Definition Documentation

◆ AIRSPEED_MS45XX_SEND_ABI

#define AIRSPEED_MS45XX_SEND_ABI   true

Definition at line 44 of file airspeed_ms45xx_i2c.c.

◆ AUTOSET_NB_MAX

#define AUTOSET_NB_MAX   200

Definition at line 242 of file airspeed_ms45xx_i2c.c.

◆ InH2O_TO_PA

#define InH2O_TO_PA   249.08891

Conversion factor from InH2O to Pa.

Definition at line 95 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_I2C_ADDR

#define MS45XX_I2C_ADDR   0x50

Sensor I2C slave address (existing defaults 0x50, 0x6C and 0x8C)

Definition at line 56 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_I2C_DEV

#define MS45XX_I2C_DEV   i2c2

Default I2C device.

Definition at line 50 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_LOWPASS_TAU

#define MS45XX_LOWPASS_TAU   0.15

Time constant for second order Butterworth low pass filter Default of 0.15 should give cut-off freq of 1/(2*pi*tau) ~= 1Hz.

Definition at line 158 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_OUTPUT_TYPE

#define MS45XX_OUTPUT_TYPE   0

MS45xx output Type.

0 = Output Type A with 10% to 90% 1 = Output Type B with 5% to 95%

Definition at line 91 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_PRESSURE_OFFSET

#define MS45XX_PRESSURE_OFFSET   (16383 / 2)

Definition at line 121 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_PRESSURE_OUTPUT_TYPE_InH2O

#define MS45XX_PRESSURE_OUTPUT_TYPE_InH2O   0

MS45xx sensors pressure output type can be in PSI or InH2O, as defined in the datasheet if not defined to be MS45XX_PRESSURE_OUTPUT_TYPE_InH2O then PSI is used.

Definition at line 63 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_PRESSURE_RANGE

#define MS45XX_PRESSURE_RANGE   1

MS45xx pressure range in PSI or InH2O The sensor is available in many ranges, the datasheet of your pressure sensor will tell which one and what this range represents.

Definition at line 71 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_PRESSURE_SCALE

#define MS45XX_PRESSURE_SCALE   (2 * MS45XX_PRESSURE_RANGE / (0.8 * 16383) * OutputPressureToPa)

Definition at line 118 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_PRESSURE_TYPE

#define MS45XX_PRESSURE_TYPE   0

Pressure Type 0 = Differential, 1 = Gauge note there are theoretical more types than 2, e.g.

Absolute not implemented

Definition at line 77 of file airspeed_ms45xx_i2c.c.

◆ MS45XX_RHO_DIV_2

#define MS45XX_RHO_DIV_2   1.6327

Quadratic scale factor for indicated airspeed.

airspeed = sqrt(2*p_diff/density) With p_diff in Pa and standard air density of 1.225 kg/m^3, default airspeed scale is 2/1.225

Definition at line 151 of file airspeed_ms45xx_i2c.c.

◆ OutputPressureToPa

#define OutputPressureToPa   PSI_TO_PA

Definition at line 103 of file airspeed_ms45xx_i2c.c.

◆ PSI_TO_PA

#define PSI_TO_PA   6894.75729

Conversion factor from psi to Pa.

Definition at line 98 of file airspeed_ms45xx_i2c.c.

◆ USE_AIRSPEED_LOWPASS_FILTER

#define USE_AIRSPEED_LOWPASS_FILTER   TRUE

Use low pass filter on pressure values.

Definition at line 83 of file airspeed_ms45xx_i2c.c.

Function Documentation

◆ airspeed_ms45xx_i2c_change_tau()

void airspeed_ms45xx_i2c_change_tau ( float  new_tau)

Definition at line 224 of file airspeed_ms45xx_i2c.c.

References get_butterworth_2_low_pass(), init_butterworth_2_low_pass(), AirspeedMs45xx::lowpass_tau, ms45xx, and ms45xx_filter.

+ Here is the call graph for this function:

◆ ms45xx_downlink()

static void ms45xx_downlink ( struct transport_tx *  trans,
struct link_device *  dev 
)
static

◆ ms45xx_i2c_event()

◆ ms45xx_i2c_init()

◆ ms45xx_i2c_periodic()

void ms45xx_i2c_periodic ( void  )

Definition at line 234 of file airspeed_ms45xx_i2c.c.

References i2c_receive(), I2CTransDone, MS45XX_I2C_ADDR, MS45XX_I2C_DEV, ms45xx_trans, and i2c_transaction::status.

+ Here is the call graph for this function:

Variable Documentation

◆ ms45xx

◆ ms45xx_filter

Butterworth2LowPass ms45xx_filter
static

◆ ms45xx_trans

struct i2c_transaction ms45xx_trans
static

Definition at line 1 of file airspeed_ms45xx_i2c.c.

Referenced by ms45xx_i2c_event(), ms45xx_i2c_init(), and ms45xx_i2c_periodic().