[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Paparazzi-devel] Critical behaviour of baro_ms5611_i2c
From: |
afishindouban |
Subject: |
Re: [Paparazzi-devel] Critical behaviour of baro_ms5611_i2c |
Date: |
Sun, 22 Jun 2014 20:13:04 -0700 (PDT) |
Hi Felix
I can not find the reason, I think it is the bug of MS5611, maybe its read
when the data is not ready. Anyway simple add a checker in the ms5611.c
<https://github.com/paparazzi/paparazzi/blob/master/sw/airborne/peripherals/ms5611.c>
solve the problem. the checker is reasonable and works in any case, the
range is from MS5611 document
<http://www.meas-spec.com/downloads/MS5611-01BA03.pdf> .
So would you like to include it into master?
here is the modified ms5611_calc()
void ms5611_calc(struct Ms5611Data* ms) {
int64_t dt, tempms, off, sens, t2, off2, sens2, p;
/* difference between actual and ref temperature */
dt = ms->d2 - (int64_t)ms->c[5] * (1<<8);
/* actual temperature */
tempms = 2000 + ((int64_t)dt * ms->c[6]) / (1<<23);
/* offset at actual temperature */
off = ((int64_t)ms->c[2] * (1<<16)) + ((int64_t)ms->c[4] * dt) / (1<<7);
/* sensitivity at actual temperature */
sens = ((int64_t)ms->c[1] * (1<<15)) + ((int64_t)ms->c[3] * dt) / (1<<8);
/* second order temperature compensation */
if (tempms < 2000) {
t2 = (dt*dt) / (1<<31);
off2 = 5 * ((int64_t)(tempms-2000)*(tempms-2000)) / (1<<1);
sens2 = 5 * ((int64_t)(tempms-2000)*(tempms-2000)) / (1<<2);
if (tempms < -1500) {
off2 = off2 + 7 * (int64_t)(tempms+1500)*(tempms+1500);
sens2 = sens2 + 11 * ((int64_t)(tempms+1500)*(tempms+1500)) / (1<<1);
}
tempms = tempms - t2;
off = off - off2;
sens = sens - sens2;
}
p = (((int64_t)ms->d1 * sens) / (1<<21) - off) / (1<<15);
if ((tempms > -4000) && (tempms < 8500) && (p > 1000 ) && (p < 120000)) {
/* temperature in deg Celsius with 0.01 degC resolultion */
ms->temperature = (int32_t)tempms;
/* temperature compensated pressure in Pascal (0.01mbar) */
ms->pressure = (uint32_t)p;
}
}
And here is the test result.
<http://lists.paparazziuav.org/file/n15720/47.png>
flixr wrote
> Hi,
>
> Would be great if you could dig a bit further! Add
> <define name="DEBUG"
> value="TRUE"/>
> to your firmware section and have a look at the BARO_MS5611
> message that is sent with every measurement from the baro board wrapper
> <https://github.com/paparazzi/paparazzi/blob/master/sw/airborne/boards/baro_board_ms5611_spi.c>.
> That should help to narrow down the problem, e.g. if D1 or D2 is suddenly
> very large.
>
> If you want to add additional checks to the ms5611 peripheral, add them in
> sw/airborne/peripherals/ms5611_spi.c
> <https://github.com/paparazzi/paparazzi/blob/master/sw/airborne/peripherals/ms5611_spi.c>
>
> Cheers, Felix
--
View this message in context:
http://lists.paparazziuav.org/Critical-behaviour-of-baro-ms5611-i2c-tp11592p15720.html
Sent from the paparazzi-devel mailing list archive at Nabble.com.
- Re: [Paparazzi-devel] Critical behaviour of baro_ms5611_i2c, afishindouban, 2014/06/05
- Re: [Paparazzi-devel] Critical behaviour of baro_ms5611_i2c, Loic Drumettaz, 2014/06/05
- Re: [Paparazzi-devel] Critical behaviour of baro_ms5611_i2c, AFISH, 2014/06/05
- Re: [Paparazzi-devel] Critical behaviour of baro_ms5611_i2c, Felix Ruess, 2014/06/05
- Re: [Paparazzi-devel] Critical behaviour of baro_ms5611_i2c, afishindouban, 2014/06/05
- Re: [Paparazzi-devel] Critical behaviour of baro_ms5611_i2c, AFISH, 2014/06/05
- Re: [Paparazzi-devel] Critical behaviour of baro_ms5611_i2c, Felix Ruess, 2014/06/10
- Re: [Paparazzi-devel] Critical behaviour of baro_ms5611_i2c, AFISH, 2014/06/10
- Re: [Paparazzi-devel] Critical behaviour of baro_ms5611_i2c, Felix Ruess, 2014/06/10
- Re: [Paparazzi-devel] Critical behaviour of baro_ms5611_i2c,
afishindouban <=
- Re: [Paparazzi-devel] Critical behaviour of baro_ms5611_i2c, Felix Ruess, 2014/06/24
- Re: [Paparazzi-devel] Critical behaviour of baro_ms5611_i2c, Felix Ruess, 2014/06/24