|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
35 #include "pprzlink/messages.h"
38 #if PERIODIC_TELEMETRY
42 #ifndef USE_AIRSPEED_MS45XX
44 #define USE_AIRSPEED_MS45XX TRUE
45 PRINT_CONFIG_MSG(
"USE_AIRSPEED_MS45XX set to TRUE since this is set USE_AIRSPEED")
49 #if USE_AIRSPEED_MS45XX
55 #ifndef MS45XX_I2C_DEV
56 #define MS45XX_I2C_DEV i2c2
61 #ifndef MS45XX_I2C_ADDR
62 #define MS45XX_I2C_ADDR 0x50
68 #ifndef MS45XX_PRESSURE_OUTPUT_TYPE_InH2O
69 #define MS45XX_PRESSURE_OUTPUT_TYPE_InH2O 0
76 #ifndef MS45XX_PRESSURE_RANGE
77 #define MS45XX_PRESSURE_RANGE 1
82 #ifndef MS45XX_PRESSURE_TYPE
83 #define MS45XX_PRESSURE_TYPE 0
88 #ifndef USE_AIRSPEED_LOWPASS_FILTER
89 #define USE_AIRSPEED_LOWPASS_FILTER TRUE
96 #ifndef MS45XX_OUTPUT_TYPE
97 #define MS45XX_OUTPUT_TYPE 0
101 #define InH2O_TO_PA 249.08891
104 #define PSI_TO_PA 6894.75729
106 #if MS45XX_PRESSURE_OUTPUT_TYPE_InH2O
107 #define OutputPressureToPa InH2O_TO_PA
109 #define OutputPressureToPa PSI_TO_PA
112 #if MS45XX_OUTPUT_TYPE == 0
123 #ifndef MS45XX_PRESSURE_SCALE
124 #define MS45XX_PRESSURE_SCALE (2 * MS45XX_PRESSURE_RANGE / (0.8 * 16383) * OutputPressureToPa)
126 #ifndef MS45XX_PRESSURE_OFFSET
127 #define MS45XX_PRESSURE_OFFSET (1.25 * MS45XX_PRESSURE_RANGE * OutputPressureToPa)
133 #ifndef MS45XX_PRESSURE_SCALE
134 #define MS45XX_PRESSURE_SCALE (MS45XX_PRESSURE_RANGE/(0.9*16383)*OutputPressureToPa)
136 #ifndef MS45XX_PRESSURE_OFFSET
137 #define MS45XX_PRESSURE_OFFSET (((MS45XX_PRESSURE_RANGE*0.05*16383)/(0.9*16383))*OutputPressureToPa)
150 #ifndef MS45XX_SYNC_SEND
151 #define MS45XX_SYNC_SEND FALSE
159 #ifndef MS45XX_AIRSPEED_SCALE
160 #define MS45XX_AIRSPEED_SCALE 1.6327
166 #ifndef MS45XX_LOWPASS_TAU
167 #define MS45XX_LOWPASS_TAU 0.15
172 #ifdef USE_AIRSPEED_LOWPASS_FILTER
178 pprz_msg_send_AIRSPEED_MS45XX(trans,
dev,AC_ID,
197 #ifdef USE_AIRSPEED_LOWPASS_FILTER
199 MS45XX_I2C_PERIODIC_PERIOD, 0);
202 #if PERIODIC_TELEMETRY
215 #define AUTOSET_NB_MAX 20
219 static int autoset_nb = 0;
220 static float autoset_offset = 0.f;
253 autoset_offset = 0.f;
262 temp_raw = temp_raw >> 5;
276 #if USE_AIRSPEED_MS45XX
struct AirspeedMs45xx ms45xx
static void stateSetAirspeed_f(float airspeed)
Set airspeed (float).
static float update_butterworth_2_low_pass(Butterworth2LowPass *filter, float value)
Update second order Butterworth low pass filter state with a new value.
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
#define MS45XX_AIRSPEED_SCALE
Quadratic scale factor for indicated airspeed.
float airspeed_scale
Quadratic scale factor to convert (differential) pressure to airspeed.
float airspeed
Airspeed in m/s estimated from (differential) pressure.
int16_t temperature
Temperature in 0.1 deg Celcius.
static void ms45xx_downlink(struct transport_tx *trans, struct link_device *dev)
@ I2CTransFailed
transaction failed
Second order low pass filter structure.
void ms45xx_i2c_init(void)
void ms45xx_i2c_periodic(void)
float pressure
(differential) pressure in Pascal
#define MS45XX_I2C_ADDR
Sensor I2C slave address (existing defaults 0x50, 0x6C and 0x8C)
@ I2CTransSuccess
transaction successfully finished by I2C driver
#define MS45XX_LOWPASS_TAU
Time constant for second order Butterworth low pass filter Default of 0.15 should give cut-off freq o...
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
static Butterworth2LowPass ms45xx_filter
float pressure_scale
Scaling factor from raw measurement to Pascal.
static const struct usb_device_descriptor dev
static struct i2c_transaction ms45xx_trans
bool sync_send
Flag to enable sending every new measurement via telemetry for debugging purpose.
bool autoset_offset
Set offset value from current filtered value.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
#define MS45XX_PRESSURE_OFFSET
#define MS45XX_PRESSURE_SCALE
enum I2CTransactionStatus status
Transaction status.
#define MS45XX_SYNC_SEND
Send a AIRSPEED_MS45XX message with every new measurement.
#define USE_AIRSPEED_LOWPASS_FILTER
Use low pass filter on pressure values.
#define MS45XX_I2C_DEV
Default I2C device.
I2C transaction structure.
Common code for AP and FBW telemetry.
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
void ms45xx_i2c_event(void)
#define MS45XX_OUTPUT_TYPE
MS45xx output Type.
@ I2CTransDone
transaction set to done by user level
#define MS45XX_PRESSURE_RANGE
MS45xx pressure range in PSI or InH2O The sensor is available in many ranges, the datasheet of your p...
static void init_butterworth_2_low_pass(Butterworth2LowPass *filter, float tau, float sample_time, float value)
Init a second order Butterworth filter.
#define MS45XX_PRESSURE_TYPE
Pressure Type 0 = Differential, 1 = Gauge note there are theoretical more types than 2,...
bool pressure_type
Pressure type Differential of Gauge.
float pressure_offset
Offset in Pascal.
#define DefaultPeriodic
Set default periodic telemetry.
bool i2c_receive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
Submit a read only transaction.
Simple first order low pass filter with bilinear transform.