Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 "subsystems/abi.h"
#include "mcu_periph/uart.h"
#include "messages.h"
#include "subsystems/datalink/downlink.h"
+ Include dependency graph for airspeed_ms45xx_i2c.c:

Go to the source code of this file.

Macros

#define MS45XX_I2C_DEV   i2c2
 Default I2C device. More...
 
#define MS45XX_I2C_ADDR   0x50
 Sensor I2C slave address (defaults 0x50, 0x6C and 0x8C) More...
 
#define MS45XX_PRESSURE_RANGE   1
 MS45xx pressure range in psi. More...
 
#define MS45XX_OUTPUT_TYPE   0
 MS45xx output Type. More...
 
#define PSI_TO_PA   6894.75729
 Conversion factor from psi to Pa. More...
 
#define MS45XX_PRESSURE_SCALE   (2 * MS45XX_PRESSURE_RANGE / (0.8 * 16383) * PSI_TO_PA)
 
#define MS45XX_PRESSURE_OFFSET   (1.25 * MS45XX_PRESSURE_RANGE * PSI_TO_PA)
 
#define MS45XX_SYNC_SEND   FALSE
 Send a AIRSPEED_MS45XX message with every new measurement. More...
 
#define MS45XX_AIRSPEED_SCALE   1.6327
 Quadratic scale factor for 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...
 

Functions

static void ms45xx_downlink (struct transport_tx *trans, struct link_device *dev)
 
void ms45xx_i2c_init (void)
 
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 one of the differential versions with 14bit pressure and 11bit temperature.

Definition in file airspeed_ms45xx_i2c.c.

Macro Definition Documentation

#define MS45XX_AIRSPEED_SCALE   1.6327

Quadratic scale factor for 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 125 of file airspeed_ms45xx_i2c.c.

Referenced by ms45xx_i2c_init().

#define MS45XX_I2C_ADDR   0x50

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

Definition at line 61 of file airspeed_ms45xx_i2c.c.

Referenced by ms45xx_i2c_periodic().

#define MS45XX_I2C_DEV   i2c2

Default I2C device.

Definition at line 56 of file airspeed_ms45xx_i2c.c.

Referenced by ms45xx_i2c_periodic().

#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 132 of file airspeed_ms45xx_i2c.c.

Referenced by ms45xx_i2c_init().

#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 77 of file airspeed_ms45xx_i2c.c.

#define MS45XX_PRESSURE_OFFSET   (1.25 * MS45XX_PRESSURE_RANGE * PSI_TO_PA)

Definition at line 98 of file airspeed_ms45xx_i2c.c.

Referenced by ms45xx_i2c_init().

#define MS45XX_PRESSURE_RANGE   1

MS45xx pressure range in psi.

The sensor is available in 1, 2, 5, 15, 30, 50, 100, 150 psi ranges. 1 psi max range should be ~100m/s max airspeed.

Definition at line 69 of file airspeed_ms45xx_i2c.c.

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

Definition at line 95 of file airspeed_ms45xx_i2c.c.

Referenced by ms45xx_i2c_init().

#define MS45XX_SYNC_SEND   FALSE

Send a AIRSPEED_MS45XX message with every new measurement.

Mainly for debug, use with caution, sends message at ~100Hz.

Definition at line 116 of file airspeed_ms45xx_i2c.c.

Referenced by ms45xx_i2c_init().

#define PSI_TO_PA   6894.75729

Conversion factor from psi to Pa.

Definition at line 81 of file airspeed_ms45xx_i2c.c.

Function Documentation

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

Definition at line 140 of file airspeed_ms45xx_i2c.c.

References AirspeedMs45xx::airspeed, AirspeedMs45xx::diff_pressure, ms45xx, and AirspeedMs45xx::temperature.

Referenced by ms45xx_i2c_event(), and ms45xx_i2c_init().

+ Here is the caller graph for this function:

void ms45xx_i2c_periodic ( void  )

Definition at line 167 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

struct AirspeedMs45xx ms45xx

Definition at line 135 of file airspeed_ms45xx_i2c.c.

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

Butterworth2LowPass ms45xx_filter
static

Definition at line 137 of file airspeed_ms45xx_i2c.c.

struct i2c_transaction ms45xx_trans
static

Definition at line 136 of file airspeed_ms45xx_i2c.c.

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