Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
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"
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 |
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.
#define AIRSPEED_MS45XX_SEND_ABI true |
Definition at line 44 of file airspeed_ms45xx_i2c.c.
#define AUTOSET_NB_MAX 200 |
Definition at line 242 of file airspeed_ms45xx_i2c.c.
#define InH2O_TO_PA 249.08891 |
Conversion factor from InH2O to Pa.
Definition at line 95 of file airspeed_ms45xx_i2c.c.
#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.
#define MS45XX_I2C_DEV i2c2 |
Default I2C device.
Definition at line 50 of file airspeed_ms45xx_i2c.c.
#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.
#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.
#define MS45XX_PRESSURE_OFFSET (16383 / 2) |
Definition at line 121 of file airspeed_ms45xx_i2c.c.
#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.
#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.
#define MS45XX_PRESSURE_SCALE (2 * MS45XX_PRESSURE_RANGE / (0.8 * 16383) * OutputPressureToPa) |
Definition at line 118 of file airspeed_ms45xx_i2c.c.
#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.
#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.
#define OutputPressureToPa PSI_TO_PA |
Definition at line 103 of file airspeed_ms45xx_i2c.c.
#define PSI_TO_PA 6894.75729 |
Conversion factor from psi to Pa.
Definition at line 98 of file airspeed_ms45xx_i2c.c.
#define USE_AIRSPEED_LOWPASS_FILTER TRUE |
Use low pass filter on pressure values.
Definition at line 83 of file airspeed_ms45xx_i2c.c.
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.
|
static |
Definition at line 181 of file airspeed_ms45xx_i2c.c.
References AirspeedMs45xx::airspeed, dev, ms45xx, MS45XX_SENDER_ID, AirspeedMs45xx::pressure, AirspeedMs45xx::pressure_offset, AirspeedMs45xx::raw_p, and AirspeedMs45xx::temperature.
Referenced by ms45xx_i2c_init().
void ms45xx_i2c_event | ( | void | ) |
Definition at line 244 of file airspeed_ms45xx_i2c.c.
References AirspeedMs45xx::airspeed, AUTOSET_NB_MAX, AirspeedMs45xx::autoset_offset, i2c_transaction::buf, I2CTransDone, I2CTransFailed, I2CTransSuccess, ms45xx, ms45xx_filter, MS45XX_RHO_DIV_2, MS45XX_SENDER_ID, ms45xx_trans, AirspeedMs45xx::offset_set, AirspeedMs45xx::pressure, AirspeedMs45xx::pressure_offset, AirspeedMs45xx::pressure_scale, AirspeedMs45xx::raw_p, sign(), i2c_transaction::status, status, AirspeedMs45xx::temperature, and update_butterworth_2_low_pass().
void ms45xx_i2c_init | ( | void | ) |
Definition at line 194 of file airspeed_ms45xx_i2c.c.
References AirspeedMs45xx::airspeed, DefaultPeriodic, I2CTransDone, init_butterworth_2_low_pass(), AirspeedMs45xx::lowpass_tau, ms45xx, ms45xx_downlink(), ms45xx_filter, MS45XX_LOWPASS_TAU, MS45XX_PRESSURE_OFFSET, MS45XX_PRESSURE_SCALE, MS45XX_PRESSURE_TYPE, ms45xx_trans, AirspeedMs45xx::offset_set, preflight_check_register(), AirspeedMs45xx::pressure, AirspeedMs45xx::pressure_offset, AirspeedMs45xx::pressure_scale, AirspeedMs45xx::pressure_type, AirspeedMs45xx::raw_p, register_periodic_telemetry(), i2c_transaction::status, and AirspeedMs45xx::temperature.
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.
struct AirspeedMs45xx ms45xx |
Definition at line 1 of file airspeed_ms45xx_i2c.c.
Referenced by airspeed_ms45xx_i2c_change_tau(), ms45xx_downlink(), ms45xx_i2c_event(), and ms45xx_i2c_init().
|
static |
Definition at line 164 of file airspeed_ms45xx_i2c.c.
Referenced by airspeed_ms45xx_i2c_change_tau(), ms45xx_i2c_event(), and ms45xx_i2c_init().
|
static |
Definition at line 1 of file airspeed_ms45xx_i2c.c.
Referenced by ms45xx_i2c_event(), ms45xx_i2c_init(), and ms45xx_i2c_periodic().